Bug 41385

Summary: Exception and error thrown from add_credit method is wrong
Product: Koha Reporter: Emmi Takkinen <emmi.takkinen>
Component: Fines and feesAssignee: Bugs List <koha-bugs>
Status: NEW --- QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low    
Version: Main   
Hardware: All   
OS: All   
GIT URL: Initiative type: ---
Sponsorship status: --- Comma delimited list of Sponsors:
Crowdfunding goal: 0 Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:

Description Emmi Takkinen 2025-12-05 13:07:16 UTC
If credit amount passed to the Koha::Account->add_credit is not negative, Koha throws exception called Koha::Exceptions::Account::AmountNotPositive with error message "Debit amount passed is not positive". This is same error thrown with method add_debit.

We should at least change error message as e.g. "Credit amount passed is not negative" and probably create a new exception called Koha::Exceptions::Account::AmountNotNegative to avoid confusion.
Comment 1 Emmi Takkinen 2025-12-05 13:09:20 UTC
On same note, sub add_credit in Koha::REST::V1::Patrons::Account checks id amount passed is positive: 

> unless ( $amount > 0 ) 

Shouldn't this too check if amount is negative?