5067

Interest Across Rate Changes

Algorithm
Medium
Pro
finance
dates
rounding

Interest Across Rate Changes

Statutory late-payment interest follows the central bank's base rate, and the base rate moves during the year — so a finance charge memo for a long-overdue invoice spans several interest rates, each valid from its own starting date. The accounting department wants the interest computed the way Business Central's multiple-interest-rates feature does it: per rate window, not one rate times the whole overdue period.

Requirements

Create two objects. Pick object IDs in the range 50100–50199, and reference other objects by name, never by ID.

A table named "Finance Charge Rate" with exactly these fields (the tests create records in a temporary copy of it, writing every field by name):

  • "Start Date" (Date) — the first calendar day this rate line is in force; make it the primary key.
  • "Interest Rate" (Decimal) — the interest in percent per interest period.
  • "Interest Period (Days)" (Integer) — how many days one interest period lasts (360, 365, 30, …).

A codeunit named "Finance Charge Interest" with one public procedure:

procedure CalculateInterest(Amount: Decimal; DueDate: Date; ClosingDate: Date; DocumentDate: Date; var FinanceChargeRate: Record "Finance Charge Rate" temporary): Decimal

Amount is the overdue amount of one customer ledger entry, DueDate its due date, ClosingDate the date it was paid (0D if it is still open), and DocumentDate the document date of the finance charge memo being created. FinanceChargeRate holds the rate lines; the procedure may filter and reposition it freely.

The rest of the statement and 3 hints Unlock with Pro
ALBusiness Central 28.5
Pro
Pro problem

Solve it with Pro

You’re reading the opening of the statement. Pro unlocks the whole problem:

  • The full statement
  • Starter code in the browser editor
  • 17 grading tests, run on Business Central 28.5
  • 3 hints
  • The reference solution

Pro also opens all 92 Pro problems and lifts the daily limits on compile checks and submissions.

$10 / month
or $100 / year
Upgrade
This problem is part of Pro
Pro unlocks the full statement, tests, hints and solution. The code editor works on a computer.
Upgrade