In order to ensure consistency we need to update several running totals upon transaction (allocation, transfer, payment, credit, encumbrance) within a database transaction. This ensures that either all of the records are updated, or none of them are.
In order to avoid partially paid invoices, we need to apply all payments/credits for an invoice at once. The approach for this is documented on the wiki (see below). When applying the payments we need to make sure that the running totals in budget and ledger are also updated.
NOTE that this involves creation of a couple new APIs:
- POST /finance-storage/transaction
- POST /finance-storage/invoice-transaction-summaries
- GET /finance-storage/invoice-transaction-summaries/<invoice id>
- DELETE /finance-storage/invoice-transaction-summaries
TODO: @cmcnally to provide details on unique indices to help with making this stuff idempotent.
NOTE: Implied - schema creation: invoice_transaction_summary
- Running totals in budget and ledger are updated as described on wiki upon transaction
- All tables involved are updated within a database transaction
- Unit tests are updated
- JavaMoney API is used for all calculations