Refactory 09

This commit is contained in:
Oscar 2021-10-12 10:25:14 -05:00
parent 4891c6b78f
commit a19e3f2e59
8 changed files with 46 additions and 31 deletions

View File

@ -94,7 +94,9 @@ COMPLEMENTARY = [
]
INVOICE_STATES = [
('', 'None'),
('invoiced', 'Invoiced'),
('draft', 'Draft'),
('validated', 'Validated'),
('posted', 'Posted'),
('paid', 'Paid'),
('cancelled', 'Cancelled'),
]

View File

@ -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

Binary file not shown.

View File

@ -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

View File

@ -51,18 +51,18 @@ this repository contains the full copyright notices and license terms. -->
<field name="notes" colspan="4"/>
</page>
</notebook>
<group col="6" colspan="6" id="state_buttons">
<group col="8" colspan="6" id="state_buttons">
<label name="registration_state"/>
<field name="registration_state"/>
<label name="total_amount"/>
<field name="total_amount"/>
<button name="check_in" string="Check In"/>
<button name="check_out" string="Check Out"/>
<button name="bill" string="Bill"/>
<button name="pay" string="Pay"/>
<label name="invoice"/>
<field name="invoice"/>
<label name="invoice_state"/>
<field name="invoice_state"/>
<label name="total_amount"/>
<field name="total_amount"/>
<label name="registration_state"/>
<field name="registration_state"/>
<button name="check_in" string="Check In"/>
<button name="check_out" string="Check Out"/>
<button name="bill" string="Bill"/>
<!-- <button name="pay" string="Pay"/> -->
</group>
</form>

View File

@ -93,7 +93,7 @@ this repository contains the full copyright notices and license terms. -->
<button name="offer" string="Offer" icon="tryton-clear"/>
<button name="confirm" string="Confirm" icon="tryton-forward"/>
</group>
<group col="2" colspan="2" id="amounts">
<group col="2" colspan="2" xfill="1" id="amounts">
<label name="untaxed_amount"/>
<field name="untaxed_amount"/>
<label name="tax_amount"/>

View File

@ -20,8 +20,8 @@ this repository contains the full copyright notices and license terms. -->
<field name="invoice_to"/>
<label name="amount"/>
<field name="amount"/>
<!-- <label name="invoice_line"/>
<field name="invoice_line"/> -->
<label name="invoice_line"/>
<field name="invoice_line"/>
<label name="state"/>
<field name="state"/>
<!-- <button name="transfer" string="Transfer"/> -->

View File

@ -6,16 +6,14 @@ this repository contains the full copyright notices and license terms. -->
<field name="room" widget="selection"/>
<label name="time_service"/>
<field name="time_service"/>
<label name="product"/>
<field name="product"/>
<label name="folio"/>
<field name="folio"/>
<label name="guest"/>
<field name="guest"/>
<label name="quantity"/>
<field name="quantity"/>
<label name="order"/>
<field name="order"/>
<label name="product"/>
<field name="product"/>
<label name="quantity"/>
<field name="quantity"/>
<label name="description"/>
<field name="description"/>
<label name="folio"/>