You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bound return gift-card credits to the server-calculated refund total #4787
The aggregate payments_cover_total check does not limit each individual gift-card payment. A return totaling -100 can pass with a gift-card payment of -200 and another payment of +100. Sale::save_value() then credits the gift card by 200, exceeding the actual refund.
Suggested fix
In postComplete(), before calling save_value(), validate that the sum of all negative gift-card payment amounts does not exceed the server-recalculated return total. Reject the sale if it does.
Context
Raised by CodeRabbit review on #4781. Tracked separately to keep that PR scoped to the #4779 regression fix.
There is no check limiting the sum of individual negative gift-card payment amounts against the server-recalculated return total — $data['payments'] is passed straight into $this->sale->save_value(...) without any per-gift-card or sum-of-gift-card-payments bound. In Sale::save_value() (app/Models/Sale.php), each gift-card payment is applied via $giftcard->decrementGiftcardValue($splitPayment[1], (float) $payment['payment_amount']), which simply decrements (credits, for negative amounts) by whatever amount is submitted — it doesn't cross-check against the overall return total either. So a return of -100 with a gift-card payment of -200 offset by another +100 payment could still pass the aggregate check and over-credit the gift card by 200, as described.
No related fix commits were found in current master history. This appears to still need the suggested validation in postComplete() before save_value() is called.
Activity
objecttothis commentedon Oct 29, 2026
Claude Issue Checker Agent (cc @objecttothis)
Status: Still present in master.
In
app/Controllers/Sales.php,postComplete()only validates the aggregate totals before callingSale::save_value():There is no check limiting the sum of individual negative gift-card payment amounts against the server-recalculated return total —
$data['payments']is passed straight into$this->sale->save_value(...)without any per-gift-card or sum-of-gift-card-payments bound. InSale::save_value()(app/Models/Sale.php), each gift-card payment is applied via$giftcard->decrementGiftcardValue($splitPayment[1], (float) $payment['payment_amount']), which simply decrements (credits, for negative amounts) by whatever amount is submitted — it doesn't cross-check against the overall return total either. So a return of-100with a gift-card payment of-200offset by another+100payment could still pass the aggregate check and over-credit the gift card by 200, as described.No related fix commits were found in current master history. This appears to still need the suggested validation in
postComplete()beforesave_value()is called.