5074

Aging As Of Any Date

Algorithm
Medium
Pro
aging
application-entries
temporary-table
date-math

Aging As Of Any Date

The Aged Accounts Receivable report has an innocent-looking option nobody thinks about until the auditors ask for it: "aged as of December 31". Printing today's open amounts is easy — reconstructing what was open ten months ago means unwinding every payment application posted since. An invoice that is fully closed today may have been wide open at the as-of date, and an invoice sitting in the ledger today may not have existed yet. That reconstruction is this task.

Requirements

The starter contains three tables — keep their fields and keys exactly as shipped; the grading tests seed the first two and read the third back:

"Aging Ledger Entry" — one row per posted sales invoice:

  • "Entry No." — Integer, the primary key
  • "Customer No." — Code[20]
  • "Posting Date" — Date, when the invoice was posted
  • "Due Date" — Date
  • "Original Amount" — Decimal, the amount the invoice was posted with
  • "Remaining Amount" — Decimal, what is still open today, after every application ever posted
  • Open — Boolean, whether the invoice is still open today

"Aging Application" — one row per posted application of a payment to an invoice:

  • "Entry No." — Integer, the primary key
  • "Invoice Entry No." — Integer, the "Entry No." of the applied invoice
  • "Amount Applied" — Decimal
  • "Application Date" — Date, when the application was posted

"Aging Bucket" — the result, primary key ("Customer No.", "Bucket No."):

  • "Customer No." — Code[20]
  • "Bucket No." — Integer, 0 to 4
  • Amount — Decimal

Create a codeunit named "Retro Aging" with one public procedure:

procedure ComputeAging(var AgingLedgerEntry: Record "Aging Ledger Entry"; var AgingApplication: Record "Aging Application"; AsOfDate: Date; var AgingBucket: Record "Aging Bucket")
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
  • 11 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