Koha-clms/pos
Martin Renvoize 8dba205b9a
Bug 41819: (follow-up) Reject 'AC' refunds for anonymous transactions server-side
The previous patch hides the 'Account credit' option in the refund modal
when the accountline has no borrowernumber, but that is a UI convenience
only. A crafted POST (or a stale page) could still submit
refund_type=AC against an anonymous accountline, which would create a
REFUND credit with no patron to attach it to and leave the register
unbalanced because the payout branch is skipped.

Add a server-side guard in pos/register.pl that refuses the operation
and surfaces a new error_refund_anonymous_ac flag, rendered in
pos/register.tt in the same style as the other refund errors.

Test plan:
1. Apply the patch
2. Log in as a user with cash_management/anonymous_refund permission
3. Record an anonymous sale against a register
4. Using the browser devtools (or curl), POST to pos/register.pl with
   op=cud-refund, refund_type=AC and the accountline id of the sale
5. => Confirm the request is rejected and the
   "Account credit refunds are not available for anonymous transactions"
   message is shown
6. => Confirm no REFUND accountline was created and the register
   balance is unchanged
7. Repeat the POST with refund_type=CASH (or any non-AC type) and
   confirm the refund + payout are created normally

Signed-off-by: Lisette Scheer <lisette@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-08-10 14:56:43 -06:00
..
pay.pl Bug 41705: Use PRG pattern for POS receipt printing to avoid popup blockers 2026-06-04 15:09:06 -06:00
printreceipt.pl Bug 41705: Use PRG pattern for POS receipt printing to avoid popup blockers 2026-06-04 15:09:06 -06:00
register.pl Bug 41819: (follow-up) Reject 'AC' refunds for anonymous transactions server-side 2026-08-10 14:56:43 -06:00
registers.pl Bug 38728: (follow-up) Fix cashup modal triggering after POST/REDIRECT/GET implementation 2026-01-22 09:25:59 -07:00