hoangsonww / hoangsonww/Library-Management-Backend
Add overdue-loan fine calculation
- Dominant language
- Go
- Stars
- 1
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
## What problem does this solve?
The loan status derivation already distinguishes `active`/`overdue`/`returned` (per the README), but "overdue" today is purely informational — there's no fee/fine concept, so there's no way to track or report on the cost of a late return, which most real library systems model explicitly.
## Proposed solution
- Add a `FINE_PER_DAY` config value and compute an overdue fine on return: `max(0, daysLate) * FINE_PER_DAY`, stored on the loan record (`fineAmount`) at the moment `POST /api/v1/loans/{id}/return` is called.
- Add `GET /api/v1/borrowers/{id}/fines` returning total outstanding fines across that borrower's loan history.
- Add a `loans fines ` CLI subcommand for quick lookup.
- Document the fine calculation clearly in the README/openapi.yaml so it's not a surprise — including that it's `0` by default (`FINE_PER_DAY=0`) so this is opt-in for deployers who want it.
## Alternatives considered
Leaving fines entirely to an external system that consumes loan history — reasonable, but the overdue/active/returned status already lives here, so the natural place for the derived fine amount is right next to it.
## Area
Loans (borrow / return), Borrowers
## Priority
Nice to have — not core to catalog/lending correctness, but a common expectation for anything calling itself a library management system.
Contributor guide
Assessment
This issue has not been assessed yet.