From 31b528192bddfba112777b4b70c731c2f37e72f8 Mon Sep 17 00:00:00 2001 From: Baptiste Wojtkowski Date: Tue, 21 Feb 2017 15:47:36 +0000 Subject: [PATCH] Bug 12310 : Decimal separators issues: fix maninvoice, mancredit The aid is to prevent x100 or /100 of the amounts. And decimal part truncation WIP fix maybe aqbudgets and aqbudgetperiods The script includes 2 function which check if it is possible to transform properly into the format "XX.XX" and which do it. The money symbols are ignored. All other symbols are ignored. Modify the tooltips helping the users entering monrtary information in the right format. Fields on all those pages are now automatically formatted - cgi-bin/koha/admin/aqbudgetperiods.tt - cgi-bin/koha/admin/aqbudgets.tt - cgi-bin/koha/members/mancredit.tt - cgi-bin/koha/members/maninvoice.tt Test plan : 1) Check you can't enter any string except like "XX.XX" when - you create a Budget (Administration->Budget) - you write a fine (Circulation->[select a Borrower]->new fine ) - you pay an existing fine 2) Apply patch 3) Check you can enter any string with - anything you want - a , or a . as separator (both are default) - change the syspref DigitSeparator into the separator you with and check again ex : XXX,XXX,XXX.XX => . XXX XXX XXX,XX => ,. or , XXX XXX XXX.XX => ,. or . The string is immediately changed after you change the field Please note that any other symbol is ignored --- .../atomicupdate/bug12310_added_DigitSeparator.sql | 2 + installer/data/mysql/sysprefs.sql | 1 + .../prog/en/includes/price-conversion-message.inc | 14 +++++++ .../intranet-tmpl/prog/en/includes/prices.inc | 25 +++++++++++ .../prog/en/modules/admin/aqbudgetperiods.tt | 29 ++++++++++++- .../prog/en/modules/admin/aqbudgets.tt | 41 +++++++++++++++--- .../en/modules/admin/preferences/i18n_l10n.pref | 4 ++ .../prog/en/modules/members/mancredit.tt | 26 +++++++++++- .../prog/en/modules/members/maninvoice.tt | 27 +++++++++++- .../prog/en/modules/members/paycollect.tt | 48 +++++++++++----------- 10 files changed, 185 insertions(+), 32 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug12310_added_DigitSeparator.sql create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/price-conversion-message.inc create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/prices.inc diff --git a/installer/data/mysql/atomicupdate/bug12310_added_DigitSeparator.sql b/installer/data/mysql/atomicupdate/bug12310_added_DigitSeparator.sql new file mode 100644 index 0000000..5022f3c --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug12310_added_DigitSeparator.sql @@ -0,0 +1,2 @@ +INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES +('DigitSeparator', ',.', NULL , 'The separator between entire and decimal part', 'Free'); diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 76bb2cc..ab449eb 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -138,6 +138,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('DefaultToLoggedInLibraryNoticesSlips', '0', NULL , 'If enabled,slips and notices editor will default to the logged in library''s rules, rather than the ''all libraries'' rules.', 'YesNo'), ('DefaultToLoggedInLibraryOverdueTriggers', '0', NULL , 'If enabled, overdue status triggers editor will default to the logged in library''s rules, rather than the ''default'' rules.', 'YesNo'), ('delimiter',';',';|tabulation|,|/|\\|#||','Define the default separator character for exporting reports','Choice'), +('DigitSeparator', '.,', NULL , 'The separator between entire and decimal part', 'Free'), ('Display856uAsImage','OFF','OFF|Details|Results|Both','Display the URI in the 856u field as an image, the corresponding Staff Client XSLT option must be on','Choice'), ('DisplayClearScreenButton','0','','If set to ON, a clear screen button will appear on the circulation page.','YesNo'), ('displayFacetCount','0',NULL,NULL,'YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/price-conversion-message.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/price-conversion-message.inc new file mode 100644 index 0000000..4fcb5a0 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/price-conversion-message.inc @@ -0,0 +1,14 @@ +[% USE Koha %] +[% INCLUDE 'prices.inc' %] + + + [% IF Koha.Preference('DigitSeparator') %]Please use any of the following character(s) "[% Koha.Preference('DigitSeparator').substr(0,1) %]" as separator : ex "XX[% Koha.Preference('DigitSeparator').substr(0,1) %]XX". + [% IF CAN_user_parameters %] + Edit Separator + [% END %] + [% ELSE %] + [% IF CAN_user_parameters %] + No Digit separator defined Chose one + [% END %] + [% END %] + diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/prices.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/prices.inc new file mode 100644 index 0000000..561ae06 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/prices.inc @@ -0,0 +1,25 @@ +[% USE Koha %] + diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt index afd893f..0673f44 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt @@ -1,6 +1,8 @@ [% USE KohaDates %] [% USE Price %] +[% USE Koha %] [% SET footerjs = 1 %] + [%- BLOCK action_menu %] +[% INCLUDE 'prices.inc' %] [% MACRO jsinclude BLOCK %] [% END %] + [% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt index 39df143..5527637 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt @@ -83,7 +83,7 @@
  • - +
  • @@ -150,7 +150,8 @@
  • - + + [% INCLUDE 'price-conversion-message.inc' %]
  • @@ -206,30 +207,31 @@ decFlag = true; } } - - if (dolAmount == "") { - dolAmount = "0"; - } - // Strip leading 0s - if (dolAmount.length > 1) { - while(dolAmount.length > 1 && dolAmount.substring(0,1) == "0") { - dolAmount = dolAmount.substring(1,dolAmount.length); - } + + + [% INCLUDE 'prices.inc' %] + + + [% END %] [% INCLUDE 'intranet-bottom.inc' %] -- 2.7.4