Bug 41385 - Exception and error thrown from add_credit method is wrong
Summary: Exception and error thrown from add_credit method is wrong
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: Fines and fees (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-12-05 13:07 UTC by Emmi Takkinen
Modified: 2025-12-05 13:09 UTC (History)
0 users

See Also:
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:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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?