5065

To the Last Cent

Algorithm
Medium
Pro
rounding
deferral
allocation

To the Last Cent

Finance defers a 12-month service contract and expects every month to carry its slice of the revenue — and the twelve slices to add up to the invoice, exactly. Divide 100.00 by 12 and round each line and you have created four missing cents; the base application's Deferral Utilities solve this by making one line absorb the rounding drift. You are building that generator: two allocation methods, currency precision on every line, and a schedule that always sums back to the source amount to the last cent.

Requirements

The starter contains a table named "Deferral Schedule Line" — the buffer your code fills. Keep its fields and keys exactly as shipped; the grading tests read the lines back from it:

  • "Period No." — Integer, the primary key, numbered 1..NoOfPeriods
  • "Posting Date" — Date, the first day of the period
  • Amount — Decimal, the slice of the source amount deferred into the period

Create a codeunit named "Deferral Schedule" with two public procedures:

procedure GenerateStraightLine(var DeferralScheduleLine: Record "Deferral Schedule Line"; TotalAmount: Decimal; StartDate: Date; NoOfPeriods: Integer)

procedure GenerateDaysPerPeriod(var DeferralScheduleLine: Record "Deferral Schedule Line"; TotalAmount: Decimal; StartDate: Date; NoOfPeriods: Integer)
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
  • 12 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