This commit is contained in:
2026-02-15 14:23:33 +01:00
parent 4059cd591e
commit 479e0d4d5a
4 changed files with 35 additions and 33 deletions

View File

@@ -57,7 +57,7 @@ class Fee(ModelSQL,ModelView):
('lumpsum', 'Lump sum'),
('perqt', 'Per qt'),
('pprice', '% price'),
('rate', '% Mth'),
('rate', '% rate'),
('pcost', '% cost price'),
('ppack', 'Per packing'),
], 'Mode', required=True)
@@ -318,32 +318,34 @@ class Fee(ModelSQL,ModelView):
#take period with estimated trigger date
if self.line:
if self.line.purchase.payment_term:
est_date = self.line.purchase.payment_term.get_date()
beg_date = self.fee_date if self.fee_date else Date.today()
factor = InterestCalculator.calculate(
start_date=beg_date,
end_date=est_date,
rate=self.price,
rate_type='annual',
convention='ACT/360',
compounding='simple'
)
est_date = self.line.purchase.payment_term[0].get_date(beg_date)
if est_date and beg_date:
factor = InterestCalculator.calculate(
start_date=beg_date,
end_date=est_date,
rate=self.price,
rate_type='annual',
convention='ACT/360',
compounding='simple'
)
return round(factor * self.line.unit_price * (self.quantity if self.quantity else 0) * sign,2)
return round(factor * self.line.unit_price * (self.quantity if self.quantity else 0) * sign,2)
if self.sale_line:
if self.sale_line.sale.payment_term:
est_date = self.sale_line.sale.payment_term.get_date()
beg_date = self.fee_date if self.fee_date else Date.today()
factor = InterestCalculator.calculate(
start_date=beg_date,
end_date=est_date,
rate=self.price,
rate_type='annual',
convention='ACT/360',
compounding='simple'
)
est_date = self.sale_line.sale.payment_term.get_date(beg_date)
if est_date and beg_date:
factor = InterestCalculator.calculate(
start_date=beg_date,
end_date=est_date,
rate=self.price,
rate_type='annual',
convention='ACT/360',
compounding='simple'
)
return round(factor * self.sale_line.unit_price * (self.quantity if self.quantity else 0) * sign,2)
return round(factor * self.sale_line.unit_price * (self.quantity if self.quantity else 0) * sign,2)
elif self.mode == 'perqt':
if self.shipment_in: