Fix amount compute
This commit is contained in:
parent
579be5972b
commit
d135a1aeeb
14
booking.py
14
booking.py
|
@ -368,7 +368,7 @@ class Booking(Workflow, ModelSQL, ModelView):
|
|||
if folio.taxes_exception:
|
||||
continue
|
||||
_taxes = folio.product.customer_taxes_used
|
||||
if not folio.occupancy and not folio.charges:
|
||||
if not folio.occupancy:
|
||||
taxes.extend(cls.compute_taxes(
|
||||
_taxes,
|
||||
folio.unit_price,
|
||||
|
@ -381,12 +381,12 @@ class Booking(Workflow, ModelSQL, ModelView):
|
|||
taxes.extend(cls.compute_taxes(
|
||||
_taxes, occ.unit_price, 1, currency))
|
||||
|
||||
for charge in folio.charges:
|
||||
taxes.extend(cls.compute_taxes(
|
||||
charge.taxes,
|
||||
charge.unit_price,
|
||||
charge.quantity,
|
||||
currency))
|
||||
for charge in folio.charges:
|
||||
taxes.extend(cls.compute_taxes(
|
||||
charge.taxes,
|
||||
charge.unit_price,
|
||||
charge.quantity,
|
||||
currency))
|
||||
_taxes = {}
|
||||
for ctax in taxes:
|
||||
if ctax['tax'] not in _taxes.keys():
|
||||
|
|
24
folio.py
24
folio.py
|
@ -1598,6 +1598,8 @@ class FolioCharge(Workflow, ModelSQL, ModelView):
|
|||
readonly=True)
|
||||
amount = fields.Function(fields.Numeric('Amount', digits=(16, 2)),
|
||||
'get_amount')
|
||||
amount_w_tax = fields.Function(fields.Numeric('Amount w Tax',
|
||||
digits=(16, 2)), 'get_amount_w_tax')
|
||||
taxed_amount = fields.Function(fields.Numeric('Amount with Tax',
|
||||
digits=(16, 2)), 'get_taxed_amount')
|
||||
kind = fields.Selection([
|
||||
|
@ -1739,21 +1741,27 @@ class FolioCharge(Workflow, ModelSQL, ModelView):
|
|||
return today
|
||||
|
||||
def get_amount(self, name=None):
|
||||
res = 0
|
||||
if self.quantity and self.unit_price:
|
||||
return self.quantity * self.unit_price
|
||||
return 0
|
||||
res = self.quantity * self.unit_price
|
||||
return res
|
||||
|
||||
def get_amount_w_tax(self, name=None):
|
||||
res = 0
|
||||
if self.quantity and self.unit_price_w_tax:
|
||||
res = self.quantity * self.unit_price_w_tax
|
||||
return res
|
||||
|
||||
def get_unit_price_w_tax(self, name=None):
|
||||
Tax = Pool().get('account.tax')
|
||||
res = self.unit_price or 0
|
||||
if self.unit_price and not self.folio.taxes_exception:
|
||||
values = Tax.compute(self.product.template.customer_taxes_used,
|
||||
_taxes = Tax.compute(
|
||||
self.product.template.customer_taxes_used,
|
||||
self.unit_price, 1)
|
||||
if values:
|
||||
value = values[0]
|
||||
res = value['base'] + value['amount']
|
||||
res = round(res, 2)
|
||||
return res
|
||||
for tax in _taxes:
|
||||
res += tax['amount']
|
||||
return round(res, 2)
|
||||
|
||||
def do_stock_move(self, name=None):
|
||||
pool = Pool()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[tryton]
|
||||
version=6.0.123
|
||||
version=6.0.124
|
||||
depends:
|
||||
party
|
||||
company
|
||||
|
|
|
@ -20,6 +20,8 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="unit_price_w_tax"/>
|
||||
<label name="amount"/>
|
||||
<field name="amount"/>
|
||||
<label name="amount_w_tax"/>
|
||||
<field name="amount_w_tax"/>
|
||||
<label name="kind"/>
|
||||
<field name="kind"/>
|
||||
<group col="8" id="invoice_state" string="Invoice State" colspan="4">
|
||||
|
|
|
@ -9,7 +9,7 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="quantity"/>
|
||||
<field name="unit_price" expand="1"/>
|
||||
<field name="unit_price_w_tax"/>
|
||||
<field name="amount" expand="1"/>
|
||||
<field name="amount_w_tax" expand="1"/>
|
||||
<field name="order"/>
|
||||
<field name="invoice_to"/>
|
||||
<field name="state" expand="1"/>
|
||||
|
|
Loading…
Reference in New Issue