taxtank-core 0.28.9 → 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.
Files changed (30) hide show
  1. package/bundles/taxtank-core.umd.js +117 -29
  2. package/bundles/taxtank-core.umd.js.map +1 -1
  3. package/esm2015/lib/collections/transaction/transaction.collection.js +26 -1
  4. package/esm2015/lib/forms/sole/sole-business.form.js +21 -2
  5. package/esm2015/lib/models/depreciation/depreciation.js +2 -2
  6. package/esm2015/lib/models/endpoint/endpoints.const.js +2 -1
  7. package/esm2015/lib/models/income-source/income-source.js +3 -3
  8. package/esm2015/lib/models/report/depreciation/index.js +4 -0
  9. package/esm2015/lib/models/report/index.js +6 -0
  10. package/esm2015/lib/models/report/property/index.js +4 -0
  11. package/esm2015/lib/models/report/sole/index.js +2 -0
  12. package/esm2015/lib/models/report/sole/sole-business/sole-business-loss-report.js +18 -0
  13. package/esm2015/lib/services/http/income-source/income-source.service.js +2 -1
  14. package/esm2015/lib/services/http/sole/index.js +2 -1
  15. package/esm2015/lib/services/http/sole/sole-business-loss/sole-business-loss.service.js +21 -0
  16. package/esm2015/lib/services/http/sole/sole-invoice/sole-invoice.service.js +1 -1
  17. package/esm2015/public-api.js +2 -8
  18. package/fesm2015/taxtank-core.js +101 -24
  19. package/fesm2015/taxtank-core.js.map +1 -1
  20. package/lib/collections/transaction/transaction.collection.d.ts +7 -0
  21. package/lib/forms/sole/sole-business.form.d.ts +10 -1
  22. package/lib/models/report/depreciation/index.d.ts +3 -0
  23. package/lib/models/report/index.d.ts +5 -0
  24. package/lib/models/report/property/index.d.ts +3 -0
  25. package/lib/models/report/sole/index.d.ts +1 -0
  26. package/lib/models/report/sole/sole-business/sole-business-loss-report.d.ts +25 -0
  27. package/lib/services/http/sole/index.d.ts +1 -0
  28. package/lib/services/http/sole/sole-business-loss/sole-business-loss.service.d.ts +11 -0
  29. package/package.json +1 -1
  30. package/public-api.d.ts +1 -7
@@ -1061,6 +1061,7 @@
1061
1061
  SOLE_BUSINESSES_GET: new Endpoint('GET', '\\/sole-businesses'),
1062
1062
  SOLE_BUSINESSES_POST: new Endpoint('POST', '\\/sole-businesses'),
1063
1063
  SOLE_BUSINESSES_PUT: new Endpoint('PUT', '\\/sole-businesses\\/\\d+'),
1064
+ SOLE_BUSINESSES_LOSSES_GET: new Endpoint('GET', '\\/sole-business-losses'),
1064
1065
  BUSINESS_ACTIVITIES_GET: new Endpoint('GET', '\\/sole-business-activities'),
1065
1066
  SOLE_DEPRECIATION_METHODS_GET: new Endpoint('GET', '\\/sole-depreciation-methods'),
1066
1067
  SOLE_DEPRECIATION_METHODS_PUT: new Endpoint('PUT', '\\/sole-depreciation-methods\\/\\d+'),
@@ -4004,13 +4005,13 @@
4004
4005
  // return this.type === IncomeSourceTypeEnum.SALARY;
4005
4006
  };
4006
4007
  IncomeSource.prototype.isSoleIncome = function () {
4007
- return this.type === exports.IncomeSourceTypeEnum.SOLE;
4008
+ return !!this.soleForecasts.length;
4008
4009
  };
4009
4010
  IncomeSource.prototype.isWorkIncome = function () {
4010
4011
  return this.type === exports.IncomeSourceTypeEnum.WORK;
4011
4012
  };
4012
4013
  IncomeSource.prototype.isOtherIncome = function () {
4013
- return this.type === exports.IncomeSourceTypeEnum.OTHER;
4014
+ return this.type === exports.IncomeSourceTypeEnum.OTHER || (!this.isSoleIncome() && !this.isSalaryIncome());
4014
4015
  };
4015
4016
  Object.defineProperty(IncomeSource.prototype, "forecasts", {
4016
4017
  /**
@@ -4543,7 +4544,7 @@
4543
4544
  */
4544
4545
  Depreciation.prototype.toTransaction = function (params) {
4545
4546
  if (params === void 0) { params = {}; }
4546
- return classTransformer.plainToClass(Transaction, Object.assign(params, this, { amount: this.currentYearForecast.amount }));
4547
+ return classTransformer.plainToClass(Transaction, Object.assign(params, this, { amount: -this.claimAmount, claimAmount: -this.amount * (this.claimPercent / 100) }));
4547
4548
  };
4548
4549
  Object.defineProperty(Depreciation.prototype, "claimAmount", {
4549
4550
  /**
@@ -7014,6 +7015,31 @@
7014
7015
  return ClientPortfolioReportCollection;
7015
7016
  }(Collection));
7016
7017
 
7018
+ /**
7019
+ * Chart serie class: chart data item
7020
+ * @TODO consider rename to ChartSerieData
7021
+ */
7022
+ var ChartSerie = /** @class */ (function () {
7023
+ function ChartSerie() {
7024
+ }
7025
+ return ChartSerie;
7026
+ }());
7027
+
7028
+ /**
7029
+ * Chart data class
7030
+ * @TODO consider rename to ChartSerie
7031
+ */
7032
+ var ChartData = /** @class */ (function () {
7033
+ function ChartData() {
7034
+ }
7035
+ return ChartData;
7036
+ }());
7037
+ __decorate([
7038
+ classTransformer.Type(function () { return ChartSerie; })
7039
+ ], ChartData.prototype, "data", void 0);
7040
+
7041
+ var MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'Jan'];
7042
+
7017
7043
  /**
7018
7044
  * Collection of transactions
7019
7045
  */
@@ -7230,6 +7256,29 @@
7230
7256
  .getVehicleTransactions()
7231
7257
  .removeBy('chartAccounts.id', [exports.ChartAccountsListEnum.KLMS_TRAVELLED_FOR_WORK, exports.ChartAccountsListEnum.KLMS_TRAVELLED]);
7232
7258
  };
7259
+ /**
7260
+ * Build chart data with transactions cash position.
7261
+ * Cash position = Income - Expenses (include depreciations)
7262
+ * Chart data for each month from fin year start till current month
7263
+ */
7264
+ TransactionCollection.prototype.getCashPositionChartData = function () {
7265
+ var _this = this;
7266
+ var chartData = [
7267
+ classTransformer.plainToClass(ChartData, { name: 'Income', data: [] }),
7268
+ classTransformer.plainToClass(ChartData, { name: 'Expense', data: [] })
7269
+ ];
7270
+ new FinancialYear().getPastMonths().forEach(function (month) {
7271
+ chartData[0].data.push({
7272
+ label: MONTHS[month],
7273
+ value: _this.getIncomeTransactions().getByMonth(month).claimAmount
7274
+ });
7275
+ chartData[1].data.push({
7276
+ label: MONTHS[month],
7277
+ value: Math.abs(_this.getExpenseTransactions().getByMonth(month).claimAmount)
7278
+ });
7279
+ });
7280
+ return chartData;
7281
+ };
7233
7282
  return TransactionCollection;
7234
7283
  }(ExportableCollection));
7235
7284
 
@@ -9146,29 +9195,6 @@
9146
9195
  return BorrowingExpenseLoan;
9147
9196
  }(BorrowingExpenseLoan$1));
9148
9197
 
9149
- /**
9150
- * Chart serie class: chart data item
9151
- * @TODO consider rename to ChartSerieData
9152
- */
9153
- var ChartSerie = /** @class */ (function () {
9154
- function ChartSerie() {
9155
- }
9156
- return ChartSerie;
9157
- }());
9158
-
9159
- /**
9160
- * Chart data class
9161
- * @TODO consider rename to ChartSerie
9162
- */
9163
- var ChartData = /** @class */ (function () {
9164
- function ChartData() {
9165
- }
9166
- return ChartData;
9167
- }());
9168
- __decorate([
9169
- classTransformer.Type(function () { return ChartSerie; })
9170
- ], ChartData.prototype, "data", void 0);
9171
-
9172
9198
  var ChartAccountsDepreciation$1 = /** @class */ (function (_super) {
9173
9199
  __extends(ChartAccountsDepreciation, _super);
9174
9200
  function ChartAccountsDepreciation() {
@@ -9841,8 +9867,6 @@
9841
9867
  IconsFileEnum["DOC"] = "icon-doc";
9842
9868
  })(exports.IconsFileEnum || (exports.IconsFileEnum = {}));
9843
9869
 
9844
- var MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'Jan'];
9845
-
9846
9870
  // Todo extend from the base model when the backend is ready TT-555
9847
9871
  var IncomePosition = /** @class */ (function () {
9848
9872
  function IncomePosition() {
@@ -10981,6 +11005,26 @@
10981
11005
  * 'My Tax' report related data (classes, enums, const, e.t.c)
10982
11006
  */
10983
11007
 
11008
+ /**
11009
+ * Class with business loss details
11010
+ * https://taxtank.atlassian.net/wiki/spaces/TAXTANK/pages/4641357930/Rules+when+a+business+makes+a+loss+Tax+Summary
11011
+ */
11012
+ var SoleBusinessLossReport = /** @class */ (function (_super) {
11013
+ __extends(SoleBusinessLossReport, _super);
11014
+ function SoleBusinessLossReport(loss, transactions, depreciations) {
11015
+ var _this = _super.call(this) || this;
11016
+ _this.openBalance = loss.openBalance;
11017
+ _this.netIncome = transactions.sumBy('claimAmount') + depreciations.sumBy('claimAmount');
11018
+ _this.taxableIncome = _this.calculateTaxableIncome();
11019
+ _this.closeBalance = Math.max(_this.taxableIncome, 0);
11020
+ return _this;
11021
+ }
11022
+ SoleBusinessLossReport.prototype.calculateTaxableIncome = function () {
11023
+ return this.netIncome - this.openBalance;
11024
+ };
11025
+ return SoleBusinessLossReport;
11026
+ }(AbstractModel));
11027
+
10984
11028
  /**
10985
11029
  * Constant with list of URLs
10986
11030
  */
@@ -11515,6 +11559,26 @@
11515
11559
  }]
11516
11560
  }] });
11517
11561
 
11562
+ var SoleBusinessLossService = /** @class */ (function (_super) {
11563
+ __extends(SoleBusinessLossService, _super);
11564
+ function SoleBusinessLossService() {
11565
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
11566
+ _this.modelClass = SoleBusinessLoss;
11567
+ _this.url = 'sole-business-losses';
11568
+ _this.isHydra = true;
11569
+ return _this;
11570
+ }
11571
+ return SoleBusinessLossService;
11572
+ }(RestService));
11573
+ SoleBusinessLossService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleBusinessLossService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
11574
+ SoleBusinessLossService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleBusinessLossService, providedIn: 'root' });
11575
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleBusinessLossService, decorators: [{
11576
+ type: i0.Injectable,
11577
+ args: [{
11578
+ providedIn: 'root'
11579
+ }]
11580
+ }] });
11581
+
11518
11582
  var SoleContactService = /** @class */ (function (_super) {
11519
11583
  __extends(SoleContactService, _super);
11520
11584
  function SoleContactService() {
@@ -12504,6 +12568,7 @@
12504
12568
  IncomeSourceService.prototype.listenSoleBusinessCreated = function () {
12505
12569
  var _this = this;
12506
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
12507
12572
  _this.resetCache();
12508
12573
  });
12509
12574
  };
@@ -17159,7 +17224,7 @@
17159
17224
  // User have to create income source with new business.
17160
17225
  // Income source is not able for edit business
17161
17226
  if (!business.id) {
17162
- // @TODO Alex: move to separated form class
17227
+ // @TODO Alex (TT-2304): move to separated form class
17163
17228
  _this.addControl('incomeSource', new forms.FormGroup({
17164
17229
  type: new forms.FormControl(exports.IncomeSourceTypeEnum.SOLE, forms.Validators.required),
17165
17230
  name: new forms.FormControl(null, forms.Validators.required),
@@ -17178,9 +17243,18 @@
17178
17243
  })
17179
17244
  ]));
17180
17245
  }
17246
+ _this.listenEvents();
17181
17247
  return _this;
17182
17248
  }
17249
+ SoleBusinessForm.prototype.listenEvents = function () {
17250
+ if (this.contains('incomeSource')) {
17251
+ this.listenNameChanges();
17252
+ }
17253
+ };
17183
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
+ */
17184
17258
  get: function () {
17185
17259
  return this.get('incomeSource').get('soleForecasts').at(0);
17186
17260
  },
@@ -17188,12 +17262,23 @@
17188
17262
  configurable: true
17189
17263
  });
17190
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
+ */
17191
17268
  get: function () {
17192
17269
  return this.get('losses').at(0);
17193
17270
  },
17194
17271
  enumerable: false,
17195
17272
  configurable: true
17196
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
+ };
17197
17282
  return SoleBusinessForm;
17198
17283
  }(AbstractForm));
17199
17284
 
@@ -18680,6 +18765,7 @@
18680
18765
  exports.PropertyForecast = PropertyForecast;
18681
18766
  exports.PropertyReportItem = PropertyReportItem;
18682
18767
  exports.PropertyReportItemCollection = PropertyReportItemCollection;
18768
+ exports.PropertyReportItemDepreciation = PropertyReportItemDepreciation;
18683
18769
  exports.PropertyReportItemDepreciationCollection = PropertyReportItemDepreciationCollection;
18684
18770
  exports.PropertyReportItemTransaction = PropertyReportItemTransaction;
18685
18771
  exports.PropertyReportItemTransactionCollection = PropertyReportItemTransactionCollection;
@@ -18724,6 +18810,8 @@
18724
18810
  exports.SoleBusinessAllocationsForm = SoleBusinessAllocationsForm;
18725
18811
  exports.SoleBusinessForm = SoleBusinessForm;
18726
18812
  exports.SoleBusinessLoss = SoleBusinessLoss;
18813
+ exports.SoleBusinessLossReport = SoleBusinessLossReport;
18814
+ exports.SoleBusinessLossService = SoleBusinessLossService;
18727
18815
  exports.SoleBusinessService = SoleBusinessService;
18728
18816
  exports.SoleContact = SoleContact;
18729
18817
  exports.SoleContactForm = SoleContactForm;