Lot invoicing + Fee padding
This commit is contained in:
@@ -687,6 +687,8 @@ class Fee(ModelSQL,ModelView):
|
||||
def get_padding_quantity(self):
|
||||
if Transaction().context.get('_purchase_trade_ignore_fee_padding'):
|
||||
return Decimal(0)
|
||||
if getattr(self, 'state', None) == 'invoiced':
|
||||
return Decimal(0)
|
||||
if not getattr(self, 'add_padding', False):
|
||||
return Decimal(0)
|
||||
return sum(
|
||||
|
||||
@@ -3095,6 +3095,7 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
||||
fee.mode = 'pprice'
|
||||
fee.price = Decimal('2')
|
||||
fee.add_padding = True
|
||||
fee.state = 'not invoiced'
|
||||
fee.unit = unit
|
||||
fee.quantity = Decimal('5')
|
||||
fee.line = None
|
||||
@@ -3131,6 +3132,8 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
||||
with patch.object(
|
||||
fee, '_get_effective_fee_lots', return_value=[lot]):
|
||||
self.assertEqual(fee.get_amount(), Decimal('14.00'))
|
||||
fee.state = 'invoiced'
|
||||
self.assertEqual(fee.get_amount(), Decimal('10.00'))
|
||||
with Transaction().set_context(
|
||||
_purchase_trade_ignore_fee_padding=True):
|
||||
self.assertEqual(fee.get_amount(), Decimal('10.00'))
|
||||
|
||||
Reference in New Issue
Block a user