@lucaapp/service-utils 1.61.2 → 1.61.3
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/dist/lib/money/money.d.ts +2 -2
- package/dist/lib/money/money.js +12 -8
- package/package.json +1 -1
|
@@ -21,6 +21,8 @@ export declare class Money<T extends SupportedCurrencies = SupportedCurrencies>
|
|
|
21
21
|
static fromAmount<T extends SupportedCurrencies>(value: number, currency: T): Money<T>;
|
|
22
22
|
static fromFloat<T extends SupportedCurrencies>(value: number, currency: T): Money<T>;
|
|
23
23
|
static zero<T extends SupportedCurrencies>(currency: T): Money<T>;
|
|
24
|
+
static min<T extends SupportedCurrencies>(value1: Money<T>, value2: Money<T>): Money<T>;
|
|
25
|
+
static max<T extends SupportedCurrencies>(value1: Money<T>, value2: Money<T>): Money<T>;
|
|
24
26
|
private constructor();
|
|
25
27
|
clone(): Money<T>;
|
|
26
28
|
getAmount(): number;
|
|
@@ -40,8 +42,6 @@ export declare class Money<T extends SupportedCurrencies = SupportedCurrencies>
|
|
|
40
42
|
isZero(): boolean;
|
|
41
43
|
isPositive(): boolean;
|
|
42
44
|
isNegative(): boolean;
|
|
43
|
-
min(comparator: Money<T>): Money<T>;
|
|
44
|
-
max(comparator: Money<T>): Money<T>;
|
|
45
45
|
}
|
|
46
46
|
export declare const moneyfiedGet: <T extends SupportedCurrencies>(model: Model, key: string) => Money<T> | null;
|
|
47
47
|
export declare const moneyfiedSet: <T extends SupportedCurrencies>(model: Model, key: string, value: Money<T> | undefined) => void;
|
package/dist/lib/money/money.js
CHANGED
|
@@ -23,6 +23,18 @@ class Money {
|
|
|
23
23
|
static zero(currency) {
|
|
24
24
|
return Money.fromAmount(0, currency);
|
|
25
25
|
}
|
|
26
|
+
static min(value1, value2) {
|
|
27
|
+
if (value1.lessThan(value2)) {
|
|
28
|
+
return value1;
|
|
29
|
+
}
|
|
30
|
+
return value2;
|
|
31
|
+
}
|
|
32
|
+
static max(value1, value2) {
|
|
33
|
+
if (value1.greaterThan(value2)) {
|
|
34
|
+
return value1;
|
|
35
|
+
}
|
|
36
|
+
return value2;
|
|
37
|
+
}
|
|
26
38
|
constructor(amount, currency) {
|
|
27
39
|
if (!currency) {
|
|
28
40
|
throw new TypeError('currency required');
|
|
@@ -113,14 +125,6 @@ class Money {
|
|
|
113
125
|
isNegative() {
|
|
114
126
|
return this.value < 0;
|
|
115
127
|
}
|
|
116
|
-
min(comparator) {
|
|
117
|
-
this.assertSameCurrency(comparator);
|
|
118
|
-
return this.value < comparator.value ? this.clone() : comparator.clone();
|
|
119
|
-
}
|
|
120
|
-
max(comparator) {
|
|
121
|
-
this.assertSameCurrency(comparator);
|
|
122
|
-
return this.value > comparator.value ? this.clone() : comparator.clone();
|
|
123
|
-
}
|
|
124
128
|
}
|
|
125
129
|
exports.Money = Money;
|
|
126
130
|
const moneyfiedGet = (model, key) => {
|