taxtank-core 0.16.7 → 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.
@@ -4371,10 +4371,10 @@
4371
4371
  return IncomeSourceType;
4372
4372
  }(AbstractModel));
4373
4373
 
4374
- exports.IncomeSourceTypeListSalaryEnum = void 0;
4374
+ var IncomeSourceTypeListSalaryEnum;
4375
4375
  (function (IncomeSourceTypeListSalaryEnum) {
4376
4376
  IncomeSourceTypeListSalaryEnum[IncomeSourceTypeListSalaryEnum["BONUSES"] = 1] = "BONUSES";
4377
- })(exports.IncomeSourceTypeListSalaryEnum || (exports.IncomeSourceTypeListSalaryEnum = {}));
4377
+ })(IncomeSourceTypeListSalaryEnum || (IncomeSourceTypeListSalaryEnum = {}));
4378
4378
 
4379
4379
  exports.IncomeSourceTypeListWorkEnum = void 0;
4380
4380
  (function (IncomeSourceTypeListWorkEnum) {
@@ -4400,7 +4400,7 @@
4400
4400
  return _super !== null && _super.apply(this, arguments) || this;
4401
4401
  }
4402
4402
  IncomeSourceType.prototype.isSalary = function () {
4403
- return !!exports.IncomeSourceTypeListSalaryEnum[this.id];
4403
+ return !!IncomeSourceTypeListSalaryEnum[this.id];
4404
4404
  };
4405
4405
  IncomeSourceType.prototype.isWork = function () {
4406
4406
  return !!exports.IncomeSourceTypeListWorkEnum[this.id];
@@ -6089,6 +6089,11 @@
6089
6089
  DepreciationWriteOffAmountEnum[DepreciationWriteOffAmountEnum["BORROWING_EXPENSES"] = 100] = "BORROWING_EXPENSES";
6090
6090
  })(exports.DepreciationWriteOffAmountEnum || (exports.DepreciationWriteOffAmountEnum = {}));
6091
6091
 
6092
+ exports.IncomeSourceTypeListSoleEnum = void 0;
6093
+ (function (IncomeSourceTypeListSoleEnum) {
6094
+ IncomeSourceTypeListSoleEnum[IncomeSourceTypeListSoleEnum["SOLE_TRADER"] = 7] = "SOLE_TRADER";
6095
+ })(exports.IncomeSourceTypeListSoleEnum || (exports.IncomeSourceTypeListSoleEnum = {}));
6096
+
6092
6097
  exports.InviteStatusEnum = void 0;
6093
6098
  (function (InviteStatusEnum) {
6094
6099
  InviteStatusEnum[InviteStatusEnum["PENDING"] = 1] = "PENDING";
@@ -8896,7 +8901,7 @@
8896
8901
  clientIncomeTypes: ['sole']
8897
8902
  }),
8898
8903
  _a[AccountSetupItemsEnum.TRANSACTION] = classTransformer.plainToClass(AccountSetupItem, {
8899
- title: 'Allocation transactions',
8904
+ title: 'Allocate transactions',
8900
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.',
8901
8906
  url: '/client/bank-feeds',
8902
8907
  urlFragment: 'allocationProductTour',
@@ -8915,6 +8920,8 @@
8915
8920
  ClientIncomeTypesService.prototype.get = function () {
8916
8921
  var _this = this;
8917
8922
  if (!this.cache) {
8923
+ // @TODO alex fix everywhere, start with rest service
8924
+ this.cache = classTransformer.plainToClass(ClientIncomeTypes, {});
8918
8925
  this.http.get(this.environment.apiV2 + "/client-income-types")
8919
8926
  .pipe(operators.map(function (response) {
8920
8927
  return classTransformer.plainToClass(ClientIncomeTypes, response['hydra:member'][0], { excludePrefixes: ['@'] });
@@ -9053,6 +9060,7 @@
9053
9060
  */
9054
9061
  RestService.prototype.get = function () {
9055
9062
  if (!this.cache) {
9063
+ this.cache = [];
9056
9064
  this.fetch().subscribe();
9057
9065
  }
9058
9066
  return this.cacheSubject.asObservable();
@@ -10042,12 +10050,22 @@
10042
10050
  AccountSetupService.prototype.get = function () {
10043
10051
  var _this = this;
10044
10052
  if (!this.cache) {
10045
- 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) {
10046
10058
  _this.clientIncomeTypesId = incomeTypes.id;
10047
- rxjs.combineLatest(_this.createBatch(incomeTypes)).subscribe(function (items) {
10048
- _this.cache = new AccountSetupItemCollection(items);
10049
- _this.cacheSubject.next(_this.cache);
10050
- });
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
+ }
10051
10069
  });
10052
10070
  }
10053
10071
  return this.cacheSubject.asObservable();
@@ -10067,6 +10085,9 @@
10067
10085
  if (result.length) {
10068
10086
  item.isCompleted = true;
10069
10087
  }
10088
+ else {
10089
+ item.isCompleted = false;
10090
+ }
10070
10091
  return item;
10071
10092
  }));
10072
10093
  };
@@ -10078,7 +10099,7 @@
10078
10099
  var batch = [];
10079
10100
  // Salary item is completed when user added salary income source
10080
10101
  if (incomeTypes.salary) {
10081
- batch.push(this.create(AccountSetupItemsEnum.SALARY, this.getIncomeSourcesByType(exports.IncomeSourceTypeEnum.SALARY)));
10102
+ batch.push(this.create(AccountSetupItemsEnum.SALARY, this.getIncomeSourcesByType(exports.IncomeSourceTypeEnum.WORK)));
10082
10103
  }
10083
10104
  // Other income item is completed when user added at least one other income source
10084
10105
  if (incomeTypes.dividends || incomeTypes.other) {
@@ -10104,7 +10125,7 @@
10104
10125
  // }
10105
10126
  // Allocation item is completed when user added at least one transaction allocation
10106
10127
  batch.push(this.create(AccountSetupItemsEnum.TRANSACTION, this.transactionAllocationService.get()));
10107
- return batch;
10128
+ return rxjs.combineLatest(batch).pipe(operators.map(function (items) { return new AccountSetupItemCollection(items); }));
10108
10129
  };
10109
10130
  /**
10110
10131
  * @TODO work with collection when services refactored
@@ -10118,15 +10139,15 @@
10118
10139
  * Show logbook item when user has at least 1 vehicle transaction
10119
10140
  */
10120
10141
  AccountSetupService.prototype.getLogbookItem = function () {
10121
- return rxjs.combineLatest([
10122
- this.transactionService.get(),
10123
- this.create(AccountSetupItemsEnum.WORK_LOGBOOK, this.vehicleClaimService.get())
10124
- ]).pipe(operators.map(function (_a) {
10125
- var _b = __read(_a, 2), transactions = _b[0], item = _b[1];
10126
- if (new TransactionCollection(transactions).getVehicleTransactions().length) {
10127
- 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());
10128
10149
  }
10129
- return null;
10150
+ return rxjs.of(null);
10130
10151
  }));
10131
10152
  };
10132
10153
  return AccountSetupService;