From 92b2fc19ed85bb153ef19f6514f44841de490277 Mon Sep 17 00:00:00 2001 From: Hammat Wele <hammat.wele@inlibro.com> Date: Wed, 4 Oct 2023 17:36:05 +0000 Subject: [PATCH] Bug 34985: Add a quantity field to the manual invoice form This patch add a Quantity field and a Cost field to the manual invoice form this will allow to automatically multiply the amount when it has a default amount. Test plan: 1) Apply the patch 2) Create multiple charge types some with default amount and some without default amount 1-1) Go to Administraion -> Debit types 1-2) Click on New Debit types 1-3) Fill the form check the "Can be manually invoiced?" field 1-5) Click on save 3) Create a manual invoice 2-1) Find a patrons 2-2) Click on Accounting tab 2-3) Click on Create manual invoice tab 2-4) Select a type with default amount set ->Cost field and Quantity field should be added to the form 2-5) Edit the Cost field or Quantity field ->The amount will be automatically calculate 2-6) Select a type with no default amount set ->Cost field and Quantity field should not be added to the form Signed-off-by: Kristi Krueger <kkrueger@cuyahogalibrary.org> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> --- .../prog/en/modules/members/maninvoice.tt | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt index 8113199b46..c278c7596b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt @@ -94,6 +94,8 @@ <li><label for="barcode">Barcode: </label><input type="text" name="barcode" id="barcode" value="[% barcode | html %]" /></li> <li><label for="desc">Description: </label><input type="text" name="desc" id="desc" size="50" value="[% desc | html %]" /></li> <li><label for="note">Note: </label><input type="text" name="note" size="50" id="note" value="[% note | html %]" /></li> + <li class="additional_field"><label for="cost">Cost: </label><input type="text" inputmode="decimal" pattern="^\d+(\.\d{2})?$" name="cost" id="cost" min="0" value="[% amount | $Price on_editing => 1 %]" /></li> + <li class="additional_field"><label for="quantity">Quantity: </label><input type="text" name="quantity" id="quantity" value="1" /></li> <li><label for="amount">Amount: </label><input type="text" inputmode="decimal" pattern="^\d+(\.\d{2})?$" name="amount" id="amount" required="required" min="0" value="[% amount | $Price on_editing => 1 %]" /> Example: 5.00</li> </ol> </fieldset> @@ -141,11 +143,29 @@ [% UNLESS amount.defined %] $("#maninvoice #desc").val($("#maninvoice #type option:selected").text()); $("#maninvoice #amount").val(type_fees[$("#maninvoice #type option:selected").val()]); + $("#maninvoice #cost").val(type_fees[$("#maninvoice #type option:selected").val()]); + if(!type_fees[$("#maninvoice #type option:selected").val()]){ + $("#maninvoice li.additional_field").hide(); + } [% END %] $("#maninvoice #type").change(function(){ $("#maninvoice #desc").val($(this).find("option:selected").text()); $("#maninvoice #amount").val(type_fees[$(this).val()]); + $("#maninvoice #cost").val(type_fees[$(this).val()]); + $("#maninvoice #quantity").val('1'); + if(type_fees[$(this).val()]){ + $("#maninvoice li.additional_field").show(); + } + else{ + $("#maninvoice li.additional_field").hide(); + } }); + $("#maninvoice #quantity").blur(function(){ + $("#maninvoice #amount").val(($("#maninvoice #cost").val() * $(this).val()).toFixed(2)); + }) + $("#maninvoice #cost").blur(function(){ + $("#maninvoice #amount").val(($("#maninvoice #quantity").val() * $(this).val()).toFixed(2)); + }) }); </script> [% END %] -- 2.30.2