{
  "schemaVersion": 1,
  "fixtureId": "restaurant-procure-to-pay-v1",
  "kit": "restaurant-bakery",
  "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-BAK-1001",
      "poDate": "2026-08-05",
      "supplierId": "SUP-01",
      "lines": 3,
      "netTotal": "165.41",
      "taxTotal": "8.27",
      "grossTotal": "173.68"
    },
    {
      "poNumber": "PO-BAK-1002",
      "poDate": "2026-08-12",
      "supplierId": "SUP-02",
      "lines": 3,
      "netTotal": "275.86",
      "taxTotal": "13.79",
      "grossTotal": "289.65"
    },
    {
      "poNumber": "PO-BAK-1003",
      "poDate": "2026-08-19",
      "supplierId": "SUP-01",
      "lines": 3,
      "netTotal": "506.52",
      "taxTotal": "25.33",
      "grossTotal": "531.85"
    },
    {
      "poNumber": "PO-BAK-1004",
      "poDate": "2026-08-26",
      "supplierId": "SUP-02",
      "lines": 3,
      "netTotal": "314.06",
      "taxTotal": "15.70",
      "grossTotal": "329.76"
    }
  ],
  "goodsReceived": [
    {
      "grnNumber": "GRN-BAK-2001",
      "poNumber": "PO-BAK-1001",
      "orderedQuantity": 51,
      "deliveredQuantity": 51,
      "returnedQuantity": 0,
      "acceptedQuantity": 51,
      "lineStatuses": [
        "received in full",
        "received in full",
        "received in full"
      ]
    },
    {
      "grnNumber": "GRN-BAK-2002",
      "poNumber": "PO-BAK-1002",
      "orderedQuantity": 66,
      "deliveredQuantity": 62,
      "returnedQuantity": 0,
      "acceptedQuantity": 62,
      "lineStatuses": [
        "received in full",
        "short delivery",
        "received in full"
      ]
    },
    {
      "grnNumber": "GRN-BAK-2003",
      "poNumber": "PO-BAK-1003",
      "orderedQuantity": 90,
      "deliveredQuantity": 90,
      "returnedQuantity": 0,
      "acceptedQuantity": 90,
      "lineStatuses": [
        "received in full",
        "substituted",
        "received in full"
      ]
    },
    {
      "grnNumber": "GRN-BAK-2004",
      "poNumber": "PO-BAK-1004",
      "orderedQuantity": 69,
      "deliveredQuantity": 69,
      "returnedQuantity": 3,
      "acceptedQuantity": 66,
      "lineStatuses": [
        "received in full",
        "received in full",
        "part returned"
      ]
    }
  ],
  "invoices": [
    {
      "invoiceNumber": "INV-BAK-5001",
      "invoiceDate": "2026-08-07",
      "dueDate": "2026-09-06",
      "supplierId": "SUP-01",
      "poNumber": "PO-BAK-1001",
      "grnNumber": "GRN-BAK-2001",
      "lines": 3,
      "netTotal": "165.41",
      "lineTaxSum": "8.27",
      "documentLevelTax": "8.27",
      "statedTaxTotal": "8.27",
      "totalDue": "173.68",
      "usesDuplicateNumber": false
    },
    {
      "invoiceNumber": "INV-BAK-5002",
      "invoiceDate": "2026-08-14",
      "dueDate": "2026-09-13",
      "supplierId": "SUP-02",
      "poNumber": "PO-BAK-1002",
      "grnNumber": "GRN-BAK-2002",
      "lines": 3,
      "netTotal": "275.86",
      "lineTaxSum": "13.79",
      "documentLevelTax": "13.79",
      "statedTaxTotal": "13.79",
      "totalDue": "289.65",
      "usesDuplicateNumber": false
    },
    {
      "invoiceNumber": "INV-BAK-5003",
      "invoiceDate": "2026-08-21",
      "dueDate": "2026-09-20",
      "supplierId": "SUP-01",
      "poNumber": "PO-BAK-1003",
      "grnNumber": "GRN-BAK-2003",
      "lines": 3,
      "netTotal": "267.12",
      "lineTaxSum": "13.36",
      "documentLevelTax": "13.36",
      "statedTaxTotal": "13.37",
      "totalDue": "280.49",
      "usesDuplicateNumber": false
    },
    {
      "invoiceNumber": "INV-BAK-5004",
      "invoiceDate": "2026-08-28",
      "dueDate": "2026-09-27",
      "supplierId": "SUP-02",
      "poNumber": "PO-BAK-1004",
      "grnNumber": "GRN-BAK-2004",
      "lines": 3,
      "netTotal": "314.06",
      "lineTaxSum": "15.70",
      "documentLevelTax": "15.70",
      "statedTaxTotal": "15.70",
      "totalDue": "329.76",
      "usesDuplicateNumber": false
    },
    {
      "invoiceNumber": "INV-BAK-5002",
      "invoiceDate": "2026-08-17",
      "dueDate": "2026-09-16",
      "supplierId": "SUP-02",
      "poNumber": "PO-BAK-1002",
      "grnNumber": "GRN-BAK-2002",
      "lines": 2,
      "netTotal": "268.60",
      "lineTaxSum": "13.43",
      "documentLevelTax": "13.43",
      "statedTaxTotal": "13.43",
      "totalDue": "282.03",
      "usesDuplicateNumber": true
    }
  ],
  "creditNotes": [
    {
      "creditNoteNumber": "CN-BAK-7001",
      "againstInvoiceNumber": "INV-BAK-5002",
      "creditedQuantity": 4,
      "netTotal": "1.32",
      "taxTotal": "0.07",
      "grossTotal": "1.39",
      "overCreditedUnits": 0
    },
    {
      "creditNoteNumber": "CN-BAK-7002",
      "againstInvoiceNumber": "INV-BAK-5004",
      "creditedQuantity": 5,
      "netTotal": "24.70",
      "taxTotal": "1.24",
      "grossTotal": "25.94",
      "overCreditedUnits": 2
    }
  ],
  "statements": [
    {
      "statementNumber": "STM-BAK-6001",
      "statementDate": "2026-08-31",
      "supplierId": "SUP-01",
      "rows": 5,
      "closingBalance": "740.74",
      "declaredAgeing": {
        "current": "454.17",
        "31-60": "121.58",
        "61-90": "95.52",
        "90-plus": "69.47"
      },
      "trueAgeing": {
        "current": "454.17",
        "31-60": "121.58",
        "61-90": "95.52",
        "90-plus": "69.47"
      },
      "declaredAgeingSum": "740.74",
      "ageingDifference": "0.00",
      "omittedFromAgeing": null
    },
    {
      "statementNumber": "STM-BAK-6002",
      "statementDate": "2026-08-31",
      "supplierId": "SUP-02",
      "rows": 8,
      "closingBalance": "1395.48",
      "declaredAgeing": {
        "current": "875.50",
        "31-60": "217.24",
        "61-90": "173.79",
        "90-plus": "130.34"
      },
      "trueAgeing": {
        "current": "874.11",
        "31-60": "217.24",
        "61-90": "173.79",
        "90-plus": "130.34"
      },
      "declaredAgeingSum": "1396.87",
      "ageingDifference": "1.39",
      "omittedFromAgeing": "CN-BAK-7001"
    }
  ],
  "remittance": {
    "remittanceNumber": "REM-BAK-8001",
    "paymentDate": "2026-09-05",
    "remittanceTotal": "946.62",
    "withheldTotal": "1189.60",
    "statementsClosingTotal": "2136.22",
    "reconciliation": "remittanceTotal + withheldTotal == statementsClosingTotal",
    "paidDocuments": [
      "OPN-BAK-9001",
      "OPN-BAK-9002",
      "INV-BAK-5001",
      "OPN-BAK-9004",
      "OPN-BAK-9005",
      "INV-BAK-5004",
      "CN-BAK-7002"
    ],
    "withheldDocuments": [
      "OPN-BAK-9003",
      "INV-BAK-5003",
      "OPN-BAK-9006",
      "INV-BAK-5002",
      "INV-BAK-5002",
      "CN-BAK-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": "1261.85",
    "purchaseOrderNetIfContractTierApplied": "1211.29",
    "purchaseOrderNetIfCasePriceReadAsUnitPrice": "12818.14",
    "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-BAK-5003 dated 2026-08-21"
      ],
      "detail": "Invoice INV-BAK-5003 states a tax total of 13.37 CAD and a total due of 280.49 CAD. Its three line tax amounts sum to 13.36 CAD, one cent less. The document-level calculation round(net x 0.05, 2) on a net of 267.12 gives 13.36 CAD.",
      "assertion": "statedTaxTotal - lineTaxSum == 0.01"
    },
    {
      "id": "po-invoice-quantity-mismatch",
      "title": "Invoice bills the ordered quantity after a recorded short delivery",
      "documents": [
        "INV-BAK-5002 line 2",
        "GRN-BAK-2002 line 2"
      ],
      "detail": "Purchase order PO-BAK-1002 line 2 ordered 22 each of ING-03. Goods-received note GRN-BAK-2002 records 18 each delivered. Invoice INV-BAK-5002 line 2 bills 22 each, a variance of 4 each and 1.32 CAD net.",
      "assertion": "invoicedQuantity - deliveredQuantity == 4"
    },
    {
      "id": "duplicate-invoice-number",
      "title": "Two different invoices carry the same invoice number",
      "documents": [
        "INV-BAK-5002 dated 2026-08-17",
        "INV-BAK-5002 dated 2026-08-14"
      ],
      "detail": "Invoice number INV-BAK-5002 is used twice: once dated 2026-08-14 with 3 lines totalling 289.65 CAD, and again dated 2026-08-17 with 2 lines totalling 282.03 CAD. Both are listed on statement STM-BAK-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-BAK-7002",
        "GRN-BAK-2004"
      ],
      "detail": "Goods-received note GRN-BAK-2004 line 3 records 3 kg returned. Credit note CN-BAK-7002 credits 5 kg at 4.94 CAD. The 2 kg difference overstates the credit by 9.88 CAD net and 10.37 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-BAK-6002"
      ],
      "detail": "Statement STM-BAK-6002 for supplier SUP-02 declares ageing buckets of 875.50 current, 217.24 at 31-60 days, 173.79 at 61-90 days and 130.34 over 90 days, summing to 1396.87 CAD. The closing balance on the same document is 1395.48 CAD. The difference of 1.39 CAD is exactly credit note CN-BAK-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)"
    }
  ]
}
