taxtank-core 0.4.1 → 0.5.2-1

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.
Files changed (33) hide show
  1. package/bundles/taxtank-core.umd.js +122 -2
  2. package/bundles/taxtank-core.umd.js.map +1 -1
  3. package/esm2015/lib/collections/income-source.collection.js +1 -1
  4. package/esm2015/lib/db/Enums/income-source-type.enum.js +2 -1
  5. package/esm2015/lib/db/Enums/tank-type.enum.js +1 -1
  6. package/esm2015/lib/db/Models/income-source.js +1 -1
  7. package/esm2015/lib/db/Models/sole-forecast.js +3 -0
  8. package/esm2015/lib/interfaces/income-source-forecast.interface.js +1 -1
  9. package/esm2015/lib/models/income-source/income-source-forecast.js +1 -1
  10. package/esm2015/lib/models/income-source/income-source-type.js +6 -1
  11. package/esm2015/lib/models/income-source/income-source.js +9 -2
  12. package/esm2015/lib/models/income-source/salary-forecast.js +1 -1
  13. package/esm2015/lib/models/income-source/sole-forecast.js +10 -0
  14. package/esm2015/lib/services/income-source/sole-forecast.service.js +87 -0
  15. package/esm2015/lib/services/transaction/transaction-allocation.service.js +8 -2
  16. package/esm2015/public-api.js +3 -2
  17. package/fesm2015/taxtank-core.js +106 -3
  18. package/fesm2015/taxtank-core.js.map +1 -1
  19. package/lib/collections/income-source.collection.d.ts +2 -2
  20. package/lib/db/Enums/income-source-type.enum.d.ts +2 -1
  21. package/lib/db/Models/income-source.d.ts +2 -0
  22. package/lib/db/Models/sole-forecast.d.ts +8 -0
  23. package/lib/interfaces/income-source-forecast.interface.d.ts +5 -2
  24. package/lib/models/income-source/income-source-forecast.d.ts +1 -2
  25. package/lib/models/income-source/income-source-type.d.ts +1 -0
  26. package/lib/models/income-source/income-source.d.ts +4 -2
  27. package/lib/models/income-source/salary-forecast.d.ts +1 -2
  28. package/lib/models/income-source/sole-forecast.d.ts +10 -0
  29. package/lib/services/income-source/sole-forecast.service.d.ts +33 -0
  30. package/package.json +1 -1
  31. package/public-api.d.ts +2 -1
  32. package/esm2015/lib/interfaces/salary-forecast.interface.js +0 -2
  33. package/lib/interfaces/salary-forecast.interface.d.ts +0 -16
@@ -3145,6 +3145,7 @@
3145
3145
  IncomeSourceTypeEnum[IncomeSourceTypeEnum["SALARY"] = 1] = "SALARY";
3146
3146
  IncomeSourceTypeEnum[IncomeSourceTypeEnum["WORK"] = 2] = "WORK";
3147
3147
  IncomeSourceTypeEnum[IncomeSourceTypeEnum["OTHER"] = 3] = "OTHER";
3148
+ IncomeSourceTypeEnum[IncomeSourceTypeEnum["SOLE"] = 4] = "SOLE";
3148
3149
  })(exports.IncomeSourceTypeEnum || (exports.IncomeSourceTypeEnum = {}));
3149
3150
 
3150
3151
  exports.IncomeSourceTypeListOtherEnum = void 0;
@@ -5112,6 +5113,23 @@
5112
5113
  classTransformer.Type(function () { return IncomeSource; })
5113
5114
  ], SalaryForecast.prototype, "incomeSource", void 0);
5114
5115
 
5116
+ var SoleForecast$1 = /** @class */ (function () {
5117
+ function SoleForecast() {
5118
+ }
5119
+ return SoleForecast;
5120
+ }());
5121
+
5122
+ var SoleForecast = /** @class */ (function (_super) {
5123
+ __extends(SoleForecast, _super);
5124
+ function SoleForecast() {
5125
+ return _super !== null && _super.apply(this, arguments) || this;
5126
+ }
5127
+ return SoleForecast;
5128
+ }(SoleForecast$1));
5129
+ __decorate([
5130
+ classTransformer.Type(function () { return IncomeSource; })
5131
+ ], SoleForecast.prototype, "incomeSource", void 0);
5132
+
5115
5133
  var IncomeSourceForecast$1 = /** @class */ (function () {
5116
5134
  function IncomeSourceForecast() {
5117
5135
  }
@@ -5138,6 +5156,9 @@
5138
5156
  IncomeSourceType.prototype.isOther = function () {
5139
5157
  return !!exports.IncomeSourceTypeListOtherEnum[this.id];
5140
5158
  };
5159
+ IncomeSourceType.prototype.isSole = function () {
5160
+ return !!exports.IncomeSourceTypeListOtherEnum[this.id];
5161
+ };
5141
5162
  Object.defineProperty(IncomeSourceType.prototype, "type", {
5142
5163
  get: function () {
5143
5164
  switch (true) {
@@ -5145,6 +5166,8 @@
5145
5166
  return exports.IncomeSourceTypeEnum.SALARY;
5146
5167
  case this.isWork():
5147
5168
  return exports.IncomeSourceTypeEnum.WORK;
5169
+ case this.isSole():
5170
+ return exports.IncomeSourceTypeEnum.SOLE;
5148
5171
  default:
5149
5172
  return exports.IncomeSourceTypeEnum.OTHER;
5150
5173
  }
@@ -5199,6 +5222,9 @@
5199
5222
  IncomeSource.prototype.isSalaryIncome = function () {
5200
5223
  return this.type === exports.IncomeSourceTypeEnum.SALARY;
5201
5224
  };
5225
+ IncomeSource.prototype.isSoleIncome = function () {
5226
+ return this.type === exports.IncomeSourceTypeEnum.SOLE;
5227
+ };
5202
5228
  IncomeSource.prototype.isWorkIncome = function () {
5203
5229
  return this.type === exports.IncomeSourceTypeEnum.WORK;
5204
5230
  };
@@ -5210,7 +5236,7 @@
5210
5236
  * Get salary and other income forecasts
5211
5237
  */
5212
5238
  get: function () {
5213
- return __spreadArray(__spreadArray([], __read(this.salaryForecasts)), __read(this.incomeSourceForecasts));
5239
+ return __spreadArray(__spreadArray(__spreadArray([], __read(this.salaryForecasts)), __read(this.incomeSourceForecasts)), __read(this.soleForecasts));
5214
5240
  },
5215
5241
  enumerable: false,
5216
5242
  configurable: true
@@ -5238,6 +5264,9 @@
5238
5264
  __decorate([
5239
5265
  classTransformer.Type(function () { return SalaryForecast; })
5240
5266
  ], IncomeSource.prototype, "salaryForecasts", void 0);
5267
+ __decorate([
5268
+ classTransformer.Type(function () { return SoleForecast; })
5269
+ ], IncomeSource.prototype, "soleForecasts", void 0);
5241
5270
  __decorate([
5242
5271
  classTransformer.Type(function () { return IncomeSourceForecast; })
5243
5272
  ], IncomeSource.prototype, "incomeSourceForecasts", void 0);
@@ -10092,6 +10121,89 @@
10092
10121
  }] }];
10093
10122
  } });
10094
10123
 
10124
+ var SoleForecastService = /** @class */ (function (_super) {
10125
+ __extends(SoleForecastService, _super);
10126
+ function SoleForecastService(http, eventDispatcherService, environment) {
10127
+ var _this = _super.call(this, http, eventDispatcherService, environment) || this;
10128
+ _this.http = http;
10129
+ _this.eventDispatcherService = eventDispatcherService;
10130
+ _this.environment = environment;
10131
+ _this.modelClass = SoleForecast;
10132
+ _this.url = 'sole-forecasts';
10133
+ _this.listenEvents();
10134
+ return _this;
10135
+ }
10136
+ /**
10137
+ * Listen to Income Sources events
10138
+ */
10139
+ SoleForecastService.prototype.listenEvents = function () {
10140
+ this.listenToAddedIncomeSources();
10141
+ this.listenToUpdatedIncomeSources();
10142
+ };
10143
+ /**
10144
+ * Listen to EventDispatcherService event related to added Income Sources
10145
+ */
10146
+ SoleForecastService.prototype.listenToAddedIncomeSources = function () {
10147
+ var _this = this;
10148
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.INCOME_SOURCES_CREATED)
10149
+ .pipe(operators.map(function (incomeSources) { return incomeSources
10150
+ .filter(function (incomeSource) { return incomeSource.isSoleIncome(); }); }))
10151
+ .subscribe(function (incomeSources) {
10152
+ var soleForecasts = _this.assignSoleForecasts(incomeSources);
10153
+ if (soleForecasts.length) {
10154
+ _this.addBatch(soleForecasts).subscribe(function (createdSoleForecasts) {
10155
+ _this.eventDispatcherService
10156
+ .dispatch(new AppEvent(exports.AppEventTypeEnum.INCOME_SOURCES_FORECASTS_CREATED, createdSoleForecasts));
10157
+ });
10158
+ }
10159
+ });
10160
+ };
10161
+ /**
10162
+ * Listen to EventDispatcherService event related to updated Income Sources
10163
+ */
10164
+ SoleForecastService.prototype.listenToUpdatedIncomeSources = function () {
10165
+ var _this = this;
10166
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.INCOME_SOURCES_UPDATED)
10167
+ .subscribe(function (incomeSources) {
10168
+ var soleForecasts = _this.assignSoleForecasts(incomeSources);
10169
+ if (soleForecasts.length) {
10170
+ _this.updateBatch(soleForecasts).subscribe(function (updatedSoleForecasts) {
10171
+ _this.eventDispatcherService
10172
+ .dispatch(new AppEvent(exports.AppEventTypeEnum.INCOME_SOURCES_FORECASTS_UPDATED, updatedSoleForecasts));
10173
+ });
10174
+ }
10175
+ });
10176
+ };
10177
+ /**
10178
+ * Assign sole forecasts based on provided income sources
10179
+ * @param incomeSources by which sole forecasts will be assigned
10180
+ */
10181
+ SoleForecastService.prototype.assignSoleForecasts = function (incomeSources) {
10182
+ return incomeSources.map(function (incomeSource) {
10183
+ incomeSource.soleForecasts = incomeSource.soleForecasts
10184
+ .map(function (soleForecast) {
10185
+ soleForecast.incomeSource = classTransformer.plainToClass(IncomeSource, { id: incomeSource.id });
10186
+ return soleForecast;
10187
+ });
10188
+ return incomeSource.soleForecasts;
10189
+ }).flat();
10190
+ };
10191
+ return SoleForecastService;
10192
+ }(BaseRestService));
10193
+ SoleForecastService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleForecastService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
10194
+ SoleForecastService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleForecastService, providedIn: 'root' });
10195
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleForecastService, decorators: [{
10196
+ type: i0.Injectable,
10197
+ args: [{
10198
+ providedIn: 'root'
10199
+ }]
10200
+ }], ctorParameters: function () {
10201
+ return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
10202
+ type: i0.Inject,
10203
+ args: ['environment']
10204
+ }] }];
10205
+ } });
10206
+
10095
10207
  /**
10096
10208
  * Service to work with intercom
10097
10209
  */
@@ -11775,7 +11887,11 @@
11775
11887
  */
11776
11888
  TransactionAllocationService.prototype.onTransactionsCreated = function () {
11777
11889
  var _this = this;
11778
- this.eventDispatcherService.on(exports.AppEventTypeEnum.TRANSACTIONS_CREATED).subscribe(function () {
11890
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.TRANSACTIONS_CREATED).subscribe(function (transactions) {
11891
+ // @TODO Alex hack: research and refactor cache update logic, dont reset cache each time transactions changed
11892
+ if (transactions[0].isTransfer) {
11893
+ return;
11894
+ }
11779
11895
  // Update allocations cache to synchronize data and fire subscriptions
11780
11896
  _this.resetCache();
11781
11897
  });
@@ -11786,6 +11902,7 @@
11786
11902
  TransactionAllocationService.prototype.onDepreciationCreated = function () {
11787
11903
  var _this = this;
11788
11904
  this.eventDispatcherService.on(exports.AppEventTypeEnum.DEPRECIATIONS_CREATED).subscribe(function () {
11905
+ // @TODO Alex hack: research and refactor cache update logic, dont reset cache each time depreciations changed
11789
11906
  // Update allocations cache to synchronize data and fire subscriptions
11790
11907
  _this.resetCache();
11791
11908
  });
@@ -11796,6 +11913,7 @@
11796
11913
  TransactionAllocationService.prototype.onTransactionDeleted = function () {
11797
11914
  var _this = this;
11798
11915
  this.eventDispatcherService.on(exports.AppEventTypeEnum.TRANSACTION_DELETED).subscribe(function () {
11916
+ // @TODO Alex hack: research and refactor cache update logic, dont reset cache each time transactions changed
11799
11917
  // Update allocations cache to synchronize data and fire subscriptions
11800
11918
  _this.resetCache();
11801
11919
  });
@@ -12629,6 +12747,8 @@
12629
12747
  exports.ServiceSubscription = ServiceSubscription;
12630
12748
  exports.ServiceSubscriptionCollection = ServiceSubscriptionCollection;
12631
12749
  exports.ServiceSubscriptionItem = ServiceSubscriptionItem;
12750
+ exports.SoleForecast = SoleForecast;
12751
+ exports.SoleForecastService = SoleForecastService;
12632
12752
  exports.SseService = SseService;
12633
12753
  exports.SubscriptionService = SubscriptionService;
12634
12754
  exports.TYPE_LOAN = TYPE_LOAN;