diff --git a/constants.py b/constants.py index 8cf9161..298c4e2 100644 --- a/constants.py +++ b/constants.py @@ -94,7 +94,9 @@ COMPLEMENTARY = [ ] INVOICE_STATES = [ - ('', 'None'), - ('invoiced', 'Invoiced'), + ('draft', 'Draft'), + ('validated', 'Validated'), + ('posted', 'Posted'), ('paid', 'Paid'), + ('cancelled', 'Cancelled'), ] diff --git a/folio.py b/folio.py index 0133e63..80c061a 100644 --- a/folio.py +++ b/folio.py @@ -66,7 +66,7 @@ class Folio(ModelSQL, ModelView): ('template.type', '=', 'service'), ('template.kind', '=', 'accommodation'), ], required=True, states=STATES_CHECKIN) - unit_price = fields.Numeric('Unit Price', digits=(16, 4), + unit_price = fields.Numeric('Unit Price', digits=(16, 2), states={ 'required': Bool(Eval('product')), 'readonly': Eval('registration_state') == 'check_in', @@ -113,7 +113,8 @@ class Folio(ModelSQL, ModelView): invoice_line = fields.Many2One('account.invoice.line', 'Invoice Line') invoice = fields.Function(fields.Many2One('account.invoice', 'Invoice', depends=['invoice_line']), 'get_invoice') - invoice_state = fields.Selection(INVOICE_STATES, 'Invoice State', readonly=True) + invoice_state = fields.Function(fields.Selection( + INVOICE_STATES, 'Invoice State'), 'get_invoice_state') type_complementary = fields.Selection(COMPLEMENTARY, 'Type Complementary', states={ 'invisible': ~Bool(Eval('complementary')), @@ -143,6 +144,9 @@ class Folio(ModelSQL, ModelView): }, 'bill': { 'invisible': Eval('registration_state') != 'check_out', + }, + 'pay': { + 'invisible': Eval('registration_state') != 'check_out', } }) @@ -199,6 +203,15 @@ class Folio(ModelSQL, ModelView): continue cls.create_invoice(rec) + @classmethod + @ModelView.button_action('hotel.wizard_booking_advance_voucher') + def pay(cls, records): + pass + + def get_invoice_state(self, name=None): + if self.invoice_line: + return self.invoice_line.invoice.state + def set_registration_number(self): """ Fill the number field for registration card with sequence @@ -295,7 +308,6 @@ class Folio(ModelSQL, ModelView): 'party': invoice.party.id, 'description': line['description'], } - print(line['taxes_exception']) if not line['taxes_exception']: taxes_ids = cls.get_taxes(invoice, line['product'], record) print(taxes_ids) @@ -630,7 +642,10 @@ class Folio(ModelSQL, ModelView): """ res = _ZERO if self.nights_quantity and self.unit_price: - res = self.nights_quantity * self.unit_price + res = self.nights_quantity * self.unit_price_w_tax + for charge in self.charges: + res += charge.amount + res = round(res, Folio.total_amount.digits[1]) return res def get_channel_commission(self, name): @@ -841,9 +856,9 @@ class HotelCharge(Workflow, ModelSQL, ModelView): domain=[('salable', '=', True)], required=True) quantity = fields.Integer('Quantity', required=True) invoice_to = fields.Many2One('party.party', 'Invoice To', required=True) - unit_price = fields.Numeric('Unit Price', required=True) - unit_price_w_tax = fields.Function(fields.Numeric('Unit Price'), - 'get_unit_price_w_tax') + unit_price = fields.Numeric('Unit Price', required=True, digits=(16, 2)) + unit_price_w_tax = fields.Function(fields.Numeric('Unit Price', + digits=(16, 2)), 'get_unit_price_w_tax') order = fields.Char('Order', select=True) description = fields.Char('Description', select=True) state = fields.Selection(INVOICE_STATES, 'State', readonly=True) @@ -877,7 +892,7 @@ class HotelCharge(Workflow, ModelSQL, ModelView): return today def get_amount(self, name=None): - if self.quantity and self.unit_price: + if self.quantity and self.unit_price_w_tax: return self.quantity * self.unit_price_w_tax return 0 diff --git a/service.fods b/service.fods index 5662d0a..440cb7a 100644 Binary files a/service.fods and b/service.fods differ diff --git a/service.py b/service.py index c954328..8b4da34 100644 --- a/service.py +++ b/service.py @@ -159,14 +159,14 @@ class ServiceLine(Workflow, ModelSQL, ModelView): states={'readonly': True}) folio = fields.Many2One('hotel.folio', 'Folio', domain=[ ('room', '=', Eval('room')), - ('registration_state', '=', 'check_in') - ]) + ('registration_state', 'in', 'check_in') + ], depends=['room']) state = fields.Selection([ ('draft', 'Draft'), ('loaded', 'Loaded'), ('deleted', 'Deleted'), ('done', 'Done'), - ], 'State') + ], 'State', readonly=True) state_string = state.translated('state') @classmethod diff --git a/view/board_folio_form.xml b/view/board_folio_form.xml index c210555..a805b69 100644 --- a/view/board_folio_form.xml +++ b/view/board_folio_form.xml @@ -51,18 +51,18 @@ this repository contains the full copyright notices and license terms. --> - + +