taxtank-core 0.16.10 → 0.16.13
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/bundles/taxtank-core.umd.js +39 -96
- package/bundles/taxtank-core.umd.js.map +1 -1
- package/esm2015/lib/collections/collection-dictionary.js +16 -1
- package/esm2015/lib/collections/income-source.collection.js +4 -1
- package/esm2015/lib/db/Enums/income-source-type-list-other.enum.js +1 -1
- package/esm2015/lib/db/Enums/income-source-type-list-work.enum.js +2 -1
- package/esm2015/lib/db/Enums/income-source-type.enum.js +3 -4
- package/esm2015/lib/models/income-source/income-source-type.js +4 -6
- package/esm2015/lib/models/income-source/income-source.js +4 -2
- package/esm2015/lib/services/account-setup/account-setup.service.js +11 -7
- package/esm2015/lib/services/http/bank/basiq/basiq.service.js +5 -79
- package/fesm2015/taxtank-core.js +38 -92
- package/fesm2015/taxtank-core.js.map +1 -1
- package/lib/collections/collection-dictionary.d.ts +5 -0
- package/lib/collections/income-source.collection.d.ts +1 -0
- package/lib/db/Enums/income-source-type-list-work.enum.d.ts +1 -0
- package/lib/db/Enums/income-source-type.enum.d.ts +3 -4
- package/lib/models/income-source/income-source-type.d.ts +1 -1
- package/lib/services/account-setup/account-setup.service.d.ts +3 -2
- package/lib/services/http/bank/basiq/basiq.service.d.ts +2 -29
- package/package.json +1 -1
- package/esm2015/lib/db/Enums/income-source-type-list-salary.enum.js +0 -5
- package/lib/db/Enums/income-source-type-list-salary.enum.d.ts +0 -3
package/fesm2015/taxtank-core.js
CHANGED
|
@@ -799,6 +799,21 @@ class CollectionDictionary {
|
|
|
799
799
|
length() {
|
|
800
800
|
return this.keys.length;
|
|
801
801
|
}
|
|
802
|
+
/**
|
|
803
|
+
* @Todo find a better solution to get list of the sorted keys
|
|
804
|
+
* Get array of the "keys" by provided order
|
|
805
|
+
*/
|
|
806
|
+
getSortedKeys(isDesc = false) {
|
|
807
|
+
return this.keys.sort((a, b) => {
|
|
808
|
+
if (a > b) {
|
|
809
|
+
return !isDesc ? 1 : -1;
|
|
810
|
+
}
|
|
811
|
+
if (a < b) {
|
|
812
|
+
return !isDesc ? -1 : 1;
|
|
813
|
+
}
|
|
814
|
+
return 0;
|
|
815
|
+
});
|
|
816
|
+
}
|
|
802
817
|
/**
|
|
803
818
|
* Group collection items by passed path into items object
|
|
804
819
|
*/
|
|
@@ -1621,6 +1636,9 @@ class IncomeSourceCollection extends Collection {
|
|
|
1621
1636
|
filterByTypes(types) {
|
|
1622
1637
|
return this.items.filter((incomeSource) => types.includes(incomeSource.type));
|
|
1623
1638
|
}
|
|
1639
|
+
getSalary() {
|
|
1640
|
+
return this.items.filter((incomeSource) => incomeSource.isSalaryIncome());
|
|
1641
|
+
}
|
|
1624
1642
|
/**
|
|
1625
1643
|
* Get income sources list of forecasts
|
|
1626
1644
|
*/
|
|
@@ -3176,10 +3194,9 @@ class IncomeSource$1 extends AbstractModel {
|
|
|
3176
3194
|
|
|
3177
3195
|
var IncomeSourceTypeEnum;
|
|
3178
3196
|
(function (IncomeSourceTypeEnum) {
|
|
3179
|
-
IncomeSourceTypeEnum[IncomeSourceTypeEnum["
|
|
3180
|
-
IncomeSourceTypeEnum[IncomeSourceTypeEnum["
|
|
3197
|
+
IncomeSourceTypeEnum[IncomeSourceTypeEnum["WORK"] = 1] = "WORK";
|
|
3198
|
+
IncomeSourceTypeEnum[IncomeSourceTypeEnum["SOLE"] = 2] = "SOLE";
|
|
3181
3199
|
IncomeSourceTypeEnum[IncomeSourceTypeEnum["OTHER"] = 3] = "OTHER";
|
|
3182
|
-
IncomeSourceTypeEnum[IncomeSourceTypeEnum["SOLE"] = 4] = "SOLE";
|
|
3183
3200
|
})(IncomeSourceTypeEnum || (IncomeSourceTypeEnum = {}));
|
|
3184
3201
|
|
|
3185
3202
|
class SalaryForecast$1 extends AbstractModel {
|
|
@@ -3222,13 +3239,9 @@ var SalaryForecastFrequencyEnum;
|
|
|
3222
3239
|
class IncomeSourceType$1 extends AbstractModel {
|
|
3223
3240
|
}
|
|
3224
3241
|
|
|
3225
|
-
var IncomeSourceTypeListSalaryEnum;
|
|
3226
|
-
(function (IncomeSourceTypeListSalaryEnum) {
|
|
3227
|
-
IncomeSourceTypeListSalaryEnum[IncomeSourceTypeListSalaryEnum["BONUSES"] = 1] = "BONUSES";
|
|
3228
|
-
})(IncomeSourceTypeListSalaryEnum || (IncomeSourceTypeListSalaryEnum = {}));
|
|
3229
|
-
|
|
3230
3242
|
var IncomeSourceTypeListWorkEnum;
|
|
3231
3243
|
(function (IncomeSourceTypeListWorkEnum) {
|
|
3244
|
+
IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["BONUSES"] = 1] = "BONUSES";
|
|
3232
3245
|
IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["DIRECTOR_FEES"] = 2] = "DIRECTOR_FEES";
|
|
3233
3246
|
IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["DIVIDENDS"] = 3] = "DIVIDENDS";
|
|
3234
3247
|
IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["INTEREST"] = 4] = "INTEREST";
|
|
@@ -3246,8 +3259,8 @@ var IncomeSourceTypeListOtherEnum;
|
|
|
3246
3259
|
})(IncomeSourceTypeListOtherEnum || (IncomeSourceTypeListOtherEnum = {}));
|
|
3247
3260
|
|
|
3248
3261
|
class IncomeSourceType extends IncomeSourceType$1 {
|
|
3249
|
-
|
|
3250
|
-
return
|
|
3262
|
+
isBonuses() {
|
|
3263
|
+
return this.id === IncomeSourceTypeListWorkEnum.BONUSES;
|
|
3251
3264
|
}
|
|
3252
3265
|
isWork() {
|
|
3253
3266
|
return !!IncomeSourceTypeListWorkEnum[this.id];
|
|
@@ -3256,12 +3269,11 @@ class IncomeSourceType extends IncomeSourceType$1 {
|
|
|
3256
3269
|
return !!IncomeSourceTypeListOtherEnum[this.id];
|
|
3257
3270
|
}
|
|
3258
3271
|
isSole() {
|
|
3272
|
+
// @TODO use IncomeSourceTypeListSoleEnum when sole tank ready
|
|
3259
3273
|
return !!IncomeSourceTypeListOtherEnum[this.id];
|
|
3260
3274
|
}
|
|
3261
3275
|
get type() {
|
|
3262
3276
|
switch (true) {
|
|
3263
|
-
case this.isSalary():
|
|
3264
|
-
return IncomeSourceTypeEnum.SALARY;
|
|
3265
3277
|
case this.isWork():
|
|
3266
3278
|
return IncomeSourceTypeEnum.WORK;
|
|
3267
3279
|
case this.isSole():
|
|
@@ -3299,7 +3311,9 @@ __decorate([
|
|
|
3299
3311
|
|
|
3300
3312
|
class IncomeSource extends IncomeSource$1 {
|
|
3301
3313
|
isSalaryIncome() {
|
|
3302
|
-
return this.
|
|
3314
|
+
return !!this.salaryForecasts.length;
|
|
3315
|
+
// @TODO Vik: old code
|
|
3316
|
+
// return this.type === IncomeSourceTypeEnum.SALARY;
|
|
3303
3317
|
}
|
|
3304
3318
|
isSoleIncome() {
|
|
3305
3319
|
return this.type === IncomeSourceTypeEnum.SOLE;
|
|
@@ -8050,11 +8064,11 @@ class AccountSetupService {
|
|
|
8050
8064
|
const batch = [];
|
|
8051
8065
|
// Salary item is completed when user added salary income source
|
|
8052
8066
|
if (incomeTypes.salary) {
|
|
8053
|
-
batch.push(this.create(AccountSetupItemsEnum.SALARY, this.
|
|
8067
|
+
batch.push(this.create(AccountSetupItemsEnum.SALARY, this.getIncomeSources(true)));
|
|
8054
8068
|
}
|
|
8055
8069
|
// Other income item is completed when user added at least one other income source
|
|
8056
8070
|
if (incomeTypes.dividends || incomeTypes.other) {
|
|
8057
|
-
batch.push(this.create(AccountSetupItemsEnum.OTHER_INCOME, this.
|
|
8071
|
+
batch.push(this.create(AccountSetupItemsEnum.OTHER_INCOME, this.getIncomeSources()));
|
|
8058
8072
|
}
|
|
8059
8073
|
// Rental income item is completed when user added at least one property
|
|
8060
8074
|
if (incomeTypes.property) {
|
|
@@ -8079,11 +8093,16 @@ class AccountSetupService {
|
|
|
8079
8093
|
return combineLatest(batch).pipe(map((items) => new AccountSetupItemCollection(items)));
|
|
8080
8094
|
}
|
|
8081
8095
|
/**
|
|
8082
|
-
* @TODO work with collection when services refactored
|
|
8096
|
+
* @TODO Alex: work with collection when services refactored
|
|
8097
|
+
* @TODO Vik: waiting for income sources refactoring
|
|
8083
8098
|
*/
|
|
8084
|
-
|
|
8099
|
+
getIncomeSources(isSalary = false) {
|
|
8085
8100
|
return this.incomeSourceService.get().pipe(map((incomeSources) => {
|
|
8086
|
-
|
|
8101
|
+
const collection = new IncomeSourceCollection(incomeSources);
|
|
8102
|
+
if (isSalary) {
|
|
8103
|
+
return collection.getSalary();
|
|
8104
|
+
}
|
|
8105
|
+
return collection.items.filter((incomeSource) => !incomeSource.isSalaryIncome() && !incomeSource.isSoleIncome());
|
|
8087
8106
|
}));
|
|
8088
8107
|
}
|
|
8089
8108
|
/**
|
|
@@ -8404,14 +8423,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
|
|
|
8404
8423
|
}]
|
|
8405
8424
|
}] });
|
|
8406
8425
|
|
|
8407
|
-
|
|
8408
|
-
* Basiq consent UI initial URL. Replace USER_ID and TOKEN by user data + handle action parameter
|
|
8409
|
-
*/
|
|
8410
|
-
const BASIQ_CONSENT_URL = 'https://consent.basiq.io/home?userId=USER_ID&token=TOKEN&action=connect';
|
|
8411
|
-
/**
|
|
8412
|
-
* Event message name we listen to handle basiq UI result
|
|
8413
|
-
*/
|
|
8414
|
-
const FINISH_BASIQ_EVENT = 'finish-basiq';
|
|
8426
|
+
// @TODO Basiq 1.0 remove if we will use basiq 2.0 or refactor if we stay with basiq 1.0
|
|
8415
8427
|
/**
|
|
8416
8428
|
* basiq is a middleman between bank and user
|
|
8417
8429
|
* service is responsible for fetching bank related information
|
|
@@ -8429,23 +8441,6 @@ class BasiqService extends RestService {
|
|
|
8429
8441
|
listenEvents() {
|
|
8430
8442
|
this.listenToBankConnectionAdded();
|
|
8431
8443
|
this.listenNotifications();
|
|
8432
|
-
this.listenBasiqConcentUpdated();
|
|
8433
|
-
}
|
|
8434
|
-
/**
|
|
8435
|
-
* Update user's basiq consents data on backend
|
|
8436
|
-
*/
|
|
8437
|
-
confirmConsents() {
|
|
8438
|
-
return this.http.put(`${this.environment.apiV2}/basiq/consents`, {}).pipe(map((isConfirmed) => {
|
|
8439
|
-
this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.BASIQ_CONSENT_UPDATED, isConfirmed));
|
|
8440
|
-
}));
|
|
8441
|
-
}
|
|
8442
|
-
/**
|
|
8443
|
-
* Notify backend to update connections
|
|
8444
|
-
*/
|
|
8445
|
-
updateConnections() {
|
|
8446
|
-
return this.http.post(`${this.environment.apiV2}/basiq/connections`, {}).pipe(map((connections) => {
|
|
8447
|
-
this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.BASIQ_CONNECTION_UPDATED, !!connections));
|
|
8448
|
-
}));
|
|
8449
8444
|
}
|
|
8450
8445
|
/**
|
|
8451
8446
|
* access token to use basiq connect ui iframe
|
|
@@ -8458,15 +8453,11 @@ class BasiqService extends RestService {
|
|
|
8458
8453
|
return new BasiqToken(response['access_token'], new Date(now + response['expires_in'] * 1000));
|
|
8459
8454
|
}))
|
|
8460
8455
|
.subscribe((token) => {
|
|
8461
|
-
this.token = token;
|
|
8462
8456
|
this.tokenSubject.next(token);
|
|
8463
8457
|
});
|
|
8464
8458
|
}
|
|
8465
8459
|
return this.tokenSubject.asObservable();
|
|
8466
8460
|
}
|
|
8467
|
-
/**
|
|
8468
|
-
* Get list of user's bank conections
|
|
8469
|
-
*/
|
|
8470
8461
|
getConnections() {
|
|
8471
8462
|
return this.get().pipe(map((bankAccounts) => {
|
|
8472
8463
|
// get all connections
|
|
@@ -8477,40 +8468,6 @@ class BasiqService extends RestService {
|
|
|
8477
8468
|
return [...new Map(connections.map((connection) => [connection.id, connection])).values()];
|
|
8478
8469
|
}));
|
|
8479
8470
|
}
|
|
8480
|
-
/**
|
|
8481
|
-
* Listen response from basiq UI to handle result.
|
|
8482
|
-
* @param isBasiqConsentExist flag from User.ClientDetails - true if user confirmed basiq consent
|
|
8483
|
-
* @param callback function we run after basiq UI work is finished
|
|
8484
|
-
*/
|
|
8485
|
-
listenBasiqResponse(isBasiqConsentExist, callback) {
|
|
8486
|
-
window.addEventListener('message', (message) => {
|
|
8487
|
-
if (message.data !== FINISH_BASIQ_EVENT) {
|
|
8488
|
-
return;
|
|
8489
|
-
}
|
|
8490
|
-
// update user's basiq consent confirmation status for the first basiq ui run
|
|
8491
|
-
if (isBasiqConsentExist) {
|
|
8492
|
-
this.updateConnections().pipe(take(1)).subscribe();
|
|
8493
|
-
}
|
|
8494
|
-
else {
|
|
8495
|
-
this.confirmConsents().pipe(take(1)).subscribe();
|
|
8496
|
-
}
|
|
8497
|
-
callback();
|
|
8498
|
-
}, { once: true });
|
|
8499
|
-
}
|
|
8500
|
-
/**
|
|
8501
|
-
* Get URL with filled params to run basiq UI iframe
|
|
8502
|
-
*/
|
|
8503
|
-
generateBasiqConsentUrl(user) {
|
|
8504
|
-
return this.getToken().pipe(map((token) => {
|
|
8505
|
-
let url = BASIQ_CONSENT_URL;
|
|
8506
|
-
url = url.replace('USER_ID', user.basiqId);
|
|
8507
|
-
url = url.replace('TOKEN', token.value);
|
|
8508
|
-
if (!user.clientDetails.basiqConsentExist) {
|
|
8509
|
-
url = url.split('&action')[0];
|
|
8510
|
-
}
|
|
8511
|
-
return url;
|
|
8512
|
-
}));
|
|
8513
|
-
}
|
|
8514
8471
|
/**
|
|
8515
8472
|
* Listen to EventDispatcherService event related to added Bank connection
|
|
8516
8473
|
*/
|
|
@@ -8533,17 +8490,6 @@ class BasiqService extends RestService {
|
|
|
8533
8490
|
}
|
|
8534
8491
|
});
|
|
8535
8492
|
}
|
|
8536
|
-
/**
|
|
8537
|
-
* Update user's basiq connections when user confirmed basiq consent
|
|
8538
|
-
*/
|
|
8539
|
-
listenBasiqConcentUpdated() {
|
|
8540
|
-
this.eventDispatcherService.on(AppEventTypeEnum.BASIQ_CONSENT_UPDATED).subscribe((isConfirmed) => {
|
|
8541
|
-
if (!isConfirmed) {
|
|
8542
|
-
return;
|
|
8543
|
-
}
|
|
8544
|
-
this.updateConnections().pipe(take(1)).subscribe();
|
|
8545
|
-
});
|
|
8546
|
-
}
|
|
8547
8493
|
}
|
|
8548
8494
|
BasiqService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: BasiqService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
8549
8495
|
BasiqService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: BasiqService, providedIn: 'root' });
|