Bug 28774 - Warnings from GetIssuingCharge when rental discount is not set
Summary: Warnings from GetIssuingCharge when rental discount is not set
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Circulation (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Nick Clemens (kidclamp)
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-07-28 12:23 UTC by Nick Clemens (kidclamp)
Modified: 2022-06-06 20:25 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
This fixes the cause of warning messages in the log files when the rental discount in the circulation rules has a blank value. Before this fix, multiple warning messages "[2021/07/28 12:11:25] [WARN] Argument "" isn't numeric in subtraction (-) at /kohadevbox/koha/C4/Circulation.pm line 3385." appeared in the log files. These warnings occurred for items checked out where they had rental charges and the rental discount value in the circulation rules was blank.
Version(s) released in:
21.11.00,21.05.04,20.11.10
Circulation function:


Attachments
Bug 28774: Don't store blank values for rental discount (3.77 KB, patch)
2021-07-28 12:31 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 28774: Don't store blank values for rental discount (3.82 KB, patch)
2021-07-30 20:01 UTC, David Nind
Details | Diff | Splinter Review
Bug 28774: Don't store blank values for rental discount (3.96 KB, patch)
2021-08-30 18:56 UTC, Joonas Kylmälä
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Clemens (kidclamp) 2021-07-28 12:23:38 UTC
If you set the rental discount field blank in circ rules it is stored as ""

Checkout an item:
[2021/07/28 12:11:25] [WARN] Argument "" isn't numeric in subtraction (-) at /kohadevbox/koha/C4/Circulation.pm line 3385.
Comment 1 Nick Clemens (kidclamp) 2021-07-28 12:31:28 UTC
Created attachment 123248 [details] [review]
Bug 28774: Don't store blank values for rental discount

This patch adds 'can_be_blank => 0' for the rentaldiscount rule to prevent
storing blank values in the database

Additionally, if there is no charge we do not need to check for a discount
and can simply return

To test:
1 - Set rental discount to "" to a rule in circulation rules
2 - Checkout an item that will follow this rule
3 - Check the intranet log:
    [WARN] Argument "" isn't numeric in subtraction (-) at /kohadevbox/koha/C4/Circulation.pm line 3385.
4 - Apply patch and restart all
5 - Update database
6 - Set the rule to "" again
7 - Check the DB, no rule is stored
    SELECT * FROM circulation_rules WHERE rule_name = 'rentaldiscount';
8 - Checkout the item again
9 - No warns in log
Comment 2 David Nind 2021-07-30 20:01:56 UTC
Created attachment 123347 [details] [review]
Bug 28774: Don't store blank values for rental discount

This patch adds 'can_be_blank => 0' for the rentaldiscount rule to prevent
storing blank values in the database

Additionally, if there is no charge we do not need to check for a discount
and can simply return

To test:
1 - Set rental discount to "" to a rule in circulation rules
2 - Checkout an item that will follow this rule
3 - Check the intranet log:
    [WARN] Argument "" isn't numeric in subtraction (-) at /kohadevbox/koha/C4/Circulation.pm line 3385.
4 - Apply patch and restart all
5 - Update database
6 - Set the rule to "" again
7 - Check the DB, no rule is stored
    SELECT * FROM circulation_rules WHERE rule_name = 'rentaldiscount';
8 - Checkout the item again
9 - No warns in log

Signed-off-by: David Nind <david@davidnind.com>
Comment 3 Joonas Kylmälä 2021-08-30 18:56:12 UTC
Created attachment 124253 [details] [review]
Bug 28774: Don't store blank values for rental discount

This patch adds 'can_be_blank => 0' for the rentaldiscount rule to prevent
storing blank values in the database

Additionally, if there is no charge we do not need to check for a discount
and can simply return

To test:
1 - Set rental discount to "" to a rule in circulation rules
2 - Checkout an item that will follow this rule
3 - Check the intranet log:
    [WARN] Argument "" isn't numeric in subtraction (-) at /kohadevbox/koha/C4/Circulation.pm line 3385.
4 - Apply patch and restart all
5 - Update database
6 - Set the rule to "" again
7 - Check the DB, no rule is stored
    SELECT * FROM circulation_rules WHERE rule_name = 'rentaldiscount';
8 - Checkout the item again
9 - No warns in log

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
Comment 4 Jonathan Druart 2021-08-31 08:28:39 UTC
Pushed to master for 21.11, thanks to everybody involved!
Comment 5 Kyle M Hall (khall) 2021-09-03 15:14:18 UTC
Pushed to 21.05.x for 21.05.04
Comment 6 Fridolin Somers 2021-09-08 20:45:55 UTC
Pushed to 20.11.x for 20.11.10
Comment 7 Victor Grousset/tuxayo 2021-09-20 11:56:10 UTC
Not backported to oldoldstable (20.05.x). Feel free to ask if it's needed.