Document Lifecycle

Each document type in Storno.ro has a defined set of statuses and allowed transitions.

Invoice Lifecycle

                                    ┌──────────┐
                              ┌────►│ cancelled │
                              │     └──────────┘
                              │          │
                              │          │ restore
                              │          ▼
┌───────┐  issue  ┌────────┐  │     ┌───────┐  submit  ┌─────────────┐
│ draft │────────►│ issued │──┘     │ draft │         │sent_to_provider│
│       │         │        │────────────────────────►│             │
└───────┘         └────────┘                         └──────┬──────┘

                                              ┌─────────────┼─────────────┐
                                              ▼             ▼             ▼
                                        ┌───────────┐ ┌──────────┐ ┌──────────┐
                                        │ validated  │ │ rejected │ │  error   │
                                        └─────┬─────┘ └──────────┘ └──────────┘

                                    ┌─────────┼──────────┐
                                    ▼         ▼          ▼
                              ┌──────┐ ┌──────────────┐ ┌─────────┐
                              │ paid │ │partially_paid│ │ overdue │
                              └──────┘ └──────────────┘ └─────────┘

Invoice Statuses

StatusDescription
draftInitial state. Invoice can be edited and deleted.
issuedInvoice has been validated and XML/PDF generated. Cannot be edited.
sent_to_providerXML uploaded to e-invoice provider. Awaiting processing.
validatedE-invoice provider accepted the invoice.
rejectedE-invoice provider rejected the invoice. Needs correction.
cancelledInvoice was cancelled. Can be restored to draft.
paidFull payment recorded (amountPaid >= total).
partially_paidPartial payment recorded (0 < amountPaid < total).
overduePast due date with outstanding balance.
syncedIncoming invoice synced from e-invoice provider (not created locally).

Key Rules

  • Only draft invoices can be edited or deleted
  • Issuing an invoice is irreversible (but it can be cancelled)
  • Cancelled invoices can be restored back to draft
  • Payment statuses (paid, partially_paid, overdue) are computed from payment records
  • Credit notes should be used to correct validated invoices

Proforma Invoice Lifecycle

┌───────┐  send   ┌──────┐  accept  ┌──────────┐  convert  ┌───────────┐
│ draft │────────►│ sent │─────────►│ accepted │──────────►│ converted │
│       │         │      │          │          │           │(→ invoice)│
└───┬───┘         └──┬───┘          └──────────┘           └───────────┘
    │                │
    │                │  reject
    │                ▼
    │           ┌──────────┐
    │           │ rejected │
    │           └──────────┘

    │  cancel

┌───────────┐
│ cancelled │
└───────────┘

Proforma Statuses

StatusDescription
draftInitial state. Can be edited and deleted.
sentProforma sent to client. Awaiting response.
acceptedClient accepted the proforma.
rejectedClient rejected the proforma.
convertedProforma converted to a real invoice.
cancelledProforma cancelled.

Key Rules

  • Only draft proformas can be edited
  • Converting creates a new invoice with the same data
  • The convertedInvoice field links to the created invoice

Delivery Note Lifecycle

┌───────┐  issue  ┌────────┐  convert  ┌───────────┐
│ draft │────────►│ issued │──────────►│ converted │
│       │         │        │           │(→ invoice)│
└───┬───┘         └────┬───┘           └───────────┘
    │                   │
    │  cancel           │  cancel
    ▼                   ▼
┌───────────┐     ┌───────────┐
│ cancelled │     │ cancelled │
└───────────┘     └───────────┘

Delivery Note Statuses

StatusDescription
draftInitial state. Can be edited and deleted.
issuedDelivery note issued. Cannot be edited.
convertedConverted to an invoice.
cancelledDelivery note cancelled.

Credit Notes

Credit notes use the Invoice entity with isCreditNote: true. They follow the same lifecycle as invoices but are specifically used to:

  • Correct errors in validated invoices
  • Issue partial or full refunds
  • Adjust quantities or prices

Credit notes reference the original invoice via parentDocumentId.

Payment Tracking

Payments are tracked separately from invoice status:

# Record a payment
POST /api/v1/invoices/{uuid}/payments
{
  "amount": 1000.00,
  "paymentDate": "2026-02-15",
  "paymentMethod": "bank_transfer"
}
  • When amountPaid == total → status becomes paid
  • When 0 < amountPaid < total → status becomes partially_paid
  • When dueDate < today && amountPaid < total → status becomes overdue
  • Deleting a payment recalculates the status

Status Transitions Summary

ActionFromTo
Issue invoicedraftissued
Submit to providerissuedsent_to_provider
Provider validatessent_to_providervalidated
Provider rejectssent_to_providerrejected
Canceldraft, issuedcancelled
Restorecancelleddraft
Full paymentany activepaid
Partial paymentany activepartially_paid
Past due dateany unpaidoverdue