late_payment

What a supplier claims for an invoice paid late: the day it fell due, how many days late it was paid, and the fixed sum and the interest the rule gives for them

kaname 0.56.0 made this page by checking the file above and the files it reads. If the file's digest is no longer what it says here, the page is out of date.

1 function, total. It calls 1 rule and 1 date of koyomi. It builds no transfer. No decision is written in its code.

Decisions in tables

The decisions the module uses are in the files it reads, each checked by its own language: the rules by rulec, the dates by koyomi, the books by chobo. The module carries their answers and joins them.

The dates file terms

dates/payment_terms.cal: it calls the date due on line 20 (claim).

The rule charges

rules/late_payment_charges.rule, called on line 23 (claim).

Functions

A function's effect puts it in one of three parts. A total function answers every input in the ranges it declares. A function checked when it runs has places the checks could not show: the generated code checks the value there, and when it is outside, fails with the kind of the place (rule and so on). A function that may not stop recurses.

Total

claim

Total: it answers every input in the ranges it declares. Its head writes total, and kaname holds it to that.

None when the invoice was paid by the day it fell due.

fn claim(invoice: Invoice, paid_on: date range >=2026-01-01 <=2029-12-31, reference_rate: rate[step 0.01%] range >=0% <=15%) -> Claim? total
  description "None when the invoice was paid by the day it fell due"
  let due = terms.due(invoiced: invoice.invoiced)
  let late = paid_on - due
  if late >= 1
    let c = charges(debt: invoice.amount, days_late: late, reference_rate: reference_rate)
    Claim { due: due, days_late: late, compensation: c.compensation, interest: c.interest }
  else
    none

Checked when they run

None.

May not stop

None.

Decisions in code

The module's decisions are all in tables.

Examples

kaname check runs each line of examples in the reference interpreter, as a host would call the function, and compares the answer with the one written. The reference interpreter answers these.

claim(invoice: Invoice { id: "inv_1", invoiced: 2026-03-02, amount: 100_000GBPc }, paid_on: 2026-05-20, reference_rate: 0.5%)
  = Claim { due: 2026-03-31, days_late: 50, compensation: 70GBP, interest: 1150GBPc }
claim(invoice: Invoice { id: "inv_2", invoiced: 2026-03-02, amount: 100_000GBPc }, paid_on: 2026-03-31, reference_rate: 0.5%)
  = none