5021

The Entries After December 31st

Filtering
Medium
Pro
closing-date
posting-date
date-filter
fiscal-year
gl-entry

The Entries After December 31st

The finance team ran Close Income Statement for 2024 last night, and this morning your home-grown period report is wrong in both directions: the 2024 income statement suddenly shows zero — the close entries that empty every P&L account landed inside your year window — and the post-close balance you print for the balance sheet is missing exactly the year's profit. The culprit is a Business Central peculiarity with no counterpart in most other stacks: the close entries are not posted on December 31st. They are posted on December 31st's closing — an extra bookkeeping instant the platform wedges between the last day of the year and the first day of the next. Your job is a small period-balance engine that puts every window boundary on the right side of that instant.

Requirements

Create a codeunit named "Period Balance Engine" with three public procedures:

procedure NetChange(GLAccountNo: Code[20]; FromDate: Date; ToDate: Date; IncludeCloseAtEnd: Boolean): Decimal
procedure BalanceAt(GLAccountNo: Code[20]; AtDate: Date; IncludeCloseAtEnd: Boolean): Decimal
procedure CloseEntriesAmount(GLAccountNo: Code[20]; YearEndDate: Date): Decimal

Rules:

  1. All three procedures sum the Amount of G/L Entry records whose "G/L Account No." equals GLAccountNo — entries of other accounts never count, however well their dates match.
  2. The timeline: every calendar day is followed by one extra instant, the day's closing. An entry posted at the closing of a day comes after every normal entry of that day and before the first entry of the next day. Fiscal-year close entries live at the closing of the year's last day, and the grading tests seed entries both on normal days and at closings.
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
  • 15 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