Use this skill when a tool library, lending library or equipment loan needs late return fees worked out per member from a list of returns (out day, days allowed, back day), e.g. 'who owes late fees', 'calculate overdue charges', 'write late-fees.csv from input.json'.
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-a4c5cefe)
---
name: tool-return-fees
description: "Use this skill when a tool library, lending library or equipment loan needs late return fees worked out per member from a list of returns (out day, days allowed, back day), e.g. 'who owes late fees', 'calculate overdue charges', 'write late-fees.csv from input.json'."
---
# Tool return late fees
Turns `input.json` (tool loans that have come back) into `late-fees.csv`: one row per member who returned at least one tool late, with the number of late tools and the total fee in whole pounds.
Not for: loans still out, fees in other currencies or fee schedules the user states differently, or other output formats. If the user gives a different fee rule, follow theirs and say so.
## Input
`input.json` in the working folder (beside where the output goes):
```json
{"returns": [{"tool": "drill", "member": "Gil", "outDay": 3, "dueDays": 7, "backDay": 10}]}
```
Each record: `tool` (text), `member` (text), `outDay`, `dueDays`, `backDay` (integers, day numbers).
## Rules (exact formulas)
For each record:
1. `dueDay = outDay + dueDays`
2. `daysLate = max(0, backDay - dueDay)`
3. Late only if `daysLate > 0`. Returned on the due day, early, or with a zero or negative `daysLate` is NOT late: no fee, not counted.
4. `toolFee = min(5, daysLate)` pounds. One pound per late day, capped at 5 per tool. (Late 1 day = 1, 4 days = 4, 5 or more days = 5.)
Per member (match member names exactly, case-sensitive, after trimming spaces):
- `late_tools` = number of that member's records with `daysLate > 0`
- `fee` = sum of their `toolFee` values (the cap applies per tool, not per member, so a total above 5 is normal)
## Steps
1. Read `input.json`. Take `returns` (if empty or missing, output only the header line).
2. For each record compute `dueDay`, `daysLate`, `toolFee`. Write the numbers out per record in your working notes; do not do it in your head for long lists.
3. Group by member; keep only members with `late_tools >= 1`. Members with only on-time returns do not appear.
4. Sort rows by `fee` descending; ties by member name ascending (A to Z, case-insensitive). The input order does not matter.
5. Write `late-fees.csv` beside `input.json`.
6. Re-read the file and check each row against your notes.
## Output format
- Header exactly: `member,late_tools,fee`
- One row per member: `name,count,fee`, integers with no decimals, no pound sign.
- Comma-separated, `\n` line endings, trailing newline at the end, no blank lines, no extra columns.
- If a member name contains a comma or double quote, wrap it in double quotes and double any inner quotes.
## Missing or odd data
- Do not ask questions; apply the rules above.
- A record missing a field, or with a non-numeric day: skip it and mention it in your reply.
- If `backDay` is before `outDay`, still apply the formulas (it will be not late).
- Never invent members or round fees; all values are whole numbers.
## Worked example
Records: drill/Gil out 3, due 7, back 10 -> dueDay 10, late 0, not late.
ladder/Dana out 1, due 7, back 16 -> dueDay 8, late 8, fee min(5,8)=5.
sander/Gil out 4, due 3, back 9 -> dueDay 7, late 2, fee 2.
jigsaw/Abel out 2, due 7, back 12 -> dueDay 9, late 3, fee 3.
```csv
member,late_tools,fee
Dana,1,5
Abel,1,3
Gil,1,2
```
More checked examples (including the tie ordering): [examples](references/examples.md). Open it if unsure about ties or the cap.