{
  "name": "Octonyx synthetic payroll intake and review queue",
  "nodes": [
    {
      "parameters": {},
      "id": "6b9f2e59-3d2e-492c-87c3-d1e31ca4ce9b",
      "name": "Run synthetic demo",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "// Original synthetic inputs. No employee or payroll system is accessed.\nconst rows = [\n  {\n    \"case_id\": \"VALID\",\n    \"adjustment_id\": \"ADJ-001\",\n    \"revision\": 1,\n    \"employee_id\": \"DEMO-001\",\n    \"period\": \"2026-10\",\n    \"hours\": 2\n  },\n  {\n    \"case_id\": \"DUPLICATE\",\n    \"adjustment_id\": \"ADJ-001\",\n    \"revision\": 1,\n    \"employee_id\": \"DEMO-001\",\n    \"period\": \"2026-10\",\n    \"hours\": 2\n  },\n  {\n    \"case_id\": \"MISSING_EMPLOYEE\",\n    \"adjustment_id\": \"ADJ-002\",\n    \"revision\": 1,\n    \"employee_id\": \"\",\n    \"period\": \"2026-10\",\n    \"hours\": 2\n  },\n  {\n    \"case_id\": \"NEGATIVE_HOURS\",\n    \"adjustment_id\": \"ADJ-003\",\n    \"revision\": 1,\n    \"employee_id\": \"DEMO-003\",\n    \"period\": \"2026-10\",\n    \"hours\": -1\n  },\n  {\n    \"case_id\": \"REVISION\",\n    \"adjustment_id\": \"ADJ-001\",\n    \"revision\": 2,\n    \"employee_id\": \"DEMO-001\",\n    \"period\": \"2026-10\",\n    \"hours\": 3\n  }\n];\nreturn rows.map(row => ({ json: row }));"
      },
      "id": "a0e250f0-5bf8-4159-b677-38987f683c1b",
      "name": "Synthetic adjustments",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        240,
        0
      ]
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "// Demonstration only: no payroll write, payment, approval or external call.\n// The duplicate set covers this execution only, not earlier workflow runs.\nconst seen = new Set();\nreturn $input.all().map(item => {\n  const row = item.json;\n  const errors = [];\n  if (typeof row.adjustment_id !== 'string' || !row.adjustment_id.trim()) errors.push('Missing adjustment ID');\n  if (!Number.isInteger(row.revision) || row.revision < 1) errors.push('Invalid revision');\n  if (typeof row.employee_id !== 'string' || !/^DEMO-[0-9]{3}$/.test(row.employee_id)) errors.push('Missing or invalid demo employee ID');\n  if (typeof row.period !== 'string' || !/^[0-9]{4}-(0[1-9]|1[0-2])$/.test(row.period)) errors.push('Invalid payroll period');\n  if (typeof row.hours !== 'number' || !Number.isFinite(row.hours) || row.hours < 0) errors.push('Hours must be a finite nonnegative number');\n  let processing_key = null;\n  let classification = 'exception';\n  let reason = errors.join('; ');\n  if (!errors.length) {\n    processing_key = [row.adjustment_id,row.revision,row.period,row.employee_id].join(':');\n    if (seen.has(processing_key)) {\n      classification = 'duplicate_in_batch';\n      reason = 'Same adjustment revision already appeared in this execution';\n    } else {\n      seen.add(processing_key);\n      classification = 'pending_review';\n      reason = 'Valid sample intake; an authorized reviewer must decide the active revision';\n    }\n  }\n  return { json: { ...row, demo: true, processing_key, classification, reason, approved_by: null, payroll_action: 'none' } };\n});"
      },
      "id": "19dc5df2-535c-4fd2-adc8-1d6608b4d2b6",
      "name": "Prepare review queue",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        480,
        0
      ]
    }
  ],
  "connections": {
    "Run synthetic demo": {
      "main": [
        [
          {
            "node": "Synthetic adjustments",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Synthetic adjustments": {
      "main": [
        [
          {
            "node": "Prepare review queue",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "tags": []
}
