Process a department store returns-desk queue from input.json (defaultDays, categoryDays, restockPercent, returns[]) into refunds.csv and refused.json. Use whenever asked to decide return eligibility, compute refunds with restocking fees, or write refunds.csv / refused.json from such a file, even if the skill is not named.
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 Return Refunds?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/gabrielmoreira-return-refunds-c599dbd9)
---
name: return-refunds
description: Process a department store returns-desk queue from input.json (defaultDays, categoryDays, restockPercent, returns[]) into refunds.csv and refused.json. Use whenever asked to decide return eligibility, compute refunds with restocking fees, or write refunds.csv / refused.json from such a file, even if the skill is not named.
---
# Return refunds
You cannot run code, so do the arithmetic by hand, carefully, one item at a time, and write the output files yourself.
## Steps
1. Read `input.json` in the working folder. Fields: `defaultDays`, `categoryDays` (object, may be empty), `restockPercent`, `returns` (array of `{ref, category, priceCents, boughtDay, returnedDay, opened}`).
2. For each item, in input order, write down a work line:
- `kept = returnedDay - boughtDay`
- `window = categoryDays[category]` if that category key exists (even if smaller than defaultDays, and even if 0); otherwise `defaultDays`. Match the category exactly as written (case-sensitive).
- Accepted if `kept <= window` (equal is accepted); otherwise refused. A negative `kept` is still <= window, so accepted; don't invent extra rules.
3. For accepted items compute the refund in integer cents:
- `opened` false: `refundCents = priceCents`.
- `opened` true: `fee = floor(priceCents * restockPercent / 100)`; compute `priceCents * restockPercent` as an exact integer, then integer-divide by 100 and drop the remainder (never round up). `refundCents = priceCents - fee`.
- Check: multiply and subtract twice for large numbers.
4. Format the refund as dollars: `refundCents / 100` with exactly two decimals, no currency sign, no thousands separator. Integer part = cents div 100, fractional = cents mod 100 padded to two digits (e.g. 5 cents -> `0.05`, 4250 -> `42.50`, 0 -> `0.00`).
5. Write `refunds.csv` beside `input.json`:
- First line: `ref,refund`
- One row per accepted item, `ref,amount`. Sort by `returnedDay` ascending; ties keep input order (stable sort). To do this reliably, list accepted items with their input index, then order by (returnedDay, index).
- If none accepted, the file contains only the header line.
- Refs are written as given; if a ref contains a comma or quote, wrap it in double quotes (doubling inner quotes).
6. Write `refused.json` beside `input.json`: a JSON array of refused refs as strings, in input order (not sorted by day). Use `[]` if none.
7. Re-verify: accepted count + refused count = number of returns; every ref appears in exactly one file; each refund recomputed once more.
## Example
defaultDays 30, restockPercent 15, opened jacket 1999 cents, bought 100, returned 130: kept 30 <= 30 accepted; fee = floor(29985/100) = 299; refund 1700 cents -> `17.00`.