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): DecimalRules:
- All three procedures sum the
AmountofG/L Entryrecords whose"G/L Account No."equalsGLAccountNo— entries of other accounts never count, however well their dates match. - 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.
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.
Already on Pro? Sign in