taxtank-core 2.1.57 → 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 +46 -50
- package/fesm2022/taxtank-core.mjs.map +1 -1
- package/index.d.ts +18 -12
- 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
|
|
@@ -7194,6 +7200,9 @@ class Transaction extends Transaction$1 {
|
|
|
7194
7200
|
calculation: this.property ? this.property.depreciationCalculation : DepreciationCalculationEnum.PRIME_COST,
|
|
7195
7201
|
transactions: [this],
|
|
7196
7202
|
business: this.business,
|
|
7203
|
+
currency: this.currency,
|
|
7204
|
+
exchangeRate: this.exchangeRate,
|
|
7205
|
+
// foreignAmount: this.foreignAmount,
|
|
7197
7206
|
});
|
|
7198
7207
|
}
|
|
7199
7208
|
/**
|
|
@@ -11026,6 +11035,7 @@ class BankAccount extends BankAccount$1 {
|
|
|
11026
11035
|
this.businessAllocations = [];
|
|
11027
11036
|
this.balances = [];
|
|
11028
11037
|
this.currency = 'AUD';
|
|
11038
|
+
this.exchangeRate = 1;
|
|
11029
11039
|
}
|
|
11030
11040
|
get bank() {
|
|
11031
11041
|
return this.bankConnection.bank;
|
|
@@ -11042,6 +11052,9 @@ class BankAccount extends BankAccount$1 {
|
|
|
11042
11052
|
get partialAccountNumber() {
|
|
11043
11053
|
return `xxxx${this.accountNumber.slice(-4)}`;
|
|
11044
11054
|
}
|
|
11055
|
+
/**
|
|
11056
|
+
* @TODO remove after tests
|
|
11057
|
+
*/
|
|
11045
11058
|
get balance() {
|
|
11046
11059
|
return FinancialYear.isCurrent() ? this.currentBalance : this.getOpeningBalance(FinancialYear.year + 1);
|
|
11047
11060
|
}
|
|
@@ -11064,8 +11077,8 @@ class BankAccount extends BankAccount$1 {
|
|
|
11064
11077
|
/**
|
|
11065
11078
|
* Get the current opening balance amount
|
|
11066
11079
|
*/
|
|
11067
|
-
getOpeningBalance(year = FinancialYear.year) {
|
|
11068
|
-
return this.getBalanceByYear(year)?.openingBalance || 0;
|
|
11080
|
+
getOpeningBalance(year = FinancialYear.year, convertToAud = false) {
|
|
11081
|
+
return (this.getBalanceByYear(year)?.openingBalance || 0) * (convertToAud ? this.exchangeRate : 1);
|
|
11069
11082
|
}
|
|
11070
11083
|
/**
|
|
11071
11084
|
* Get bank account balance for current financial year
|
|
@@ -11146,7 +11159,7 @@ class BankAccount extends BankAccount$1 {
|
|
|
11146
11159
|
* @param propertyId Id of property
|
|
11147
11160
|
*/
|
|
11148
11161
|
getPropertyBalanceAmount(propertyId) {
|
|
11149
|
-
return this.
|
|
11162
|
+
return this.convertedBalance * this.getPropertyPercentage(propertyId);
|
|
11150
11163
|
}
|
|
11151
11164
|
getMonthlyRepaymentAmount(propertyId) {
|
|
11152
11165
|
return this.loan ? this.loan.monthlyRepaymentAmount * this.getPropertyPercentage(propertyId) : 0;
|
|
@@ -11182,7 +11195,7 @@ class BankAccount extends BankAccount$1 {
|
|
|
11182
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),
|
|
11183
11196
|
// that's why the balance won't be 0 (updated by basiq)
|
|
11184
11197
|
if (shouldPayoutLoanAccount && this.isManual()) {
|
|
11185
|
-
return this.
|
|
11198
|
+
return this.convertedBalance === 0;
|
|
11186
11199
|
}
|
|
11187
11200
|
return shouldPayoutLoanAccount;
|
|
11188
11201
|
}
|
|
@@ -11192,6 +11205,9 @@ class BankAccount extends BankAccount$1 {
|
|
|
11192
11205
|
get isForeign() {
|
|
11193
11206
|
return this.currency !== 'AUD';
|
|
11194
11207
|
}
|
|
11208
|
+
get convertedBalance() {
|
|
11209
|
+
return this.currentBalance * this.exchangeRate;
|
|
11210
|
+
}
|
|
11195
11211
|
}
|
|
11196
11212
|
__decorate([
|
|
11197
11213
|
Type(() => BankAccountProperty)
|
|
@@ -11202,6 +11218,9 @@ __decorate([
|
|
|
11202
11218
|
__decorate([
|
|
11203
11219
|
Type(() => BankAccountBalance)
|
|
11204
11220
|
], BankAccount.prototype, "balances", void 0);
|
|
11221
|
+
__decorate([
|
|
11222
|
+
Type(() => Number)
|
|
11223
|
+
], BankAccount.prototype, "currentBalance", void 0);
|
|
11205
11224
|
__decorate([
|
|
11206
11225
|
Type(() => Loan)
|
|
11207
11226
|
], BankAccount.prototype, "loan", void 0);
|
|
@@ -11228,7 +11247,7 @@ class BankAccountChartData {
|
|
|
11228
11247
|
getBalancePieChartData() {
|
|
11229
11248
|
return this.bankAccounts.map((bankAccount) => plainToClass(ChartData, {
|
|
11230
11249
|
name: bankAccount.accountName,
|
|
11231
|
-
data: Math.abs(bankAccount.
|
|
11250
|
+
data: Math.abs(bankAccount.convertedBalance)
|
|
11232
11251
|
}));
|
|
11233
11252
|
}
|
|
11234
11253
|
/**
|
|
@@ -11239,7 +11258,7 @@ class BankAccountChartData {
|
|
|
11239
11258
|
name: 'Balance',
|
|
11240
11259
|
data: this.bankAccounts.map((bankAccount) => ({
|
|
11241
11260
|
label: bankAccount.accountName,
|
|
11242
|
-
value: bankAccount.
|
|
11261
|
+
value: bankAccount.convertedBalance
|
|
11243
11262
|
}))
|
|
11244
11263
|
})];
|
|
11245
11264
|
}
|
|
@@ -14357,7 +14376,7 @@ class FinancialGoalService extends RestService$1 {
|
|
|
14357
14376
|
return this.put(Object.assign({}, goal, { status: FinancialGoalStatusEnum.ACTIVE }));
|
|
14358
14377
|
}
|
|
14359
14378
|
complete(goal) {
|
|
14360
|
-
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 }));
|
|
14361
14380
|
}
|
|
14362
14381
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: FinancialGoalService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
14363
14382
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: FinancialGoalService, providedIn: 'root' }); }
|
|
@@ -21478,52 +21497,27 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.10", ngImpo
|
|
|
21478
21497
|
args: ['environment']
|
|
21479
21498
|
}] }] });
|
|
21480
21499
|
|
|
21500
|
+
/**
|
|
21501
|
+
* @TODO move to BankAccountCollection
|
|
21502
|
+
*/
|
|
21481
21503
|
class BankAccountCalculationService {
|
|
21482
21504
|
/**
|
|
21483
21505
|
* Sum of bank accounts opening balances and their bank transactions allocated amounts
|
|
21484
21506
|
*/
|
|
21485
|
-
getTaxTankBalance(bankAccounts, bankTransactions, allocations,
|
|
21486
|
-
|
|
21487
|
-
bankAccounts.items.forEach(bankAccount => {
|
|
21488
|
-
let balance = bankTransactions.getByBankAccountsIds([bankAccount.id]).getAllocatedAmount(allocations);
|
|
21489
|
-
if (!excludeOpenBalance) {
|
|
21490
|
-
balance += bankAccount.getOpeningBalance();
|
|
21491
|
-
}
|
|
21492
|
-
if (exchangeRateByCurrency && bankAccount.isForeign) {
|
|
21493
|
-
balance *= exchangeRateByCurrency.get(bankAccount.currency).rate;
|
|
21494
|
-
}
|
|
21495
|
-
totalBalance += balance;
|
|
21496
|
-
});
|
|
21497
|
-
return totalBalance;
|
|
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);
|
|
21498
21509
|
}
|
|
21499
|
-
|
|
21510
|
+
getAllocatedAmount(bankAccounts, bankTransactions, allocations, convertToAud = true) {
|
|
21500
21511
|
let total = 0;
|
|
21501
21512
|
bankAccounts.items.forEach(bankAccount => {
|
|
21502
|
-
let
|
|
21503
|
-
if (
|
|
21504
|
-
|
|
21513
|
+
let amount = bankTransactions.getByBankAccountsIds([bankAccount.id]).getAllocatedAmount(allocations);
|
|
21514
|
+
if (convertToAud) {
|
|
21515
|
+
amount *= bankAccount.exchangeRate;
|
|
21505
21516
|
}
|
|
21506
|
-
total +=
|
|
21517
|
+
total += amount;
|
|
21507
21518
|
});
|
|
21508
21519
|
return total;
|
|
21509
21520
|
}
|
|
21510
|
-
getCashOut(bankAccounts, bankTransactions, allocations, exchangeRateByCurrency) {
|
|
21511
|
-
let total = 0;
|
|
21512
|
-
bankAccounts.items.forEach(bankAccount => {
|
|
21513
|
-
let cash = bankTransactions.getByBankAccountsIds([bankAccount.id]).debitTransactions.getAllocatedAmount(allocations);
|
|
21514
|
-
if (bankAccount.isForeign) {
|
|
21515
|
-
cash *= exchangeRateByCurrency.get(bankAccount.currency).rate;
|
|
21516
|
-
}
|
|
21517
|
-
total += cash;
|
|
21518
|
-
});
|
|
21519
|
-
return total;
|
|
21520
|
-
}
|
|
21521
|
-
/**
|
|
21522
|
-
* get difference between total loans amount and total cash amount
|
|
21523
|
-
*/
|
|
21524
|
-
getNetPosition(bankAccounts, bankTransactions, allocations) {
|
|
21525
|
-
return bankAccounts.currentBalance - this.getTaxTankBalance(bankAccounts.getLoanAccounts(), bankTransactions, allocations);
|
|
21526
|
-
}
|
|
21527
21521
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: BankAccountCalculationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
21528
21522
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: BankAccountCalculationService, providedIn: 'root' }); }
|
|
21529
21523
|
}
|
|
@@ -24674,7 +24668,7 @@ class FinancialGoalForm extends AbstractForm {
|
|
|
24674
24668
|
this.get('bankAccount').valueChanges
|
|
24675
24669
|
.pipe(filter((bankAccount) => !!bankAccount))
|
|
24676
24670
|
.subscribe(bankAccount => {
|
|
24677
|
-
this.get('initialValue').setValue(bankAccount.
|
|
24671
|
+
this.get('initialValue').setValue(bankAccount.convertedBalance);
|
|
24678
24672
|
});
|
|
24679
24673
|
}
|
|
24680
24674
|
/**
|
|
@@ -25455,7 +25449,7 @@ class BankAccountForm extends BankAccountAllocationForm {
|
|
|
25455
25449
|
super(bankAccount, {
|
|
25456
25450
|
type: new FormControl(bankAccount.type, Validators.required),
|
|
25457
25451
|
accountName: new FormControl(bankAccount.accountName, Validators.required),
|
|
25458
|
-
currentBalance: new FormControl(bankAccount.
|
|
25452
|
+
currentBalance: new FormControl(bankAccount.convertedBalance, Validators.required),
|
|
25459
25453
|
accountNumber: new FormControl(bankAccount.accountNumber, [Validators.required, Validators.pattern(BankAccountForm.accountNumberPattern)]),
|
|
25460
25454
|
payId: new FormControl(bankAccount.payId),
|
|
25461
25455
|
currency: new FormControl({ value: bankAccount.currency, disabled: !!bankAccount.id }),
|
|
@@ -27344,6 +27338,8 @@ class TransactionForm extends TransactionBaseForm {
|
|
|
27344
27338
|
buildTransactions(transaction) {
|
|
27345
27339
|
return this.get('transactions').value.map((childTransaction) => Object.assign({
|
|
27346
27340
|
description: childTransaction.chartAccounts?.name,
|
|
27341
|
+
currency: transaction.currency,
|
|
27342
|
+
exchangeRate: transaction.exchangeRate,
|
|
27347
27343
|
date: transaction.date,
|
|
27348
27344
|
claimPercent: (transaction.claimPercent * childTransaction.chartAccounts?.taxablePercent) / 100,
|
|
27349
27345
|
source: TransactionSourceEnum.BANK_TRANSACTION,
|