Bug 18723 : Decimal separator issues: some fixes in acquisitions

The main goal is to prevent
- x100 or /100 of the amounts
- decimal part truncation

Bonuses:
- Gets rid of the spaces, currency symbols, names (EUR)
  There is nothing specific about currency symbols is this patch.
  It just removes everything that is not a digit a minus or a separator.

It handles:
- by default comma and dot as decimal separators on the same instance
- dot or comma as thousands separators if choose to use only one of them
    as decimal separator. See DecimalSeparators syspref.
- minuses, doesn't remove them
- non-decimal values: it doesn't touch them

== Test plan ==
1. Use a translation of the staff interface if possible.
2. Go to the "Add budget" page
     staff://cgi-bin/koha/admin/aqbudgetperiods.pl?op=add_form
3. Check that you can't enter any string except like "XX.XX" (examples in
     Annex 1) in the "Total amount" field, without having an issue after
     validation. (x100, truncation, etc)
4. Apply this patch
5. run ~/src/installer/data/mysql/updatedatabase.pl
6. Go to the "Add budget" page
     staff://cgi-bin/koha/admin/aqbudgetperiods.pl?op=add_form
7. Apply the annex 1 to the "Total amount" field
8. Create an active budget
9. Go to the "Add Fund" page for this budget
10. Apply the annex 1 to both "Amount" and "Warning at (amount)" fields
11. If you have ideas of stuff to try to find *regressions* from the previous
    versions, then try. You might spare librarian tears by finding something
    before it's released. (and prevent me from having bounty on my head)
12. Express the joy of a successful sign off.
      (this is important, otherwise the sign off spell won't work!)

=== Annex 1: Subpart for each concerned page ===
1. Set DecimalSeparators syspref to ",."
2. Input "12,34"
3. Press the "Tab/Tabulation" key. It will unfocus the field and trigger the
     conversion. Validating the form does the same but it's a trick to test more
     quickly by not switching to another page.
4. The value should have been converted to 12.34
5. What follows is just a list of examples. They don't have to be tried on each
     field.
6. Do the same with "12,34 EUR" and ensure that it's converted to "12,34"
7. Same with "EUR 12.34" -> "12.34"
8. "EUR 12.34€hi bulac" -> "12.34"
9. "123 456,7" -> "123456.7"
10. "2" -> "2"
11. "2,0" -> "2.0"
12. "-1'345.95" -> "-1345.95"
13. ",1234" -> ".1234"
14. Set DecimalSeparators syspref to ","
15. Reload the page with the form
16. "1.000" -> "1000"
17. "1.000.000,10" -> "1000000.10"
18. Set DecimalSeparators syspref to "."
19. Reload the page with the form
20. "1,000" -> "1000"
21. "1,000,000.10" -> "1000000.10"
22. Validate the form and check that the final value with the dot was
      well handled.
23. Spin on your chair (the direction is not important) or bounce on your
      exercise ball if that's what you use for sitting.
parent 074c44ef
......@@ -34,6 +34,7 @@
[% END -%]
[% INCLUDE 'doc-head-open.inc' %]
[% INCLUDE 'decimal-input-js.inc' %]
[% INCLUDE 'doc-head-close.inc' %]
[% Asset.css("css/datatables.css") %]
[% IF close_form %]
......@@ -221,7 +222,7 @@
<!-- TOTAL -->
<!-- ############################## -->
<label for="budget_period_total">Total amount: </label>
<input type="text" id="budget_period_total" name="budget_period_total"
<input type="text" id="budget_period_total" class="decimal-unformating" name="budget_period_total"
size="10" maxlength="80" value="[% budget_period_total | $Price on_editing => 1 %]" />
</li>
......
......@@ -232,7 +232,7 @@
<li>
<label style="white-space: nowrap;" for="budget_amount" class="required">Amount: </label>
<input type="text" name="budget_amount" id="budget_amount" value="[% budget_amount | $Price on_editing => 1 %]" size="8" />
<input type="text" name="budget_amount" id="budget_amount" class="decimal-unformating" value="[% budget_amount | $Price on_editing => 1 %]" size="8" />
</li>
<li>
......@@ -243,8 +243,8 @@
<li>
<label for="budget_expend">Warning at (amount): </label>
<input type="text" name="budget_expend" id="budget_expend" value="[% budget_expend | $Price on_editing => 1 %]" size="10" />
<span class="hint">0 to disable</span>
<input type="text" name="budget_expend" id="budget_expend" class="decimal-unformating" value="[% budget_expend | $Price on_editing => 1 %]" size="10" />
<span class="hint">0 to disable.</span>
</li>
<li>
......@@ -450,6 +450,7 @@
[% Asset.js("js/acq.js") %]
[% IF op == 'add_form' %]
[% INCLUDE 'decimal-input-js.inc' %]
<script type="text/javascript">
//<![CDATA[
......@@ -693,5 +694,5 @@
//]]>
</script>
[% END %]
[% END %]
[% END %][%# end of MACRO jsinclude %]
[% INCLUDE 'intranet-bottom.inc' %]
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment