A functional core concentrates deterministic domain logic in a boundary that depends only on its inputs. Database calls, randomness, clocks, and external services remain outside it, so dependency arrows flow outward toward an imperative shell. section 6.2 section 11.2
A practical design separates the work into two areas:
- Keep pure transformations such as collecting past-due invoices, building fee drafts, and assessing drafts inside the core. section 6.2
- Push billing APIs, approval services, customer facades, rules lookup, and current-date access outside the core. section 6.2
- Give the boundary an explicit home such as a Core class or package, while treating that organization as a convention rather than a requirement. section 6.3
- Pass time, ratings, and other environmental values as data instead of retrieving them inside domain functions. section 11.2
Late-fee assessment
A function such as isPastDue(invoice, rating, currentDate) can decide whether an open standard invoice exceeds its rating-based grace period without consulting a clock or ratings API. The surrounding shell obtains those values and supplies them. Tests then assert directly on inputs and outputs, including generated account or invoice states. section 11.2 section 6.2
Listing 6.28 The simplified view of how data flows through our program
NOTES.md ------------------------------------------------------------------- // step 1: collect the past due List<Invoice> -> List<PastDue> // Step 2: use those to build the draft List<PastDue> -> LateFee<Draft> // Step 3: decide what to do with the draft LateFee<Draft> -> (Billable OR NotBillable OR NeedsReview // then depending on what we decided, either: // Step 4.1: submit billable items Billable -> (LateFee<Billed> OR LateFee<Rejected>) // OR Step 4.2: Start the approval process for those that need it NeedsReviewed -> LateFee<InReview> // OR Step 4.3: keep the non-billable data for posterity NotBillable -> LateFee<Rejected>
Trace the late-fee data flow from past-due invoices through draft assessment and the separate billing, approval, or rejection paths. section 6.2


