@stevenkellner/team-conduct-api 1.0.9 → 1.0.10

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.
@@ -44,7 +44,7 @@ var FineAmount;
44
44
  this.amount = amount;
45
45
  }
46
46
  formatted(configuration) {
47
- return this.amount.formatted(configuration.currency);
47
+ return this.amount.formatted(configuration.currency, configuration);
48
48
  }
49
49
  get flatten() {
50
50
  return {
@@ -5,7 +5,9 @@ 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
- formatted(currency: Configuration.Currency): string;
8
+ added(amount: MoneyAmount): MoneyAmount;
9
+ multiplied(factor: number): MoneyAmount;
10
+ formatted(currency: Configuration.Currency, configuration: Configuration): string;
9
11
  get flatten(): MoneyAmount.Flatten;
10
12
  }
11
13
  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,8 +11,18 @@ class MoneyAmount {
45
11
  static get zero() {
46
12
  return new MoneyAmount(0, 0);
47
13
  }
48
- formatted(currency) {
49
- const numberFormat = Intl.NumberFormat(i18n.getLocale(), {
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
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stevenkellner/team-conduct-api",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "Firebase API for Team Conduct",
5
5
  "license": "MIT",
6
6
  "author": "Steven Kellner",
@@ -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 {
@@ -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,8 +12,20 @@ export class MoneyAmount implements Flattable<MoneyAmount.Flatten> {
13
12
  return new MoneyAmount(0, 0);
14
13
  }
15
14
 
16
- public formatted(currency: Configuration.Currency): string {
17
- const numberFormat = Intl.NumberFormat(i18n.getLocale(), {
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
  });