Compute per-member late fees for a neighbourhood tool library from input.json (returns with tool, member, outDay, dueDays, backDay) and write late-fees.csv beside it. Use whenever asked for late fees, overdue tool returns, or late-fees.csv from a tool-return input.json, even if the rules are not restated.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Tool Return Fees?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/gabrielmoreira-tool-return-fees-e18f565f)
---
name: tool-return-fees
description: Compute per-member late fees for a neighbourhood tool library from input.json (returns with tool, member, outDay, dueDays, backDay) and write late-fees.csv beside it. Use whenever asked for late fees, overdue tool returns, or late-fees.csv from a tool-return input.json, even if the rules are not restated.
---
# Tool return late fees
Work by hand (no code can be run). Read `input.json` in the working folder, compute, then write `late-fees.csv` in the same folder.
## Rules (derived from the worked examples; all three verify)
For each entry in `returns`:
1. `dueDay = outDay + dueDays`
2. `daysLate = backDay - dueDay`. If `daysLate <= 0` the return is on time (returning exactly on the due day is NOT late): ignore it entirely.
3. Otherwise the tool is late. Its fee is `min(daysLate, 5)` whole pounds: £1 per day late, capped at £5 **per tool** (not per member).
Per member:
- `late_tools` = number of that member's late returns.
- `fee` = sum of that member's per-tool fees (the cap applies per tool before summing, so a member total can exceed 5, e.g. 3 + 4 = 7).
- Members with no late tools do not appear in the output at all.
## Output
- File `late-fees.csv`, header exactly `member,late_tools,fee`, then one row per member with at least one late tool. Plain integers, no quotes, no pound signs, no spaces, newline after each line.
- Row order: `fee` descending; ties broken by member name ascending (alphabetical, A→Z). Example: Brigid 5 comes before Farah 5; Eamon 2 before Jules 2.
- Group by exact member name as written (same member may appear in several returns).
- If nobody is late, write only the header line.
## Procedure
1. Read input.json.
2. Write out a working list: for each return, due day, days late, fee (0 if on time). Double-check subtraction.
3. Total per member, count late tools, drop members with zero late tools.
4. Sort as above, write the CSV.
## Check against example
Returns: Gil drill out 3 due 7 back 10 → due 10, on time. Dana ladder out 1 due 7 back 16 → 8 late → fee 5. Gil sander out 4 due 3 back 9 → 2 late → 2. Abel jigsaw out 2 due 7 back 12 → 3 late → 3.
Result: Dana,1,5 / Abel,1,3 / Gil,1,2.