Bug 29184 - Warn from chargelostitem when no replacement cost set for item
Summary: Warn from chargelostitem when no replacement cost set for item
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal (vote)
Assignee: Nick Clemens (kidclamp)
QA Contact: Joonas Kylmälä
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-10-06 12:48 UTC by Nick Clemens (kidclamp)
Modified: 2023-06-08 22:26 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.11.00


Attachments
Bug 29184: Fix warn about undefined replacecost (1.31 KB, patch)
2021-10-06 12:50 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 29184: Fix warn about undefined replacecost (1.81 KB, patch)
2022-05-17 16:22 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 29184: Fix warn about undefined replacecost (1.78 KB, patch)
2022-09-07 20:13 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 29184: Fix warn about undefined replacecost (1.83 KB, patch)
2022-09-08 12:32 UTC, David Nind
Details | Diff | Splinter Review
Bug 29184: Fix warn about undefined replacecost (1.97 KB, patch)
2022-09-08 16:20 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-10-06 12:48:11 UTC
To recreate:
1 - Create a new item with no replacement cost set
2 - Check the item out to a patron
3 - Mark the item lost
4 - Note in plack-intranet-error.log:
    [2021/10/06 12:43:26] [WARN] Use of uninitialized value $replacementprice in numeric gt (>) at /kohadevbox/koha/C4/Accounts.pm line 114.
Comment 1 Nick Clemens (kidclamp) 2021-10-06 12:50:00 UTC Comment hidden (obsolete)
Comment 2 Fridolin Somers 2022-03-22 23:31:15 UTC
We see in chargelostitem() :

if ($usedefaultreplacementcost && $amount == 0 && $defaultreplacecost){

Shouldn't we patch with :
$amount = $amount // 0

Items sql table contains :
`replacementprice` decimal(28,6) DEFAULT NULL

So indeed default in undef.
Comment 3 Nick Clemens (kidclamp) 2022-05-17 16:22:52 UTC
Created attachment 135076 [details] [review]
Bug 29184: Fix warn about undefined replacecost

This patch simply sets the cost to 0 if undefined

To test:
1 - Create a new item with no replacement cost set
2 - Check the item out to a patron
3 - Mark the item lost
4 - Note in plack-intranet-error.log:
    [2021/10/06 12:43:26] [WARN] Use of uninitialized value $replacementprice in numeric gt (>) at /kohadevbox/koha/C4/Accounts.pm line 114.
5 - Apply patch
6 - Repeat
7 - No warn
Comment 4 Joonas Kylmälä 2022-09-07 18:38:42 UTC
Doesn't apply anymore and I think we have a bug: $replacementprice is initialized twice (two my $replacementprice).
Comment 5 Nick Clemens (kidclamp) 2022-09-07 20:13:47 UTC
Created attachment 140325 [details] [review]
Bug 29184: Fix warn about undefined replacecost

This patch simply sets the cost to 0 if undefined

To test:
1 - Create a new item with no replacement cost set
2 - Check the item out to a patron
3 - Mark the item lost
4 - Note in plack-intranet-error.log:
    [2021/10/06 12:43:26] [WARN] Use of uninitialized value $replacementprice in numeric gt (>) at /kohadevbox/koha/C4/Accounts.pm line 114.
5 - Apply patch
6 - Repeat
7 - No warn
Comment 6 David Nind 2022-09-08 12:32:09 UTC
Created attachment 140335 [details] [review]
Bug 29184: Fix warn about undefined replacecost

This patch simply sets the cost to 0 if undefined

To test:
1 - Create a new item with no replacement cost set
2 - Check the item out to a patron
3 - Mark the item lost
4 - Note in plack-intranet-error.log:
    [2021/10/06 12:43:26] [WARN] Use of uninitialized value $replacementprice in numeric gt (>) at /kohadevbox/koha/C4/Accounts.pm line 114.
5 - Apply patch
6 - Repeat
7 - No warn

Signed-off-by: David Nind <david@davidnind.com>
Comment 7 Joonas Kylmälä 2022-09-08 16:20:02 UTC
Created attachment 140352 [details] [review]
Bug 29184: Fix warn about undefined replacecost

This patch simply sets the cost to 0 if undefined

To test:
1 - Create a new item with no replacement cost set
2 - Check the item out to a patron
3 - Mark the item lost
4 - Note in plack-intranet-error.log:
    [2021/10/06 12:43:26] [WARN] Use of uninitialized value $replacementprice in numeric gt (>) at /kohadevbox/koha/C4/Accounts.pm line 114.
5 - Apply patch
6 - Repeat
7 - No warn

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

Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
Comment 8 Tomás Cohen Arazi 2022-09-08 17:53:47 UTC
Pushed to master for 22.11.

Nice work everyone, thanks!
Comment 9 Lucas Gass 2022-10-31 20:24:47 UTC
Doesn't apply clean to 22.05.x, no backport