taxtank-core 0.17.11 → 0.17.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.
@@ -2547,6 +2547,25 @@
2547
2547
  PropertyCollection.prototype.getCategories = function () {
2548
2548
  return uniqBy__default["default"](this.items.map(function (property) { return property.category; }), 'id');
2549
2549
  };
2550
+ /**
2551
+ * Get property with the highest growth percent
2552
+ */
2553
+ PropertyCollection.prototype.getBestPerformanceGrowthProperty = function () {
2554
+ return this.items.reduce(function (max, current) {
2555
+ return max.growthPercent < current.growthPercent ? current : max;
2556
+ }, this.first);
2557
+ };
2558
+ /**
2559
+ * Get property with the lowest tax position
2560
+ */
2561
+ PropertyCollection.prototype.getBestPerformanceTaxProperty = function (transactions, depreciations) {
2562
+ return this.items.reduce(function (min, current) {
2563
+ return min.getTaxPosition(transactions.getBy('property.id', min.id), depreciations.getBy('property.id', min.id))
2564
+ > current.getTaxPosition(transactions.getBy('property.id', current.id), depreciations.getBy('property.id', current.id))
2565
+ ? current
2566
+ : min;
2567
+ }, this.first);
2568
+ };
2550
2569
  return PropertyCollection;
2551
2570
  }(Collection));
2552
2571
 
@@ -4357,6 +4376,9 @@
4357
4376
  if (unitOfTime === void 0) { unitOfTime = 'days'; }
4358
4377
  return moment__namespace(sale.contractDate).diff(moment__namespace(this.contractDate), unitOfTime);
4359
4378
  };
4379
+ Property.prototype.getTaxPosition = function (transactions, depreciations) {
4380
+ return transactions.cashPosition - Math.abs(depreciations.claimAmount);
4381
+ };
4360
4382
  return Property;
4361
4383
  }(Property$1));
4362
4384
  __decorate([
@@ -5184,11 +5206,17 @@
5184
5206
  };
5185
5207
  Object.defineProperty(Depreciation.prototype, "currentYearForecast", {
5186
5208
  /**
5187
- * @TODO wrong year, use current financial year, check everywhere
5209
+ * @TODO Vik: Research a problem with depreciations without current year forecast
5188
5210
  */
5189
5211
  get: function () {
5190
5212
  return this.forecasts.find(function (forecast) {
5191
5213
  return forecast.financialYear === new FinancialYear().year;
5214
+ }) || classTransformer.plainToClass(DepreciationForecast, {
5215
+ financialYear: new FinancialYear().year,
5216
+ openBalance: 0,
5217
+ closeBalance: 0,
5218
+ amount: 0,
5219
+ claimPercent: 0
5192
5220
  });
5193
5221
  },
5194
5222
  enumerable: false,
@@ -5218,6 +5246,9 @@
5218
5246
  return classTransformer.plainToClass(Transaction, Object.assign(params, this, { amount: this.currentYearForecast.amount }));
5219
5247
  };
5220
5248
  Object.defineProperty(Depreciation.prototype, "claimAmount", {
5249
+ /**
5250
+ * @TODO Michael: remove and check everywhere in reports
5251
+ */
5221
5252
  get: function () {
5222
5253
  var _a;
5223
5254
  return ((_a = this.currentYearForecast) === null || _a === void 0 ? void 0 : _a.claimAmount) || 0;
@@ -9396,7 +9427,7 @@
9396
9427
  */
9397
9428
  PropertyService.prototype.activate = function (property) {
9398
9429
  var _this = this;
9399
- return this.http.post(this.environment.apiV2 + "/property-subscriptions", { user: property.user, property: property })
9430
+ return this.http.post(this.environment.apiV2 + "/property-subscriptions", { property: property })
9400
9431
  .pipe(operators.map(function (propertySubscriptionBase) {
9401
9432
  var newPropertySubscription = classTransformer.plainToClass(PropertySubscription, propertySubscriptionBase);
9402
9433
  var activatedProperty = classTransformer.plainToClass(Property, Object.assign({}, property, { subscriptions: [newPropertySubscription] }));
@@ -11448,32 +11479,6 @@
11448
11479
  return response || 0;
11449
11480
  }));
11450
11481
  };
11451
- /**
11452
- * @TODO wrong place, move to collection model
11453
- */
11454
- DepreciationService.prototype.calculateSummaryAmount = function (depreciationList) {
11455
- return depreciationList.reduce(function (sum, depreciation) {
11456
- // depreciation may not have forecast item for current financial year
11457
- if (!depreciation.currentYearForecast) {
11458
- return sum;
11459
- }
11460
- return sum + depreciation.currentYearForecast.claimAmount;
11461
- }, 0);
11462
- };
11463
- DepreciationService.prototype.calculateBorrowingExpenses = function (depreciationList) {
11464
- var _this = this;
11465
- return this.getByIds(depreciationList)
11466
- .pipe(operators.map(function (depreciations) {
11467
- return _this.calculateSummaryAmount(depreciations.filter(function (depreciation) { return depreciation.isBorrowingExpense(); }));
11468
- }));
11469
- };
11470
- DepreciationService.prototype.calculateDepreciations = function (depreciationList) {
11471
- var _this = this;
11472
- return this.getByIds(depreciationList)
11473
- .pipe(operators.map(function (depreciations) {
11474
- return _this.calculateSummaryAmount(depreciations.filter(function (depreciation) { return !depreciation.isBorrowingExpense(); }));
11475
- }));
11476
- };
11477
11482
  /**
11478
11483
  * Upload depreciation receipt
11479
11484
  * @param depreciation for which will be uploaded receipt