This commit is contained in:
oscar alvarez 2023-11-06 17:46:52 -05:00
parent 737448d658
commit b619e84704
2 changed files with 18 additions and 3 deletions

View File

@ -997,13 +997,15 @@ class Booking(Workflow, ModelSQL, ModelView):
pool = Pool()
Folio = pool.get('hotel.folio')
Party = pool.get('party.party')
Config = pool.get('hotel.configuration')
FolioCharge = pool.get('hotel.folio.charge')
Invoice = pool.get('account.invoice')
InvoiceLine = pool.get('account.invoice.line')
bookings = cls.browse([booking_id])
folios = Folio.browse(folios_ids)
for folio in folios:
folio.add_charge_occupancy(ctx='invoice')
invoice = {}
invoices = []
party = Party(party_id)
invoice_to_create = cls.get_grouped_invoices(
@ -1015,7 +1017,7 @@ class Booking(Workflow, ModelSQL, ModelView):
invoice = cls._get_new_invoice(rec)
invoice.on_change_invoice_type()
invoice.save()
invoices.append(invoice)
for _line in rec['lines']:
line, = InvoiceLine.create([
cls._get_invoice_line(invoice, _line)
@ -1023,10 +1025,23 @@ class Booking(Workflow, ModelSQL, ModelView):
FolioCharge.write([_line.get('charge')], {
'invoice_line': line.id,
})
# ################# only for tests ##################
# invoice.invoice_type = 'P'
# ###################################################
invoice.save()
invoice.update_taxes([invoice])
Booking.concile_charges(bookings)
Booking.check_finished(bookings)
config = Config.get_configuration()
if config.auto_invoice == 'validate_send':
Invoice.validate_invoice(invoices)
for invoice in invoices:
if invoice.invoice_type == 'P':
# Invoice.post([invoice])
pass
elif invoice.invoice_type == '1':
Invoice.submit([invoice])
def get_link_web_checkin(self, name=None):
transaction = Transaction().context

View File

@ -30,7 +30,7 @@ class Party(metaclass=PoolMeta):
def _set_account_defaults(cls, value):
ObligationFiscal = Pool().get('party.obligation_fiscal')
type_document = value.get('type_document')
if type_document == '31': # Is Nights
if type_document == '31':
regime_tax = 'regimen_responsable'
type_person = 'persona_juridica'
fiscal_regimen = '48'