[Invoices] Implementation (Router) #191

Closed
opened 2026-01-19 22:28:21 +00:00 by duarteneves5 · 0 comments
duarteneves5 commented 2026-01-19 22:28:21 +00:00 (Migrated from github.com)

Create src/routers/invoices.py.

Endpoints:

  • POST /: Create (Emit) a new invoice from a WorkOrder.
    • Input: InvoiceCreate (contains workOrderId).
    • Logic: Call repo.create_invoice().
    • Handle ClientAddressMissingError (400) and DuplicateKeyError (500/409).
  • GET /{id}: Retrieve an invoice by ObjectId.
  • GET /: List invoices OR Find by Filter.
    • If ?client_id={val} is present -> Call repo.get_invoices_by_client_id.
    • If ?work_order_id={val} is present -> Call repo.get_invoices_by_work_order_id.
    • Else -> Return all (if implemented) or empty list.
  • PATCH /{id}: Update invoice status.
    • Input: InvoiceUpdate (e.g., status="Paid").
    • Call repo.update_invoice().
Create `src/routers/invoices.py`. **Endpoints:** - **POST /**: Create (Emit) a new invoice from a `WorkOrder`. - Input: `InvoiceCreate` (contains `workOrderId`). - Logic: Call `repo.create_invoice()`. - Handle `ClientAddressMissingError` (400) and `DuplicateKeyError` (500/409). - **GET /{id}**: Retrieve an invoice by ObjectId. - **GET /**: List invoices OR Find by Filter. - If `?client_id={val}` is present -> Call `repo.get_invoices_by_client_id`. - If `?work_order_id={val}` is present -> Call `repo.get_invoices_by_work_order_id`. - Else -> Return all (if implemented) or empty list. - **PATCH /{id}**: Update invoice status. - Input: `InvoiceUpdate` (e.g., status="Paid"). - Call `repo.update_invoice()`.
Sign in to join this conversation.
No description provided.