From 0052fe42bf7820672cf257f3d835fb6df63e7a8f Mon Sep 17 00:00:00 2001
From: Nick Clemens <nick@bywatersolutions.com>
Date: Fri, 10 Sep 2021 12:12:07 +0000
Subject: [PATCH] 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>
---
.../prog/en/modules/admin/itemtypes.tt | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt
index dbab84bdcb..f61e0602f0 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt
@@ -311,12 +311,12 @@ Item types › Administration › Koha
</li>
<li>
<label for="rentalcharge">Rental charge: </label>
- <input type="text" id="rentalcharge" name="rentalcharge" size="10" value="[% itemtype.rentalcharge | $Price on_editing => 1 %]" />
+ <input type="text" id="rentalcharge" name="rentalcharge" size="10" value="[% itemtype.rentalcharge | $Price on_editing => 1 %]" min="0" />
<span class="hint">This fee is charged once per checkout/renewal per item</span>
</li>
<li>
<label for="rentalcharge_daily">Daily rental charge: </label>
- <input type="text" id="rentalcharge_daily" name="rentalcharge_daily" size="10" value="[% itemtype.rentalcharge_daily | $Price on_editing => 1 %]" />
+ <input type="text" id="rentalcharge_daily" name="rentalcharge_daily" size="10" value="[% itemtype.rentalcharge_daily | $Price on_editing => 1 %]" min="0" />
<span class="hint">This fee is charged at checkout/renewal time for each day between the checkout/renewal date and due date for loans specified in days.</span>
</li>
<li>
@@ -330,7 +330,7 @@ Item types › Administration › Koha
</li>
<li>
<label for="rentalcharge_hourly">Hourly rental charge: </label>
- <input type="text" id="rentalcharge_hourly" name="rentalcharge_hourly" size="10" value="[% itemtype.rentalcharge_hourly | $Price on_editing => 1 %]" />
+ <input type="text" id="rentalcharge_hourly" name="rentalcharge_hourly" size="10" value="[% itemtype.rentalcharge_hourly | $Price on_editing => 1 %]" min="0" />
<span class="hint">This fee is charged at checkout/renewal time for each hour between the checkout/renewal date and due date for loans specified in hours.</span>
</li>
<li>
@@ -344,11 +344,11 @@ Item types › Administration › Koha
</li>
<li>
<label for="defaultreplacecost">Default replacement cost: </label>
- <input type="text" id="defaultreplacecost" name="defaultreplacecost" size="10" value="[% itemtype.defaultreplacecost | $Price on_editing => 1 %]" />
+ <input type="text" id="defaultreplacecost" name="defaultreplacecost" size="10" value="[% itemtype.defaultreplacecost | $Price on_editing => 1 %]" min="0" />
</li>
<li>
<label for="processfee">Processing fee (when lost): </label>
- <input type="text" id="processfee" name="processfee" size="10" value="[% itemtype.processfee | $Price on_editing => 1 %]" />
+ <input type="text" id="processfee" name="processfee" size="10" value="[% itemtype.processfee | $Price on_editing => 1 %]" min="0" />
</li>
<li>
<label for="checkinmsg">Checkin message: </label>
@@ -601,7 +601,10 @@ Item types › Administration › Koha
rules: {
itemtype: { required: true },
description: { required: true },
- rentalcharge: { number: true }
+ rentalcharge: { number: true },
+ rentalcharge_hourly: { number: true },
+ defaultreplacecost: { number: true },
+ processfee: { number: true }
}
});
$("#itemtype").on("blur",function(){
--
2.20.1