# Online Invoicing Architecture ## Overview Online invoices are automatically generated upon successful order confirmation via `InvoiceRouter.py` and Celery workers. --- ## Workflow 1. Order reaches status `ORDER_CONFIRMED`. 2. An Outbox event `ORDER_CONFIRMED` is picked up by `InvoiceWorker`. 3. Worker fetches order details, calculates GST, and allocates invoice number from range pool. 4. Worker generates PDF using HTML/WeasyPrint template. 5. PDF saved to object storage (`/uploads/invoices/`) and `pdf_path` updated in MySQL. 6. Email notification with PDF attachment dispatched to customer.