taxtank-core 0.16.9 → 0.16.12
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 +23 -96
- package/bundles/taxtank-core.umd.js.map +1 -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 +23 -92
- package/fesm2015/taxtank-core.js.map +1 -1
- 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
|
@@ -1621,6 +1621,9 @@ class IncomeSourceCollection extends Collection {
|
|
|
1621
1621
|
filterByTypes(types) {
|
|
1622
1622
|
return this.items.filter((incomeSource) => types.includes(incomeSource.type));
|
|
1623
1623
|
}
|
|
1624
|
+
getSalary() {
|
|
1625
|
+
return this.items.filter((incomeSource) => incomeSource.isSalaryIncome());
|
|
1626
|
+
}
|
|
1624
1627
|
/**
|
|
1625
1628
|
* Get income sources list of forecasts
|
|
1626
1629
|
*/
|
|
@@ -3176,10 +3179,9 @@ class IncomeSource$1 extends AbstractModel {
|
|
|
3176
3179
|
|
|
3177
3180
|
var IncomeSourceTypeEnum;
|
|
3178
3181
|
(function (IncomeSourceTypeEnum) {
|
|
3179
|
-
IncomeSourceTypeEnum[IncomeSourceTypeEnum["
|
|
3180
|
-
IncomeSourceTypeEnum[IncomeSourceTypeEnum["
|
|
3182
|
+
IncomeSourceTypeEnum[IncomeSourceTypeEnum["WORK"] = 1] = "WORK";
|
|
3183
|
+
IncomeSourceTypeEnum[IncomeSourceTypeEnum["SOLE"] = 2] = "SOLE";
|
|
3181
3184
|
IncomeSourceTypeEnum[IncomeSourceTypeEnum["OTHER"] = 3] = "OTHER";
|
|
3182
|
-
IncomeSourceTypeEnum[IncomeSourceTypeEnum["SOLE"] = 4] = "SOLE";
|
|
3183
3185
|
})(IncomeSourceTypeEnum || (IncomeSourceTypeEnum = {}));
|
|
3184
3186
|
|
|
3185
3187
|
class SalaryForecast$1 extends AbstractModel {
|
|
@@ -3222,13 +3224,9 @@ var SalaryForecastFrequencyEnum;
|
|
|
3222
3224
|
class IncomeSourceType$1 extends AbstractModel {
|
|
3223
3225
|
}
|
|
3224
3226
|
|
|
3225
|
-
var IncomeSourceTypeListSalaryEnum;
|
|
3226
|
-
(function (IncomeSourceTypeListSalaryEnum) {
|
|
3227
|
-
IncomeSourceTypeListSalaryEnum[IncomeSourceTypeListSalaryEnum["BONUSES"] = 1] = "BONUSES";
|
|
3228
|
-
})(IncomeSourceTypeListSalaryEnum || (IncomeSourceTypeListSalaryEnum = {}));
|
|
3229
|
-
|
|
3230
3227
|
var IncomeSourceTypeListWorkEnum;
|
|
3231
3228
|
(function (IncomeSourceTypeListWorkEnum) {
|
|
3229
|
+
IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["BONUSES"] = 1] = "BONUSES";
|
|
3232
3230
|
IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["DIRECTOR_FEES"] = 2] = "DIRECTOR_FEES";
|
|
3233
3231
|
IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["DIVIDENDS"] = 3] = "DIVIDENDS";
|
|
3234
3232
|
IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["INTEREST"] = 4] = "INTEREST";
|
|
@@ -3246,8 +3244,8 @@ var IncomeSourceTypeListOtherEnum;
|
|
|
3246
3244
|
})(IncomeSourceTypeListOtherEnum || (IncomeSourceTypeListOtherEnum = {}));
|
|
3247
3245
|
|
|
3248
3246
|
class IncomeSourceType extends IncomeSourceType$1 {
|
|
3249
|
-
|
|
3250
|
-
return
|
|
3247
|
+
isBonuses() {
|
|
3248
|
+
return this.id === IncomeSourceTypeListWorkEnum.BONUSES;
|
|
3251
3249
|
}
|
|
3252
3250
|
isWork() {
|
|
3253
3251
|
return !!IncomeSourceTypeListWorkEnum[this.id];
|
|
@@ -3256,12 +3254,11 @@ class IncomeSourceType extends IncomeSourceType$1 {
|
|
|
3256
3254
|
return !!IncomeSourceTypeListOtherEnum[this.id];
|
|
3257
3255
|
}
|
|
3258
3256
|
isSole() {
|
|
3257
|
+
// @TODO use IncomeSourceTypeListSoleEnum when sole tank ready
|
|
3259
3258
|
return !!IncomeSourceTypeListOtherEnum[this.id];
|
|
3260
3259
|
}
|
|
3261
3260
|
get type() {
|
|
3262
3261
|
switch (true) {
|
|
3263
|
-
case this.isSalary():
|
|
3264
|
-
return IncomeSourceTypeEnum.SALARY;
|
|
3265
3262
|
case this.isWork():
|
|
3266
3263
|
return IncomeSourceTypeEnum.WORK;
|
|
3267
3264
|
case this.isSole():
|
|
@@ -3299,7 +3296,9 @@ __decorate([
|
|
|
3299
3296
|
|
|
3300
3297
|
class IncomeSource extends IncomeSource$1 {
|
|
3301
3298
|
isSalaryIncome() {
|
|
3302
|
-
return this.
|
|
3299
|
+
return !!this.salaryForecasts.length;
|
|
3300
|
+
// @TODO Vik: old code
|
|
3301
|
+
// return this.type === IncomeSourceTypeEnum.SALARY;
|
|
3303
3302
|
}
|
|
3304
3303
|
isSoleIncome() {
|
|
3305
3304
|
return this.type === IncomeSourceTypeEnum.SOLE;
|
|
@@ -8050,11 +8049,11 @@ class AccountSetupService {
|
|
|
8050
8049
|
const batch = [];
|
|
8051
8050
|
// Salary item is completed when user added salary income source
|
|
8052
8051
|
if (incomeTypes.salary) {
|
|
8053
|
-
batch.push(this.create(AccountSetupItemsEnum.SALARY, this.
|
|
8052
|
+
batch.push(this.create(AccountSetupItemsEnum.SALARY, this.getIncomeSources(true)));
|
|
8054
8053
|
}
|
|
8055
8054
|
// Other income item is completed when user added at least one other income source
|
|
8056
8055
|
if (incomeTypes.dividends || incomeTypes.other) {
|
|
8057
|
-
batch.push(this.create(AccountSetupItemsEnum.OTHER_INCOME, this.
|
|
8056
|
+
batch.push(this.create(AccountSetupItemsEnum.OTHER_INCOME, this.getIncomeSources()));
|
|
8058
8057
|
}
|
|
8059
8058
|
// Rental income item is completed when user added at least one property
|
|
8060
8059
|
if (incomeTypes.property) {
|
|
@@ -8079,11 +8078,16 @@ class AccountSetupService {
|
|
|
8079
8078
|
return combineLatest(batch).pipe(map((items) => new AccountSetupItemCollection(items)));
|
|
8080
8079
|
}
|
|
8081
8080
|
/**
|
|
8082
|
-
* @TODO work with collection when services refactored
|
|
8081
|
+
* @TODO Alex: work with collection when services refactored
|
|
8082
|
+
* @TODO Vik: waiting for income sources refactoring
|
|
8083
8083
|
*/
|
|
8084
|
-
|
|
8084
|
+
getIncomeSources(isSalary = false) {
|
|
8085
8085
|
return this.incomeSourceService.get().pipe(map((incomeSources) => {
|
|
8086
|
-
|
|
8086
|
+
const collection = new IncomeSourceCollection(incomeSources);
|
|
8087
|
+
if (isSalary) {
|
|
8088
|
+
return collection.getSalary();
|
|
8089
|
+
}
|
|
8090
|
+
return collection.items.filter((incomeSource) => !incomeSource.isSalaryIncome() && !incomeSource.isSoleIncome());
|
|
8087
8091
|
}));
|
|
8088
8092
|
}
|
|
8089
8093
|
/**
|
|
@@ -8404,14 +8408,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
|
|
|
8404
8408
|
}]
|
|
8405
8409
|
}] });
|
|
8406
8410
|
|
|
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';
|
|
8411
|
+
// @TODO Basiq 1.0 remove if we will use basiq 2.0 or refactor if we stay with basiq 1.0
|
|
8415
8412
|
/**
|
|
8416
8413
|
* basiq is a middleman between bank and user
|
|
8417
8414
|
* service is responsible for fetching bank related information
|
|
@@ -8429,23 +8426,6 @@ class BasiqService extends RestService {
|
|
|
8429
8426
|
listenEvents() {
|
|
8430
8427
|
this.listenToBankConnectionAdded();
|
|
8431
8428
|
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
8429
|
}
|
|
8450
8430
|
/**
|
|
8451
8431
|
* access token to use basiq connect ui iframe
|
|
@@ -8458,15 +8438,11 @@ class BasiqService extends RestService {
|
|
|
8458
8438
|
return new BasiqToken(response['access_token'], new Date(now + response['expires_in'] * 1000));
|
|
8459
8439
|
}))
|
|
8460
8440
|
.subscribe((token) => {
|
|
8461
|
-
this.token = token;
|
|
8462
8441
|
this.tokenSubject.next(token);
|
|
8463
8442
|
});
|
|
8464
8443
|
}
|
|
8465
8444
|
return this.tokenSubject.asObservable();
|
|
8466
8445
|
}
|
|
8467
|
-
/**
|
|
8468
|
-
* Get list of user's bank conections
|
|
8469
|
-
*/
|
|
8470
8446
|
getConnections() {
|
|
8471
8447
|
return this.get().pipe(map((bankAccounts) => {
|
|
8472
8448
|
// get all connections
|
|
@@ -8477,40 +8453,6 @@ class BasiqService extends RestService {
|
|
|
8477
8453
|
return [...new Map(connections.map((connection) => [connection.id, connection])).values()];
|
|
8478
8454
|
}));
|
|
8479
8455
|
}
|
|
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
|
-
});
|
|
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
8456
|
/**
|
|
8515
8457
|
* Listen to EventDispatcherService event related to added Bank connection
|
|
8516
8458
|
*/
|
|
@@ -8533,17 +8475,6 @@ class BasiqService extends RestService {
|
|
|
8533
8475
|
}
|
|
8534
8476
|
});
|
|
8535
8477
|
}
|
|
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
8478
|
}
|
|
8548
8479
|
BasiqService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: BasiqService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
8549
8480
|
BasiqService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: BasiqService, providedIn: 'root' });
|