From 06c03d9d85b41a6b2c5566598bf68d0ac65c0055 Mon Sep 17 00:00:00 2001 From: oscar alvarez Date: Thu, 2 Nov 2023 00:38:22 -0500 Subject: [PATCH] Add config advance payment --- booking.py | 7 ++++++- configuration.py | 5 +++++ invoice.py | 10 +++++++++- sale.py | 2 +- view/configuration_form.xml | 2 ++ 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/booking.py b/booking.py index c2409e2..41d2977 100644 --- a/booking.py +++ b/booking.py @@ -496,6 +496,7 @@ class Booking(Workflow, ModelSQL, ModelView): def add_payment(cls, args): pool = Pool() StatementLine = pool.get('account.statement.line') + Config = pool.get('hotel.configuration') Folio = pool.get('hotel.folio') Booking = pool.get('hotel.booking') Party = pool.get('party.party') @@ -513,8 +514,12 @@ class Booking(Workflow, ModelSQL, ModelView): party_id = args['party'] party = Party(party_id) + config = Config.get_configuration() try: - account = party.account_receivable.id + if config.advance_account: + account = config.advance_account.id + else: + account = party.account_receivable.id except: raise UserError(gettext('hotel.party_without_account_receivable')) diff --git a/configuration.py b/configuration.py index 1ce8e23..afc7ddd 100644 --- a/configuration.py +++ b/configuration.py @@ -93,6 +93,11 @@ class Configuration(ModelSQL, ModelView): ('type', '!=', None), ], depends=['company']) space_booking = fields.Many2One('analytic_account.space', 'Default Space') + advance_account = fields.Many2One('account.account', 'Advance Account', + domain=[ + ('company', '=', Eval('company')), + ('type', '!=', None), + ], depends=['company']) token_siat = fields.Char('Token Siat') @staticmethod diff --git a/invoice.py b/invoice.py index 9eebcce..a1aa960 100644 --- a/invoice.py +++ b/invoice.py @@ -100,14 +100,22 @@ class Invoice(metaclass=PoolMeta): if invoice.amount_to_pay == 0 and to_reconcile: MoveLine.reconcile(to_reconcile) + @classmethod + def do_move_writeoff_advance(cls, invoices): + # Asiento de cancelacion de los anticipos en la reserva + # Para abono de pago en factura + Config = Pool().get('hotel.configuration') + config = Config.get_configuration() + pass + @classmethod def _post(cls, invoices): for invoice in invoices: - lines_ids = None if invoice.type == 'in': super()._post([invoice]) continue + lines_ids = None if invoice.type == 'out' and invoice.agent: lines_ids = cls.process_offset_move(invoice) diff --git a/sale.py b/sale.py index b0c856a..e8ad2d1 100644 --- a/sale.py +++ b/sale.py @@ -54,7 +54,7 @@ class Sale(metaclass=PoolMeta): 'kind': 'product', 'order': number, 'status': 'pending', - 'origin': f'sale.sale,{sale_id}', + 'origin': f'sale.line,{line.id}', }) charges_ids = Charge.create(to_create) diff --git a/view/configuration_form.xml b/view/configuration_form.xml index 56feed8..5da2c2f 100644 --- a/view/configuration_form.xml +++ b/view/configuration_form.xml @@ -42,6 +42,8 @@ this repository contains the full copyright notices and license terms. -->