{
  "name": "10 · Finance & Ops / Subscription Billing Reconciliation",
  "active": false,
  "nodes": [
    {
      "id": "29d8d018-b490-4b2f-8976-8da80efb16a4",
      "name": "📘 Guide",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -640,
        -120
      ],
      "parameters": {
        "content": "## 10 · Finance & Ops · Subscription Billing Reconciliation\n\n### What this does\nReconciles Stripe-like charges vs CRM entitlements and flags mismatches.\n\n### Setup checklist\n1. Billing export\n2. CRM entitlements\n3. Finance alert\n\n### How to test locally\nRun schedule or POST `fin-reconcile`.\n\n### Tips\n- Keep credentials in n8n Credentials (never hardcode secrets).\n- Use **Test URL** on the Webhook while developing.\n- Activate only after credentials + destinations are configured.\n",
        "width": 560,
        "height": 560,
        "color": 3
      }
    },
    {
      "id": "c908750c-979e-4b21-ba18-2e0baf1e0cae",
      "name": "⚙️ Config",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -640,
        480
      ],
      "parameters": {
        "content": "## Config map\n\n- **Webhook path:** `fin-reconcile`\n- **Replace** all `https://httpbin.org/...` calls with real integrations.\n- **Credentials:** create in n8n → Credentials, then select on HTTP nodes.\n- **Activate** workflow only after a successful Test execution.\n\n### Local files\nShared host folder is mounted at `/files` inside n8n.",
        "width": 560,
        "height": 320,
        "color": 2
      }
    },
    {
      "id": "69228e6a-cdd6-4179-9ca7-0bfc048795b0",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        200
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes",
              "minutesInterval": 60
            }
          ]
        }
      }
    },
    {
      "id": "cab278b5-0286-4fae-a594-47a2ff413a78",
      "name": "Pull Records",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        280,
        200
      ],
      "parameters": {
        "method": "GET",
        "url": "https://httpbin.org/get",
        "options": {}
      }
    },
    {
      "id": "57a5c2a6-a1cd-475c-a63f-5abd07c1e065",
      "name": "Triage & Score",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        560,
        200
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "const now = Date.now();\nconst sample = [\n  { id: 'A1', ageHours: 52, severity: 'high', owner: 'ada' },\n  { id: 'B2', ageHours: 5, severity: 'low', owner: 'lin' },\n  { id: 'C3', ageHours: 30, severity: 'medium', owner: 'sam' },\n];\nconst flagged = sample\n  .map(r => ({ ...r, breach: r.ageHours > 24 || r.severity === 'high', score: r.ageHours + (r.severity==='high'?50:0) }))\n  .filter(r => r.breach)\n  .sort((a,b) => b.score - a.score);\nreturn flagged.length\n  ? flagged.map(f => ({ json: { workflow: 'Subscription Billing Reconciliation', ...f, checkedAt: new Date(now).toISOString() } }))\n  : [{ json: { workflow: 'Subscription Billing Reconciliation', ok: true, flagged: 0 } }];"
      }
    },
    {
      "id": "7896b742-67f3-42c4-8d64-9fd44ffe1274",
      "name": "Needs Alert?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        840,
        200
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "09b4cdb7-acc5-4773-a1d0-71123b3928a7",
              "leftValue": "={{ $json.breach === true }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      }
    },
    {
      "id": "f87e13ea-fc06-472d-8ef0-d964f66fe1e4",
      "name": "Send Alert",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1120,
        80
      ],
      "parameters": {
        "method": "POST",
        "url": "https://httpbin.org/post",
        "options": {},
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify($json) }}"
      }
    },
    {
      "id": "876cd1ce-0872-4baf-9921-cb9fad757f28",
      "name": "All Clear",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1120,
        320
      ],
      "parameters": {
        "mode": "manual",
        "duplicateItem": false,
        "assignments": {
          "assignments": [
            {
              "id": "1",
              "name": "status",
              "value": "healthy",
              "type": "string"
            }
          ]
        },
        "options": {}
      }
    }
  ],
  "connections": {
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Pull Records",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pull Records": {
      "main": [
        [
          {
            "node": "Triage & Score",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Triage & Score": {
      "main": [
        [
          {
            "node": "Needs Alert?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Needs Alert?": {
      "main": [
        [
          {
            "node": "Send Alert",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "All Clear",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "callerPolicy": "workflowsFromSameOwner"
  },
  "tags": [],
  "meta": {
    "templateCredsSetupCompleted": true,
    "description": "Reconciles Stripe-like charges vs CRM entitlements and flags mismatches."
  },
  "pinData": {}
}