Bugzilla – Attachment 95734 Details for
Bug 21507
Decimal separators issues in patrons payments/fines, simplified
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
WIP Bug 21507 - Fix decimal separators issues in patrons payments/fines
WIP-Bug-21507---Fix-decimal-separators-issues-in-p.patch (text/plain), 7.05 KB, created by
Victor Grousset/tuxayo
on 2019-11-22 18:02:43 UTC
(
hide
)
Description:
WIP Bug 21507 - Fix decimal separators issues in patrons payments/fines
Filename:
MIME Type:
Creator:
Victor Grousset/tuxayo
Created:
2019-11-22 18:02:43 UTC
Size:
7.05 KB
patch
obsolete
>From 610ee61a5494ec88e9142e221cbd0a591210bde9 Mon Sep 17 00:00:00 2001 >From: Victor Grousset <victor.grousset@biblibre.com> >Date: Wed, 17 Oct 2018 11:07:05 +0200 >Subject: [PATCH] WIP Bug 21507 - Fix decimal separators issues in patrons > payments/fines > >--- > .../prog/en/includes/decimal-input-js.inc | 24 +++++++++++++++++++ > .../prog/en/modules/members/mancredit.tt | 14 ++++++++++- > .../prog/en/modules/members/maninvoice.tt | 13 +++++++++- > members/maninvoice.pl | 5 ++-- > 4 files changed, 52 insertions(+), 4 deletions(-) > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/decimal-input-js.inc > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/decimal-input-js.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/decimal-input-js.inc >new file mode 100644 >index 0000000000..2e3836c5af >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/decimal-input-js.inc >@@ -0,0 +1,24 @@ >+[% USE Koha %] >+ >+<script type="text/javascript"> >+ var currency_format = "[% Koha.Preference('CurrencyFormat') %]"; >+ if (currency_format === "US" || currency_format === "CH") { >+ var decimal_separator = "."; >+ } else if (currency_format === "FR") { >+ var decimal_separator = ","; >+ } else { >+ console.error("Unhandled value for currency_format: \"" + currency_format +"\" You should report this issue to avoid unexpected behavior with numbers. Note that you should also check the code displaying the example value in manual invoice and credit pages.") >+ var decimal_separator = "."; >+ } >+ >+ // allow only non-decimal numbers and decimal numbers containing a dot or a comma >+ jQuery.validator.addMethod("is_decimal_number", function(value, element){ >+ return /^\d+(\.|,)?\d*$/.test(value); >+ }, _("Please input a decimal number without thousands separators")); >+ >+ jQuery.validator.addMethod("uses_correct_decimal_separator", function(value, element){ >+ var non_decimal_number = /^\d+$/.test(value); >+ var correct_decimal_number = value.indexOf(decimal_separator) !== -1; >+ return non_decimal_number || correct_decimal_number; >+ }, _("Please do not use thousands separators and only the decimal separator shown in the example: ")); >+</script> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tt >index c02943d96c..c5c94fe529 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tt >@@ -44,7 +44,8 @@ > <li><label for="barcode">Barcode: </label><input type="text" name="barcode" id="barcode" /></li> > <li><label for="desc">Description: </label><input type="text" name="desc" size="50" id="desc" /></li> > <li><label for="note">Note: </label><input type="text" name="note" size="50" id="note" /></li> >- <li><label for="amount">Amount: </label><input type="number" name="amount" id="amount" required="required" value="" step="any" min="0" /> Example: 5.00</li> >+ <li><label for="amount">Amount: </label><input name="amount" id="amount" value="" /> <span>Example:</span> 5[% IF Koha.Preference("CurrencyFormat") == 'FR' %],[% ELSE %].[% END %]12</li> >+ > </ol></fieldset> > > <fieldset class="action"><input type="submit" name="add" value="Add credit" /> <a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% patron.borrowernumber | html %]">Cancel</a></fieldset> >@@ -63,10 +64,21 @@ > [% MACRO jsinclude BLOCK %] > [% INCLUDE 'str/members-menu.inc' %] > [% Asset.js("js/members-menu.js") | $raw %] >+ [% INCLUDE 'decimal-input-js.inc' %] > <script type="text/javascript"> > $(document).ready(function(){ > $('#mancredit').preventDoubleFormSubmit(); > $("fieldset.rows input, fieldset.rows select").addClass("noEnterSubmit"); >+ >+ // decimal input >+ $("#mancredit").validate({ >+ rules: { >+ amount: { >+ is_decimal_number: true, >+ uses_correct_decimal_separator: true >+ }, >+ } >+ }); > }); > </script> > [% END %] >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 3014227bae..c9828c04f6 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt >@@ -57,7 +57,7 @@ > <li><label for="barcode">Barcode: </label><input type="text" name="barcode" id="barcode" /></li> > <li><label for="desc">Description: </label><input type="text" name="desc" id="desc" size="50" /></li> > <li><label for="note">Note: </label><input type="text" name="note" size="50" id="note" /></li> >- <li><label for="amount">Amount: </label><input type="number" name="amount" id="amount" required="required" value="" step="any" min="0" /> Example: 5.00</li> >+ <li><label for="amount">Amount: </label><input name="amount" id="amount" value="" /> <span>Example:</span> 5[% IF Koha.Preference("CurrencyFormat") == 'FR' %],[% ELSE %].[% END %]12</li> > </ol></fieldset> > <fieldset class="action"><input type="submit" name="add" value="Save" /> <a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% patron.borrowernumber | html %]">Cancel</a></fieldset> > </form> >@@ -76,6 +76,7 @@ > [% MACRO jsinclude BLOCK %] > [% INCLUDE 'str/members-menu.inc' %] > [% Asset.js("js/members-menu.js") | $raw %] >+ [% INCLUDE 'decimal-input-js.inc' %] > <script type="text/javascript"> > var type_fees = {'L':'','F':'','A':'','N':'','M':''}; > [% FOREACH invoice_types_loo IN invoice_types_loop %] >@@ -88,6 +89,16 @@ > this.form.desc.value = this.options[this.selectedIndex].value; > this.form.amount.value = type_fees[this.options[this.selectedIndex].value]; > }); >+ >+ // decimal input >+ $("#maninvoice").validate({ >+ rules: { >+ amount: { >+ is_decimal_number: true, >+ uses_correct_decimal_separator: true >+ }, >+ } >+ }); > }); > </script> > [% END %] >diff --git a/members/maninvoice.pl b/members/maninvoice.pl >index db7a447ffa..1e411a098c 100755 >--- a/members/maninvoice.pl >+++ b/members/maninvoice.pl >@@ -31,12 +31,12 @@ use C4::Members; > use C4::Accounts; > use C4::Items; > use C4::Members::Attributes qw(GetBorrowerAttributes); >-use Koha::Token; > >+use Koha::Token; > use Koha::Items; > use Koha::Patrons; >- > use Koha::Patron::Categories; >+use Koha::Number::Price; > > my $input=new CGI; > my $flagsrequired = { borrowers => 'edit_borrowers' }; >@@ -67,6 +67,7 @@ if ($add){ > } > my $desc=$input->param('desc'); > my $amount=$input->param('amount'); >+ $amount=Koha::Number::Price->new( $amount )->unformat(); > my $type=$input->param('type'); > my $note = $input->param('note'); > my $error = manualinvoice( $borrowernumber, $itemnum, $desc, $type, $amount, $note ); >-- >2.23.0
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 21507
:
95734
|
95735
|
144502
|
144535
|
144536
|
144537