bkper-js 2.0.0 → 2.2.0

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.
@@ -9,6 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { getRepresentativeValue, normalizeName } from "../utils.js";
11
11
  import { Amount } from "./Amount.js";
12
+ import { Balance } from "./Balance.js";
13
+ import { BalancesDataTableBuilder } from "./BalancesDataTableBuilder.js";
12
14
  /** @internal */
13
15
  export class AccountBalancesContainer {
14
16
  constructor(parent, balancesReport, payload) {
@@ -50,7 +52,7 @@ export class AccountBalancesContainer {
50
52
  return this.payload.credit;
51
53
  }
52
54
  isPermanent() {
53
- return this.payload.permanent;
55
+ return this.payload.permanent || false;
54
56
  }
55
57
  isFromAccount() {
56
58
  return true;
@@ -67,27 +69,86 @@ export class AccountBalancesContainer {
67
69
  getCumulativeBalanceRaw() {
68
70
  return new Amount(this.payload.cumulativeBalance || 0);
69
71
  }
72
+ getCumulativeCredit() {
73
+ return new Amount(this.payload.cumulativeCredit || 0);
74
+ }
75
+ getCumulativeDebit() {
76
+ return new Amount(this.payload.cumulativeDebit || 0);
77
+ }
70
78
  getCumulativeBalanceText() {
71
79
  return this.balancesReport.getBook().formatValue(this.getCumulativeBalance());
72
80
  }
73
81
  getCumulativeBalanceRawText() {
74
82
  return this.balancesReport.getBook().formatValue(this.getCumulativeBalanceRaw());
75
83
  }
84
+ getCumulativeCreditText() {
85
+ return this.balancesReport.getBook().formatValue(this.getCumulativeCredit());
86
+ }
87
+ getCumulativeDebitText() {
88
+ return this.balancesReport.getBook().formatValue(this.getCumulativeDebit());
89
+ }
76
90
  getPeriodBalance() {
77
91
  return getRepresentativeValue(new Amount(this.payload.periodBalance || 0), this.isCredit());
78
92
  }
79
93
  getPeriodBalanceRaw() {
80
94
  return new Amount(this.payload.periodBalance || 0);
81
95
  }
96
+ getPeriodCredit() {
97
+ return new Amount(this.payload.periodCredit || 0);
98
+ }
99
+ getPeriodDebit() {
100
+ return new Amount(this.payload.periodDebit || 0);
101
+ }
82
102
  getPeriodBalanceText() {
83
103
  return this.balancesReport.getBook().formatValue(this.getPeriodBalance());
84
104
  }
85
105
  getPeriodBalanceRawText() {
86
106
  return this.balancesReport.getBook().formatValue(this.getPeriodBalanceRaw());
87
107
  }
108
+ getPeriodCreditText() {
109
+ return this.balancesReport.getBook().formatValue(this.getPeriodCredit());
110
+ }
111
+ getPeriodDebitText() {
112
+ return this.balancesReport.getBook().formatValue(this.getPeriodDebit());
113
+ }
114
+ createDataTable() {
115
+ return new BalancesDataTableBuilder(this.balancesReport.getBook(), [this], this.balancesReport.getPeriodicity());
116
+ }
88
117
  getBalancesContainers() {
89
118
  return [];
90
119
  }
120
+ getBalances() {
121
+ if (!this.payload.balances) {
122
+ return new Array();
123
+ }
124
+ return this.payload.balances.map(balancePlain => new Balance(this, balancePlain));
125
+ }
126
+ getProperties() {
127
+ return this.payload.properties != null ? Object.assign({}, this.payload.properties) : {};
128
+ }
129
+ getProperty(...keys) {
130
+ for (let index = 0; index < keys.length; index++) {
131
+ const key = keys[index];
132
+ let value = this.payload.properties != null ? this.payload.properties[key] : null;
133
+ if (value != null && value.trim() != '') {
134
+ return value;
135
+ }
136
+ }
137
+ return undefined;
138
+ }
139
+ getPropertyKeys() {
140
+ let properties = this.getProperties();
141
+ let propertyKeys = [];
142
+ if (properties) {
143
+ for (var key in properties) {
144
+ if (Object.prototype.hasOwnProperty.call(properties, key)) {
145
+ propertyKeys.push(key);
146
+ }
147
+ }
148
+ }
149
+ propertyKeys = propertyKeys.sort();
150
+ return propertyKeys;
151
+ }
91
152
  getBalancesContainer(name) {
92
153
  const normalizedName = normalizeName(name);
93
154
  if (this.getNormalizedName() == normalizedName) {
@@ -10,6 +10,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { Amount } from "./Amount.js";
11
11
  import { getRepresentativeValue, normalizeName } from "../utils.js";
12
12
  import { AccountBalancesContainer } from "./BalancesContainerAccount.js";
13
+ import { Balance } from "./Balance.js";
14
+ import { BalancesDataTableBuilder } from "./BalancesDataTableBuilder.js";
13
15
  /** @internal */
14
16
  export class GroupBalancesContainer {
15
17
  constructor(parent, balancesReport, payload) {
@@ -48,10 +50,10 @@ export class GroupBalancesContainer {
48
50
  return this.depth;
49
51
  }
50
52
  isCredit() {
51
- return this.payload.credit;
53
+ return this.payload.credit || false;
52
54
  }
53
55
  isPermanent() {
54
- return this.payload.permanent;
56
+ return this.payload.permanent || false;
55
57
  }
56
58
  isFromAccount() {
57
59
  return false;
@@ -69,24 +71,83 @@ export class GroupBalancesContainer {
69
71
  getCumulativeBalanceRaw() {
70
72
  return new Amount(this.payload.cumulativeBalance || 0);
71
73
  }
74
+ getCumulativeCredit() {
75
+ return new Amount(this.payload.cumulativeCredit || 0);
76
+ }
77
+ getCumulativeDebit() {
78
+ return new Amount(this.payload.cumulativeDebit || 0);
79
+ }
72
80
  getCumulativeBalanceText() {
73
81
  return this.balancesReport.getBook().formatValue(this.getCumulativeBalance());
74
82
  }
75
83
  getCumulativeBalanceRawText() {
76
84
  return this.balancesReport.getBook().formatValue(this.getCumulativeBalanceRaw());
77
85
  }
86
+ getCumulativeCreditText() {
87
+ return this.balancesReport.getBook().formatValue(this.getCumulativeCredit());
88
+ }
89
+ getCumulativeDebitText() {
90
+ return this.balancesReport.getBook().formatValue(this.getCumulativeDebit());
91
+ }
78
92
  getPeriodBalance() {
79
93
  return getRepresentativeValue(new Amount(this.payload.periodBalance || 0), this.isCredit());
80
94
  }
81
95
  getPeriodBalanceRaw() {
82
96
  return new Amount(this.payload.periodBalance || 0);
83
97
  }
98
+ getPeriodCredit() {
99
+ return new Amount(this.payload.periodCredit || 0);
100
+ }
101
+ getPeriodDebit() {
102
+ return new Amount(this.payload.periodDebit || 0);
103
+ }
84
104
  getPeriodBalanceText() {
85
105
  return this.balancesReport.getBook().formatValue(this.getPeriodBalance());
86
106
  }
87
107
  getPeriodBalanceRawText() {
88
108
  return this.balancesReport.getBook().formatValue(this.getPeriodBalanceRaw());
89
109
  }
110
+ getPeriodCreditText() {
111
+ return this.balancesReport.getBook().formatValue(this.getPeriodCredit());
112
+ }
113
+ getPeriodDebitText() {
114
+ return this.balancesReport.getBook().formatValue(this.getPeriodDebit());
115
+ }
116
+ getBalances() {
117
+ if (!this.payload.balances) {
118
+ return new Array();
119
+ }
120
+ return this.payload.balances.map(balancePlain => new Balance(this, balancePlain));
121
+ }
122
+ createDataTable() {
123
+ return new BalancesDataTableBuilder(this.balancesReport.getBook(), this.getBalancesContainers(), this.balancesReport.getPeriodicity());
124
+ }
125
+ getProperties() {
126
+ return this.payload.properties != null ? Object.assign({}, this.payload.properties) : {};
127
+ }
128
+ getProperty(...keys) {
129
+ for (let index = 0; index < keys.length; index++) {
130
+ const key = keys[index];
131
+ let value = this.payload.properties != null ? this.payload.properties[key] : null;
132
+ if (value != null && value.trim() != '') {
133
+ return value;
134
+ }
135
+ }
136
+ return undefined;
137
+ }
138
+ getPropertyKeys() {
139
+ let properties = this.getProperties();
140
+ let propertyKeys = [];
141
+ if (properties) {
142
+ for (var key in properties) {
143
+ if (Object.prototype.hasOwnProperty.call(properties, key)) {
144
+ propertyKeys.push(key);
145
+ }
146
+ }
147
+ }
148
+ propertyKeys = propertyKeys.sort();
149
+ return propertyKeys;
150
+ }
90
151
  getBalancesContainers() {
91
152
  let containers = [];
92
153
  const groupContainers = this.getGroupContainers();