Lot invoicing + Fee padding
This commit is contained in:
@@ -4767,7 +4767,7 @@ class LotInvoice(Wizard):
|
||||
val['fee_quantity'] = f.quantity
|
||||
val['fee_price'] = f.price
|
||||
val['fee_unit'] = purchase_line.unit.id
|
||||
val['fee_amount'] = f.amount
|
||||
val['fee_amount'] = self._fee_display_amount(f, act)
|
||||
val['fee_landed_cost'] = f.fee_landed_cost
|
||||
fee_pur.append(val)
|
||||
if line:
|
||||
@@ -4796,7 +4796,7 @@ class LotInvoice(Wizard):
|
||||
val['fee_quantity'] = f.quantity
|
||||
val['fee_price'] = f.price
|
||||
val['fee_unit'] = current_sale_line.unit.id
|
||||
val['fee_amount'] = f.amount
|
||||
val['fee_amount'] = self._fee_display_amount(f, act)
|
||||
val['fee_landed_cost'] = f.fee_landed_cost
|
||||
fee_sale.append(val)
|
||||
if sale_line:
|
||||
@@ -4818,9 +4818,20 @@ class LotInvoice(Wizard):
|
||||
'pp_pur': pp_pur,
|
||||
'fee_sale': fee_sale,
|
||||
'pp_sale': pp_sale,
|
||||
'action': act
|
||||
}
|
||||
|
||||
'action': act
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def _fee_display_amount(fee, action):
|
||||
if (
|
||||
action == 'final'
|
||||
and getattr(fee, 'state', None) == 'invoiced'
|
||||
and getattr(fee, 'add_padding', False)):
|
||||
with Transaction().set_context(
|
||||
_purchase_trade_ignore_fee_padding=True):
|
||||
return fee.amount
|
||||
return fee.amount
|
||||
|
||||
def transition_invoicing(self):
|
||||
Lot = Pool().get('lot.lot')
|
||||
Purchase = Pool().get('purchase.purchase')
|
||||
|
||||
@@ -3402,6 +3402,25 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
||||
self.assertEqual(fee_line.fee_quantity, Decimal('5'))
|
||||
self.assertEqual(fee_line.fee_amount, Decimal('10.00'))
|
||||
|
||||
def test_lot_invoice_default_final_fee_display_ignores_padding(self):
|
||||
'initial final fee display reads amount without padding'
|
||||
class FeeStub:
|
||||
state = 'invoiced'
|
||||
add_padding = True
|
||||
|
||||
@property
|
||||
def amount(self):
|
||||
if Transaction().context.get(
|
||||
'_purchase_trade_ignore_fee_padding'):
|
||||
return Decimal('14970')
|
||||
return Decimal('14985')
|
||||
|
||||
fee = FeeStub()
|
||||
|
||||
self.assertEqual(
|
||||
lot_module.LotInvoice._fee_display_amount(fee, 'final'),
|
||||
Decimal('14970'))
|
||||
|
||||
def test_fee_get_non_cog_returns_zero_without_move_lines(self):
|
||||
'fee non-cog amount is zero before any accounting move line exists'
|
||||
fee = fee_module.Fee()
|
||||
|
||||
Reference in New Issue
Block a user