taxtank-core 0.16.5 → 0.16.8

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.
@@ -3951,8 +3951,7 @@
3951
3951
  exports.PropertyCategoryListEnum = void 0;
3952
3952
  (function (PropertyCategoryListEnum) {
3953
3953
  PropertyCategoryListEnum[PropertyCategoryListEnum["OWNER_OCCUPIED"] = 3] = "OWNER_OCCUPIED";
3954
- // @TODO prod use 5
3955
- PropertyCategoryListEnum[PropertyCategoryListEnum["VACANT_LAND"] = 6] = "VACANT_LAND";
3954
+ PropertyCategoryListEnum[PropertyCategoryListEnum["VACANT_LAND"] = 5] = "VACANT_LAND";
3956
3955
  })(exports.PropertyCategoryListEnum || (exports.PropertyCategoryListEnum = {}));
3957
3956
 
3958
3957
  exports.TaxExemptionMetadataEnum = void 0;
@@ -4372,10 +4371,10 @@
4372
4371
  return IncomeSourceType;
4373
4372
  }(AbstractModel));
4374
4373
 
4375
- exports.IncomeSourceTypeListSalaryEnum = void 0;
4374
+ var IncomeSourceTypeListSalaryEnum;
4376
4375
  (function (IncomeSourceTypeListSalaryEnum) {
4377
4376
  IncomeSourceTypeListSalaryEnum[IncomeSourceTypeListSalaryEnum["BONUSES"] = 1] = "BONUSES";
4378
- })(exports.IncomeSourceTypeListSalaryEnum || (exports.IncomeSourceTypeListSalaryEnum = {}));
4377
+ })(IncomeSourceTypeListSalaryEnum || (IncomeSourceTypeListSalaryEnum = {}));
4379
4378
 
4380
4379
  exports.IncomeSourceTypeListWorkEnum = void 0;
4381
4380
  (function (IncomeSourceTypeListWorkEnum) {
@@ -4401,7 +4400,7 @@
4401
4400
  return _super !== null && _super.apply(this, arguments) || this;
4402
4401
  }
4403
4402
  IncomeSourceType.prototype.isSalary = function () {
4404
- return !!exports.IncomeSourceTypeListSalaryEnum[this.id];
4403
+ return !!IncomeSourceTypeListSalaryEnum[this.id];
4405
4404
  };
4406
4405
  IncomeSourceType.prototype.isWork = function () {
4407
4406
  return !!exports.IncomeSourceTypeListWorkEnum[this.id];
@@ -6090,6 +6089,11 @@
6090
6089
  DepreciationWriteOffAmountEnum[DepreciationWriteOffAmountEnum["BORROWING_EXPENSES"] = 100] = "BORROWING_EXPENSES";
6091
6090
  })(exports.DepreciationWriteOffAmountEnum || (exports.DepreciationWriteOffAmountEnum = {}));
6092
6091
 
6092
+ exports.IncomeSourceTypeListSoleEnum = void 0;
6093
+ (function (IncomeSourceTypeListSoleEnum) {
6094
+ IncomeSourceTypeListSoleEnum[IncomeSourceTypeListSoleEnum["SOLE_TRADER"] = 7] = "SOLE_TRADER";
6095
+ })(exports.IncomeSourceTypeListSoleEnum || (exports.IncomeSourceTypeListSoleEnum = {}));
6096
+
6093
6097
  exports.InviteStatusEnum = void 0;
6094
6098
  (function (InviteStatusEnum) {
6095
6099
  InviteStatusEnum[InviteStatusEnum["PENDING"] = 1] = "PENDING";
@@ -8897,7 +8901,7 @@
8897
8901
  clientIncomeTypes: ['sole']
8898
8902
  }),
8899
8903
  _a[AccountSetupItemsEnum.TRANSACTION] = classTransformer.plainToClass(AccountSetupItem, {
8900
- title: 'Allocation transactions',
8904
+ title: 'Allocate transactions',
8901
8905
  description: 'Select one or multiple transactions, the category from the dropdown and attach your receipt. It’s that simple to capture every possible deduction, and keep organised all throughout the year.',
8902
8906
  url: '/client/bank-feeds',
8903
8907
  urlFragment: 'allocationProductTour',
@@ -8916,6 +8920,8 @@
8916
8920
  ClientIncomeTypesService.prototype.get = function () {
8917
8921
  var _this = this;
8918
8922
  if (!this.cache) {
8923
+ // @TODO alex fix everywhere, start with rest service
8924
+ this.cache = classTransformer.plainToClass(ClientIncomeTypes, {});
8919
8925
  this.http.get(this.environment.apiV2 + "/client-income-types")
8920
8926
  .pipe(operators.map(function (response) {
8921
8927
  return classTransformer.plainToClass(ClientIncomeTypes, response['hydra:member'][0], { excludePrefixes: ['@'] });
@@ -9054,6 +9060,7 @@
9054
9060
  */
9055
9061
  RestService.prototype.get = function () {
9056
9062
  if (!this.cache) {
9063
+ this.cache = [];
9057
9064
  this.fetch().subscribe();
9058
9065
  }
9059
9066
  return this.cacheSubject.asObservable();
@@ -10043,12 +10050,22 @@
10043
10050
  AccountSetupService.prototype.get = function () {
10044
10051
  var _this = this;
10045
10052
  if (!this.cache) {
10046
- this.clientIncomeTypesService.get().subscribe(function (incomeTypes) {
10053
+ this.cache = new AccountSetupItemCollection([]);
10054
+ this.clientIncomeTypesService.get()
10055
+ .pipe(
10056
+ // we need account setup only when user selected at least one income type
10057
+ operators.filter(function (incomeTypes) { return !!incomeTypes.length; }), operators.mergeMap(function (incomeTypes) {
10047
10058
  _this.clientIncomeTypesId = incomeTypes.id;
10048
- rxjs.combineLatest(_this.createBatch(incomeTypes)).subscribe(function (items) {
10049
- _this.cache = new AccountSetupItemCollection(items);
10050
- _this.cacheSubject.next(_this.cache);
10051
- });
10059
+ return _this.createBatch(incomeTypes);
10060
+ }))
10061
+ .subscribe(function (items) {
10062
+ switch (true) {
10063
+ case !_this.cache:
10064
+ case _this.cache.getBy('isCompleted', true).length !== items.getBy('isCompleted', true).length:
10065
+ case _this.cache.length !== items.length:
10066
+ _this.cache = cloneDeep__default["default"](items);
10067
+ _this.cacheSubject.next(_this.cache);
10068
+ }
10052
10069
  });
10053
10070
  }
10054
10071
  return this.cacheSubject.asObservable();
@@ -10068,6 +10085,9 @@
10068
10085
  if (result.length) {
10069
10086
  item.isCompleted = true;
10070
10087
  }
10088
+ else {
10089
+ item.isCompleted = false;
10090
+ }
10071
10091
  return item;
10072
10092
  }));
10073
10093
  };
@@ -10079,7 +10099,7 @@
10079
10099
  var batch = [];
10080
10100
  // Salary item is completed when user added salary income source
10081
10101
  if (incomeTypes.salary) {
10082
- batch.push(this.create(AccountSetupItemsEnum.SALARY, this.getIncomeSourcesByType(exports.IncomeSourceTypeEnum.SALARY)));
10102
+ batch.push(this.create(AccountSetupItemsEnum.SALARY, this.getIncomeSourcesByType(exports.IncomeSourceTypeEnum.WORK)));
10083
10103
  }
10084
10104
  // Other income item is completed when user added at least one other income source
10085
10105
  if (incomeTypes.dividends || incomeTypes.other) {
@@ -10105,7 +10125,7 @@
10105
10125
  // }
10106
10126
  // Allocation item is completed when user added at least one transaction allocation
10107
10127
  batch.push(this.create(AccountSetupItemsEnum.TRANSACTION, this.transactionAllocationService.get()));
10108
- return batch;
10128
+ return rxjs.combineLatest(batch).pipe(operators.map(function (items) { return new AccountSetupItemCollection(items); }));
10109
10129
  };
10110
10130
  /**
10111
10131
  * @TODO work with collection when services refactored
@@ -10119,15 +10139,15 @@
10119
10139
  * Show logbook item when user has at least 1 vehicle transaction
10120
10140
  */
10121
10141
  AccountSetupService.prototype.getLogbookItem = function () {
10122
- return rxjs.combineLatest([
10123
- this.transactionService.get(),
10124
- this.create(AccountSetupItemsEnum.WORK_LOGBOOK, this.vehicleClaimService.get())
10125
- ]).pipe(operators.map(function (_a) {
10126
- var _b = __read(_a, 2), transactions = _b[0], item = _b[1];
10127
- if (new TransactionCollection(transactions).getVehicleTransactions().length) {
10128
- return item;
10142
+ var _this = this;
10143
+ return this.transactionService.get()
10144
+ .pipe(
10145
+ // @TODO Alex: remove map when services start work with collections
10146
+ operators.map(function (transactions) { return new TransactionCollection(transactions); }), operators.mergeMap(function (transactions) {
10147
+ if (transactions.getVehicleTransactions().length) {
10148
+ return _this.create(AccountSetupItemsEnum.WORK_LOGBOOK, _this.vehicleClaimService.get());
10129
10149
  }
10130
- return null;
10150
+ return rxjs.of(null);
10131
10151
  }));
10132
10152
  };
10133
10153
  return AccountSetupService;
@@ -10462,6 +10482,14 @@
10462
10482
  }]
10463
10483
  }] });
10464
10484
 
10485
+ /**
10486
+ * Basiq consent UI initial URL. Replace USER_ID and TOKEN by user data + handle action parameter
10487
+ */
10488
+ var BASIQ_CONSENT_URL = 'https://consent.basiq.io/home?userId=USER_ID&token=TOKEN&action=connect';
10489
+ /**
10490
+ * Event message name we listen to handle basiq UI result
10491
+ */
10492
+ var FINISH_BASIQ_EVENT = 'finish-basiq';
10465
10493
  /**
10466
10494
  * basiq is a middleman between bank and user
10467
10495
  * service is responsible for fetching bank related information
@@ -10481,6 +10509,7 @@
10481
10509
  BasiqService.prototype.listenEvents = function () {
10482
10510
  this.listenToBankConnectionAdded();
10483
10511
  this.listenNotifications();
10512
+ this.listenBasiqConcentUpdated();
10484
10513
  };
10485
10514
  /**
10486
10515
  * Update user's basiq consents data on backend
@@ -10489,7 +10518,6 @@
10489
10518
  var _this = this;
10490
10519
  return this.http.put(this.environment.apiV2 + "/basiq/consents", {}).pipe(operators.map(function (isConfirmed) {
10491
10520
  _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.BASIQ_CONSENT_UPDATED, isConfirmed));
10492
- return isConfirmed;
10493
10521
  }));
10494
10522
  };
10495
10523
  /**
@@ -10516,6 +10544,9 @@
10516
10544
  }
10517
10545
  return this.tokenSubject.asObservable();
10518
10546
  };
10547
+ /**
10548
+ * Get list of user's bank conections
10549
+ */
10519
10550
  BasiqService.prototype.getConnections = function () {
10520
10551
  return this.get().pipe(operators.map(function (bankAccounts) {
10521
10552
  // get all connections
@@ -10526,6 +10557,41 @@
10526
10557
  return __spreadArray([], __read(new Map(connections.map(function (connection) { return [connection.id, connection]; })).values()));
10527
10558
  }));
10528
10559
  };
10560
+ /**
10561
+ * Listen response from basiq UI to handle result.
10562
+ * @param isBasiqConsentExist flag from User.ClientDetails - true if user confirmed basiq consent
10563
+ * @param callback function we run after basiq UI work is finished
10564
+ */
10565
+ BasiqService.prototype.listenBasiqResponse = function (isBasiqConsentExist, callback) {
10566
+ var _this = this;
10567
+ window.addEventListener('message', function (message) {
10568
+ if (message.data !== FINISH_BASIQ_EVENT) {
10569
+ return;
10570
+ }
10571
+ // update user's basiq consent confirmation status for the first basiq ui run
10572
+ if (isBasiqConsentExist) {
10573
+ _this.updateConnections().pipe(operators.take(1)).subscribe();
10574
+ }
10575
+ else {
10576
+ _this.confirmConsents().pipe(operators.take(1)).subscribe();
10577
+ }
10578
+ callback();
10579
+ });
10580
+ };
10581
+ /**
10582
+ * Get URL with filled params to run basiq UI iframe
10583
+ */
10584
+ BasiqService.prototype.generateBasiqConsentUrl = function (user) {
10585
+ return this.getToken().pipe(operators.map(function (token) {
10586
+ var url = BASIQ_CONSENT_URL;
10587
+ url = url.replace('USER_ID', user.basiqId);
10588
+ url = url.replace('TOKEN', token.value);
10589
+ if (!user.clientDetails.basiqConsentExist) {
10590
+ url = url.split('&action')[0];
10591
+ }
10592
+ return url;
10593
+ }));
10594
+ };
10529
10595
  /**
10530
10596
  * Listen to EventDispatcherService event related to added Bank connection
10531
10597
  */
@@ -10550,6 +10616,18 @@
10550
10616
  }
10551
10617
  });
10552
10618
  };
10619
+ /**
10620
+ * Update user's basiq connections when user confirmed basiq consent
10621
+ */
10622
+ BasiqService.prototype.listenBasiqConcentUpdated = function () {
10623
+ var _this = this;
10624
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.BASIQ_CONSENT_UPDATED).subscribe(function (isConfirmed) {
10625
+ if (!isConfirmed) {
10626
+ return;
10627
+ }
10628
+ _this.updateConnections().pipe(operators.take(1)).subscribe();
10629
+ });
10630
+ };
10553
10631
  return BasiqService;
10554
10632
  }(RestService));
10555
10633
  BasiqService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BasiqService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });