Skip to content
Back to skills

Return Refunds

ASecurity

Process a department store returns-desk queue from input.json (defaultDays, categoryDays, restockPercent, returns) into refunds.csv and refused.json. Use whenever asked to work out return windows, accept or refuse returns, compute refunds or restocking fees, or process a returns queue, even if the files are not named exactly.

  • 24 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 6, 2026
developmentgogit

Security analysis

A100/100

Scanned December 6, 2026

npx -y skills add gabrielmoreira/agent-skills-mirror --skill return-refunds --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Return Refunds?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Return Refunds
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/gabrielmoreira-return-refunds-91b468f3/badge)](https://www.skillsdirectory.com/skills/gabrielmoreira-return-refunds-91b468f3)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
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 work out return windows, accept or refuse returns, compute refunds or restocking fees, or process a returns queue, even if the files are not named exactly.
---

# Return refunds

Read `input.json` in the working folder. Write `refunds.csv` and `refused.json` beside it. You cannot run code, so do the arithmetic by hand, one item at a time, using whole numbers only. Money stays in integer cents until the final formatting step. This avoids floating-point and rounding mistakes.

## Input
- `defaultDays`: integer window for categories not listed in `categoryDays`.
- `categoryDays`: object of category -> window days. Some categories only.
- `restockPercent`: integer percent.
- `returns`: array of `{ref, category, priceCents, boughtDay, returnedDay, opened}`.

## Step 1: Build a working table
Go through `returns` in file order. For each item, write one line in your notes:

`index | ref | window | kept | accepted? | fee | refundCents | returnedDay`

1. **window**: if the item's category is a key in `categoryDays`, use that value, even if it is smaller than `defaultDays` and even if it is 0. Otherwise use `defaultDays`. Match the category text exactly. Check the key list literally rather than assuming.
2. **kept** = `returnedDay - boughtDay`.
3. **accepted** if `kept <= window`. Equal is accepted. `kept = window + 1` is refused. If kept is negative or 0, it is still accepted (it is not above the window); apply the rule as written.
4. If accepted and `opened` is false: fee = 0, refundCents = priceCents.
5. If accepted and `opened` is true: fee = floor(priceCents × restockPercent ÷ 100). Compute the product exactly, divide by 100, and drop everything after the decimal point. Never round up. refundCents = priceCents − fee.
   - Check: 1999 × 15 = 29985; ÷100 = 299.85; floor 299; refund 1700 → `17.00`.
   - To divide by 100, drop the last two digits of the product (a product under 100 gives fee 0).
6. If refused: no refund and it goes only to `refused.json`.

Do the multiplication digit by digit and double-check it; this is where errors creep in. Only `opened` equal to JSON `true` is opened.

## Step 2: refunds.csv
- First line exactly `ref,refund`.
- One row per accepted item only, as `ref,amount`.
- Order rows by `returnedDay` ascending. Items with equal `returnedDay` keep their relative order from `input.json`. To do this, list the accepted items by index, then place them in order of returnedDay, breaking ties by lower index first.
- amount = dollars with exactly two decimals, no currency sign, no thousands separators. Convert cents: integer part = refundCents ÷ 100 (floor), decimals = remainder padded to two digits. Examples: 1700 → `17.00`; 5 → `0.05`; 4250 → `42.50`; 0 → `0.00`; 123456 → `1234.56`.
- Write one row per line with a trailing newline. No quotes unless a ref contains a comma or quote (then use standard CSV quoting). Do not alter refs.
- If nothing is accepted, the file contains only the header line.

## Step 3: refused.json
- A JSON array of the refs of refused items, as strings, in the original `input.json` order (not sorted by day).
- Example: `["A12","B07"]`. If none are refused write `[]`.

## Step 4: Verify before finishing
- Accepted count + refused count = number of returns, and every ref appears in exactly one file.
- Re-check each item that sits at the boundary (kept equal to or one more than the window) and each opened item's fee.
- Re-check the CSV order: returnedDay never decreases down the file.
- Confirm both files were written beside `input.json`, and that the refs are copied exactly (case, leading zeros, and so on).

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.