Bugzilla – Attachment 144502 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]
Bug 21507 : WIP - rebase actual proposal on master
Bug-21507--WIP---rebase-actual-proposal-on-master.patch (text/plain), 9.55 KB, created by
Thibaud Guillot
on 2022-12-08 15:48:52 UTC
(
hide
)
Description:
Bug 21507 : WIP - rebase actual proposal on master
Filename:
MIME Type:
Creator:
Thibaud Guillot
Created:
2022-12-08 15:48:52 UTC
Size:
9.55 KB
patch
obsolete
>From 204aaa874e026a1e06fdccb241985f305b7a9cd3 Mon Sep 17 00:00:00 2001 >From: Thibaud Guillot <thibaud.guillot@biblibre.com> >Date: Thu, 8 Dec 2022 16:39:12 +0100 >Subject: [PATCH] Bug 21507 : WIP - rebase actual proposal on master > >Test plan : > >1) Go on 'cgi-bin/koha/members/mancredit.pl?borrowernumber={patron_id}' >2) Create manual invoice or credit and see differents input pattern and example >3) You can also test payment feature with 'total due' transformation > >Let's discuss about it :) >--- > .../prog/en/modules/members/mancredit.tt | 2 +- > .../prog/en/modules/members/maninvoice.tt | 34 ++----------------- > members/mancredit.pl | 12 +++++++ > members/maninvoice.pl | 33 ++++++++++++------ > 4 files changed, 38 insertions(+), 43 deletions(-) > >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 18f411937b..3dd2270dc0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tt >@@ -83,7 +83,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" 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" class="required">Amount: </label><input type="text" inputmode="decimal" pattern="^\d+(\.\d{2})?$" name="amount" id="amount" required="required" min="0" value=""/> Example: 5[% IF Koha.Preference("CurrencyFormat") == 'FR' %],[% ELSE %].[% END %]12</li> >+ <li><label for="amount" class="required">Amount: </label><input type="text" inputmode="decimal" pattern=[% decimal_input_pattern %] name="amount" id="amount" required="required" value=""/> Example: 5[% decimal_delimiter | html %]12</li> > [% INCLUDE 'transaction_types.inc' type="credit" %] > [% IF Koha.Preference('UseCashRegisters') %] > <li> >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 f6fd54d14d..7f46f5dcaf 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt >@@ -16,35 +16,6 @@ > [% WRAPPER 'header.inc' %] > [% INCLUDE 'patron-search-header.inc' %] > [% END %] >-<<<<<<< HEAD >-======= >-[% ELSE %] >-<form action="/cgi-bin/koha/members/maninvoice.pl" method="post" id="maninvoice"><input type="hidden" name="borrowernumber" id="borrowernumber" value="[% patron.borrowernumber | html %]" /> >- <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" /> >- <fieldset class="rows"> >- <legend>Manual invoice</legend> >- <ol> >- <li> >- <label for="type">Type: </label> >- <select name="type" id="invoice_type"> >- <option value="L">Lost item</option> >- <option value="F">Fine</option> >- <option value="A">Account management fee</option> >- <option value="N">New card</option> >- <option value="M">Sundry</option> >- [% FOREACH invoice_types_loo IN invoice_types_loop %] >- <option value="[% invoice_types_loo.authorised_value | html %]">[% invoice_types_loo.authorised_value | html %]</option> >- [% END %] >- </select> >- </li> >- <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 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> >->>>>>>> WIP Bug 21507 - Fix decimal separators issues in patrons payments/fines > > [% WRAPPER 'sub-header.inc' %] > <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb"> >@@ -124,7 +95,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><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[% IF Koha.Preference("CurrencyFormat") == 'FR' %],[% ELSE %].[% END %]12</li> >+ >+ <li><label for="amount">Amount: </label><input type="text" inputmode="decimal" pattern=[% decimal_input_pattern %] name="amount" id="amount" required="required" value="[% amount | $Price on_editing => 1 %]" /> 5[% decimal_delimiter | html %]12</li> > </ol> > </fieldset> > >@@ -185,7 +157,7 @@ > $("#maninvoice #type").change(function(){ > $("#maninvoice #desc").val($(this).find("option:selected").text()); > $("#maninvoice #amount").val(type_fees[$(this).val()]); >- >+ }); > }); > </script> > [% END %] >diff --git a/members/mancredit.pl b/members/mancredit.pl >index e77c82defc..88f1a36a76 100755 >--- a/members/mancredit.pl >+++ b/members/mancredit.pl >@@ -68,6 +68,17 @@ output_and_exit_if_error( > my $library_id = > C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; > >+my $decimal_delimiter = >+ C4::Context->preference('CurrencyFormat') eq 'FR' ? ',' : '.'; >+my $decimal_input_pattern = >+ C4::Context->preference('CurrencyFormat') eq 'FR' >+ ? '^\d+(\,\d{2})?$' >+ : '^\d+(\.\d{2})?$'; >+$template->param( >+ decimal_delimiter => $decimal_delimiter, >+ decimal_input_pattern => $decimal_input_pattern, >+); >+ > my $add = $input->param('add'); > if ($add) { > output_and_exit( $input, $cookie, $template, 'wrong_csrf_token' ) >@@ -89,6 +100,7 @@ if ($add) { > my $description = $input->param('desc'); > my $note = $input->param('note'); > my $amount = $input->param('amount') || 0; >+ $amount = Koha::Number::Price->new($amount)->unformat(); > my $type = $input->param('type'); > my $credit_type = $input->param('credit_type'); > my $cash_register_id = $input->param('cash_register'); >diff --git a/members/maninvoice.pl b/members/maninvoice.pl >index 5e2b2278f9..e220a6cb91 100755 >--- a/members/maninvoice.pl >+++ b/members/maninvoice.pl >@@ -43,6 +43,7 @@ use Koha::Patron::Categories; > use Koha::Account::DebitTypes; > use Koha::AdditionalFields; > use Koha::Number::Price; >+use C4::Context; > > my $input = CGI->new; > my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >@@ -82,14 +83,23 @@ my $amount = $input->param('amount'); > my $note = $input->param('note'); > my $debit_type = $input->param('type'); > my $barcode = $input->param('barcode'); >+my $decimal_delimiter = >+ C4::Context->preference('CurrencyFormat') eq 'FR' ? ',' : '.'; >+my $decimal_input_pattern = >+ C4::Context->preference('CurrencyFormat') eq 'FR' >+ ? '^\d+(\,\d{2})?$' >+ : '^\d+(\.\d{2})?$'; > $template->param( >- desc => $desc, >- amount => $amount, >- note => $note, >- type => $debit_type, >- barcode => $barcode >+ desc => $desc, >+ amount => $amount, >+ note => $note, >+ type => $debit_type, >+ barcode => $barcode, >+ decimal_delimiter => $decimal_delimiter, >+ decimal_input_pattern => $decimal_input_pattern, > ); > >+ > my $add = $input->param('add'); > if ($add) { > output_and_exit( $input, $cookie, $template, 'wrong_csrf_token' ) >@@ -102,11 +112,12 @@ if ($add) { > > # Note: If the logged in user is not allowed to see this patron an invoice can be forced > # Here we are trusting librarians not to hack the system >- my $desc = $input->param('desc'); >- my $amount = $input->param('amount'); >- $amount=Koha::Number::Price->new( $amount )->unformat(); >- my $note = $input->param('note'); >- my $debit_type = $input->param('type'); >+ my $desc = $input->param('desc'); >+ my $amount = $input->param('amount'); >+ $amount = Koha::Number::Price->new($amount)->unformat(); >+ my $note = $input->param('note'); >+ my $debit_type = $input->param('type'); >+ > > # If barcode is passed, attempt to find the associated item > my $failed; >@@ -164,7 +175,7 @@ if ($add) { > library_id => $library_id, > type => $debit_type, > ( $olditem ? () : ( item_id => $item_id ) ), >- issue_id => $issue_id >+ issue_id => $issue_id, > } > ); > >-- >2.25.1
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