Lot invoicing + Fee padding

This commit is contained in:
2026-06-23 16:06:17 +02:00
parent cf7aa7f5b5
commit c9dceb9c06
2 changed files with 5 additions and 0 deletions

View File

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

View File

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