Bug 28985

Summary: Negative rental amounts can be saved but not enforced
Product: Koha Reporter: Andrew Fuerste-Henry <andrewfh>
Component: CirculationAssignee: Nick Clemens (kidclamp) <nick>
Status: CLOSED FIXED QA Contact: Joonas Kylmälä <joonas.kylmala>
Severity: normal    
Priority: P5 - low CC: fridolin.somers, gmcharlt, joonas.kylmala, kyle.m.hall, victor
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
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
Bug 28985: Force positive numbers for itemtype charge fields
Bug 28985: Force positive numbers for itemtype charge fields

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 (kidclamp) 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.