@@ -17,9 +17,42 @@ $ npm install --save moneyjs
17
17
var Money = require (' moneyjs' );
18
18
19
19
// instantiate a new money
20
- var price = new Money (12 ,Money .USD ,new Date ())
21
- ...
22
- // continue with money usage see API guide
20
+ var purchasePrice = new Money (12 ,Money .USD ,new Date ())
21
+ var margin = new Money (156 ,Money .TZS ,new Date ());
22
+
23
+ // compute selling price
24
+ // by adding purchase price and margin
25
+ purchasePrice .plus (margin, function (error ,sellingPrice ){
26
+ ...
27
+ });
28
+
29
+ var profit = Money .THOUSAND ;
30
+ var tax = Money .FIFTY ;
31
+ // compute net profit by subtract tax from profit
32
+ profit .minus (tax,function (error ,netProfit ){
33
+ ...
34
+ });
35
+
36
+ // check if net profit is zero
37
+ nextProfit .isZero ();
38
+
39
+ // check if net profit is negative
40
+ netProfit .isNegative ();
41
+
42
+ var expectedProfit = Money .HUNDRED ;
43
+
44
+ // check if net profit is greater than
45
+ // expected profit
46
+ netProfit .isGreaterThan (expectedProfit);
47
+
48
+ // check if net profit is less than
49
+ // expected profit
50
+ netProfit .isLessThan (expectedProfit);
51
+
52
+ // check if net profit is equal to
53
+ // expected profit
54
+ netProfit .isEqualTo (expectedProfit);
55
+
23
56
...
24
57
```
25
58
@@ -49,7 +82,12 @@ Used to get `exchange rates` when `exchange` money instance from one currency to
49
82
50
83
Example of implementation
51
84
``` js
52
- var rates = {USD : 1 ,TZS : 1900 ,KES : 90 };
85
+ var rates = {
86
+ USD : 1 ,
87
+ TZS : 1900 ,
88
+ KES : 90
89
+ };
90
+
53
91
function getExchangeRates (date ,done ){
54
92
// fetch exchange rates
55
93
// from API or anywhere else
0 commit comments