Skip to content
Back to skills

Gift Card Ledger

ASecurity

Use this skill when the user wants to replay a day of gift card activity (loads and spends from the tills) against opening card balances and a card limit, producing end-of-day balances per card and a list of declined events. Covers requests like 'apply today's gift card events', 'work out end-of-day gift card balances', or 'which gift card transactions were declined'. Not for general payments, refunds, or reconciling bank data.

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

Works with

  • cli

Security analysis

A100/100

Scanned December 6, 2026

npx -y skills add gabrielmoreira/agent-skills-mirror --skill gift-card-ledger --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Gift Card Ledger?

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

Security grade badge for Gift Card Ledger
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/gabrielmoreira-gift-card-ledger-2ff8b3b5/badge)](https://www.skillsdirectory.com/skills/gabrielmoreira-gift-card-ledger-2ff8b3b5)

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: gift-card-ledger
description: "Use this skill when the user wants to replay a day of gift card activity (loads and spends from the tills) against opening card balances and a card limit, producing end-of-day balances per card and a list of declined events. Covers requests like 'apply today's gift card events', 'work out end-of-day gift card balances', or 'which gift card transactions were declined'. Not for general payments, refunds, or reconciling bank data."
---

# Gift card ledger replay

## When to use
Use for replaying ordered gift card events (load/spend) over opening balances with a maximum card limit. Do not use for other ledgers or when no `input.json` of this shape exists (if missing, tell the user and stop).

## Input: `input.json` in the working folder
- `limitCents`: max balance a card may hold (integer cents).
- `cards`: array of `{card, balanceCents}`; every issued card, opening balance.
- `events`: array of `{seq, card, type, cents}` in the order the tills sent them. `card` is an 8-digit string (keep as string, keep leading zeros). `type` is `"load"` or `"spend"`. `cents` is a positive integer.

## Procedure
1. Read `input.json`. Build a table card -> balance (integer cents) from `cards`.
2. Process `events` strictly in listed order (do NOT sort by `seq`; `seq` is only an identifier). For each event, with `b` = current balance:
   - Card not in table: declined; change nothing; never create a card.
   - `load`: if `b + cents <= limitCents` then `b = b + cents`; otherwise declined, balance unchanged (no partial top-up).
   - `spend`: if `cents <= b` then `b = b - cents`; otherwise declined, balance unchanged (no partial payment).
   - Any other `type`: declined, no change (note this in your reply).
   - Record the `seq` of every declined event, in the order applied.
   Each event sees the balance left by earlier events, including declined ones (which changed nothing). Work in integer cents only; never use dollars/floats while computing.
3. Write `card-balances.csv` beside `input.json`:
   - Header line exactly `card,balance`, then one row per card in `cards` (all of them, including untouched ones; no duplicates).
   - Sort rows by card number ascending. Cards are all 8 digits, so plain string comparison equals numeric order (compare digit by digit from the left).
   - balance = end-of-day cents converted to dollars with exactly two decimals, no currency sign, no thousands separator: `dollars = floor(c / 100)`, `rem = c mod 100` written as two digits. E.g. 12500 -> `125.00`, 5 -> `0.05`, 0 -> `0.00`, 100050 -> `1000.50`.
   - Write card as the original string (leading zeros kept). Use newline-separated lines.
4. Write `declined.json` beside `input.json`: JSON array of declined `seq` values as numbers, in applied order, e.g. `[3,7,12]`; `[]` if none.
5. Re-check: row count equals `cards` length; sorted order; each balance is within 0..limitCents (an opening balance already above the limit stays as is until a spend); re-verify arithmetic for any card with several events.

## Edge rules
- Load landing exactly on `limitCents` is accepted; spend of exactly the balance is accepted (leaves `0.00`).
- Load of 1 cent over the limit is declined whole; spend of 1 cent over balance is declined whole.
- A load on a card whose opening balance already exceeds the limit is declined (any positive cents exceed it).
- Duplicate card entries in `cards`: use the first, mention it in the reply. Unknown cards never appear in the CSV.

## Worked example
limitCents 50000; card `00000001` opens at 48000; events in order:
1. seq 5 load 2000 -> 50000 accepted.
2. seq 6 load 1 -> 50001 > limit, declined.
3. seq 7 spend 60000 -> exceeds balance, declined.
4. seq 8 card `99999999` (not issued) load 100 -> declined.

Output: `card-balances.csv`
```
card,balance
00000001,500.00
```
`declined.json`: `[6,7,8]`

## Limits
No commands are needed; do the arithmetic by hand carefully, step by step, tracking each card's running balance in a written table when there are many events.

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 tools →

Comments

Loading comments…

Newsletter

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