Sales Cycle¶
Backend domains:
- app/graphql/quotes/
- app/graphql/orders/
- app/graphql/invoices/ (customer-side; supplier mutations live alongside but belong to the Purchasing Cycle)
- app/graphql/receipts/
- app/graphql/payments/
- app/graphql/credits/ (customer credit notes)
RBAC Paths: QUOTES, ORDERS, INVOICES, RECEIPTS, PAYMENTS, CREDITS.
Overview¶
The customer flow follows the standard PYME sales pipeline:
flowchart LR
Q[Quote] -->|convert| O[Order]
Q -->|convert| I[Invoice]
O -->|convert| I
I -->|partial / full payment| R[Receipt]
R -->|cash batch deposit| P[Payment]
I -->|reversal| C[Credit Note]
I -->|DGI| PAC[(PAC / DGI)]
C -->|DGI| PAC
Each step can be skipped — many PYMES go straight Quote → Invoice without an Order, or Invoice → Receipt without aggregating Payments.
Quotes¶
Quotes are non-posting price proposals. They support per-line discounts and tax rates, client-specific pricing (items_client_discount_*), and bulk operations.
Key mutations: createQuote, updateQuote, deleteQuote, createExistingQuoteForClients (replicate a quote to many clients), bulkDeleteQuotes.
Key queries: getQuoteById, getQuoteByNumber, getQuotedAmountsReport, getQuotesByClientId, getClientQuoteMovementsReport.
Orders¶
Orders confirm a quote and reserve inventory (no GL posting yet). They support partial fulfilment and commission tracking per salesperson.
Key mutations: createOrder, updateOrder, createOrderFromQuote, createOrdersFromQuotes (batch), cancelOrder, deleteOrder.
Key queries: getOrderById, getCommissionPerSalespersonReport, getOrdersByClientId, getClientOrderMovementsReport.
Invoices (customer)¶
Invoices are the first step that posts to the GL (AR ↔ Revenue + ITBMS Payable) and that can be lifted to PAC/DGI. They support multiple line types, multiple tax rates per line, retentions, foreign currency, and conversion from quotes.
Key mutations:
- Create / lifecycle:
createInvoice,updateInvoice,deleteInvoice,voidInvoice,convertInvoiceToInternal. - Conversion:
convertQuoteToInvoice,convertQuotesToInvoices. - Generation (auto-numbering only):
generateInvoice,generateInvoices. - Communication:
resendInvoiceEmail. - DGI lifecycle: see PAC → Invoice Submission and PAC → GraphQL API. Relevant mutations live in
invoices/mutations/dgi_invoice_mutations.py. - Bulk:
bulkInvoiceMutations(delete, convert to DGI, etc.).
Key queries: getInvoiceById, getInvoiceByOrderId, searchOpenInvoices, searchOpenInvoicesForAppointments (medics module).
Frontend pages typically need: landing page response, lite response (for searches), balance response (for AR drill-downs), and detail response.
Receipts¶
A receipt records cash/cheque/transfer/Yappy received from a customer against one or more invoices. Receipts post Cash/Bank ↔ AR and can be partial or pre-paid (find_open_prepayment_receipt_details returns receipt details still owed against future invoices).
Key mutations: createReceipt, updateReceipt, deleteReceipt, bulkDeleteReceipts.
Key queries: getReceiptsById, findOpenPrepaymentReceiptDetails.
Payments (cash batches)¶
payments/ is the deposit-batch concept: many receipts grouped into a single bank deposit / reconciliation line.
Key mutations: createPayment, updatePayment, deletePayment.
Key query: getPaymentsById.
Credits (customer credit notes)¶
A Credit is a customer credit note — a partial or full reversal of an invoice. Once converted to DGI it becomes the legal credit note (notaCredito) attached to the original electronic invoice.
Key mutations: createCredit, cancelCredit, voidCredit, deleteCredit, convertCreditToDgi, bulkConvertCreditsToDgi, bulkDeleteCredits.
Key queries: getCreditById, getCreditsByInvoiceId.
See PAC → Credit Notes for the DGI side.
Cross-cutting¶
- Numbering: every numbered doc in the cycle pulls from
auto_sequences/. Don't roll your own. - Inventory: invoices and orders consume inventory; see Items & Inventory.
- Approvals: not currently wired for quotes / orders / invoices; the framework is there if you want to add it.
- AI tabular import: each domain has a
tabular/package that accepts CSV/XLSX and routes through the standard mutations.