Declining Balance, Then Straight Line
Business Central's DB1/SL depreciation method front-loads depreciation with a declining-balance percentage, then switches to straight-line the moment straight-line over the remaining life yields more — and a real fixed-asset ledger must land the book value on the salvage value to the cent, no matter how many periods rounded along the way. You will build that schedule generator, distilled to its core.
Requirements
The starter contains a table "Depr. Schedule Line" and an enum "Depr. Line Method" (values "Declining Balance" and "Straight Line"). Keep both exactly as shipped — the grading tests read the table and reference the enum values by name:
"Period No."—Integer, the primary key,1-basedMonths—Integer, the number of months the period coversMethod—Enum "Depr. Line Method", which formula produced the period's amountAmount—Decimal, the period's depreciation, always whole cents"Book Value"—Decimal, the book value at the end of the period, always whole cents
Create a codeunit named "Depreciation Scheduler" with one public procedure:
procedure BuildSchedule(var ScheduleLine: Record "Depr. Schedule Line"; AcquisitionCost: Decimal; SalvageValue: Decimal; LifeYears: Integer; DecliningBalancePct: Decimal; FirstYearMonths: Integer): IntegerIt writes the complete depreciation schedule into the buffer, one line per period, and returns the "Period No." of the first line whose Method is "Straight Line".
Whenever a rule below says an amount is rounded, it means AL's default Round to 0.01 — to the nearest cent, halves away from zero.
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
- 7 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