Use this skill when a user wants to process a department store returns desk queue: decide which returns are accepted or refused under return windows (default or per-category days), apply restocking fees to opened items, and produce a refund list and a refused list. Not for exchanges, order tracking, or unrelated refund policies.
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-40d675be)
---
name: return-refunds
description: "Use this skill when a user wants to process a department store returns desk queue: decide which returns are accepted or refused under return windows (default or per-category days), apply restocking fees to opened items, and produce a refund list and a refused list. Not for exchanges, order tracking, or unrelated refund policies."
---
# Return refunds
Process a returns queue from `input.json` into `refunds.csv` and `refused.json`, using only file reads and writes. Do the arithmetic by hand, carefully, with integers only.
## Input
Read `input.json` in the working folder (the folder that holds it is where outputs go):
- `defaultDays`: integer window for categories not listed.
- `categoryDays`: object, category -> window days. Overrides `defaultDays` even when shorter (or 0).
- `restockPercent`: integer.
- `returns`: array of `{ref, category, priceCents, boughtDay, returnedDay, opened}`. Refs are unique.
If `input.json` is missing or unreadable, stop and tell the user. If `categoryDays` is absent treat it as `{}`. Match categories by exact, case-sensitive string.
## Steps
1. For each return, in file order, compute:
- `kept = returnedDay - boughtDay`
- `window = categoryDays[category]` if the category is a key there, else `defaultDays`. A listed value of 0 is still used (do not treat it as missing).
2. Accept if `kept <= window`; otherwise refuse. Equal is accepted. A negative `kept` (returned before bought) is `<= window` for any non-negative window, so it is accepted; do not invent extra rules. Note it in the final reply.
3. For accepted items, in integer cents:
- `opened` false: `refundCents = priceCents`.
- `opened` true: `fee = floor(priceCents * restockPercent / 100)`; `refundCents = priceCents - fee`.
- Compute `priceCents * restockPercent` exactly, divide by 100, drop the remainder (never round up). E.g. 1999*15 = 29985 -> fee 299.
4. Format refund dollars: `dollars = floor(refundCents / 100)`, `cents = refundCents mod 100` written as two digits (pad with 0). Result `dollars.cents`, e.g. 1700 -> `17.00`, 5 -> `0.05`, 4250 -> `42.50`. No currency sign, no thousands separators.
5. Order accepted rows by `returnedDay` ascending; ties keep their `input.json` order (stable sort). Do this by listing accepted items with their original index and ordering by (returnedDay, index).
6. Write `refunds.csv` beside `input.json`:
```
ref,refund
<ref>,<dollars.cents>
```
Header first, one row per accepted return, newline after each line, no quoting unless a ref contains a comma or quote. With no accepted returns, write only the header line.
7. Write `refused.json` beside `input.json`: a JSON array of refused refs (strings, as they appear in the input) in `input.json` order, e.g. `["A7","B2"]`; `[]` if none.
8. Re-read both outputs and check: every ref appears in exactly one of the two files, row count + refused count = number of returns, and sort order is correct.
## Worked example
defaultDays 30, restockPercent 15, categoryDays `{"electronics": 14}`.
| ref | category | price | bought | returned | opened | result |
|---|---|---|---|---|---|---|
| J1 | clothing | 1999 | 100 | 130 | true | kept 30 <= 30, fee 299, refund 1700 -> 17.00 |
| E1 | electronics | 5000 | 100 | 115 | false | kept 15 > 14, refused |
| S1 | shoes | 4250 | 110 | 120 | false | kept 10, refund 42.50 |
`refunds.csv`:
```
ref,refund
S1,42.50
J1,17.00
```
(S1 returned day 120 precedes J1 at day 130.) `refused.json`: `["E1"]`
## Final reply
Briefly state counts of accepted and refused, and mention any anomalies (negative days kept, missing fields).