Bug 37535: Adding a debit via API will show the belated patron as the librarian that caused the debit
This patch fixes the addPatronDebit route so that the librarian that caused the debit is taken from either the requests payload user_id or if not set from the api user.
Test plan:
a) enable system preference RESTBasicAuth
b) use a REST client to send a POST request with the following JSON body to http://localhost:8081/api/v1/patrons/5/account/debits
Authentication username and password is "koha"
c) verify that "user_id" is the same as patron_id in response.
d) send a different request including user_id to the same endpoint
{
"amount": 1.23,
"description": "some description",
"internal_note": "internal_note",
"type": "MANUAL",
"user_id": 19
}
e) verify that "user_id" is the same as patron_id in response.
f) apply patch and repeat step b) and d)
e) verify that user_id in b) is now 51 (which is the borrowernumber of koha user)
f) verify that user_id in d) is now 19 as defined in request
g) recheck on http://localhost:8081/cgi-bin/koha/members/accountline-details.pl?accountlines_id=<account_line_id> (from response) that column Librarian now says the user from user_id
h) sign off :)
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>