Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Document Flows

Document flow settings control P2P (Procure-to-Pay) and O2C (Order-to-Cash) process generation, including document types, three-way matching, credit checks, and document chain management.

Configuration

document_flows:
  p2p:
    enabled: true
    flow_rate: 0.3
    completion_rate: 0.95
    three_way_match:
      quantity_tolerance: 0.02
      price_tolerance: 0.01

  o2c:
    enabled: true
    flow_rate: 0.3
    completion_rate: 0.95

Procure-to-Pay (P2P)

Flow

Purchase     Purchase    Goods      Vendor     Three-Way
Requisition → Order   → Receipt  → Invoice  → Match    → Payment
                │                     │          │
                │                ┌────┘          │
                ▼                ▼               ▼
           AP Open Item ← Match Result      AP Aging

Purchase Order Types

SyntheticData models 6 PO types, each with different downstream behavior:

TypeDescriptionRequires GR?Use Case
StandardStandard goods purchaseYesMost common PO type
ServiceService procurementNoConsulting, maintenance, etc.
FrameworkBlanket/framework agreementYesLong-term supply agreements
ConsignmentVendor-managed inventoryYesConsignment stock
StockTransferInter-plant transferYesInternal stock movement
SubcontractingExternal processingYesOutsourced manufacturing

Goods Receipt Movement Types

Goods receipts use SAP-style movement type codes:

Movement TypeCodeDescription
GrForPo101Standard GR against purchase order
ReturnToVendor122Return materials to vendor
GrForProduction131GR from production order
TransferPosting301Transfer between plants/locations
InitialEntry561Initial stock entry
Scrapping551Scrap disposal
Consumption201Direct consumption posting

Three-Way Match

The three-way match validator compares Purchase Order, Goods Receipt, and Vendor Invoice to detect variances before payment.

Algorithm

For each invoice line item:
  1. Find matching PO line (by PO reference + line number)
  2. Sum GR quantities for that PO line (supports multiple partial GRs)
  3. Compare:
     a. PO quantity vs GR quantity → QuantityPoGr variance
     b. GR quantity vs Invoice quantity → QuantityGrInvoice variance
     c. PO unit price vs Invoice unit price → PricePoInvoice variance
     d. PO total vs Invoice total → TotalAmount variance
  4. Apply tolerances:
     - Quantity: ±quantity_tolerance (default 2%)
     - Price: ±price_tolerance (default 5%)
     - Absolute: ±absolute_amount_tolerance (default $0.01)
  5. Check over-delivery:
     - If GR qty > PO qty and allow_over_delivery=true:
       allow up to max_over_delivery_pct (default 10%)

Variance Types

Variance TypeDescriptionDetection
QuantityPoGrGR quantity differs from PO quantityPO vs GR comparison
QuantityGrInvoiceInvoice quantity differs from GR quantityGR vs Invoice comparison
PricePoInvoiceInvoice unit price differs from PO pricePO vs Invoice comparison
TotalAmountTotal invoice amount mismatchOverall amount check
MissingLinePO line not found in invoice or GRLine matching
ExtraLineInvoice has lines not on POLine matching

Match Outcomes

OutcomeMeaningAction
passedAll within toleranceProceed to payment
quantity_varianceQuantity outside toleranceReview required
price_variancePrice outside toleranceReview required
blockedMultiple variances or critical mismatchManual resolution

Configuration

document_flows:
  p2p:
    three_way_match:
      enabled: true
      price_tolerance: 0.05              # 5% price variance allowed
      quantity_tolerance: 0.02            # 2% quantity variance allowed
      absolute_amount_tolerance: 0.01     # $0.01 rounding tolerance
      allow_over_delivery: true
      max_over_delivery_pct: 0.10         # 10% over-delivery allowed

P2P Stage Configuration

document_flows:
  p2p:
    enabled: true
    flow_rate: 0.3                       # 30% of JEs from P2P
    completion_rate: 0.95                # 95% complete full flow

    stages:
      po_approval_rate: 0.9             # 90% of POs approved
      gr_rate: 0.98                     # 98% of POs get goods receipts
      invoice_rate: 0.95                # 95% of GRs get invoices
      payment_rate: 0.92                # 92% of invoices get paid

    timing:
      po_to_gr_days:
        min: 1
        max: 30
      gr_to_invoice_days:
        min: 1
        max: 14
      invoice_to_payment_days:
        min: 10
        max: 60

P2P Journal Entries

StageDebitCreditTrigger
Goods ReceiptInventory (1300)GR/IR Clearing (2100)GR posted
Invoice ReceiptGR/IR Clearing (2100)Accounts Payable (2000)Invoice verified
PaymentAccounts Payable (2000)Cash (1000)Payment executed
Price VariancePPV Expense (5xxx)GR/IR Clearing (2100)Price mismatch

Order-to-Cash (O2C)

Flow

Sales     Credit   Delivery    Customer    Customer
Order   → Check  → (Pick/   → Invoice   → Receipt
  │                Pack/         │           │
  │                Ship)         │           │
  │                  │           ▼           ▼
  │                  │      AR Open Item   AR Aging
  │                  │           │
  │                  │           └→ Dunning (if overdue)
  │                  ▼
  │            Inventory Issue
  │            (COGS posting)
  ▼
Revenue Recognition
(ASC 606 / IFRS 15)

Sales Order Types

SyntheticData models 9 SO types:

TypeDescriptionRequires Delivery?
StandardStandard sales orderYes
RushPriority/expedited orderYes
CashSaleImmediate payment at saleYes
ReturnCustomer return orderNo (creates return delivery)
FreeOfChargeNo-charge delivery (samples, warranty)Yes
ConsignmentConsignment fill-up/issueYes
ServiceService order (no physical delivery)No
CreditMemoRequestRequest for credit memoNo
DebitMemoRequestRequest for debit memoNo

Delivery Types

6 delivery types model different fulfillment scenarios:

TypeDescriptionDirection
OutboundStandard outbound deliveryShip to customer
ReturnCustomer return deliveryReceive from customer
StockTransferInter-plant stock transferInternal movement
ReplenishmentReplenishment deliveryWarehouse → store
ConsignmentIssueIssue from consignment stockConsignment → customer
ConsignmentReturnReturn to consignment stockCustomer → consignment

Customer Invoice Types

7 invoice types with different accounting treatment:

TypeDescriptionAR Impact
StandardNormal sales invoiceCreates receivable
CreditMemoCredit for returns/adjustmentsReduces receivable
DebitMemoAdditional chargeIncreases receivable
ProFormaPre-delivery invoice (no posting)None
DownPaymentRequestAdvance payment requestCreates special receivable
FinalInvoiceSettles down paymentClears down payment
IntercompanyIC billingCreates IC receivable

Credit Check

Sales orders pass through credit verification before delivery:

document_flows:
  o2c:
    credit_check:
      enabled: true
      check_credit_limit: true          # Verify customer limit
      check_overdue: true               # Check for past-due AR
      block_threshold: 0.9              # Block if >90% of limit used

O2C Stage Configuration

document_flows:
  o2c:
    enabled: true
    flow_rate: 0.3                       # 30% of JEs from O2C
    completion_rate: 0.95                # 95% complete full flow

    stages:
      so_approval_rate: 0.95            # 95% of SOs approved
      credit_check_pass_rate: 0.9       # 90% pass credit check
      delivery_rate: 0.98               # 98% of SOs get deliveries
      invoice_rate: 0.95                # 95% of deliveries get invoices
      collection_rate: 0.85             # 85% of invoices collected

    timing:
      so_to_delivery_days:
        min: 1
        max: 14
      delivery_to_invoice_days:
        min: 0
        max: 3
      invoice_to_payment_days:
        min: 15
        max: 90

O2C Journal Entries

StageDebitCreditTrigger
DeliveryCost of Goods Sold (5000)Inventory (1300)Goods issued
InvoiceAccounts Receivable (1100)Revenue (4000)Invoice posted
ReceiptCash (1000)Accounts Receivable (1100)Payment received
Credit MemoRevenue (4000)Accounts Receivable (1100)Credit issued

Document Chain Manager

The document chain manager maintains referential integrity across the complete document flow by tracking references between documents.

Reference Types

TypeDescriptionExample
FollowOnNext document in normal flowPO → GR → Invoice → Payment
PaymentPayment for invoicePAY-001 → INV-001
ReversalCorrection or reversal documentCRED-001 → INV-001
PartialPartial fulfillmentGR-001 (partial) → PO-001
CreditMemoCredit against invoiceCM-001 → INV-001
DebitMemoDebit against invoiceDM-001 → INV-001
ReturnReturn against deliveryRET-001 → DEL-001
IntercompanyMatchIC matched pairIC-INV-001 → IC-INV-002
ManualUser-defined referenceAny → Any

Document Chain Output

PO-001 ─→ GR-001 ─→ INV-001 ─→ PAY-001
   │          │          │          │
   └──────────┴──────────┴──────────┘
              Document Chain

The document_references.csv output file records all links:

FieldDescription
source_document_idReferencing document
target_document_idReferenced document
reference_typeType of reference
created_dateDate reference was created

Complex Scenario Examples

Partial Deliveries with Split Invoice

document_flows:
  p2p:
    enabled: true
    flow_rate: 0.4
    completion_rate: 0.90           # 10% incomplete (partial deliveries)
    three_way_match:
      quantity_tolerance: 0.05      # 5% tolerance for partials
      allow_over_delivery: true
      max_over_delivery_pct: 0.10
    timing:
      po_to_gr_days: { min: 3, max: 45 }    # Longer lead times
      gr_to_invoice_days: { min: 1, max: 21 }
      invoice_to_payment_days: { min: 30, max: 90 }

High-Volume Retail O2C

document_flows:
  o2c:
    enabled: true
    flow_rate: 0.5                  # 50% of JEs from O2C
    completion_rate: 0.98           # High completion rate
    stages:
      so_approval_rate: 0.99       # Auto-approved
      credit_check_pass_rate: 0.95
      delivery_rate: 0.99
      invoice_rate: 0.99
      collection_rate: 0.92
    timing:
      so_to_delivery_days: { min: 0, max: 3 }     # Fast fulfillment
      delivery_to_invoice_days: { min: 0, max: 0 } # Immediate invoice
      invoice_to_payment_days: { min: 10, max: 45 }

Combined Manufacturing P2P + O2C

document_flows:
  p2p:
    enabled: true
    flow_rate: 0.35
    completion_rate: 0.95
    three_way_match:
      quantity_tolerance: 0.02
      price_tolerance: 0.01
    timing:
      po_to_gr_days: { min: 5, max: 30 }
      gr_to_invoice_days: { min: 1, max: 10 }
      invoice_to_payment_days: { min: 20, max: 45 }

  o2c:
    enabled: true
    flow_rate: 0.35
    completion_rate: 0.90
    credit_check:
      enabled: true
      block_threshold: 0.85
    timing:
      so_to_delivery_days: { min: 3, max: 21 }
      delivery_to_invoice_days: { min: 0, max: 2 }
      invoice_to_payment_days: { min: 30, max: 60 }

Validation

CheckRule
flow_rate0.0 - 1.0
completion_rate0.0 - 1.0
tolerance values0.0 - 1.0
timing.min≥ 0
timing.max≥ min
Stage rates0.0 - 1.0

See Also