{"name":"CWC 09 - The Balance Check - starter","nodes":[{"id":"c09-starter-start","name":"Start here","type":"n8n-nodes-base.manualTrigger","typeVersion":1,"position":[80,160],"parameters":{}},{"id":"c09-starter-settings","name":"Your account","type":"n8n-nodes-base.set","typeVersion":3.5,"position":[368,160],"parameters":{"mode":"manual","assignments":{"assignments":[{"id":"c09-user","name":"username","value":"","type":"string"},{"id":"c09-key","name":"participantKey","value":"","type":"string"}]},"includeOtherFields":false,"options":{}},"notes":"Enter your community username and current participant key in these two empty fields. The HTTP node checks them locally before sending a request. Clear the key in your upload copy."},{"id":"c09-starter-fetch","name":"Fetch invoices and payments","type":"n8n-nodes-base.httpRequest","typeVersion":4.5,"position":[656,160],"parameters":{"method":"GET","url":"={{ (function c09StarterDataUrl(settings) {\n  const username = typeof settings?.username === 'string' ? settings.username.trim().toLowerCase() : '';\n  const key = typeof settings?.participantKey === 'string' ? settings.participantKey.trim().toUpperCase() : '';\n  if (!/^[a-z0-9_.-]{2,40}$/.test(username)\n    || ['your_username', 'your_community_username', 'community_username'].includes(username)) {\n    return 'Open Your account and enter your community username without @ before running';\n  }\n  if (!key || key.length > 128 || ['YOUR_PARTICIPANT_KEY', 'YOUR_KEY', 'REPLACE_ME'].includes(key)) {\n    return 'Open Your account and enter your current participant key before running';\n  }\n  return 'https://marketing.app.n8n.cloud/webhook/cwc/challenge-09/data';\n})($json) }}","sendQuery":true,"queryParameters":{"parameters":[{"name":"username","value":"={{ $json.username.trim().toLowerCase() }}"}]},"sendHeaders":true,"headerParameters":{"parameters":[{"name":"x-participant-key","value":"={{ $json.participantKey.trim().toUpperCase() }}"},{"name":"Accept","value":"application/json"}]},"options":{"timeout":30000,"redirect":{"redirect":{"followRedirects":false}},"response":{"response":{"responseFormat":"json"}}},"authentication":"none"},"notes":"One permanent GET returns both personal lists. The first successful personal issuance starts your clock. Empty or placeholder account fields stop locally. Before C09 opens this endpoint stays protected; never add organiser credentials.","retryOnFail":false},{"id":"c09-starter-invoices","name":"Split invoices","type":"n8n-nodes-base.splitOut","typeVersion":1.1,"position":[992,32],"parameters":{"fieldToSplitOut":"assignment.invoices","include":"noOtherFields","options":{}},"notes":"Each output item is one invoice. Continue with your own native nodes."},{"id":"c09-starter-payments","name":"Split payments","type":"n8n-nodes-base.splitOut","typeVersion":1.1,"position":[992,320],"parameters":{"fieldToSplitOut":"assignment.payments","include":"noOtherFields","options":{}},"notes":"Each output item is one payment. Continue with your own native nodes."},{"id":"c09-final-starter-intro","name":"The Balance Check","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[-64,-544],"parameters":{"width":896,"height":400,"color":6,"content":"# The Balance Check\n**Community Weekly Challenge 09 | Season 3**\n\nMatch payments to invoices. Work out how many active invoices still need payment and the total amount outstanding. Build the calculation yourself with native n8n nodes.\n\n## Your personal packet\n- **8 invoices**\n- **12 payments**\n- **2 final answers**\n\nThis starter fetches and splits the lists. It does not calculate the answers.\n\n[Read the challenge](https://marketing.app.n8n.cloud/webhook/cwc/site) · [Full FAQ](https://marketing.app.n8n.cloud/webhook/cwc/site?view=faq) · [Leaderboard](https://marketing.app.n8n.cloud/webhook/cwc/site?view=results)"}},{"id":"c09-final-starter-setup","name":"1. Connect your own account","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[864,-544],"parameters":{"width":1024,"height":400,"color":5,"content":"# 1. Enter your account, then run\nOpen **Your account** and fill the two empty fields:\n\n- `username`: your community username, without `@`\n- `participantKey`: your current weekly-challenge key\n\nThe empty starter stops locally before making a request. Once the fields are filled, click **Execute workflow**. One HTTP request returns both lists.\n\n**The first successful personal data issuance starts your clock.** Importing this file does not start it.\n\n[Create an account](https://marketing.app.n8n.cloud/webhook/cwc/site?view=register) · [Recover your key](https://marketing.app.n8n.cloud/webhook/cwc/site?view=reset)\n\nThe endpoint is permanent. It stays protected until C09 opens. Wait for opening; do not add organiser authentication."}},{"id":"c09-final-starter-invoices","name":"Invoice lane","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[1248,-64],"parameters":{"width":640,"height":288,"color":4,"content":"# Invoice lane\nContinue from **Split invoices**. Each item contains:\n\n- `invoice_id`: the exact match key\n- `status`: `active` or `cancelled`\n- `total_cents`: the original invoice amount\n\nAll invoices are still present. Add your own selection and calculation nodes."}},{"id":"c09-final-starter-payments","name":"Payment lane","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[1248,272],"parameters":{"width":640,"height":288,"color":4,"content":"# Payment lane\nContinue from **Split payments**. Each item contains:\n\n- `payment_id`: the payment reference\n- `invoice_id`: the invoice it belongs to\n- `status`: `posted` or `pending`\n- `amount_cents`: the payment amount\n\nNo payment has been filtered or grouped yet."}},{"id":"c09-final-starter-rules","name":"2. Build the balance check","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[-64,608],"parameters":{"width":608,"height":576,"color":4,"content":"# 2. Build your calculation\n1. Use only **active** invoices. Ignore cancelled invoices.\n2. Add only **posted** payments for the exact same `invoice_id`. Ignore pending payments.\n3. Subtract that invoice's posted total from `total_cents`. No matching posted payments means zero paid.\n4. Keep a minimum outstanding balance of zero. Overpayment cannot pay another invoice.\n5. Count the positive balances and add those balances. Keep all amounts in whole cents.\n\n## Final answer fields\n- `unpaid_invoice_count`\n- `total_outstanding_cents`\n\nYour ranked packet has at least one unpaid active invoice. Individual balances can still be zero.\n\nNative Filter, Summarize, Merge and Edit Fields are useful choices. No calculation nodes or solved balance expressions are supplied."}},{"id":"c09-final-starter-submit","name":"3. Export a clean copy","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[576,608],"parameters":{"width":640,"height":576,"color":3,"content":"# 3. Export and submit\nKeep your working original. Make a **separate clean copy** for upload.\n\n- Clear `participantKey` and any passwords or secret headers.\n- Remove credential references.\n- Remove pinned data and saved execution data.\n- Export the clean copy as workflow JSON.\n\n[Submit both answers and your clean JSON](https://marketing.app.n8n.cloud/webhook/cwc/site?view=submit). The website handles submission; a submission HTTP node is not needed here.\n\n## Participation rules\nBuild your own workflow without AI-generated or AI-assisted solving. Do not include Code, Function or Function Item nodes, even if disabled or disconnected.\n\nCorrect eligible submissions are accepted automatically. [Read the full rules and FAQ](https://marketing.app.n8n.cloud/webhook/cwc/site?view=faq)."}},{"id":"c09-final-starter-timing","name":"Timing and saved results","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[1248,608],"parameters":{"width":640,"height":576,"color":2,"content":"# Timing and retries\nYour first successful personal data issuance starts the clock. Re-fetching returns the same assignment and original start. A key reset does not restart the challenge.\n\nThe recorded complete final that is accepted sets the finish. Confirmation processing is shown separately.\n\nIf an upload or response is uncertain, check **My result** before creating another final. Keep the same request while its outcome is being confirmed.\n\n[My result](https://marketing.app.n8n.cloud/webhook/cwc/site?view=status) · [Submit](https://marketing.app.n8n.cloud/webhook/cwc/site?view=submit)\n\n[Full FAQ](https://marketing.app.n8n.cloud/webhook/cwc/site?view=faq) · [Leaderboard](https://marketing.app.n8n.cloud/webhook/cwc/site?view=results)\n\nKeep your participant key and complete solution private."}}],"connections":{"Start here":{"main":[[{"node":"Your account","type":"main","index":0}]]},"Your account":{"main":[[{"node":"Fetch invoices and payments","type":"main","index":0}]]},"Fetch invoices and payments":{"main":[[{"node":"Split invoices","type":"main","index":0},{"node":"Split payments","type":"main","index":0}]]}},"settings":{"executionOrder":"v1"},"pinData":{},"active":false,"meta":{"templateCredsSetupCompleted":true}}