Skip to content

Financials: Implement idempotent refund system & fix partial refund over-collection #278

Description

@khaira777

Financial Integrity & Refund Tracking Request

Extracted from fork codewithsharma/FloCafe (branch: develop):

Overview

Improvements to track refunds, ensure idempotency on financial transactions, handle cash refunds during shift/day close, and prevent math issues on partial refunds.

Proposed Changes

  1. Refunds Table & Idempotency Tracking:
    • Add dedicated refunds table and refund_idempotency table (Migration 72).
    • Track amount_cents, original_method, approved_by, and shift_id.
    • Reference: main/routes/refunds.ts, main/services/refund.ts.
  2. Partial Refund Over-Collection Fix:
    • Fix calculation logic preventing over-collection or double refund balance mismatches on partial refunds.
    • Reference: commit fedbe4c.
  3. Cash Refund Integration into Day Close:
    • Ensure cash refund subtractions are properly accounted for in expected cash counts during shift reconciliation and day close.
    • Reference: commit aaf8720.
  4. Fail-Closed DB Recovery Guard:
    • Fail closed safely if the production SQLite database is missing or unreadable rather than generating a blank database in production mode.
    • Reference: commit e236542.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:backendBackend (Express/SQLite)enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions