# HG changeset patch
# User Adrián Romero <adrianromero@openbravo.com>
# Date 1528991924 -7200
#      Thu Jun 14 17:58:44 2018 +0200
# Node ID 32e30b1120558d201768c9b16220f81c5cf09c5f
# Parent  a05dce5920aa6c56ff3b607215e2cefc20b37d39
Fixes issue 38762: OB.DEC functions does not take the scale from the arguments

diff --git a/web/org.openbravo.mobile.core/source/utils/ob-arithmetic.js b/web/org.openbravo.mobile.core/source/utils/ob-arithmetic.js
--- a/web/org.openbravo.mobile.core/source/utils/ob-arithmetic.js
+++ b/web/org.openbravo.mobile.core/source/utils/ob-arithmetic.js
@@ -1,6 +1,6 @@
 /*
  ************************************************************************************
- * Copyright (C) 2012-2016 Openbravo S.L.U.
+ * Copyright (C) 2012-2018 Openbravo S.L.U.
  * Licensed under the Openbravo Commercial License version 1.0
  * You may obtain a copy of the License at http://www.openbravo.com/legal/obcl.html
  * or in the legal folder of this module distribution.
@@ -21,7 +21,7 @@
       };
 
   var toNumber = function (big, arg_scale) {
-      var localscale = arg_scale || scale;
+      var localscale = _.isNumber(arg_scale) ? arg_scale : scale;
       if (big.scale) {
         return parseFloat(big.setScale(localscale, roundingmode).toString(), 10);
       } else {
@@ -61,7 +61,7 @@
   };
 
   OB.DEC.div = function (a, b, arg_scale) {
-    return toNumber(toBigDecimal(a).divide(toBigDecimal(b), arg_scale || scale, roundingmode), arg_scale);
+    return toNumber(toBigDecimal(a).divide(toBigDecimal(b), _.isNumber(arg_scale) ? arg_scale : scale, roundingmode), arg_scale);
   };
 
   OB.DEC.compare = function (a) {
