{
 "name": "[노드 한 장] Workflow Tool 계산하는 서브 · 샘플 할인합계",
 "nodes": [
  {
   "id": "trigger",
   "name": "When called by another workflow",
   "type": "n8n-nodes-base.executeWorkflowTrigger",
   "typeVersion": 1.3,
   "position": [
    0,
    0
   ],
   "parameters": {
    "inputSource": "workflowInputs",
    "workflowInputs": {
     "values": [
      {
       "name": "unitPrice",
       "type": "number"
      },
      {
       "name": "discountPercent",
       "type": "number"
      },
      {
       "name": "quantity",
       "type": "number"
      }
     ]
    }
   }
  },
  {
   "id": "calculate",
   "name": "Calculate sample total in Code",
   "type": "n8n-nodes-base.code",
   "typeVersion": 2,
   "position": [
    300,
    0
   ],
   "parameters": {
    "jsCode": "const x=$input.first().json; const unitPrice=Number(x.unitPrice), discountPercent=Number(x.discountPercent), quantity=Number(x.quantity); if(![unitPrice,discountPercent,quantity].every(Number.isFinite)||unitPrice<0||discountPercent<0||discountPercent>100||!Number.isInteger(quantity)||quantity<1)throw new Error('Invalid sample input'); const netUnitPrice=unitPrice*(1-discountPercent/100); return [{json:{sample:true,unitPrice,discountPercent,quantity,netUnitPrice,total:netUnitPrice*quantity,currency:'KRW',calculatedBy:'child Code'}}];"
   }
  }
 ],
 "connections": {
  "When called by another workflow": {
   "main": [
    [
     {
      "node": "Calculate sample total in Code",
      "type": "main",
      "index": 0
     }
    ]
   ]
  }
 },
 "settings": {
  "executionOrder": "v1"
 },
 "meta": {
  "templateCredsSetupCompleted": false,
  "source": "datapopcorn.ai/workflow/nodes"
 }
}