taxtank-core 0.17.11 → 0.17.14

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;
@@ -7079,6 +7110,9 @@
7079
7110
  __decorate([
7080
7111
  classTransformer.Type(function () { return User; })
7081
7112
  ], Chat.prototype, "client", void 0);
7113
+ __decorate([
7114
+ classTransformer.Type(function () { return Date; })
7115
+ ], Chat.prototype, "updatedAt", void 0);
7082
7116
 
7083
7117
  exports.ChatViewTypeEnum = void 0;
7084
7118
  (function (ChatViewTypeEnum) {
@@ -9396,7 +9430,7 @@
9396
9430
  */
9397
9431
  PropertyService.prototype.activate = function (property) {
9398
9432
  var _this = this;
9399
- return this.http.post(this.environment.apiV2 + "/property-subscriptions", { user: property.user, property: property })
9433
+ return this.http.post(this.environment.apiV2 + "/property-subscriptions", { property: property })
9400
9434
  .pipe(operators.map(function (propertySubscriptionBase) {
9401
9435
  var newPropertySubscription = classTransformer.plainToClass(PropertySubscription, propertySubscriptionBase);
9402
9436
  var activatedProperty = classTransformer.plainToClass(Property, Object.assign({}, property, { subscriptions: [newPropertySubscription] }));
@@ -10902,6 +10936,7 @@
10902
10936
  _this.url = 'chats';
10903
10937
  _this.isHydra = true;
10904
10938
  _this.listenChats();
10939
+ _this.listenMessages();
10905
10940
  return _this;
10906
10941
  }
10907
10942
  /**
@@ -10938,6 +10973,20 @@
10938
10973
  _this.updateCache();
10939
10974
  });
10940
10975
  };
10976
+ /**
10977
+ * Update chat's 'updatedAt' field with the last chat's message date for chat list sorting
10978
+ */
10979
+ ChatService.prototype.listenMessages = function () {
10980
+ var _this = this;
10981
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.MESSAGE_CREATED).subscribe(function (message) {
10982
+ var cache = cloneDeep__default["default"](_this.cache);
10983
+ var updatedChat = cache.find(function (chat) { return chat.id === message.chat.id; });
10984
+ updatedChat.updatedAt = message.createdAt;
10985
+ replace(cache, updatedChat);
10986
+ _this.cache = cache;
10987
+ _this.updateCache();
10988
+ });
10989
+ };
10941
10990
  return ChatService;
10942
10991
  }(RestService));
10943
10992
  ChatService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ChatService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }, { token: ToastService }, { token: SseService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
@@ -11448,32 +11497,6 @@
11448
11497
  return response || 0;
11449
11498
  }));
11450
11499
  };
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
11500
  /**
11478
11501
  * Upload depreciation receipt
11479
11502
  * @param depreciation for which will be uploaded receipt