# POS Project Fixes Applied

## Core fixes
- Fixed sale invoice update/delete to reverse stock and clean related stock movements.
- Added centralized inventory consistency helper for stock movement cleanup and supplier ledger recalculation.
- Fixed customer reward rollback on sale update/delete so points and wallet transaction rows do not duplicate.
- Fixed purchase update flow to fully rebuild purchase lines instead of leaving stale stock lines in place.
- Fixed purchase delete flow to reverse stock, remove payments/account transactions, and clean supplier ledger references.
- Added blocking rule: purchase edit/delete now stops if supplier return already exists against that purchase's items.
- Fixed duplicate `branch_id` / duplicate `branches` issues in purchase controller.
- Added model fillable support for `branch_id` on `Sale` and `Purchase`.

## Return module fixes
- Fixed sale return quantity validation so cumulative returns cannot exceed sold quantity.
- Fixed supplier return quantity validation so cumulative returns cannot exceed purchased quantity.
- Fixed sale return delete to stop when reverse stock would become negative.
- Fixed return deletion stock movement handling to remove original movement and add explicit reverse movement entries.

## Inventory fixes
- Fixed stock transfer to use one consistent transfer reference number.
- Added stock availability check before transfer note is saved.

## Notes
- All patched PHP files pass syntax lint.
- Full Laravel runtime boot could not be verified inside this container because required PHP extensions are missing here (`mbstring`; earlier environment also lacked sqlite runtime support).
- Remaining deeper business improvements may still be possible, but the critical stock / delete / update / return consistency issues identified in audit were patched.
