Invoices Collection for Billing #35

Closed
opened 2025-10-19 19:09:58 +00:00 by GFMpt13 · 1 comment
GFMpt13 commented 2025-10-19 19:09:58 +00:00 (Migrated from github.com)

This task is to design the invoices collection, which will store finalized billing records. This collection must be separate from workOrders to ensure fiscal integrity (RNF05) and immutability.

Key Strategy: We will "snapshot" data. When an invoice is created, all relevant details (client info, vehicle info, line items, totals) will be copied from the workOrder into the invoice document. This ensures the invoice record never changes, even if the original client or work order details are modified later.

Requirements Covered

  • RF08 (Automatic invoicing)
  • RB01 (No invoice before FO is concluded)
  • RNF05 (Fiscal requirements)

Tasks

  • Define the invoices schema (e.g., invoiceNumber, invoiceDate, status ['Emitted', 'Paid']).
  • Define the structure for the embedded clientDetails and vehicleDetails snapshots.
  • Define the structure for the copied items array.
  • Add a workOrderId reference to link back to the source work order for traceability.
  • Document the application logic check required to enforce RB01 (i.e., the backend will only allow invoice creation if the corresponding workOrders.status is 'Completed').
This task is to design the `invoices` collection, which will store finalized billing records. This collection must be separate from `workOrders` to ensure fiscal integrity (**RNF05**) and immutability. **Key Strategy:** We will **"snapshot"** data. When an invoice is created, all relevant details (client info, vehicle info, line items, totals) will be **copied** from the `workOrder` into the `invoice` document. This ensures the invoice record never changes, even if the original client or work order details are modified later. ### Requirements Covered * RF08 (Automatic invoicing) * RB01 (No invoice before FO is concluded) * RNF05 (Fiscal requirements) ### Tasks - [x] Define the `invoices` schema (e.g., `invoiceNumber`, `invoiceDate`, `status` ['Emitted', 'Paid']). - [x] Define the structure for the embedded `clientDetails` and `vehicleDetails` snapshots. - [x] Define the structure for the copied `items` array. - [x] Add a `workOrderId` reference to link back to the source work order for traceability. - [x] Document the application logic check required to enforce **RB01** (i.e., the backend will only allow invoice creation if the corresponding `workOrders.status` is 'Completed').
GFMpt13 commented 2025-10-28 15:57:56 +00:00 (Migrated from github.com)

The scheme is looking like this now:
Invoices are a "snapshot"
Image

The scheme is looking like this now: Invoices are a "snapshot" ![Image](https://github.com/user-attachments/assets/6b4dd5cd-854b-4906-ab33-d1d8c28a64cb)
Sign in to join this conversation.
No description provided.