I would like to build a ERP system with localization(English and Vietnamese).
ERP - DETAILED BUSINESS FLOWS FOR DEVELOPERS
English flow-by-flow specification (Web + Mobile)
Hard rule: Main Warehouse = inventory storage only. All sales (Wholesale B2B and Retail POS) must be fulfilled from Retail Warehouses.
This document focuses on: process flows, validations, stock ledger rules, and accounting triggers.
0. GLOBAL RULES (APPLY TO ALL MODULES)
0.1 Document states (standard)
• Draft: editable, no stock impact, no accounting posting.
Submitted: locked for key fields; may require approval depending on config. •Approved: allowed to execute downstream actions (receive/deliver/post). Posted/Completed: stock/accounting effects are finalized; limited edit.
• Cancelled: creates reversing entries where applicable; must preserve audit trail.
0.2 Stock Ledger (mandatory)
• No module is allowed to directly update stock balances.
• Every stock movement must append a Stock Ledger row: (timestamp, warehouse, SKU, qty_in, qty_out, unit cost, reference_doc_type, reference_doc_id, balance_after).
• Stock balance for any warehouse/SKU is computed from the ledger (or maintained as a materialized view/cached table but still sourced from ledger).
0.3 Warehouse constraints
• Main Warehouse cannot be selected on Sales Order, Delivery, POS, or Export Delivery documents.
• Retail Warehouse can be selected on Sales Order / POS and receives stock only via Stock Transfer (Main Retail).
• If a user attempts to sell from Main Warehouse: return validation error.
0.4 Accounting triggers (high level)
• Procurement: AP Invoice posts Accounts Payable; GRN may post Inventory accrual depending on configuration.
• Sales: Delivery posts COGS; AR Invoice posts Revenue + VAT + Accounts Receivable. Payments: receipts/payments reduce AR/AP and increase Cash/Bank.
• Import landed cost allocation increases Inventory value (and adjusts COGS if items already sold, optional in Phase 2).
1. SUPPLIER & PROCUREMENT FLOW
1.1 Supplier master
• Create/Update Supplier: legal name, tax ID, address, contact persons, payment terms, currency, bank info.
• Supplier status: Active/Inactive (inactive cannot be used in new POs).
1.2 Purchase Requisition (PR)
• Input: requester, requested warehouse (Main), items (SKU, qty, required date), notes.
• Validations: SKU exists; qty > 0; requester has permission.
• States: Draft → Submitted → Approved → Closed/Cancelled.
• No stock/accounting effect.
1.3 Purchase Order (PO)
Flow:
• Create PO from PR or direct: supplier, currency, items, unit price, tax, expected delivery date, incoterms (optional). • Submit/Approve PO (based on amount threshold).
Allow partial receiving; track ordered_qty, received_qty, remaining_qty per line.
Key validations:
• Suppliers must be Active.
• Currency must be configured; exchange rate required if not base currency.
• Unit price >= 0; qty > 0.
1.4 Goods Receipt Note (GRN) - ALWAYS INTO MAIN WAREHOUSE
Flow:
• Create GRN from PO lines (supports partial).
• Receive quantities; capture batch/lot/expiry if enabled.
• On POST: append Stock Ledger entries: Main Warehouse qty in for each SKU.
Update PO line received_qty.
Validations:
• GRN warehouse must be Main Warehouse (system-enforced).
• Received qty cannot exceed remaining_qty unless 'over-receipt' permission enabled.
• If batch/expiry enabled: require batch number and expiry date.
Accounting trigger (recommended MVP):
• Option A (simple): No accounting at GRN; accounting happens at Supplier Invoice.
• Option B (accrual): GRN posts Inventory Dr / GRNI (Goods Received Not Invoiced) Cr, Supplier Invoice clears GRNI
1.5 Supplier Invoice (AP Invoice) & Payment
• Create AP Invoice linked to PO and/or GRN (3-way match).
• Post AP Invoice: Accounts Payable Cr; Inventory/Expense Dr, VAT input Dr (if applicable).
• Record Payment(s): reduce AP; increase/decrease Cash/Bank.
• AP Aging report based on due dates.
2. INVENTORY & STOCK TRANSFER (MAIN RETAIL)
2.1 Stock Transfer Request
• Create Transfer Request: from_warehouse-Main, to_warehouse-Retail, items (SKU, qty).
• State: Draft → Submitted → Approved.
• No ledger impact until picked/received (depending on design).
2.2 Pick at Main Warehouse
Warehouse staff confirms picked quantities.
• On PICK/ISSUE: append Stock Ledger: Main Warehouse qty_out for each SKU (reference: Transfer).
• State: Issued/In-Transit.
2.3 Receive at Retail Warehouse
• Retail staff confirms received quantities.
On RECEIVE: append Stock Ledger: Retail Warehouse qty in for each SKU (reference: Transfer). State: Completed.
Validations & edge cases
• Do not allow negative stock in Main Warehouse unless explicitly enabled.
• Handle partial receive: keep transfer open with remaining qty in transit.
• If discrepancy: create variance record requiring manager approval.
• Accounting: no P&L; impact; inventory value unchanged (location change only).
3. SALES-WHOLESALE (B2B) FLOW
3.1 Quotation
• Create quotation: customer, price list, items, discount, validity date.
•States: Draft → Submitted → Approved → Converted/Closed.
No stock/accounting impact.
3.2 Sales Order (SO)
• Create SO from quotation or direct.
• Mandatory field: Retail Warehouse (NOT Main).
• Validations: customer Active; credit limit check; item price/discount within allowed thresholds.
States: Draft→ Submitted → Approved → In Fulfillment → Closed/Cancelled.
• No stock impact at SO stage (reservation optional, Phase 2).
3.3 Delivery (Goods Issue) - FROM RETAIL WAREHOUSE
• Create Delivery from approved SO; source warehouse = SO.retail_warehouse.
• On POST: append Stock Ledger qty_out from Retail Warehouse.
• Generate COGS journal entry: COGS Dr/Inventory Cr (based on costing method).
• Allow partial delivery; track delivered_qty vs ordered_qty.
3.4 AR Invoice & Receipt
• Create AR invoice from Delivery (or from SO if allowed).
• On POST: Accounts Receivable Dr, Revenue Cr; VAT Output Cr (if applicable).
• Record Receipt(s): Cash/Bank Dr, Accounts Receivable Cr.
• AR Aging report based on due dates; block new SO if overdue (config).
4. SALES - RETAIL (POS) FLOW
4.1 POS Session (Shift)
• Cashier opens session: selects Retail Warehouse + cash drawer start amount.
• Session states: Open → Closed; cannot sell if session is closed.
4.2 POS Sale
• Scan/select items; apply promotions/discount rules; calculate tax.
• On COMPLETE: append Stock Ledger qty out from Retail Warehouse immediately.
• Create accounting entry: Cash/Bank Dr; Revenue Cr, VAT Output Cr; and COGS Dr/Inventory Cr.
• Print receipt; store unique receipt number.
4.3 POS Return/Refund
• Return by receipt (preferred): reference original receipt.
• On POST: append Stock Ledger qty in to Retail Warehouse.
• Accounting: reverse revenue/VAT and reverse COGS accordingly.
• If the refund method differs from original payment, record difference in payment journal.
5. IMPORT & EXPORT FLOW
5.1 Import Shipment
• Create Import Shipment: supplier, incoterms, ETD/ETA, port, container details. • Attach docs: Commercial Invoice, Packing List, B/L, CO/CQ.
• Link shipment to one or multiple POs.
5.2 Import Receipt & Landed Cost
Receive goods into Main Warehouse via GRN (reference shipment). Capture logistics costs (freight, insurance, customs, local charges).
Allocate landed cost to SKUS by rule: by value / weight/volume/qty (config).
• Update inventory unit cost in ledger for received lots/batches.
5.3 Export Shipment
• Create Export Shipment linked to Sales Orders.
• Delivery must be from Retail Warehouse (per core rule).
• Export docs attached and status tracking (Draft →In Progress → Shipped→ Closed).
6. CRM FLOW
• Lead: capture source, contact details, interest products, owner. • Opportunity: value, stage, probability, expected close date.
• Activities: calls/meetings/notes/tasks; reminders and due dates.
• Conversion: Lead → Customer; Opportunity →Quotation.
7. ACCOUNTING FLOW & PERIOD CLOSING
7.1 Chart of Accounts & Posting Rules
• Configure COA, tax accounts, inventory account, COGS account, AR/AP, Cash/Bank. Auto-posting must create Journal Entries with reference to source document and line items.
7.2 Period Lock
Close period by date: prevent edits/posting before lock date.
Changes after lock require a reversal entry and a new corrected entry (no hard delete).
7.3 Audit Trail
• Log: who, when, action, old value, new value, doc id.
• All cancellations must be reversible records, not deletions.
8. REPORTING DATA SOURCES & DEFINITIONS
• Inventory reports derive from Stock Ledger and current balance views.
• Sales reports derive from AR Invoices (revenue) and Deliveries/COGS.
• Procurement reports derive from PO/GRN/AP Invoice.
• Financial reports derive from General Ledger / Journal Entries.
Minimum dashboards
• CEO: revenue, gross profit, inventory value, AR/AP.
• Sales: pipeline, orders, deliveries, collections.
• Warehouse: stock on hand, transfers, low stock.
• Accounting: AR/AP aging, cash/bank, VAT.
Show More