Lot invoicing + Fee padding
This commit is contained in:
@@ -5049,6 +5049,8 @@ class LotInvoiceStart(ModelView):
|
||||
return getattr(record, 'id', None) or id(record)
|
||||
|
||||
def _fee_wizard_padding_quantity(self, fee, padding_by_lot):
|
||||
if self._fee_wizard_ignores_padding(fee):
|
||||
return Decimal(0)
|
||||
if not getattr(fee, 'add_padding', False):
|
||||
return Decimal(0)
|
||||
quantity = Decimal(0)
|
||||
@@ -5090,7 +5092,12 @@ class LotInvoiceStart(ModelView):
|
||||
return Decimal(str(getattr(lot.line, 'unit_price', 0) or 0))
|
||||
return Decimal(0)
|
||||
|
||||
@fields.depends('type', 'sale_padding', 'lot_s', 'fee_sale')
|
||||
def _fee_wizard_ignores_padding(self, fee):
|
||||
return (
|
||||
self.action == 'final'
|
||||
and getattr(fee, 'state', None) == 'invoiced')
|
||||
|
||||
@fields.depends('type', 'action', 'sale_padding', 'lot_s', 'fee_sale')
|
||||
def on_change_sale_padding(self):
|
||||
if self.type != 'sale' or not self.fee_sale:
|
||||
return
|
||||
|
||||
@@ -3369,6 +3369,39 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
||||
self.assertEqual(fee_line.fee_quantity, Decimal('7'))
|
||||
self.assertEqual(fee_line.fee_amount, Decimal('14.00'))
|
||||
|
||||
def test_lot_invoice_final_existing_fee_display_ignores_padding(self):
|
||||
'final DN/CN fee display ignores padding for the current value'
|
||||
start = lot_module.LotInvoiceStart()
|
||||
unit = SimpleNamespace(id=1)
|
||||
sale_line = SimpleNamespace(unit=unit, unit_price=Decimal('100'))
|
||||
lot = SimpleNamespace(id=10, sale_line=sale_line)
|
||||
fee = SimpleNamespace(
|
||||
add_padding=True,
|
||||
state='invoiced',
|
||||
mode='pprice',
|
||||
price=Decimal('2'),
|
||||
quantity=Decimal('5'),
|
||||
sale_line=sale_line,
|
||||
_get_effective_fee_lots=Mock(return_value=[lot]),
|
||||
_get_effective_fee_lots_quantity=Mock(return_value=Decimal('5')),
|
||||
_convert_padding_quantity=Mock(
|
||||
side_effect=lambda quantity, unit: Decimal(str(quantity))),
|
||||
get_quantity=Mock(return_value=Decimal('5')))
|
||||
fee_line = SimpleNamespace(
|
||||
fee=fee,
|
||||
fee_quantity=Decimal('5'),
|
||||
fee_amount=Decimal('10'))
|
||||
start.type = 'sale'
|
||||
start.action = 'final'
|
||||
start.sale_padding = Decimal('2')
|
||||
start.lot_s = [SimpleNamespace(lot=lot)]
|
||||
start.fee_sale = [fee_line]
|
||||
|
||||
start.on_change_sale_padding()
|
||||
|
||||
self.assertEqual(fee_line.fee_quantity, Decimal('5'))
|
||||
self.assertEqual(fee_line.fee_amount, Decimal('10.00'))
|
||||
|
||||
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