Bugzilla – Attachment 83971 Details for
Bug 18723
Dot not recognized as decimal separator on receive
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18723: (Alternate Solution) Block form submission
Bug-18723-Alternate-Solution-Block-form-submission.patch (text/plain), 5.12 KB, created by
José-Mario Monteiro-Santos
on 2019-01-15 14:39:21 UTC
(
hide
)
Description:
Bug 18723: (Alternate Solution) Block form submission
Filename:
MIME Type:
Creator:
José-Mario Monteiro-Santos
Created:
2019-01-15 14:39:21 UTC
Size:
5.12 KB
patch
obsolete
>From c56decebbca0c22c11c872739720eba7a95615a5 Mon Sep 17 00:00:00 2001 >From: Jose-Mario <jose-mario.monteiro-santos@inLibro.com> >Date: Mon, 14 Jan 2019 14:50:57 -0500 >Subject: [PATCH] Bug 18723: (Alternate Solution) Block form submission > >When entering an amount in "Actual Cost" on the orderreceive page, >it is multiplied by 100 if the entered number's format does not >match the "CurrencyFormat" syspref. > >This patch adds a value check before submitting the form. It uses >regexps based on the "CurrencyFormat" syspref to validate that the >number will be processed correctly. > >Test Plan: >a)Replicate the issue: > 0- Set CurrencyFormat to FR > 1- Go to Acquisitions > 2- Search for a Vendor > 3- Click on "New basket" > 4- Give basket a name and click "Save" > 5- Click on "Add to basket" > 6- Add an order through preferred method > 7- In Accounting details, enter a vendor price with dot decimal (i.e. 19.44) > 8- Save your order line > 9- Click on "Close this basket" > 10- Confirm closing of basket by clicking on "Yes, close" > 11- Click on "Receive shipment" > 12- Enter an invoice number and click "Next" > 13- Click on "Receive" to the right of your order > 14- In Accounting details, notice the Actual cost is written with a decimal dot. > 15- Change the Actual cost, using a dot decimal (i.e 20.99) > 16- Receive the order > 17- Click on "Save" > 18- In "Already received" notice the price is multiplied by 100 (i.e. 2099,00) > 19- Click on "Cancel receipt" > 20- Click on "Receive" to the right of your order > 21- In Accounting details, change the Actual cost, using a comma decimal (i.e. 20,99) > 22- Receive the order > 23- Click on "Save" > 24- In "Already received", notice the price is correct. >b)Apply the patch >c)Test the patch: > 1- Click on "Cancel receipt" > 2- Click on "Receive to the right of your order > 3- In Accounting Details, notice the Actual cost is formatted correctly (comma decimal) > 4- Change the Actual cost, using a dot decimal (21.99) > 5- Receive the order > 6- Click on "Save" > 7- Notice an error message explaining the proper format for Actual cost (click "Ok") > 8- Change the Actual cost, using a comma decimal (21,99) > 9- Click on "Save" > 10- In "Already received", notice the price is correct. > 11- Test the other CurrencyFormat settings >--- > .../prog/en/modules/acqui/orderreceive.tt | 26 +++++++++++++++++++++- > 1 file changed, 25 insertions(+), 1 deletion(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt >index fca13a6..535937e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt >@@ -1,5 +1,6 @@ > [% USE raw %] > [% USE Asset %] >+[% USE Koha %] > [% USE KohaDates %] > [% USE Branches %] > [% USE Price %] >@@ -296,7 +297,7 @@ > <li><label for="ecost">Budgeted cost: </label>[% ecost | $Price %] <span class="hint">[% IF (listincgst == 1) %](tax inclusive)[% ELSE %](tax exclusive)[% END %]</span></li> > <li> > <label for="unitprice">Actual cost:</label> >- <input type="text" size="20" name="unitprice" id="unitprice" value="[% unitprice | $Price on_editing => 1 %]" /> <span class="hint">[% IF (invoiceincgst == 1) %](tax inclusive)[% ELSE %](tax exclusive)[% END %]</span> >+ <input type="text" size="20" name="unitprice" id="unitprice" value="[% unitprice | $Price %]" /> <span class="hint">[% IF (invoiceincgst == 1) %](tax inclusive)[% ELSE %](tax exclusive)[% END %]</span> > </li> > <li><label for="order_internalnote">Internal note: </label><textarea name="order_internalnote" width="40" rows="8" >[% order_internalnote | html %]</textarea></li> > [% IF order_vendornote %] >@@ -369,6 +370,29 @@ > }; > [% END %] > >+ //Check if unit price is correctly formatted >+ var unit_price_correct_format = false; >+ >+ switch("[%- Koha.Preference( 'CurrencyFormat' ) -%]") { >+ case 'FR': >+ var unit_price_regexp = /^(?![^.])*([0-9])+(,[0-9]{1,2})?$/; >+ var unit_price_format_error_alert_message = _("Decimals must be separated by a comma."); >+ break; >+ case 'CH': >+ var unit_price_regexp = /(?=.*?\d)^\$?(([1-9]\d{0,2}('\d{3})*)|\d+)?(\.\d{1,2})?$/; >+ var unit_price_format_error_alert_message = _("Decimals must be separated by a period and thousands by an apostrophe."); >+ break; >+ default: >+ var unit_price_regexp = /(?=.*?\d)^\$?(([1-9]\d{0,2}(,\d{3})*)|\d+)?(\.\d{1,2})?$/; >+ var unit_price_format_error_alert_message = _("Decimals must be separated by a period and thousands by a comma."); >+ break; >+ } >+ >+ if (!(unit_price_regexp.test(document.getElementById("unitprice").value))){ >+ alert(_("Actual cost: ") + unit_price_format_error_alert_message); >+ return false; >+ } >+ > return true; > } > >-- >2.7.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 18723
:
79892
|
83971
|
84150
|
84166
|
84280
|
84843
|
86082