Bug 18723: Change dot into comma
authorJose-Mario Monteiro-Santos <jose-mario.monteiro-santos@inLibro.com>
Thu, 17 Jan 2019 21:41:58 +0000 (16:41 -0500)
committerNick Clemens <nick@bywatersolutions.com>
Fri, 8 Feb 2019 20:38:16 +0000 (20:38 +0000)
This fixes the regression that multiplies the amount entered by 100
when CurrencyFormat is set to FR. It replaces the last dot with a
comma before dealing with the value of ActualCost and ReplacementCost.

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- Change the Actual cost/Replacement cost, using a dot decimal (21.99)
    4- Receive the order
    5- Click on "Save"
    6- Notice that the Actual cost and the Replacement cost use commas
    7- Change the Actual cost, using a comma decimal (21,99)
    8- Click on "Save"
    9- In "Already received", notice the price is still correct.

Signed-off-by: Victor Grousset <victor.grousset@biblibre.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

acqui/finishreceive.pl
koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt

index 79b6326..90faed3 100755 (executable)
@@ -59,6 +59,16 @@ my $bookfund         = $input->param("bookfund");
 my $order            = GetOrder($ordernumber);
 my $new_ordernumber  = $ordernumber;
 
+#bug18723 regression fix
+if (C4::Context->preference("CurrencyFormat") eq 'FR') {
+    if (rindex($unitprice, '.') ge 0) {
+        substr($unitprice, rindex($unitprice, '.'), 1, ',');
+    }
+    if (rindex($replacementprice,'.') ge 0) {
+        substr($replacementprice, rindex($replacementprice, '.'), 1, ',');
+    }
+}
+
 $unitprice = Koha::Number::Price->new( $unitprice )->unformat();
 $replacementprice = Koha::Number::Price->new( $replacementprice )->unformat();
 my $order_obj = Koha::Acquisition::Orders->find( $ordernumber );
index fca13a6..ef27531 100644 (file)
         <li><label for="rrp">Retail price: </label>[% rrp | $Price %] <span class="hint">(adjusted for [% cur_active | html %], [% IF (listincgst == 1) %]tax inclusive[% ELSE %]tax exclusive[% END %])</span></li>
         <li>
             <label for="replacementprice">Replacement price:</label>
-            <input type="text" size="20" name="replacementprice" id="replacementprice" value="[% replacementprice | $Price %]" />
+            <input type="text" size="20" name="replacementprice" id="replacementprice" value="[% replacementprice | $Price on_editing => 1 %]" />
         </li>
         <li><label for="ecost">Budgeted cost: </label>[% ecost | $Price %] <span class="hint">[% IF (listincgst == 1) %](tax inclusive)[% ELSE %](tax exclusive)[% END %]</span></li>
         <li>