taxtank-core 0.28.32 → 0.28.34

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.
@@ -2777,9 +2777,7 @@
2777
2777
  var SoleBusinessLoss = /** @class */ (function (_super) {
2778
2778
  __extends(SoleBusinessLoss, _super);
2779
2779
  function SoleBusinessLoss() {
2780
- var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
2781
- _this.openBalance = 0;
2782
- return _this;
2780
+ return _super !== null && _super.apply(this, arguments) || this;
2783
2781
  }
2784
2782
  Object.defineProperty(SoleBusinessLoss.prototype, "hasOffset", {
2785
2783
  get: function () {
@@ -7522,8 +7520,7 @@
7522
7520
  return _super !== null && _super.apply(this, arguments) || this;
7523
7521
  }
7524
7522
  TransactionBaseCollection.prototype.getClaimAmountByBusiness = function (business) {
7525
- return this.filterBy('business.id', business.id)
7526
- .sumBy('claimAmount');
7523
+ return +this.filterBy('business.id', business.id).items.map(function (transaction) { return transaction instanceof Depreciation ? -transaction.claimAmount : transaction['claimAmount']; }).reduce(function (sum, claimAmount) { return sum + claimAmount; }).toFixed(2);
7527
7524
  };
7528
7525
  return TransactionBaseCollection;
7529
7526
  }(Collection));
@@ -11408,14 +11405,10 @@
11408
11405
  function SoleBusinessLossReport(loss, transactions, depreciations) {
11409
11406
  var _this = _super.call(this) || this;
11410
11407
  _this.openBalance = loss.openBalance;
11411
- _this.netIncome = transactions.sumBy('claimAmount') + depreciations.sumBy('claimAmount');
11412
- _this.taxableIncome = _this.calculateTaxableIncome();
11413
- _this.closeBalance = Math.max(_this.taxableIncome, 0);
11408
+ _this.netIncome = transactions.sumBy('claimAmount') - depreciations.sumBy('claimAmount');
11409
+ _this.closeBalance = _this.netIncome - _this.openBalance;
11414
11410
  return _this;
11415
11411
  }
11416
- SoleBusinessLossReport.prototype.calculateTaxableIncome = function () {
11417
- return this.netIncome - this.openBalance;
11418
- };
11419
11412
  return SoleBusinessLossReport;
11420
11413
  }(AbstractModel));
11421
11414
 
@@ -15574,6 +15567,7 @@
15574
15567
  SoleForecastService.prototype.listenEvents = function () {
15575
15568
  this.listenToAddedIncomeSources();
15576
15569
  this.listenToUpdatedIncomeSources();
15570
+ this.listenBusinessCreated();
15577
15571
  };
15578
15572
  /**
15579
15573
  * Listen to EventDispatcherService event related to added Income Sources
@@ -15623,6 +15617,15 @@
15623
15617
  return incomeSource.soleForecasts;
15624
15618
  }).flat();
15625
15619
  };
15620
+ /**
15621
+ * Listen business created because we create sole forests together with business
15622
+ */
15623
+ SoleForecastService.prototype.listenBusinessCreated = function () {
15624
+ var _this = this;
15625
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.SOLE_BUSINESS_CREATED).subscribe(function () {
15626
+ _this.resetCache();
15627
+ });
15628
+ };
15626
15629
  return SoleForecastService;
15627
15630
  }(RestService));
15628
15631
  SoleForecastService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleForecastService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
@@ -17378,6 +17381,7 @@
17378
17381
  function AbstractForm(controls, model, validatorOrOpts, asyncValidator) {
17379
17382
  var _this = _super.call(this, controls, validatorOrOpts, asyncValidator) || this;
17380
17383
  /**
17384
+ * @TODO Alex bad name, it's also about unchanged
17381
17385
  * Flag display if some form values changed
17382
17386
  */
17383
17387
  _this.unsaved = false;
@@ -17867,18 +17871,18 @@
17867
17871
 
17868
17872
  var SoleBusinessLossForm = /** @class */ (function (_super) {
17869
17873
  __extends(SoleBusinessLossForm, _super);
17870
- function SoleBusinessLossForm(loss, balance) {
17874
+ function SoleBusinessLossForm(loss, profit) {
17871
17875
  var _this = this;
17872
17876
  var _a;
17873
17877
  _this = _super.call(this, {
17874
17878
  openBalance: new forms.FormControl(loss.openBalance, forms.Validators.required),
17875
17879
  offsetRule: new forms.FormControl((_a = loss.offsetRule) === null || _a === void 0 ? void 0 : _a.id),
17876
17880
  // sum of depreciations/transactions claim amount - openBalance
17877
- balance: new forms.FormControl({ value: balance, disabled: true }),
17881
+ balance: new forms.FormControl({ value: profit - loss.openBalance, disabled: true }),
17878
17882
  }, loss) || this;
17879
17883
  _this.loss = loss;
17880
17884
  _this.get('openBalance').valueChanges.subscribe(function (openBalance) {
17881
- _this.get('balance').setValue(balance - openBalance);
17885
+ _this.get('balance').setValue(profit - openBalance);
17882
17886
  });
17883
17887
  return _this;
17884
17888
  }