fable 3.0.74 → 3.0.77

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fable",
3
- "version": "3.0.74",
3
+ "version": "3.0.77",
4
4
  "description": "An entity behavior management and API bundling library.",
5
5
  "main": "source/Fable.js",
6
6
  "scripts": {
@@ -59,8 +59,9 @@
59
59
  "data-arithmatic": "^1.0.7",
60
60
  "fable-log": "^3.0.10",
61
61
  "fable-serviceproviderbase": "^3.0.10",
62
- "fable-settings": "^3.0.6",
62
+ "fable-settings": "^3.0.8",
63
63
  "fable-uuid": "^3.0.5",
64
+ "js-big-decimal": "^1.4.1",
64
65
  "manyfest": "^1.0.25",
65
66
  "simple-get": "^4.0.1"
66
67
  }
@@ -256,7 +256,12 @@ class DataFormat extends libFableServiceProviderBase
256
256
  */
257
257
  formatterDollars (pValue)
258
258
  {
259
- let tmpDollarAmount = parseFloat(pValue).toFixed(2);
259
+ if (isNaN(pValue))
260
+ {
261
+ return this._Value_NaN_Currency;
262
+ }
263
+
264
+ let tmpDollarAmount = this.fable.Utility.bigDecimal.round(pValue, 2);
260
265
 
261
266
  if (isNaN(tmpDollarAmount))
262
267
  {
@@ -288,7 +293,13 @@ class DataFormat extends libFableServiceProviderBase
288
293
  {
289
294
  let tmpDigits = (typeof(pDigits) == 'undefined') ? 2 : pDigits;
290
295
 
291
- let tmpValue = parseFloat(pValue).toFixed(tmpDigits);
296
+ if (isNaN(pValue))
297
+ {
298
+ let tmpZed = 0;
299
+ return tmpZed.toFixed(tmpDigits);
300
+ }
301
+
302
+ let tmpValue = this.fable.Utility.bigDecimal.round(pValue, tmpDigits);
292
303
  if (isNaN(tmpValue))
293
304
  {
294
305
  let tmpZed = 0;
@@ -4,6 +4,8 @@ const libFableServiceBase = require('../Fable-ServiceManager.js').ServiceProvide
4
4
  const libAsyncWaterfall = require('async.waterfall');
5
5
  const libAsyncEachLimit = require('async.eachlimit');
6
6
 
7
+ const libBigDecimal = require('js-big-decimal');
8
+
7
9
  class FableServiceUtility extends libFableServiceBase
8
10
  {
9
11
  // Underscore and lodash have a behavior, _.template, which compiles a
@@ -24,6 +26,8 @@ class FableServiceUtility extends libFableServiceBase
24
26
  // These two functions are used extensively throughout
25
27
  this.waterfall = libAsyncWaterfall;
26
28
  this.eachLimit = libAsyncEachLimit;
29
+
30
+ this.bigDecimal = libBigDecimal;
27
31
  }
28
32
 
29
33
  // Underscore and lodash have a behavior, _.extend, which merges objects.
@@ -58,6 +58,30 @@ suite
58
58
  Expect(_DataFormat
59
59
  .formatterDollars(1000))
60
60
  .to.equal('$1,000.00');
61
+ Expect(_DataFormat
62
+ .formatterDollars(1000.011))
63
+ .to.equal('$1,000.01');
64
+ Expect(_DataFormat
65
+ .formatterDollars(1000.013))
66
+ .to.equal('$1,000.01');
67
+ Expect(_DataFormat
68
+ .formatterDollars(1000.014))
69
+ .to.equal('$1,000.01');
70
+ Expect(_DataFormat
71
+ .formatterDollars(1000.015))
72
+ .to.equal('$1,000.02');
73
+ Expect(_DataFormat
74
+ .formatterDollars(1000.017))
75
+ .to.equal('$1,000.02');
76
+ Expect(_DataFormat
77
+ .formatterDollars(1000.019))
78
+ .to.equal('$1,000.02');
79
+ Expect(_DataFormat
80
+ .formatterDollars(1000.021))
81
+ .to.equal('$1,000.02');
82
+ Expect(_DataFormat
83
+ .formatterDollars(1000.515))
84
+ .to.equal('$1,000.52');
61
85
  Expect(_DataFormat
62
86
  .formatterDollars('Not dollars!'))
63
87
  .to.equal('--');