{"skills":[{"name":"Split trip expenses by who took part","description":"Reconcile who paid with who benefited, including unequal shares, exclusions and payments friends have already made.","content":"# Split trip expenses by who took part\n\nReconcile who paid with who benefited, including unequal shares, exclusions and payments friends have already made.\n\n## When to use this skill\n\n- A group has a list of trip expenses where different people paid and not everyone joined everything.\n- Some costs are shared unequally, for example by nights stayed or by room.\n- Some money has already been paid back, or a refund went to someone other than the person who paid.\n\n## When not to use it\n\n- Settling a disagreement about who should pay for what. The skill applies the shares the group agrees.\n- Business travel claims, which follow the employer's expenses policy.\n\n## What you need\n\n- Expense amounts, currency, payer, participants and agreed equal or weighted shares for each expense.\n- Previously settled payments, participant order for penny adjustments and any agreed exchange rate.\n\n## Ask before you start\n\nIf any of these are missing or unclear, ask before doing the work.\n\n- Who was on the trip, in a fixed order? The order decides who takes any leftover penny.\n- For each expense: who paid, how much, in which currency, and who shared it, with any unequal shares?\n- Have any repayments or refunds already happened, and who sent or received them?\n- Should currencies stay separate, or has everyone agreed one exchange rate?\n\n## Method\n\n1. Check every expense has an amount, currency, payer and list of participants. Set aside any line without participants or shares as unresolved, and do not guess.\n2. For each expense, credit the payer with the full amount and charge each listed participant their agreed share: equal, weighted or exact. People who did not take part pay nothing for it.\n3. Work in the currency's smallest unit, such as pence or cents. Give each participant the whole units of their exact share, then hand out the leftover units by largest fractional remainder, breaking ties in the trip's participant order. Check the shares add back to the receipt exactly.\n4. Record a repayment between two people as a transfer: the sender's balance goes up and the recipient's goes down. Do not record it as a new shared expense.\n5. Treat a merchant refund as reducing the original cost: credit each participant their share of the refund and charge the person who received it, even if it went to a different card from the original payer's. For a full refund, reverse the original allocations exactly, pennies included.\n6. Keep a separate ledger for each currency unless everyone agreed a rate. Check that each currency's balances sum to zero, then list who pays whom to settle in as few payments as possible.\n\n## Checks before you deliver\n\n- A person can pay for an activity they did not join.\n- An earlier repayment recorded as another dinner creates a second round of artificial debt.\n- Rounding every share to the nearest penny separately, so the shares no longer add up to the receipt.\n- Mixing currencies in one balance, or converting at different rates for different people.\n- Charging a refund to the original payer when it actually went to someone else's card.\n\n## How to present the result\n\nLead with the settlement: who pays whom and how much, for each currency. Then give each person's net balance, a line-by-line table of expenses with payer, participants and shares, and the repayments already made. List unresolved receipts last with what is needed to include them.\n\n## Worked example\n\n**Request:** What is each person's balance after the transfer?\n\n**Supplied material:**\n\n```text\nOrder: Amy, Ben, Cal. GBP only. Cabin \u00a3240 paid by Amy, weights Amy 2, Ben 2, Cal 1. Meal \u00a360 paid by Ben, split equally Ben and Cal. Cal already paid Amy \u00a320.\n```\n\n**Answer:** Ben owes Amy \u00a366 and Cal owes Amy \u00a358. This already credits Cal with the \u00a320 he paid. Together those two payments settle the \u00a3124 Amy is still owed.\n\n## Structured output for tests\n\nFor an ordinary job, answer in the format above and point back to the supplied evidence. Use this structure only for the test cases published with this skill, or when someone asks for structured JSON.\n\nReturn net as an object keyed first by currency (ISO code), then by participant name, showing signed balances in major units to two decimals. Positive means money to receive. Include all people in the trip roster in each used currency. Report unresolved as the receipt IDs with absent allocation data and exclude those lines from net.\n\n## Sources\n\n- [Splitwise: how to divide expenses and record payments](https:\/\/kb.splitwise.com\/getting-started\/how-do-i-use-splitwise): Splitwise's help centre documents equal splits by default, splitting by exact amount, percentage or shares, and recording a repayment between people with Settle up rather than as an expense. The skill keeps the same separation between expenses and transfers.\n- [Splitwise: recording a refund or reimbursement](https:\/\/kb.splitwise.com\/balances-and-expenses\/how-do-i-add-a-refund-or-reimbursement): Splitwise's reimbursement split records how much of a refund each person should get back, so a refund reverses the shares of the people who bore the cost instead of becoming a new expense.\n- [SIX: ISO 4217 currency code maintenance agency](https:\/\/www.six-group.com\/en\/products-services\/financial-information\/market-reference-data\/data-standards.html): SIX is the secretariat of the ISO 4217 maintenance agency and publishes the current currency list with each currency's alphabetic code, numeric code and minor unit. The skill keys balances by these codes and allocates leftover amounts in the currency's minor unit.\n\nTest cases and an answer checker for this skill: https:\/\/skills.raq.com\/skills\/split-shared-trip-expenses\n","scope":"contextual","trigger_keywords":["Split trip expenses by who took part","split-shared-trip-expenses","split shared trip expenses","Who owes whom after our group trip, when not everyone joined everything?","Who owes whom after our group trip, when not everyone joined everything","split our trip expenses","split these trip expenses","settle shared travel costs"],"is_private":true,"is_active":true,"scripts":[{"name":"split-shared-trip-expenses-check","description":"Compare a saved JSON answer with a published test. Pass tests\/case-1\/expected.json (or another case) and the path to your answer.","language":"python","filename":"split-shared-trip-expenses-check.py","content":"from pathlib import Path\nimport runpy\n\nrunpy.run_path(str(Path(__file__).parent \/ 'tests' \/ 'check.py'), run_name='__main__')\n","supporting_files":[{"path":"SKILL.md","content":"---\nname: split-shared-trip-expenses\ndescription: \"Work out who owes whom after a shared trip, charging each expense only to the people who took part, with unequal shares, refunds, repayments already made and separate currencies. Use when friends or family want to split holiday, trip or group travel costs and settle up.\"\nlicense: CC-BY-4.0\nmetadata:\n  author: Raq.com\n  version: \"2026-11-22\"\n  homepage: https:\/\/skills.raq.com\/skills\/split-shared-trip-expenses\n---\n\n# Split trip expenses by who took part\n\nReconcile who paid with who benefited, including unequal shares, exclusions and payments friends have already made.\n\n## When to use this skill\n\n- A group has a list of trip expenses where different people paid and not everyone joined everything.\n- Some costs are shared unequally, for example by nights stayed or by room.\n- Some money has already been paid back, or a refund went to someone other than the person who paid.\n\n## When not to use it\n\n- Settling a disagreement about who should pay for what. The skill applies the shares the group agrees.\n- Business travel claims, which follow the employer's expenses policy.\n\n## What you need\n\n- Expense amounts, currency, payer, participants and agreed equal or weighted shares for each expense.\n- Previously settled payments, participant order for penny adjustments and any agreed exchange rate.\n\n## Ask before you start\n\nIf any of these are missing or unclear, ask before doing the work.\n\n- Who was on the trip, in a fixed order? The order decides who takes any leftover penny.\n- For each expense: who paid, how much, in which currency, and who shared it, with any unequal shares?\n- Have any repayments or refunds already happened, and who sent or received them?\n- Should currencies stay separate, or has everyone agreed one exchange rate?\n\n## Method\n\n1. Check every expense has an amount, currency, payer and list of participants. Set aside any line without participants or shares as unresolved, and do not guess.\n2. For each expense, credit the payer with the full amount and charge each listed participant their agreed share: equal, weighted or exact. People who did not take part pay nothing for it.\n3. Work in the currency's smallest unit, such as pence or cents. Give each participant the whole units of their exact share, then hand out the leftover units by largest fractional remainder, breaking ties in the trip's participant order. Check the shares add back to the receipt exactly.\n4. Record a repayment between two people as a transfer: the sender's balance goes up and the recipient's goes down. Do not record it as a new shared expense.\n5. Treat a merchant refund as reducing the original cost: credit each participant their share of the refund and charge the person who received it, even if it went to a different card from the original payer's. For a full refund, reverse the original allocations exactly, pennies included.\n6. Keep a separate ledger for each currency unless everyone agreed a rate. Check that each currency's balances sum to zero, then list who pays whom to settle in as few payments as possible.\n\n## Checks before you deliver\n\n- A person can pay for an activity they did not join.\n- An earlier repayment recorded as another dinner creates a second round of artificial debt.\n- Rounding every share to the nearest penny separately, so the shares no longer add up to the receipt.\n- Mixing currencies in one balance, or converting at different rates for different people.\n- Charging a refund to the original payer when it actually went to someone else's card.\n\n## How to present the result\n\nLead with the settlement: who pays whom and how much, for each currency. Then give each person's net balance, a line-by-line table of expenses with payer, participants and shares, and the repayments already made. List unresolved receipts last with what is needed to include them.\n\n## Worked example\n\n**Request:** What is each person's balance after the transfer?\n\n**Supplied material:**\n\n```text\nOrder: Amy, Ben, Cal. GBP only. Cabin \u00a3240 paid by Amy, weights Amy 2, Ben 2, Cal 1. Meal \u00a360 paid by Ben, split equally Ben and Cal. Cal already paid Amy \u00a320.\n```\n\n**Answer:** Ben owes Amy \u00a366 and Cal owes Amy \u00a358. This already credits Cal with the \u00a320 he paid. Together those two payments settle the \u00a3124 Amy is still owed.\n\n## Structured output for tests\n\nFor an ordinary job, answer in the format above and point back to the supplied evidence. Use this structure only for the test cases published with this skill, or when someone asks for structured JSON.\n\nReturn net as an object keyed first by currency (ISO code), then by participant name, showing signed balances in major units to two decimals. Positive means money to receive. Include all people in the trip roster in each used currency. Report unresolved as the receipt IDs with absent allocation data and exclude those lines from net.\n\n## Sources\n\n- [Splitwise: how to divide expenses and record payments](https:\/\/kb.splitwise.com\/getting-started\/how-do-i-use-splitwise): Splitwise's help centre documents equal splits by default, splitting by exact amount, percentage or shares, and recording a repayment between people with Settle up rather than as an expense. The skill keeps the same separation between expenses and transfers.\n- [Splitwise: recording a refund or reimbursement](https:\/\/kb.splitwise.com\/balances-and-expenses\/how-do-i-add-a-refund-or-reimbursement): Splitwise's reimbursement split records how much of a refund each person should get back, so a refund reverses the shares of the people who bore the cost instead of becoming a new expense.\n- [SIX: ISO 4217 currency code maintenance agency](https:\/\/www.six-group.com\/en\/products-services\/financial-information\/market-reference-data\/data-standards.html): SIX is the secretariat of the ISO 4217 maintenance agency and publishes the current currency list with each currency's alphabetic code, numeric code and minor unit. The skill keys balances by these codes and allocates leftover amounts in the currency's minor unit.\n\nTest cases and an answer checker for this skill: https:\/\/skills.raq.com\/skills\/split-shared-trip-expenses\n"},{"path":"LICENSE.txt","content":"Original Raq.com instructions and synthetic examples: CC BY 4.0.\nhttps:\/\/creativecommons.org\/licenses\/by\/4.0\/\nAttribution: Raq.com, https:\/\/skills.raq.com\/skills\/split-shared-trip-expenses\nReferenced third-party materials retain their own terms.\n"},{"path":"examples\/worked-example.md","content":"# One person stayed fewer nights\n\nWhat is each person's balance after the transfer?\n\n## Supplied material\n\nOrder: Amy, Ben, Cal. GBP only. Cabin \u00a3240 paid by Amy, weights Amy 2, Ben 2, Cal 1. Meal \u00a360 paid by Ben, split equally Ben and Cal. Cal already paid Amy \u00a320.\n\n## Worked answer\n\nBen owes Amy \u00a366 and Cal owes Amy \u00a358. This already credits Cal with the \u00a320 he paid. Together those two payments settle the \u00a3124 Amy is still owed.\n\n## Reasoning\n\nAmy advanced \u00a3240, owes \u00a396 for the cabin and has already received \u00a320.\n"},{"path":"tests\/check.py","content":"\"\"\"Check a saved agent answer locally with Python 3 (standard library only).\"\"\"\nimport json\nimport math\nimport sys\nfrom pathlib import Path\n\n\ndef compare(expected, actual, path=\"$\", accepted=None):\n    if isinstance(expected, bool) or isinstance(actual, bool):\n        if expected is not actual:\n            yield path\n    elif isinstance(expected, (int, float)) and isinstance(actual, (int, float)):\n        if not math.isclose(expected, actual, rel_tol=0, abs_tol=1e-8):\n            yield path\n    elif isinstance(expected, dict) and isinstance(actual, dict):\n        for key in sorted(set(expected) | set(actual)):\n            if key not in expected or key not in actual:\n                yield f\"{path}.{key}\"\n            elif not any(\n                not list(compare(option, actual[key]))\n                for option in (accepted or {}).get(key, [])\n            ):\n                yield from compare(expected[key], actual[key], f\"{path}.{key}\")\n    elif isinstance(expected, list) and isinstance(actual, list):\n        if len(expected) != len(actual):\n            yield f\"{path} (length)\"\n        for i, (left, right) in enumerate(zip(expected, actual)):\n            yield from compare(left, right, f\"{path}[{i}]\")\n    elif type(expected) != type(actual) or expected != actual:\n        yield path\n\n\ndef main():\n    if len(sys.argv) != 3:\n        raise SystemExit(\"Usage: python3 check.py expected.json answer.json\")\n    try:\n        expected, actual = [json.loads(Path(p).read_text(encoding=\"utf-8\")) for p in sys.argv[1:]]\n        alternatives = Path(sys.argv[1]).with_name(\"accepted.json\")\n        accepted = json.loads(alternatives.read_text(encoding=\"utf-8\")) if alternatives.is_file() else {}\n    except (ValueError, OSError) as error:\n        raise SystemExit(str(error))\n    differences = list(compare(expected, actual, accepted=accepted))\n    if differences:\n        raise SystemExit(\"Different fields: \" + \", \".join(differences))\n    print(\"Pass\")\n\n\nif __name__ == \"__main__\":\n    main()\n"},{"path":"tests\/README.md","content":"Give your agent SKILL.md and one request.txt in a fresh session. Keep the expected answer aside. Save the reply as answer.json, then run this from the tests folder:\n\n    python3 check.py case-1\/expected.json answer.json\n\nEach case also has an explanation. Where accepted.json exists, the checker accepts the alternatives listed there.\n"},{"path":"tests\/case-1\/request.txt","content":"What is each person's balance after the transfer?\nReturn only the JSON specified in SKILL.md for this test.\n\nOrder: Amy, Ben, Cal. GBP only. Cabin \u00a3240 paid by Amy, weights Amy 2, Ben 2, Cal 1. Meal \u00a360 paid by Ben, split equally Ben and Cal. Cal already paid Amy \u00a320.\n"},{"path":"tests\/case-1\/expected.json","content":"{\n    \"net\": {\n        \"GBP\": {\n            \"Amy\": 124,\n            \"Ben\": -66,\n            \"Cal\": -58\n        }\n    },\n    \"unresolved\": []\n}\n"},{"path":"tests\/case-1\/explanation.txt","content":"Amy advanced \u00a3240, owes \u00a396 for the cabin and has already received \u00a320.\n"},{"path":"tests\/case-2\/request.txt","content":"Keep my euro costs separate from sterling.\nReturn only the JSON specified in SKILL.md for this test.\n\nOrder: Kit, Lou, Max. Ticket EUR 10 paid by Lou, split equally three ways. Taxi GBP 12 paid by Kit, split equally Kit and Max. Receipt U4 EUR 7, payer Kit, no participants specified.\n"},{"path":"tests\/case-2\/expected.json","content":"{\n    \"net\": {\n        \"EUR\": {\n            \"Kit\": -3.34,\n            \"Lou\": 6.67,\n            \"Max\": -3.33\n        },\n        \"GBP\": {\n            \"Kit\": 6,\n            \"Lou\": 0,\n            \"Max\": -6\n        }\n    },\n    \"unresolved\": [\n        \"U4\"\n    ]\n}\n"},{"path":"tests\/case-2\/explanation.txt","content":"Kit gets the first rounding cent on the euro bill. U4 needs an allocation before it affects anyone\u2019s balance.\n"},{"path":"tests\/case-3\/request.txt","content":"Who owes what after the merchant refund and the private repayment?\nReturn only the JSON specified in SKILL.md for this test.\n\nOrder A, B, C. A paid \u00a390 for a meal shared equally by A, B and C. A \u00a312 merchant refund for all three posted to B's card. C has already paid \u00a310 to A.\n"},{"path":"tests\/case-3\/expected.json","content":"{\n    \"net\": {\n        \"GBP\": {\n            \"A\": 54,\n            \"B\": -38,\n            \"C\": -16\n        }\n    },\n    \"unresolved\": []\n}\n"},{"path":"tests\/case-3\/explanation.txt","content":"After the refund each person's meal cost is \u00a326. B owes \u00a338 because B also received the \u00a312 refund; C owes only \u00a316 after the transfer.\n"}],"is_active":true,"is_approved":false}]}]}