This commit is contained in:
2026-03-25 18:45:54 +01:00
parent d38d0324d5
commit 1f49c00cff
5 changed files with 131 additions and 13 deletions

View File

@@ -333,20 +333,25 @@ class Fee(ModelSQL,ModelView):
elif self.mode == 'rate':
#take period with estimated trigger date
if self.line:
if self.line.purchase.payment_term:
if self.line.estimated_date:
beg_date = self.fee_date if self.fee_date else Date.today()
est_date = self.line.purchase.payment_term.lines[0].get_date(beg_date,self.line)
if est_date and beg_date:
factor = InterestCalculator.calculate(
start_date=beg_date,
end_date=est_date,
rate=self.price/100,
rate_type='annual',
convention='ACT/360',
compounding='simple'
est_lines = [dd for dd in self.line.estimated_date if dd.trigger == 'bldate']
est_line = est_lines[0] if est_lines else None
if est_line and est_line.estimated_date:
est_date = est_line.estimated_date + datetime.timedelta(
days=est_line.fin_int_delta or 0
)
if est_date and beg_date:
factor = InterestCalculator.calculate(
start_date=beg_date,
end_date=est_date,
rate=self.price/100,
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:
beg_date = self.fee_date if self.fee_date else Date.today()