{
  "nodes": [
    {
      "type": "inputNode",
      "id": "input",
      "name": "request",
      "position": { "x": 100, "y": 180 }
    },
    {
      "type": "decisionTableNode",
      "id": "baseRates",
      "name": "BaseRates",
      "position": { "x": 400, "y": 100 },
      "content": {
        "hitPolicy": "first",
        "inputs": [
          { "id": "i1", "name": "Deal Type", "field": "deal.type" },
          { "id": "i2", "name": "Product Line", "field": "deal.productLine" }
        ],
        "outputs": [
          { "id": "o1", "name": "Base Rate", "field": "rate" }
        ],
        "rules": [
          { "_id": "r1", "i1": "\"new_business\"", "i2": "\"enterprise\"", "o1": "0.12" },
          { "_id": "r2", "i1": "\"new_business\"", "i2": "\"professional\"", "o1": "0.10" },
          { "_id": "r3", "i1": "\"new_business\"", "i2": "\"starter\"", "o1": "0.08" },
          { "_id": "r4", "i1": "\"expansion\"", "i2": "", "o1": "0.08" },
          { "_id": "r5", "i1": "\"renewal\"", "i2": "", "o1": "0.04" },
          { "_id": "r6", "i1": "", "i2": "", "o1": "0.05" }
        ],
        "passThrough": true
      }
    },
    {
      "type": "expressionNode",
      "id": "attainment",
      "name": "QuotaAttainment",
      "position": { "x": 400, "y": 260 },
      "content": {
        "expressions": [
          { "id": "e1", "key": "quotaAttainment", "value": "period.sales / rep.quota" },
          { "id": "e2", "key": "attainmentPercent", "value": "round($.quotaAttainment * 100)" }
        ],
        "passThrough": true
      }
    },
    {
      "type": "decisionTableNode",
      "id": "attainmentTier",
      "name": "AttainmentTier",
      "position": { "x": 750, "y": 260 },
      "content": {
        "hitPolicy": "first",
        "inputs": [
          { "id": "i1", "name": "Attainment %", "field": "attainmentPercent" }
        ],
        "outputs": [
          { "id": "o1", "name": "Multiplier", "field": "multiplier" },
          { "id": "o2", "name": "Tier Name", "field": "tier" }
        ],
        "rules": [
          { "_id": "r1", "i1": ">= 150", "o1": "2.0", "o2": "\"president_club\"" },
          { "_id": "r2", "i1": "[125..149]", "o1": "1.5", "o2": "\"accelerator_2\"" },
          { "_id": "r3", "i1": "[100..124]", "o1": "1.25", "o2": "\"accelerator_1\"" },
          { "_id": "r4", "i1": "[75..99]", "o1": "1.0", "o2": "\"on_track\"" },
          { "_id": "r5", "i1": "[50..74]", "o1": "0.75", "o2": "\"below_target\"" },
          { "_id": "r6", "i1": "< 50", "o1": "0.5", "o2": "\"at_risk\"" }
        ],
        "passThrough": true
      }
    },
    {
      "type": "expressionNode",
      "id": "calculate",
      "name": "Calculate",
      "position": { "x": 1100, "y": 180 },
      "content": {
        "expressions": [
          { "id": "e1", "key": "dealAmount", "value": "deal.amount" },
          { "id": "e2", "key": "baseRate", "value": "$nodes.BaseRates.rate" },
          { "id": "e3", "key": "multiplier", "value": "$nodes.AttainmentTier.multiplier" },
          { "id": "e4", "key": "baseCommission", "value": "$.dealAmount * $.baseRate" },
          { "id": "e5", "key": "adjustedCommission", "value": "$.baseCommission * $.multiplier" },
          { "id": "e6", "key": "finalCommission", "value": "round($.adjustedCommission, 2)" }
        ],
        "passThrough": true
      }
    },
    {
      "type": "decisionTableNode",
      "id": "roleCap",
      "name": "RoleCap",
      "position": { "x": 1450, "y": 180 },
      "content": {
        "hitPolicy": "first",
        "inputs": [
          { "id": "i1", "name": "Role", "field": "rep.role" },
          { "id": "i2", "name": "Commission", "field": "finalCommission" }
        ],
        "outputs": [
          { "id": "o1", "name": "Final Payout", "field": "payout" },
          { "id": "o2", "name": "Capped", "field": "capped" }
        ],
        "rules": [
          { "_id": "r1", "i1": "\"account_executive\"", "i2": "> 50000", "o1": "50000", "o2": "true" },
          { "_id": "r2", "i1": "\"sdr\"", "i2": "> 15000", "o1": "15000", "o2": "true" },
          { "_id": "r3", "i1": "\"manager\"", "i2": "> 75000", "o1": "75000", "o2": "true" },
          { "_id": "r4", "i1": "", "i2": "", "o1": "finalCommission", "o2": "false" }
        ],
        "passThrough": false
      }
    }
  ],
  "edges": [
    { "id": "e1", "sourceId": "input", "targetId": "baseRates", "type": "edge" },
    { "id": "e2", "sourceId": "input", "targetId": "attainment", "type": "edge" },
    { "id": "e3", "sourceId": "attainment", "targetId": "attainmentTier", "type": "edge" },
    { "id": "e4", "sourceId": "baseRates", "targetId": "calculate", "type": "edge" },
    { "id": "e5", "sourceId": "attainmentTier", "targetId": "calculate", "type": "edge" },
    { "id": "e6", "sourceId": "calculate", "targetId": "roleCap", "type": "edge" }
  ]
}
