|
|
for record in self:
example_preview = ""
record.example_preview_discount = ""
currency = record.currency_id
if record.early_discount:
date = record._get_last_discount_date_formatted(record.example_date or fields.Date.context_today(record))
discount_amount = record._get_amount_due_after_discount(record.example_amount, 0.0)
record.example_preview_discount = _(
"Early Payment Discount: <b>%(amount)s</b> if paid before <b>%(date)s</b>",
amount=formatLang(self.env, discount_amount, currency_obj=currency),
date=date,
)
if not record.example_invalid:
terms = record._compute_terms(
date_ref=record.example_date or fields.Date.context_today(record),
currency=currency,
company=self.env.company,
tax_amount=0,
tax_amount_currency=0,
untaxed_amount=record.example_amount,
untaxed_amount_currency=record.example_amount,
sign=1)
for i, info_by_dates in enumerate(record._get_amount_by_date(terms).values()):
date = info_by_dates['date']
amount = info_by_dates['amount']
example_preview += "<div>"
example_preview += _(
"<b>%(count)s#</b> Installment of <b>%(amount)s</b> due on <b style='color: #704A66;'>%(date)s</b>",
count=i+1,
amount=formatLang(self.env, amount, currency_obj=currency),
date=date,
)
example_preview += "</div>"
record.example_preview = example_preview
|
|