Bug 28985 - Negative rental amounts can be saved but not enforced
Summary: Negative rental amounts can be saved but not enforced
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Circulation (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Nick Clemens
QA Contact: Joonas Kylmälä
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-09-09 14:56 UTC by Andrew Fuerste-Henry
Modified: 2021-10-16 02:21 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Text to go in the release notes:
Version(s) released in:
21.11.00,21.05.05,21.11.11


Attachments
Bug 28985: Force positive numbers for itemtype charge fields (4.69 KB, patch)
2021-09-10 12:18 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 28985: Force positive numbers for itemtype charge fields (4.75 KB, patch)
2021-09-10 13:21 UTC, Andrew Fuerste-Henry
Details | Diff | Splinter Review
Bug 28985: Force positive numbers for itemtype charge fields (4.90 KB, patch)
2021-09-11 15:21 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 Andrew Fuerste-Henry 2021-09-09 14:56:48 UTC
In item types, one can enter a negative amount for a rental charge. Koha allows this, saves the value, and shows it to you in admin. However, that value gets ignored at checkout.

On the one hand, I can see weird use cases for giving patrons credits for checking out items.

On the other hand, it would be a lot simpler to just not allow negative values to get set in the first place.

Whichever way we go, we should pursue consistency and not let users enter values that don't get used.
Comment 1 Nick Clemens 2021-09-10 12:18:25 UTC
Created attachment 124758 [details] [review]
Bug 28985: Force positive numbers for itemtype charge fields

This patch adds a min attribute to the fields on this page and adds
other cost related fields to validator

To test:
1 - Apply patch
2 - Browse to Administration->Item types
3 - Edit or create an item type
4 - Attempt to place a negative or non numeric value in:
    Daily rental charge
    Hourly rental charge
    Default replacement cost
    Processing fee
5 - You should not be able to
Comment 2 Andrew Fuerste-Henry 2021-09-10 13:21:38 UTC
Created attachment 124761 [details] [review]
Bug 28985: Force positive numbers for itemtype charge fields

This patch adds a min attribute to the fields on this page and adds
other cost related fields to validator

To test:
1 - Apply patch
2 - Browse to Administration->Item types
3 - Edit or create an item type
4 - Attempt to place a negative or non numeric value in:
    Daily rental charge
    Hourly rental charge
    Default replacement cost
    Processing fee
5 - You should not be able to

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Comment 3 Joonas Kylmälä 2021-09-11 15:21:48 UTC
Created attachment 124798 [details] [review]
Bug 28985: Force positive numbers for itemtype charge fields

This patch adds a min attribute to the fields on this page and adds
other cost related fields to validator

To test:
1 - Apply patch
2 - Browse to Administration->Item types
3 - Edit or create an item type
4 - Attempt to place a negative or non numeric value in:
    Daily rental charge
    Hourly rental charge
    Default replacement cost
    Processing fee
5 - You should not be able to

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>

Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
Comment 4 Jonathan Druart 2021-09-20 12:48:16 UTC
Pushed to master for 21.11, thanks to everybody involved!
Comment 5 Fridolin Somers 2021-10-06 20:24:08 UTC
I see it is in 21.05.x for 21.05.05
Comment 6 Fridolin Somers 2021-10-06 20:24:31 UTC
Pushed to 20.11.x for 20.11.11
Comment 7 Victor Grousset/tuxayo 2021-10-16 02:21:04 UTC
Not backported to oldoldstable (20.05.x). Feel free to ask if it's needed.