liveBook · Manning

Invoice

As explained in Data-Oriented Programming in Java

An invoice is a document or domain entity stating an amount owed for supplied goods or services.

An invoice states what a customer owes for services. It begins open when issued and becomes closed when paid, with an invoice date and a due date shaped by payment terms. section 5.1.1

Several details make the apparently simple model more consequential:

  • Past-due status depends on the customer's rating: good customers receive a longer grace period, while others incur fees sooner. section 5.1.1
  • Invoice numbers belong to a centralized billing service, which allocates the number and delivers the real invoice; the local service acts as an intermediary. section 5.1.1
  • A record such as PastDue(Invoice invoice) can wrap what is known about an invoice without pretending that the underlying Invoice is immutable. section 5.4.1

This boundary makes the domain meaning explicit while containing legacy mutability. Data orientation complements object-oriented design here: clarity matters more than enforcing immutable-data purity, and the boundary can be redrawn later. section 5.4.1

Listing 5.21 Creating the PastDue type
record PastDue(Invoice invoice){}   #A

A compact Java record shows how PastDue can quarantine an Invoice's mutable identity behind a named domain type. section 5.4.1

How Data-Oriented Programming in Java covers it

How deep it goes
Explains lifecycle, dates, grace periods, numbering, and a record wrapper, but stops short of a complete invoice implementation.
Examples
Uses open and closed states, invoice and due dates, grace periods, centralized numbering, and a PastDue Java record.
What it assumes
Assumes familiarity with invoices and Java records, while deriving payment timing and mutability concerns from the domain.
What you can do after
Apply via Java records to name derived invoice information while containing an underlying mutable entity.
How it connects
Connects invoices to payment terms, customer rating, grace periods, mutable entities, records, and data orientation.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data-Oriented Programming in Java. The section links point to the parts of the book it draws on.