Invoice Lifecycle
An invoice has two independent state machines: a workflow status and a payment
status. They're updated by two different endpoints and don't move in lock-step, except that marking an
invoice fully paid also advances its workflow status to paid.
Workflow status
text
CREATE
|
v
[draft] <--------+
| |
approve/reject revert to draft
| |
+-----+-----+---------+
v v
[approved] [cancelled]
|
(once validated/submitted/transmitted/reported to FIRS, the invoice is
locked — Update Invoice returns 409 and further status changes stop
making sense outside FIRS's own lifecycle)
| From | To | Action |
|---|---|---|
| draft | approved | Update status to approved |
| draft | cancelled | Update status to cancelled |
| approved | draft | Revert with draft status |
Payment status
text
[pending]
/ | \
v v v
[rejected] [partial] [paid] (requires status = approved first)
|
v
[paid] (once amount_paid reaches the payable amount, send
status = paid to close it out)
| From | To | Action |
|---|---|---|
| pending | partial | Update payment status to partial with an amount |
| partial | partial | Repeat with another amount — installments accumulate against the payable amount |
| pending / partial | paid | Update payment status to paid (workflow status must already be approved) |
| pending | rejected | Update payment status to rejected |