5084

Project WIP Recognition Engine

Algorithm
Hard
Pro
wip
revenue-recognition
projects
rounding

Project WIP Recognition Engine

Every month-end, finance runs Calculate WIP on running projects so the income statement shows earned revenue and matched costs instead of raw postings. Business Central ships five WIP methods for this; you are going to build the recognition arithmetic behind three of them — Percentage of Completion, Cost of Sales, and Completed Contract — as a small stateful engine that is pumped with usage and invoice postings across periods and asked for a fresh recognition snapshot after each one.

Requirements

Create an enum named "Job WIP Recognition Method" with exactly three values, named "Percentage of Completion", "Cost of Sales" and "Completed Contract" (ordinal numbers are your choice).

Create a codeunit named "Job WIP Engine" with five public procedures:

procedure Initialize(WIPMethod: Enum "Job WIP Recognition Method"; BudgetTotalCost: Decimal; BillableTotalPrice: Decimal)
procedure PostUsage(CostAmount: Decimal)
procedure PostInvoice(PriceAmount: Decimal)
procedure CompleteProject()
procedure Recalculate(var RecognizedCosts: Decimal; var RecognizedSales: Decimal; var WIPBalance: Decimal)

Lifecycle rules:

  1. Initialize starts a fresh project on the codeunit instance: it stores the method, the budget total cost and the billable total price, and resets everything else — cumulative usage, cumulative invoiced and the completed flag. Calling Initialize again on the same instance begins a brand-new project with no leftovers from the previous one.
  2. PostUsage adds CostAmount to the project's cumulative usage total cost; PostInvoice adds PriceAmount to the project's cumulative invoiced total price. The tests only ever post positive amounts with at most two decimal places, and BudgetTotalCost / BillableTotalPrice are never negative.
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
  • 19 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