Skip to content

Accepted billing basis and reservations

The project billing basis records accepted commercial rows and the amount already reserved or consumed by linked invoices. It preserves the source quote and quote-line identity. Its remainder answers what can be selected for further billing under that accepted authority; it is not an account balance, a payment receipt or a measurement of performed work.

Accepted agreements establish commercial authority. A historical source-offer link alone does not. The settlement workflow owns the full invoice, correction and provider sequence; this article explains the basis within that sequence.

flowchart LR
Accepted[Accepted quote and selected rows] --> Basis[Project billing basis]
Basis --> Select[Reviewed positive amount selection]
Select --> Atomic[Atomic invoice and basis reservation]
Atomic --> Draft[Editable invoice draft]
Draft --> External[Separate accounting and delivery]
Draft --> Release[Draft deletion releases basis]
External --> Credit[Locked linked credit restores reversed basis]
Source authority, reserved basis and external outcomes retain separate owners.

Mandatory quote rows move into the basis; optional rows require the acceptance’s selected_at. The basis retains currency, VAT category/rate, commercial quantity/price, article/account and household-work provenance. Fixed-price quote-hour allocations remain estimated provenance, separate from reported eligible hours.

The service reads complete ordered quote/basis sets when reconciling their source relationships. The database transaction for invoice creation then locks and rechecks consumption. A generic successful source-row synchronization is not a guarantee that every preceding service request was one transaction.

State or action Basis meaning Required boundary
Accepted row Authorized commercial amount Accepted version and selected option evidence
Partial invoice selection Explicit positive amount from selected rows No row can exceed its current remainder
Final selection Remaining eligible basis when no narrower selection is supplied Historical invoice links and incomplete reconciliation can block creation
Created invoice draft Reserved/consumed amount linked to exact invoice lines Header, lines, deduction rows and reservations commit atomically
Deleted draft / restored draft Release / reacquire its basis and applicable estimated hours Restore fails if the released amount was used elsewhere
Locked source-linked credit Release the exact reversed source amount Credit must remain within the original consumption; reversal of the lock reacquires basis

create_project_invoice_from_basis validates the persisted invoice-line amount against its basis consumption. Concurrent requests cannot each reserve the same remainder. A manual adjustment needs its own explicit reason and line; it does not rewrite the accepted source or create agreement evidence.

The current API generates an invoice ID rather than accepting a general client replay key for this creation. Atomicity therefore does not make repeating a lost-response request harmless. Inspect the project invoice list and remainder before another deliberate creation. If enough basis remains, an unchecked repeat can create another partial invoice.

Imported invoices that lack reconciled basis links block new billing rather than making the accepted quote appear wholly unbilled. A missing historical allocated-hour value remains unknown. Do not derive performed hours from the invoiced percentage or silently treat missing provenance as zero.

A non-deduction SEK basis row authorizes 10,000 excluding VAT. A draft reserving 3,000 leaves 7,000 available. Deleting that draft releases its reservation; restoring it must reserve the same amount again against the current remainder.

If the 3,000 invoice proceeds and a supported locked linked credit reverses 1,500 of that source, the reversal restores 1,500 to the available basis. It does not prove a customer refund or an accounting settlement. Another invoice can consume only the resulting current remainder. Payment reconciliation needs its own provider evidence.

The service tests specify selected rows, exact amounts, source traceability, hour provenance and RPC calls. Database tests establish lock, rollback and concurrency invariants when executed on the local stack. Neither proves every live financial variant accepted. Current financial acceptance remains separately scoped, and Vi Målar must not be used for a real Fortnox write test.

See application transactions, database transactions and deduction evidence for adjacent boundaries.