taxtank-core 2.1.58 → 2.1.60
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/fesm2022/taxtank-core.mjs +42 -51
- package/fesm2022/taxtank-core.mjs.map +1 -1
- package/index.d.ts +16 -9
- package/package.json +1 -1
|
@@ -17,8 +17,8 @@ import uniqBy from 'lodash/uniqBy';
|
|
|
17
17
|
import first from 'lodash/first';
|
|
18
18
|
import last from 'lodash/last';
|
|
19
19
|
import orderBy from 'lodash/orderBy';
|
|
20
|
-
import round from 'lodash/round';
|
|
21
20
|
import uniq from 'lodash/uniq';
|
|
21
|
+
import round from 'lodash/round';
|
|
22
22
|
import moment from 'moment';
|
|
23
23
|
import { DateRange as DateRange$1 } from 'moment-range';
|
|
24
24
|
import * as i3 from 'taxtank-core/common';
|
|
@@ -289,9 +289,6 @@ class ObservableModel extends AbstractModel {
|
|
|
289
289
|
let BankAccount$1 = class BankAccount extends ObservableModel {
|
|
290
290
|
static { this.className = 'BankAccount'; }
|
|
291
291
|
};
|
|
292
|
-
__decorate([
|
|
293
|
-
Type(() => Number)
|
|
294
|
-
], BankAccount$1.prototype, "currentBalance", void 0);
|
|
295
292
|
|
|
296
293
|
let BankConnection$1 = class BankConnection extends ObservableModel {
|
|
297
294
|
static { this.className = 'BankConnection'; }
|
|
@@ -1310,6 +1307,12 @@ class TransactionBase extends ObservableModel {
|
|
|
1310
1307
|
get grossClaimAmount() {
|
|
1311
1308
|
return this.grossAmount * this.claimRatio;
|
|
1312
1309
|
}
|
|
1310
|
+
get isForeign() {
|
|
1311
|
+
return this.currency !== 'AUD';
|
|
1312
|
+
}
|
|
1313
|
+
get foreignAmount() {
|
|
1314
|
+
return this.amount / this.exchangeRate;
|
|
1315
|
+
}
|
|
1313
1316
|
}
|
|
1314
1317
|
__decorate([
|
|
1315
1318
|
Transform(({ value }) => value === null ? null : +value)
|
|
@@ -1735,7 +1738,7 @@ class AllocationGroup extends AbstractModel {
|
|
|
1735
1738
|
category: transaction.chartAccounts.name,
|
|
1736
1739
|
tankType: transaction.tankType,
|
|
1737
1740
|
amount: transaction.netAmount,
|
|
1738
|
-
foreignAmount: transaction.foreignAmount,
|
|
1741
|
+
// foreignAmount: transaction.foreignAmount,
|
|
1739
1742
|
childTransactions: transaction.transactions,
|
|
1740
1743
|
allocations,
|
|
1741
1744
|
bankTransactions
|
|
@@ -2205,6 +2208,9 @@ class Collection {
|
|
|
2205
2208
|
.filter((item) => !!get(item, path))
|
|
2206
2209
|
.map((item) => get(item, path));
|
|
2207
2210
|
}
|
|
2211
|
+
uniqMapBy(path) {
|
|
2212
|
+
return uniq(this.mapBy(path));
|
|
2213
|
+
}
|
|
2208
2214
|
sortBy(paths = ['id'], order = ['desc']) {
|
|
2209
2215
|
this.items = orderBy(this.items, paths instanceof Array ? paths : [paths], order instanceof Array ? order : [order]);
|
|
2210
2216
|
return this;
|
|
@@ -6939,7 +6945,7 @@ class PropertyEquityChartData {
|
|
|
6939
6945
|
return bankAccounts.items.reduce((totalSum, bankAccount) => totalSum + (bankAccount.getPropertyPercentage(property.id) * (loans.getByBankAccountId(bankAccount.id)?.getLastPaymentByYear(year)?.totalOwed || 0)), 0) - offset;
|
|
6940
6946
|
}
|
|
6941
6947
|
if (year == this.currentYear) {
|
|
6942
|
-
return bankAccounts.items.reduce((totalSum, bankAccount) => totalSum + (bankAccount.getPropertyPercentage(property.id) * (Math.abs(
|
|
6948
|
+
return bankAccounts.items.reduce((totalSum, bankAccount) => totalSum + (bankAccount.getPropertyPercentage(property.id) * (Math.abs(bankAccount.convertedBalance) || 0)), 0) - offset;
|
|
6943
6949
|
}
|
|
6944
6950
|
return Math.abs(property.getForecastByYear(year).loanBalance) - offset;
|
|
6945
6951
|
// @TODO TT-4888 no idea why it was calculated like that
|
|
@@ -7196,7 +7202,7 @@ class Transaction extends Transaction$1 {
|
|
|
7196
7202
|
business: this.business,
|
|
7197
7203
|
currency: this.currency,
|
|
7198
7204
|
exchangeRate: this.exchangeRate,
|
|
7199
|
-
foreignAmount: this.foreignAmount,
|
|
7205
|
+
// foreignAmount: this.foreignAmount,
|
|
7200
7206
|
});
|
|
7201
7207
|
}
|
|
7202
7208
|
/**
|
|
@@ -11029,6 +11035,7 @@ class BankAccount extends BankAccount$1 {
|
|
|
11029
11035
|
this.businessAllocations = [];
|
|
11030
11036
|
this.balances = [];
|
|
11031
11037
|
this.currency = 'AUD';
|
|
11038
|
+
this.exchangeRate = 1;
|
|
11032
11039
|
}
|
|
11033
11040
|
get bank() {
|
|
11034
11041
|
return this.bankConnection.bank;
|
|
@@ -11045,6 +11052,9 @@ class BankAccount extends BankAccount$1 {
|
|
|
11045
11052
|
get partialAccountNumber() {
|
|
11046
11053
|
return `xxxx${this.accountNumber.slice(-4)}`;
|
|
11047
11054
|
}
|
|
11055
|
+
/**
|
|
11056
|
+
* @TODO remove after tests
|
|
11057
|
+
*/
|
|
11048
11058
|
get balance() {
|
|
11049
11059
|
return FinancialYear.isCurrent() ? this.currentBalance : this.getOpeningBalance(FinancialYear.year + 1);
|
|
11050
11060
|
}
|
|
@@ -11067,8 +11077,8 @@ class BankAccount extends BankAccount$1 {
|
|
|
11067
11077
|
/**
|
|
11068
11078
|
* Get the current opening balance amount
|
|
11069
11079
|
*/
|
|
11070
|
-
getOpeningBalance(year = FinancialYear.year) {
|
|
11071
|
-
return this.getBalanceByYear(year)?.openingBalance || 0;
|
|
11080
|
+
getOpeningBalance(year = FinancialYear.year, convertToAud = false) {
|
|
11081
|
+
return (this.getBalanceByYear(year)?.openingBalance || 0) * (convertToAud ? this.exchangeRate : 1);
|
|
11072
11082
|
}
|
|
11073
11083
|
/**
|
|
11074
11084
|
* Get bank account balance for current financial year
|
|
@@ -11149,7 +11159,7 @@ class BankAccount extends BankAccount$1 {
|
|
|
11149
11159
|
* @param propertyId Id of property
|
|
11150
11160
|
*/
|
|
11151
11161
|
getPropertyBalanceAmount(propertyId) {
|
|
11152
|
-
return this.
|
|
11162
|
+
return this.convertedBalance * this.getPropertyPercentage(propertyId);
|
|
11153
11163
|
}
|
|
11154
11164
|
getMonthlyRepaymentAmount(propertyId) {
|
|
11155
11165
|
return this.loan ? this.loan.monthlyRepaymentAmount * this.getPropertyPercentage(propertyId) : 0;
|
|
@@ -11185,7 +11195,7 @@ class BankAccount extends BankAccount$1 {
|
|
|
11185
11195
|
// we don't check the current balance for basiq accounts, because basiq doesn't provide us last transactions (can't do for closed accounts),
|
|
11186
11196
|
// that's why the balance won't be 0 (updated by basiq)
|
|
11187
11197
|
if (shouldPayoutLoanAccount && this.isManual()) {
|
|
11188
|
-
return this.
|
|
11198
|
+
return this.convertedBalance === 0;
|
|
11189
11199
|
}
|
|
11190
11200
|
return shouldPayoutLoanAccount;
|
|
11191
11201
|
}
|
|
@@ -11195,6 +11205,9 @@ class BankAccount extends BankAccount$1 {
|
|
|
11195
11205
|
get isForeign() {
|
|
11196
11206
|
return this.currency !== 'AUD';
|
|
11197
11207
|
}
|
|
11208
|
+
get convertedBalance() {
|
|
11209
|
+
return this.currentBalance * this.exchangeRate;
|
|
11210
|
+
}
|
|
11198
11211
|
}
|
|
11199
11212
|
__decorate([
|
|
11200
11213
|
Type(() => BankAccountProperty)
|
|
@@ -11205,6 +11218,9 @@ __decorate([
|
|
|
11205
11218
|
__decorate([
|
|
11206
11219
|
Type(() => BankAccountBalance)
|
|
11207
11220
|
], BankAccount.prototype, "balances", void 0);
|
|
11221
|
+
__decorate([
|
|
11222
|
+
Type(() => Number)
|
|
11223
|
+
], BankAccount.prototype, "currentBalance", void 0);
|
|
11208
11224
|
__decorate([
|
|
11209
11225
|
Type(() => Loan)
|
|
11210
11226
|
], BankAccount.prototype, "loan", void 0);
|
|
@@ -11231,7 +11247,7 @@ class BankAccountChartData {
|
|
|
11231
11247
|
getBalancePieChartData() {
|
|
11232
11248
|
return this.bankAccounts.map((bankAccount) => plainToClass(ChartData, {
|
|
11233
11249
|
name: bankAccount.accountName,
|
|
11234
|
-
data: Math.abs(bankAccount.
|
|
11250
|
+
data: Math.abs(bankAccount.convertedBalance)
|
|
11235
11251
|
}));
|
|
11236
11252
|
}
|
|
11237
11253
|
/**
|
|
@@ -11242,7 +11258,7 @@ class BankAccountChartData {
|
|
|
11242
11258
|
name: 'Balance',
|
|
11243
11259
|
data: this.bankAccounts.map((bankAccount) => ({
|
|
11244
11260
|
label: bankAccount.accountName,
|
|
11245
|
-
value: bankAccount.
|
|
11261
|
+
value: bankAccount.convertedBalance
|
|
11246
11262
|
}))
|
|
11247
11263
|
})];
|
|
11248
11264
|
}
|
|
@@ -14360,7 +14376,7 @@ class FinancialGoalService extends RestService$1 {
|
|
|
14360
14376
|
return this.put(Object.assign({}, goal, { status: FinancialGoalStatusEnum.ACTIVE }));
|
|
14361
14377
|
}
|
|
14362
14378
|
complete(goal) {
|
|
14363
|
-
return this.put(Object.assign({}, goal, { status: FinancialGoalStatusEnum.COMPLETE, finalValue: goal.bankAccount.
|
|
14379
|
+
return this.put(Object.assign({}, goal, { status: FinancialGoalStatusEnum.COMPLETE, finalValue: goal.bankAccount.convertedBalance }));
|
|
14364
14380
|
}
|
|
14365
14381
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: FinancialGoalService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
14366
14382
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: FinancialGoalService, providedIn: 'root' }); }
|
|
@@ -21481,52 +21497,27 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.10", ngImpo
|
|
|
21481
21497
|
args: ['environment']
|
|
21482
21498
|
}] }] });
|
|
21483
21499
|
|
|
21500
|
+
/**
|
|
21501
|
+
* @TODO move to BankAccountCollection
|
|
21502
|
+
*/
|
|
21484
21503
|
class BankAccountCalculationService {
|
|
21485
21504
|
/**
|
|
21486
21505
|
* Sum of bank accounts opening balances and their bank transactions allocated amounts
|
|
21487
21506
|
*/
|
|
21488
|
-
getTaxTankBalance(bankAccounts, bankTransactions, allocations,
|
|
21489
|
-
|
|
21490
|
-
bankAccounts.items.forEach(bankAccount => {
|
|
21491
|
-
let balance = bankTransactions.getByBankAccountsIds([bankAccount.id]).getAllocatedAmount(allocations);
|
|
21492
|
-
if (!excludeOpenBalance) {
|
|
21493
|
-
balance += bankAccount.getOpeningBalance();
|
|
21494
|
-
}
|
|
21495
|
-
if (exchangeRateByCurrency && bankAccount.isForeign) {
|
|
21496
|
-
balance *= exchangeRateByCurrency.get(bankAccount.currency).rate;
|
|
21497
|
-
}
|
|
21498
|
-
totalBalance += balance;
|
|
21499
|
-
});
|
|
21500
|
-
return totalBalance;
|
|
21501
|
-
}
|
|
21502
|
-
getCashIn(bankAccounts, bankTransactions, allocations, exchangeRateByCurrency) {
|
|
21503
|
-
let total = 0;
|
|
21504
|
-
bankAccounts.items.forEach(bankAccount => {
|
|
21505
|
-
let cash = bankTransactions.getByBankAccountsIds([bankAccount.id]).creditTransactions.getAllocatedAmount(allocations);
|
|
21506
|
-
if (bankAccount.isForeign) {
|
|
21507
|
-
cash *= exchangeRateByCurrency.get(bankAccount.currency).rate;
|
|
21508
|
-
}
|
|
21509
|
-
total += cash;
|
|
21510
|
-
});
|
|
21511
|
-
return total;
|
|
21507
|
+
getTaxTankBalance(bankAccounts, bankTransactions, allocations, convertToAud = true) {
|
|
21508
|
+
return bankAccounts.reduce((sum, bankAccount) => sum + bankAccount.getOpeningBalance(FinancialYear.year, convertToAud)) + this.getAllocatedAmount(bankAccounts, bankTransactions, allocations, convertToAud);
|
|
21512
21509
|
}
|
|
21513
|
-
|
|
21510
|
+
getAllocatedAmount(bankAccounts, bankTransactions, allocations, convertToAud = true) {
|
|
21514
21511
|
let total = 0;
|
|
21515
21512
|
bankAccounts.items.forEach(bankAccount => {
|
|
21516
|
-
let
|
|
21517
|
-
if (
|
|
21518
|
-
|
|
21513
|
+
let amount = bankTransactions.getByBankAccountsIds([bankAccount.id]).getAllocatedAmount(allocations);
|
|
21514
|
+
if (convertToAud) {
|
|
21515
|
+
amount *= bankAccount.exchangeRate;
|
|
21519
21516
|
}
|
|
21520
|
-
total +=
|
|
21517
|
+
total += amount;
|
|
21521
21518
|
});
|
|
21522
21519
|
return total;
|
|
21523
21520
|
}
|
|
21524
|
-
/**
|
|
21525
|
-
* get difference between total loans amount and total cash amount
|
|
21526
|
-
*/
|
|
21527
|
-
getNetPosition(bankAccounts, bankTransactions, allocations) {
|
|
21528
|
-
return bankAccounts.currentBalance - this.getTaxTankBalance(bankAccounts.getLoanAccounts(), bankTransactions, allocations);
|
|
21529
|
-
}
|
|
21530
21521
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: BankAccountCalculationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
21531
21522
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: BankAccountCalculationService, providedIn: 'root' }); }
|
|
21532
21523
|
}
|
|
@@ -24677,7 +24668,7 @@ class FinancialGoalForm extends AbstractForm {
|
|
|
24677
24668
|
this.get('bankAccount').valueChanges
|
|
24678
24669
|
.pipe(filter((bankAccount) => !!bankAccount))
|
|
24679
24670
|
.subscribe(bankAccount => {
|
|
24680
|
-
this.get('initialValue').setValue(bankAccount.
|
|
24671
|
+
this.get('initialValue').setValue(bankAccount.convertedBalance);
|
|
24681
24672
|
});
|
|
24682
24673
|
}
|
|
24683
24674
|
/**
|
|
@@ -25458,7 +25449,7 @@ class BankAccountForm extends BankAccountAllocationForm {
|
|
|
25458
25449
|
super(bankAccount, {
|
|
25459
25450
|
type: new FormControl(bankAccount.type, Validators.required),
|
|
25460
25451
|
accountName: new FormControl(bankAccount.accountName, Validators.required),
|
|
25461
|
-
currentBalance: new FormControl(bankAccount.
|
|
25452
|
+
currentBalance: new FormControl(bankAccount.convertedBalance, Validators.required),
|
|
25462
25453
|
accountNumber: new FormControl(bankAccount.accountNumber, [Validators.required, Validators.pattern(BankAccountForm.accountNumberPattern)]),
|
|
25463
25454
|
payId: new FormControl(bankAccount.payId),
|
|
25464
25455
|
currency: new FormControl({ value: bankAccount.currency, disabled: !!bankAccount.id }),
|