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 で検査して作ったページです。ファイルのハッシュが今のものと違えば、このページは古くなっています。

関数 1 個、total。呼ぶのは規則 1 個と、koyomi の日付 1 個です。振替は組み立てません。コードに書いた判断はありません。

表にある判断

モジュールが使う判断は、読むファイルにあります。規則は rulec が、日付は koyomi が、帳簿は chobo が、それぞれ検査しています。モジュールは、その答えを運んでつなぎます。

日付のファイル terms

dates/payment_terms.cal。日付 due を 20 行目(claim)で呼んでいます。

規則 charges

rules/late_payment_charges.rule。23 行目(claim)で呼んでいます。

関数

関数は、エフェクトで三つに分かれます。total な関数は、宣言した範囲のどの入力にも答えます。実行時に確かめる関数には、検査が示せなかった場所があります。生成したコードはそこで値を確かめ、外れれば、その場所の失敗の種類(rule など)で失敗します。止まらないかもしれない関数は、再帰を持ちます。

total な関数

claim

total な関数です。宣言した範囲のどの入力にも答えます。見出しに total と書いてあり、kaname がそれを確かめています。

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

実行時に確かめる関数

ありません。

止まらないかもしれない関数

ありません。

コードにある判断

このモジュールの判断は、どれも表にあります。

例

kaname check は、examples の行ごとに、ホストが呼ぶときと同じように関数を参照インタプリタで流し、書いてある答えと比べます。参照インタプリタの答えは次のとおりです。

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