{
  "schemaVersion": 1,
  "fixtureId": "restaurant-procure-to-pay-v1",
  "kit": "restaurant-cafe",
  "asOf": "2026-09-08",
  "currency": "CAD",
  "taxName": "GST",
  "taxRate": "0.05",
  "moneyFormat": "Every monetary value below is a decimal string with exactly two places.",
  "documentCounts": {
    "priceListRows": 48,
    "purchaseOrders": 4,
    "purchaseOrderLines": 12,
    "goodsReceivedNotes": 4,
    "goodsReceivedLines": 12,
    "invoiceDocuments": 5,
    "distinctInvoiceNumbers": 4,
    "invoiceLines": 14,
    "creditNotes": 2,
    "statements": 2,
    "remittanceLines": 13,
    "threeWayMatchRows": 14
  },
  "priceList": {
    "suppliers": [
      "SUP-01",
      "SUP-02"
    ],
    "items": [
      "ING-01",
      "ING-02",
      "ING-03",
      "ING-04",
      "ING-05",
      "ING-06"
    ],
    "effectiveDates": [
      "2026-08-05",
      "2026-08-12",
      "2026-08-19",
      "2026-08-26"
    ],
    "contractTierMinQuantity": 250,
    "contractTierReachedByAnyOrder": false
  },
  "purchaseOrders": [
    {
      "poNumber": "PO-CAF-1001",
      "poDate": "2026-08-05",
      "supplierId": "SUP-01",
      "lines": 3,
      "netTotal": "330.69",
      "taxTotal": "16.53",
      "grossTotal": "347.22"
    },
    {
      "poNumber": "PO-CAF-1002",
      "poDate": "2026-08-12",
      "supplierId": "SUP-02",
      "lines": 3,
      "netTotal": "332.22",
      "taxTotal": "16.61",
      "grossTotal": "348.83"
    },
    {
      "poNumber": "PO-CAF-1003",
      "poDate": "2026-08-19",
      "supplierId": "SUP-01",
      "lines": 3,
      "netTotal": "208.19",
      "taxTotal": "10.41",
      "grossTotal": "218.60"
    },
    {
      "poNumber": "PO-CAF-1004",
      "poDate": "2026-08-26",
      "supplierId": "SUP-02",
      "lines": 3,
      "netTotal": "191.06",
      "taxTotal": "9.56",
      "grossTotal": "200.62"
    }
  ],
  "goodsReceived": [
    {
      "grnNumber": "GRN-CAF-2001",
      "poNumber": "PO-CAF-1001",
      "orderedQuantity": 48,
      "deliveredQuantity": 48,
      "returnedQuantity": 0,
      "acceptedQuantity": 48,
      "lineStatuses": [
        "received in full",
        "received in full",
        "received in full"
      ]
    },
    {
      "grnNumber": "GRN-CAF-2002",
      "poNumber": "PO-CAF-1002",
      "orderedQuantity": 63,
      "deliveredQuantity": 59,
      "returnedQuantity": 0,
      "acceptedQuantity": 59,
      "lineStatuses": [
        "received in full",
        "short delivery",
        "received in full"
      ]
    },
    {
      "grnNumber": "GRN-CAF-2003",
      "poNumber": "PO-CAF-1003",
      "orderedQuantity": 87,
      "deliveredQuantity": 87,
      "returnedQuantity": 0,
      "acceptedQuantity": 87,
      "lineStatuses": [
        "received in full",
        "substituted",
        "received in full"
      ]
    },
    {
      "grnNumber": "GRN-CAF-2004",
      "poNumber": "PO-CAF-1004",
      "orderedQuantity": 66,
      "deliveredQuantity": 66,
      "returnedQuantity": 3,
      "acceptedQuantity": 63,
      "lineStatuses": [
        "received in full",
        "received in full",
        "part returned"
      ]
    }
  ],
  "invoices": [
    {
      "invoiceNumber": "INV-CAF-5001",
      "invoiceDate": "2026-08-07",
      "dueDate": "2026-09-06",
      "supplierId": "SUP-01",
      "poNumber": "PO-CAF-1001",
      "grnNumber": "GRN-CAF-2001",
      "lines": 3,
      "netTotal": "330.69",
      "lineTaxSum": "16.53",
      "documentLevelTax": "16.53",
      "statedTaxTotal": "16.53",
      "totalDue": "347.22",
      "usesDuplicateNumber": false
    },
    {
      "invoiceNumber": "INV-CAF-5002",
      "invoiceDate": "2026-08-14",
      "dueDate": "2026-09-13",
      "supplierId": "SUP-02",
      "poNumber": "PO-CAF-1002",
      "grnNumber": "GRN-CAF-2002",
      "lines": 3,
      "netTotal": "332.22",
      "lineTaxSum": "16.61",
      "documentLevelTax": "16.61",
      "statedTaxTotal": "16.61",
      "totalDue": "348.83",
      "usesDuplicateNumber": false
    },
    {
      "invoiceNumber": "INV-CAF-5003",
      "invoiceDate": "2026-08-21",
      "dueDate": "2026-09-20",
      "supplierId": "SUP-01",
      "poNumber": "PO-CAF-1003",
      "grnNumber": "GRN-CAF-2003",
      "lines": 3,
      "netTotal": "767.60",
      "lineTaxSum": "38.38",
      "documentLevelTax": "38.38",
      "statedTaxTotal": "38.39",
      "totalDue": "805.99",
      "usesDuplicateNumber": false
    },
    {
      "invoiceNumber": "INV-CAF-5004",
      "invoiceDate": "2026-08-28",
      "dueDate": "2026-09-27",
      "supplierId": "SUP-02",
      "poNumber": "PO-CAF-1004",
      "grnNumber": "GRN-CAF-2004",
      "lines": 3,
      "netTotal": "191.06",
      "lineTaxSum": "9.56",
      "documentLevelTax": "9.55",
      "statedTaxTotal": "9.56",
      "totalDue": "200.62",
      "usesDuplicateNumber": false
    },
    {
      "invoiceNumber": "INV-CAF-5002",
      "invoiceDate": "2026-08-17",
      "dueDate": "2026-09-16",
      "supplierId": "SUP-02",
      "poNumber": "PO-CAF-1002",
      "grnNumber": "GRN-CAF-2002",
      "lines": 2,
      "netTotal": "277.62",
      "lineTaxSum": "13.88",
      "documentLevelTax": "13.88",
      "statedTaxTotal": "13.88",
      "totalDue": "291.50",
      "usesDuplicateNumber": true
    }
  ],
  "creditNotes": [
    {
      "creditNoteNumber": "CN-CAF-7001",
      "againstInvoiceNumber": "INV-CAF-5002",
      "creditedQuantity": 4,
      "netTotal": "10.40",
      "taxTotal": "0.52",
      "grossTotal": "10.92",
      "overCreditedUnits": 0
    },
    {
      "creditNoteNumber": "CN-CAF-7002",
      "againstInvoiceNumber": "INV-CAF-5004",
      "creditedQuantity": 5,
      "netTotal": "7.60",
      "taxTotal": "0.38",
      "grossTotal": "7.98",
      "overCreditedUnits": 2
    }
  ],
  "statements": [
    {
      "statementNumber": "STM-CAF-6001",
      "statementDate": "2026-08-31",
      "supplierId": "SUP-01",
      "rows": 5,
      "closingBalance": "1726.12",
      "declaredAgeing": {
        "current": "1153.21",
        "31-60": "243.05",
        "61-90": "190.97",
        "90-plus": "138.89"
      },
      "trueAgeing": {
        "current": "1153.21",
        "31-60": "243.05",
        "61-90": "190.97",
        "90-plus": "138.89"
      },
      "declaredAgeingSum": "1726.12",
      "ageingDifference": "0.00",
      "omittedFromAgeing": null
    },
    {
      "statementNumber": "STM-CAF-6002",
      "statementDate": "2026-08-31",
      "supplierId": "SUP-02",
      "rows": 8,
      "closingBalance": "1449.94",
      "declaredAgeing": {
        "current": "832.97",
        "31-60": "261.62",
        "61-90": "209.30",
        "90-plus": "156.97"
      },
      "trueAgeing": {
        "current": "822.05",
        "31-60": "261.62",
        "61-90": "209.30",
        "90-plus": "156.97"
      },
      "declaredAgeingSum": "1460.86",
      "ageingDifference": "10.92",
      "omittedFromAgeing": "CN-CAF-7001"
    }
  ],
  "remittance": {
    "remittanceNumber": "REM-CAF-8001",
    "paymentDate": "2026-09-05",
    "remittanceTotal": "1235.99",
    "withheldTotal": "1940.07",
    "statementsClosingTotal": "3176.06",
    "reconciliation": "remittanceTotal + withheldTotal == statementsClosingTotal",
    "paidDocuments": [
      "OPN-CAF-9001",
      "OPN-CAF-9002",
      "INV-CAF-5001",
      "OPN-CAF-9004",
      "OPN-CAF-9005",
      "INV-CAF-5004",
      "CN-CAF-7002"
    ],
    "withheldDocuments": [
      "OPN-CAF-9003",
      "INV-CAF-5003",
      "OPN-CAF-9006",
      "INV-CAF-5002",
      "INV-CAF-5002",
      "CN-CAF-7001"
    ]
  },
  "threeWayMatch": {
    "rows": 14,
    "matchedRows": 9,
    "exceptionRows": 5,
    "resultCounts": {
      "duplicate-invoice-number": 2,
      "item-substituted": 1,
      "matched": 9,
      "matched-credit-expected": 1,
      "quantity-variance": 1
    }
  },
  "costingTraps": {
    "purchaseOrderNetAtListPrice": "1062.16",
    "purchaseOrderNetIfContractTierApplied": "1019.91",
    "purchaseOrderNetIfCasePriceReadAsUnitPrice": "16267.72",
    "note": "The first figure is correct. The second is what a costing engine produces if it applies the contract tier price without checking the break quantity. The third is what it produces if it reads price_per_case as the unit price."
  },
  "deliberateDefects": [
    {
      "id": "vat-rounding-one-cent",
      "title": "Stated tax total is one cent above the sum of the line tax amounts",
      "documents": [
        "INV-CAF-5003 dated 2026-08-21"
      ],
      "detail": "Invoice INV-CAF-5003 states a tax total of 38.39 CAD and a total due of 805.99 CAD. Its three line tax amounts sum to 38.38 CAD, one cent less. The document-level calculation round(net x 0.05, 2) on a net of 767.60 gives 38.38 CAD.",
      "assertion": "statedTaxTotal - lineTaxSum == 0.01"
    },
    {
      "id": "po-invoice-quantity-mismatch",
      "title": "Invoice bills the ordered quantity after a recorded short delivery",
      "documents": [
        "INV-CAF-5002 line 2",
        "GRN-CAF-2002 line 2"
      ],
      "detail": "Purchase order PO-CAF-1002 line 2 ordered 21 l of ING-03. Goods-received note GRN-CAF-2002 records 17 l delivered. Invoice INV-CAF-5002 line 2 bills 21 l, a variance of 4 l and 10.40 CAD net.",
      "assertion": "invoicedQuantity - deliveredQuantity == 4"
    },
    {
      "id": "duplicate-invoice-number",
      "title": "Two different invoices carry the same invoice number",
      "documents": [
        "INV-CAF-5002 dated 2026-08-17",
        "INV-CAF-5002 dated 2026-08-14"
      ],
      "detail": "Invoice number INV-CAF-5002 is used twice: once dated 2026-08-14 with 3 lines totalling 348.83 CAD, and again dated 2026-08-17 with 2 lines totalling 291.50 CAD. Both are listed on statement STM-CAF-6002 and both are included in its closing balance.",
      "assertion": "count(invoices where invoiceNumber == that number) == 2"
    },
    {
      "id": "credit-note-over-credit",
      "title": "Credit note credits more units than the goods-received note records returned",
      "documents": [
        "CN-CAF-7002",
        "GRN-CAF-2004"
      ],
      "detail": "Goods-received note GRN-CAF-2004 line 3 records 3 each returned. Credit note CN-CAF-7002 credits 5 each at 1.52 CAD. The 2 each difference overstates the credit by 3.04 CAD net and 3.19 CAD including GST.",
      "assertion": "creditedQuantity - returnedQuantity == 2"
    },
    {
      "id": "statement-ageing-does-not-sum",
      "title": "Statement ageing buckets do not sum to the closing balance",
      "documents": [
        "STM-CAF-6002"
      ],
      "detail": "Statement STM-CAF-6002 for supplier SUP-02 declares ageing buckets of 832.97 current, 261.62 at 31-60 days, 209.30 at 61-90 days and 156.97 over 90 days, summing to 1460.86 CAD. The closing balance on the same document is 1449.94 CAD. The difference of 10.92 CAD is exactly credit note CN-CAF-7001, which appears in the transaction lines but was never applied to the ageing analysis.",
      "assertion": "sum(declaredAgeing) - closingBalance == creditNote.grossTotal"
    },
    {
      "id": "edi-segment-count-trailer",
      "title": "EDI 810 SE segment count disagrees with the actual segment count",
      "documents": [
        "edi-810-invalid-segment-count.edi"
      ],
      "detail": "The SE segment of the invalid interchange declares a segment count two lower than the number of segments actually present between ST and SE inclusive. Every other segment, the ISA/GS/GE/IEA control numbers and the TDS total are unchanged from edi-810-invoice.edi, so a parser that checks only syntax accepts the file.",
      "assertion": "SE01 != count(segments from ST to SE inclusive)"
    }
  ]
}
