@stevenkellner/team-conduct-api 1.0.9 → 1.0.11
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.
|
@@ -5,7 +5,10 @@ export declare class MoneyAmount implements Flattable<MoneyAmount.Flatten> {
|
|
|
5
5
|
subunitValue: number;
|
|
6
6
|
constructor(value: number, subunitValue: number);
|
|
7
7
|
static get zero(): MoneyAmount;
|
|
8
|
-
|
|
8
|
+
added(amount: MoneyAmount): MoneyAmount;
|
|
9
|
+
multiplied(factor: number): MoneyAmount;
|
|
10
|
+
formatted(currency: Configuration.Currency, configuration: Configuration): string;
|
|
11
|
+
get completeValue(): number;
|
|
9
12
|
get flatten(): MoneyAmount.Flatten;
|
|
10
13
|
}
|
|
11
14
|
export declare namespace MoneyAmount {
|
|
@@ -1,40 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
3
|
exports.MoneyAmount = void 0;
|
|
37
|
-
const i18n = __importStar(require("i18n"));
|
|
38
4
|
class MoneyAmount {
|
|
39
5
|
value;
|
|
40
6
|
subunitValue;
|
|
@@ -45,13 +11,26 @@ class MoneyAmount {
|
|
|
45
11
|
static get zero() {
|
|
46
12
|
return new MoneyAmount(0, 0);
|
|
47
13
|
}
|
|
48
|
-
|
|
49
|
-
const
|
|
14
|
+
added(amount) {
|
|
15
|
+
const subunitValue = this.subunitValue + amount.subunitValue;
|
|
16
|
+
const value = this.value + amount.value + Math.floor(subunitValue / 100);
|
|
17
|
+
return new MoneyAmount(value, subunitValue % 100);
|
|
18
|
+
}
|
|
19
|
+
multiplied(factor) {
|
|
20
|
+
const subunitValue = this.subunitValue * factor;
|
|
21
|
+
const value = this.value * factor + Math.floor(subunitValue / 100);
|
|
22
|
+
return new MoneyAmount(value, subunitValue % 100);
|
|
23
|
+
}
|
|
24
|
+
formatted(currency, configuration) {
|
|
25
|
+
const numberFormat = Intl.NumberFormat(configuration.locale, {
|
|
50
26
|
style: 'currency',
|
|
51
27
|
currency: currency
|
|
52
28
|
});
|
|
53
29
|
return numberFormat.format(this.value + this.subunitValue / 100);
|
|
54
30
|
}
|
|
31
|
+
get completeValue() {
|
|
32
|
+
return this.value + this.subunitValue / 100;
|
|
33
|
+
}
|
|
55
34
|
get flatten() {
|
|
56
35
|
return this.value + this.subunitValue / 100;
|
|
57
36
|
}
|
package/package.json
CHANGED
package/src/types/FineAmount.ts
CHANGED
|
@@ -16,7 +16,7 @@ export namespace FineAmount {
|
|
|
16
16
|
) {}
|
|
17
17
|
|
|
18
18
|
public formatted(configuration: Configuration): string {
|
|
19
|
-
return this.amount.formatted(configuration.currency);
|
|
19
|
+
return this.amount.formatted(configuration.currency, configuration);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
public get flatten(): Money.Flatten {
|
package/src/types/MoneyAmount.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Flattable, ITypeBuilder } from '@stevenkellner/typescript-common-functionality';
|
|
2
|
-
import * as i18n from 'i18n';
|
|
3
2
|
import { Configuration } from './Configuration';
|
|
4
3
|
|
|
5
4
|
export class MoneyAmount implements Flattable<MoneyAmount.Flatten> {
|
|
@@ -13,14 +12,30 @@ export class MoneyAmount implements Flattable<MoneyAmount.Flatten> {
|
|
|
13
12
|
return new MoneyAmount(0, 0);
|
|
14
13
|
}
|
|
15
14
|
|
|
16
|
-
public
|
|
17
|
-
const
|
|
15
|
+
public added(amount: MoneyAmount): MoneyAmount {
|
|
16
|
+
const subunitValue = this.subunitValue + amount.subunitValue;
|
|
17
|
+
const value = this.value + amount.value + Math.floor(subunitValue / 100);
|
|
18
|
+
return new MoneyAmount(value, subunitValue % 100);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public multiplied(factor: number): MoneyAmount {
|
|
22
|
+
const subunitValue = this.subunitValue * factor;
|
|
23
|
+
const value = this.value * factor + Math.floor(subunitValue / 100);
|
|
24
|
+
return new MoneyAmount(value, subunitValue % 100);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public formatted(currency: Configuration.Currency, configuration: Configuration): string {
|
|
28
|
+
const numberFormat = Intl.NumberFormat(configuration.locale, {
|
|
18
29
|
style: 'currency',
|
|
19
30
|
currency: currency
|
|
20
31
|
});
|
|
21
32
|
return numberFormat.format(this.value + this.subunitValue / 100);
|
|
22
33
|
}
|
|
23
34
|
|
|
35
|
+
public get completeValue(): number {
|
|
36
|
+
return this.value + this.subunitValue / 100;
|
|
37
|
+
}
|
|
38
|
+
|
|
24
39
|
public get flatten(): MoneyAmount.Flatten {
|
|
25
40
|
return this.value + this.subunitValue / 100;
|
|
26
41
|
}
|