taxtank-core 0.28.11 → 0.28.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.
@@ -4005,13 +4005,13 @@
4005
4005
  // return this.type === IncomeSourceTypeEnum.SALARY;
4006
4006
  };
4007
4007
  IncomeSource.prototype.isSoleIncome = function () {
4008
- return this.type === exports.IncomeSourceTypeEnum.SOLE;
4008
+ return !!this.soleForecasts.length;
4009
4009
  };
4010
4010
  IncomeSource.prototype.isWorkIncome = function () {
4011
4011
  return this.type === exports.IncomeSourceTypeEnum.WORK;
4012
4012
  };
4013
4013
  IncomeSource.prototype.isOtherIncome = function () {
4014
- return this.type === exports.IncomeSourceTypeEnum.OTHER;
4014
+ return this.type === exports.IncomeSourceTypeEnum.OTHER || (!this.isSoleIncome() && !this.isSalaryIncome());
4015
4015
  };
4016
4016
  Object.defineProperty(IncomeSource.prototype, "forecasts", {
4017
4017
  /**
@@ -12568,6 +12568,7 @@
12568
12568
  IncomeSourceService.prototype.listenSoleBusinessCreated = function () {
12569
12569
  var _this = this;
12570
12570
  this.eventDispatcherService.on(exports.AppEventTypeEnum.SOLE_BUSINESS_CREATED).subscribe(function () {
12571
+ // @TODO Alex/Vik (TT-1777): we clear cache a lot, a better and easier way required, add todo and task to refactor
12571
12572
  _this.resetCache();
12572
12573
  });
12573
12574
  };
@@ -17223,7 +17224,7 @@
17223
17224
  // User have to create income source with new business.
17224
17225
  // Income source is not able for edit business
17225
17226
  if (!business.id) {
17226
- // @TODO Alex: move to separated form class
17227
+ // @TODO Alex (TT-2304): move to separated form class
17227
17228
  _this.addControl('incomeSource', new forms.FormGroup({
17228
17229
  type: new forms.FormControl(exports.IncomeSourceTypeEnum.SOLE, forms.Validators.required),
17229
17230
  name: new forms.FormControl(null, forms.Validators.required),
@@ -17242,9 +17243,18 @@
17242
17243
  })
17243
17244
  ]));
17244
17245
  }
17246
+ _this.listenEvents();
17245
17247
  return _this;
17246
17248
  }
17249
+ SoleBusinessForm.prototype.listenEvents = function () {
17250
+ if (this.contains('incomeSource')) {
17251
+ this.listenNameChanges();
17252
+ }
17253
+ };
17247
17254
  Object.defineProperty(SoleBusinessForm.prototype, "forecastFormGroup", {
17255
+ /**
17256
+ * We take the first forecast because income sources available only for new business, so we have only one forecast
17257
+ */
17248
17258
  get: function () {
17249
17259
  return this.get('incomeSource').get('soleForecasts').at(0);
17250
17260
  },
@@ -17252,12 +17262,23 @@
17252
17262
  configurable: true
17253
17263
  });
17254
17264
  Object.defineProperty(SoleBusinessForm.prototype, "lossFormGroup", {
17265
+ /**
17266
+ * We take the first loss because losses available only for new business, so we have only one loss
17267
+ */
17255
17268
  get: function () {
17256
17269
  return this.get('losses').at(0);
17257
17270
  },
17258
17271
  enumerable: false,
17259
17272
  configurable: true
17260
17273
  });
17274
+ SoleBusinessForm.prototype.listenNameChanges = function () {
17275
+ var _this = this;
17276
+ console.log('subs');
17277
+ this.get('name').valueChanges.subscribe(function (name) {
17278
+ console.log('listenNameChants');
17279
+ _this.get('incomeSource').get('name').setValue(name);
17280
+ });
17281
+ };
17261
17282
  return SoleBusinessForm;
17262
17283
  }(AbstractForm));
17263
17284