welaborate-labs / inka_backoffice

0 stars 0 forks source link

Bills are getting orphaned from Bookings #60

Open filabreu opened 2 years ago

filabreu commented 2 years ago

Some Bills are being created and loosing their Bookings. That probably happens when a Bill create for one or more Bookings are being submitted twice.

This causes a NFE to be created twice and can't be cancelled. The NFe data is also being lost, since there is a validation on Bill model that checks if Bookings are present, but since the references actually sit at Bookings side, a Bill can loose it's Bookings without being saved, thus validations won't run.

We need to add a validation on Bookings or Bills (or even maybe a check in Bills controller) to avoid creating a new Bill for Bookings that already have a Bill.

We will also need to cleanup the database for orphaned Bills and to cancel it's NFes

rodolforpr88 commented 2 years ago

Added the validation duplicated to avoid submit the same twice or more when is billing or already billed