Approvals & Sequences¶
Backend domains:
- app/graphql/approval_configs/ — approval rules
- app/graphql/auto_sequences/ — document numbering
RBAC Paths: APPROVAL_CONFIGS, AUTO_SEQUENCES.
Approval configurations¶
ApprovalConfig rules route documents to approvers when they exceed a threshold or match a condition. Today this is wired only on purchase_requisitions/, but the framework is generic — any domain can call into it.
Each config carries:
document_type—PURCHASE_REQUISITION(more to come).condition— currentlyamount >= threshold.approver_user_ids— one or more users who must approve.approval_mode—ANY_ONEorALL.escalation_after_hours— optional time-based escalation.
Key mutations: createApprovalConfig, updateApprovalConfig, deleteApprovalConfig.
Key queries: getAllApprovalConfigs, getApprovalConfig.
When a PR is submitted, purchase_requisitions/services/ looks up the matching config, creates approval records for each approver, and emits a notification (today email-only; WhatsApp planned). The PR cannot convert to a PO until the approval policy is satisfied.
Auto sequences (document numbering)¶
Every numbered document — quote, order, invoice, receipt, payment, PR, PO, JE, credit, supplier invoice, supplier credit — pulls its number from auto_sequences/. This is the centralised, concurrency-safe counter for the tenant.
An AutoSequence carries:
document_type—QUOTE,ORDER,INVOICE,RECEIPT,PAYMENT,PURCHASE_REQUISITION,PURCHASE_ORDER,JOURNAL,CREDIT,SUPPLIER_INVOICE,SUPPLIER_CREDIT, …prefix— e.g.INV-,PO-.padding— pad-to-N zeros, e.g.5→00001.current_value— last issued integer.reset_strategy—NEVER,YEARLY,MONTHLY.branch_code— optional per-branch sub-sequence.
Key mutations: createAutoSequence, updateAutoSequence, deleteAutoSequence, resetAutoSequenceCounter.
Key queries: autoSequences, autoSequence.
Sequences are reserved transactionally — concurrent invoice creations cannot collide on the same number. Numbers are never re-issued, even if the document is deleted (so audit trails stay clean).
Frontend notes¶
- Settings UI for both lives under "Configuración → Documentos".
- A PYME owner should be able to configure a one-step approval ("anything over $500 → me") in under a minute.
- Approval-pending counts should surface on the home dashboard for any user who is an approver.