taxtank-core 0.17.10 → 0.17.13

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.
@@ -540,13 +540,103 @@
540
540
  }]
541
541
  }] });
542
542
 
543
+ exports.AppEventTypeEnum = void 0;
544
+ (function (AppEventTypeEnum) {
545
+ AppEventTypeEnum[AppEventTypeEnum["CLIENT_MOVEMENT_CLOSED"] = 0] = "CLIENT_MOVEMENT_CLOSED";
546
+ AppEventTypeEnum[AppEventTypeEnum["BANK_CONNECTION_ADDED"] = 1] = "BANK_CONNECTION_ADDED";
547
+ AppEventTypeEnum[AppEventTypeEnum["BANK_ACCOUNT_CREATED"] = 2] = "BANK_ACCOUNT_CREATED";
548
+ AppEventTypeEnum[AppEventTypeEnum["BANK_ACCOUNT_UPDATED"] = 3] = "BANK_ACCOUNT_UPDATED";
549
+ AppEventTypeEnum[AppEventTypeEnum["BANK_TRANSACTION_ALLOCATED"] = 4] = "BANK_TRANSACTION_ALLOCATED";
550
+ AppEventTypeEnum[AppEventTypeEnum["BASIQ_CONSENT_UPDATED"] = 5] = "BASIQ_CONSENT_UPDATED";
551
+ AppEventTypeEnum[AppEventTypeEnum["BASIQ_CONNECTION_UPDATED"] = 6] = "BASIQ_CONNECTION_UPDATED";
552
+ AppEventTypeEnum[AppEventTypeEnum["CLIENT_INVITE_ACCEPTED"] = 7] = "CLIENT_INVITE_ACCEPTED";
553
+ AppEventTypeEnum[AppEventTypeEnum["CLIENT_OPEN_CHAT"] = 8] = "CLIENT_OPEN_CHAT";
554
+ AppEventTypeEnum[AppEventTypeEnum["CLIENT_TRANSFER_TO_OTHER_EMPLOYEE"] = 9] = "CLIENT_TRANSFER_TO_OTHER_EMPLOYEE";
555
+ AppEventTypeEnum[AppEventTypeEnum["CURRENT_USER_GET_FAILED"] = 10] = "CURRENT_USER_GET_FAILED";
556
+ AppEventTypeEnum[AppEventTypeEnum["DEPRECIATION_DELETED"] = 11] = "DEPRECIATION_DELETED";
557
+ AppEventTypeEnum[AppEventTypeEnum["DEPRECIATIONS_CREATED"] = 12] = "DEPRECIATIONS_CREATED";
558
+ AppEventTypeEnum[AppEventTypeEnum["INCOME_SOURCES_CREATED"] = 13] = "INCOME_SOURCES_CREATED";
559
+ AppEventTypeEnum[AppEventTypeEnum["INCOME_SOURCES_UPDATED"] = 14] = "INCOME_SOURCES_UPDATED";
560
+ AppEventTypeEnum[AppEventTypeEnum["INCOME_SOURCES_FORECASTS_CREATED"] = 15] = "INCOME_SOURCES_FORECASTS_CREATED";
561
+ AppEventTypeEnum[AppEventTypeEnum["INCOME_SOURCES_FORECASTS_UPDATED"] = 16] = "INCOME_SOURCES_FORECASTS_UPDATED";
562
+ AppEventTypeEnum[AppEventTypeEnum["LOAN_UPDATED"] = 17] = "LOAN_UPDATED";
563
+ AppEventTypeEnum[AppEventTypeEnum["LOAN_PAYOUT_UPDATED"] = 18] = "LOAN_PAYOUT_UPDATED";
564
+ AppEventTypeEnum[AppEventTypeEnum["MESSAGE_CREATED"] = 19] = "MESSAGE_CREATED";
565
+ AppEventTypeEnum[AppEventTypeEnum["MESSAGE_FILE_CREATED"] = 20] = "MESSAGE_FILE_CREATED";
566
+ AppEventTypeEnum[AppEventTypeEnum["MESSAGE_FILE_DELETED"] = 21] = "MESSAGE_FILE_DELETED";
567
+ AppEventTypeEnum[AppEventTypeEnum["NOTIFICATION_ADDED"] = 22] = "NOTIFICATION_ADDED";
568
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_UPDATED_WITH_DOCUMENT"] = 23] = "PROPERTY_UPDATED_WITH_DOCUMENT";
569
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_DOCUMENT_ADDED"] = 24] = "PROPERTY_DOCUMENT_ADDED";
570
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_MOVEMENT_CREATED"] = 25] = "PROPERTY_MOVEMENT_CREATED";
571
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_MOVEMENT_UPDATED"] = 26] = "PROPERTY_MOVEMENT_UPDATED";
572
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_MOVEMENT_DELETED"] = 27] = "PROPERTY_MOVEMENT_DELETED";
573
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SHARE_UPDATED"] = 28] = "PROPERTY_SHARE_UPDATED";
574
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SUBSCRIPTION_ADDED"] = 29] = "PROPERTY_SUBSCRIPTION_ADDED";
575
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SUBSCRIPTION_DELETED"] = 30] = "PROPERTY_SUBSCRIPTION_DELETED";
576
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_VALUATION_DOCUMENT_CREATED"] = 31] = "PROPERTY_VALUATION_DOCUMENT_CREATED";
577
+ AppEventTypeEnum[AppEventTypeEnum["SERVICE_SUBSCRIPTION_UPDATED"] = 32] = "SERVICE_SUBSCRIPTION_UPDATED";
578
+ AppEventTypeEnum[AppEventTypeEnum["TAX_REVIEW_UPDATED"] = 33] = "TAX_REVIEW_UPDATED";
579
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_CREATED"] = 34] = "TRANSACTION_CREATED";
580
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_DELETED"] = 35] = "TRANSACTION_DELETED";
581
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_UPDATED"] = 36] = "TRANSACTION_UPDATED";
582
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTIONS_CREATED"] = 37] = "TRANSACTIONS_CREATED";
583
+ AppEventTypeEnum[AppEventTypeEnum["USER_UPDATED"] = 38] = "USER_UPDATED";
584
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_UPDATED"] = 39] = "VEHICLE_CLAIM_UPDATED";
585
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_CREATED"] = 40] = "VEHICLE_CLAIM_CREATED";
586
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_CREATED"] = 41] = "VEHICLE_LOGBOOK_CREATED";
587
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_UPDATED"] = 42] = "VEHICLE_LOGBOOK_UPDATED";
588
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_DELETED"] = 43] = "VEHICLE_LOGBOOK_DELETED";
589
+ })(exports.AppEventTypeEnum || (exports.AppEventTypeEnum = {}));
590
+
591
+ var EventDispatcherService = /** @class */ (function () {
592
+ function EventDispatcherService() {
593
+ this.eventSubject = new rxjs.Subject();
594
+ }
595
+ /**
596
+ * subscription to specific event type
597
+ */
598
+ EventDispatcherService.prototype.on = function (eventType) {
599
+ return this.eventSubject.pipe(operators.filter(function (event) { return [].concat(eventType).includes(event.type); }), operators.map(function (event) { return event.payload; }));
600
+ };
601
+ /**
602
+ * deliver new event
603
+ */
604
+ EventDispatcherService.prototype.dispatch = function (event) {
605
+ this.eventSubject.next(event);
606
+ };
607
+ return EventDispatcherService;
608
+ }());
609
+ EventDispatcherService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: EventDispatcherService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
610
+ EventDispatcherService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: EventDispatcherService, providedIn: 'root' });
611
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: EventDispatcherService, decorators: [{
612
+ type: i0.Injectable,
613
+ args: [{
614
+ providedIn: 'root'
615
+ }]
616
+ }] });
617
+
543
618
  var AuthService = /** @class */ (function () {
544
- function AuthService(http, jwtService, environment) {
619
+ function AuthService(http, jwtService, eventDispatcherService, environment) {
545
620
  this.http = http;
546
621
  this.jwtService = jwtService;
622
+ this.eventDispatcherService = eventDispatcherService;
547
623
  this.environment = environment;
624
+ this.listenEvents();
548
625
  this.isLoggedInSubject = new rxjs.BehaviorSubject(!this.jwtService.isTokenExpired());
549
626
  }
627
+ /**
628
+ * Listen to Event Dispatcher events
629
+ */
630
+ AuthService.prototype.listenEvents = function () {
631
+ this.listenUserGetFailed();
632
+ };
633
+ /**
634
+ * User logout if failed current user get
635
+ */
636
+ AuthService.prototype.listenUserGetFailed = function () {
637
+ var _this = this;
638
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.CURRENT_USER_GET_FAILED).subscribe(function () { return _this.logoutFront(); });
639
+ };
550
640
  AuthService.prototype.setAuth = function (response) {
551
641
  this.jwtService.saveTokens(response);
552
642
  this.isLoggedInSubject.next(true);
@@ -572,7 +662,7 @@
572
662
  };
573
663
  return AuthService;
574
664
  }());
575
- AuthService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: AuthService, deps: [{ token: i1__namespace.HttpClient }, { token: JwtService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
665
+ AuthService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: AuthService, deps: [{ token: i1__namespace.HttpClient }, { token: JwtService }, { token: EventDispatcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
576
666
  AuthService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: AuthService, providedIn: 'root' });
577
667
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: AuthService, decorators: [{
578
668
  type: i0.Injectable,
@@ -580,7 +670,7 @@
580
670
  providedIn: 'root'
581
671
  }]
582
672
  }], ctorParameters: function () {
583
- return [{ type: i1__namespace.HttpClient }, { type: JwtService }, { type: undefined, decorators: [{
673
+ return [{ type: i1__namespace.HttpClient }, { type: JwtService }, { type: EventDispatcherService }, { type: undefined, decorators: [{
584
674
  type: i0.Inject,
585
675
  args: ['environment']
586
676
  }] }];
@@ -2556,6 +2646,25 @@
2556
2646
  PropertyCollection.prototype.getCategories = function () {
2557
2647
  return uniqBy__default["default"](this.items.map(function (property) { return property.category; }), 'id');
2558
2648
  };
2649
+ /**
2650
+ * Get property with the highest growth percent
2651
+ */
2652
+ PropertyCollection.prototype.getBestPerformanceGrowthProperty = function () {
2653
+ return this.items.reduce(function (max, current) {
2654
+ return max.growthPercent < current.growthPercent ? current : max;
2655
+ }, this.first);
2656
+ };
2657
+ /**
2658
+ * Get property with the lowest tax position
2659
+ */
2660
+ PropertyCollection.prototype.getBestPerformanceTaxProperty = function (transactions, depreciations) {
2661
+ return this.items.reduce(function (min, current) {
2662
+ return min.getTaxPosition(transactions.getBy('property.id', min.id), depreciations.getBy('property.id', min.id))
2663
+ > current.getTaxPosition(transactions.getBy('property.id', current.id), depreciations.getBy('property.id', current.id))
2664
+ ? current
2665
+ : min;
2666
+ }, this.first);
2667
+ };
2559
2668
  return PropertyCollection;
2560
2669
  }(Collection));
2561
2670
 
@@ -4366,6 +4475,9 @@
4366
4475
  if (unitOfTime === void 0) { unitOfTime = 'days'; }
4367
4476
  return moment__namespace(sale.contractDate).diff(moment__namespace(this.contractDate), unitOfTime);
4368
4477
  };
4478
+ Property.prototype.getTaxPosition = function (transactions, depreciations) {
4479
+ return transactions.cashPosition - Math.abs(depreciations.claimAmount);
4480
+ };
4369
4481
  return Property;
4370
4482
  }(Property$1));
4371
4483
  __decorate([
@@ -5193,11 +5305,17 @@
5193
5305
  };
5194
5306
  Object.defineProperty(Depreciation.prototype, "currentYearForecast", {
5195
5307
  /**
5196
- * @TODO wrong year, use current financial year, check everywhere
5308
+ * @TODO Vik: Research a problem with depreciations without current year forecast
5197
5309
  */
5198
5310
  get: function () {
5199
5311
  return this.forecasts.find(function (forecast) {
5200
5312
  return forecast.financialYear === new FinancialYear().year;
5313
+ }) || classTransformer.plainToClass(DepreciationForecast, {
5314
+ financialYear: new FinancialYear().year,
5315
+ openBalance: 0,
5316
+ closeBalance: 0,
5317
+ amount: 0,
5318
+ claimPercent: 0
5201
5319
  });
5202
5320
  },
5203
5321
  enumerable: false,
@@ -5227,6 +5345,9 @@
5227
5345
  return classTransformer.plainToClass(Transaction, Object.assign(params, this, { amount: this.currentYearForecast.amount }));
5228
5346
  };
5229
5347
  Object.defineProperty(Depreciation.prototype, "claimAmount", {
5348
+ /**
5349
+ * @TODO Michael: remove and check everywhere in reports
5350
+ */
5230
5351
  get: function () {
5231
5352
  var _a;
5232
5353
  return ((_a = this.currentYearForecast) === null || _a === void 0 ? void 0 : _a.claimAmount) || 0;
@@ -7628,53 +7749,6 @@
7628
7749
  return AppEvent;
7629
7750
  }());
7630
7751
 
7631
- exports.AppEventTypeEnum = void 0;
7632
- (function (AppEventTypeEnum) {
7633
- AppEventTypeEnum[AppEventTypeEnum["CLIENT_MOVEMENT_CLOSED"] = 0] = "CLIENT_MOVEMENT_CLOSED";
7634
- AppEventTypeEnum[AppEventTypeEnum["BANK_CONNECTION_ADDED"] = 1] = "BANK_CONNECTION_ADDED";
7635
- AppEventTypeEnum[AppEventTypeEnum["BANK_ACCOUNT_CREATED"] = 2] = "BANK_ACCOUNT_CREATED";
7636
- AppEventTypeEnum[AppEventTypeEnum["BANK_ACCOUNT_UPDATED"] = 3] = "BANK_ACCOUNT_UPDATED";
7637
- AppEventTypeEnum[AppEventTypeEnum["BANK_TRANSACTION_ALLOCATED"] = 4] = "BANK_TRANSACTION_ALLOCATED";
7638
- AppEventTypeEnum[AppEventTypeEnum["BASIQ_CONSENT_UPDATED"] = 5] = "BASIQ_CONSENT_UPDATED";
7639
- AppEventTypeEnum[AppEventTypeEnum["BASIQ_CONNECTION_UPDATED"] = 6] = "BASIQ_CONNECTION_UPDATED";
7640
- AppEventTypeEnum[AppEventTypeEnum["CLIENT_INVITE_ACCEPTED"] = 7] = "CLIENT_INVITE_ACCEPTED";
7641
- AppEventTypeEnum[AppEventTypeEnum["CLIENT_OPEN_CHAT"] = 8] = "CLIENT_OPEN_CHAT";
7642
- AppEventTypeEnum[AppEventTypeEnum["CLIENT_TRANSFER_TO_OTHER_EMPLOYEE"] = 9] = "CLIENT_TRANSFER_TO_OTHER_EMPLOYEE";
7643
- AppEventTypeEnum[AppEventTypeEnum["DEPRECIATION_DELETED"] = 10] = "DEPRECIATION_DELETED";
7644
- AppEventTypeEnum[AppEventTypeEnum["DEPRECIATIONS_CREATED"] = 11] = "DEPRECIATIONS_CREATED";
7645
- AppEventTypeEnum[AppEventTypeEnum["INCOME_SOURCES_CREATED"] = 12] = "INCOME_SOURCES_CREATED";
7646
- AppEventTypeEnum[AppEventTypeEnum["INCOME_SOURCES_UPDATED"] = 13] = "INCOME_SOURCES_UPDATED";
7647
- AppEventTypeEnum[AppEventTypeEnum["INCOME_SOURCES_FORECASTS_CREATED"] = 14] = "INCOME_SOURCES_FORECASTS_CREATED";
7648
- AppEventTypeEnum[AppEventTypeEnum["INCOME_SOURCES_FORECASTS_UPDATED"] = 15] = "INCOME_SOURCES_FORECASTS_UPDATED";
7649
- AppEventTypeEnum[AppEventTypeEnum["LOAN_UPDATED"] = 16] = "LOAN_UPDATED";
7650
- AppEventTypeEnum[AppEventTypeEnum["LOAN_PAYOUT_UPDATED"] = 17] = "LOAN_PAYOUT_UPDATED";
7651
- AppEventTypeEnum[AppEventTypeEnum["MESSAGE_CREATED"] = 18] = "MESSAGE_CREATED";
7652
- AppEventTypeEnum[AppEventTypeEnum["MESSAGE_FILE_CREATED"] = 19] = "MESSAGE_FILE_CREATED";
7653
- AppEventTypeEnum[AppEventTypeEnum["MESSAGE_FILE_DELETED"] = 20] = "MESSAGE_FILE_DELETED";
7654
- AppEventTypeEnum[AppEventTypeEnum["NOTIFICATION_ADDED"] = 21] = "NOTIFICATION_ADDED";
7655
- AppEventTypeEnum[AppEventTypeEnum["PROPERTY_UPDATED_WITH_DOCUMENT"] = 22] = "PROPERTY_UPDATED_WITH_DOCUMENT";
7656
- AppEventTypeEnum[AppEventTypeEnum["PROPERTY_DOCUMENT_ADDED"] = 23] = "PROPERTY_DOCUMENT_ADDED";
7657
- AppEventTypeEnum[AppEventTypeEnum["PROPERTY_MOVEMENT_CREATED"] = 24] = "PROPERTY_MOVEMENT_CREATED";
7658
- AppEventTypeEnum[AppEventTypeEnum["PROPERTY_MOVEMENT_UPDATED"] = 25] = "PROPERTY_MOVEMENT_UPDATED";
7659
- AppEventTypeEnum[AppEventTypeEnum["PROPERTY_MOVEMENT_DELETED"] = 26] = "PROPERTY_MOVEMENT_DELETED";
7660
- AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SHARE_UPDATED"] = 27] = "PROPERTY_SHARE_UPDATED";
7661
- AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SUBSCRIPTION_ADDED"] = 28] = "PROPERTY_SUBSCRIPTION_ADDED";
7662
- AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SUBSCRIPTION_DELETED"] = 29] = "PROPERTY_SUBSCRIPTION_DELETED";
7663
- AppEventTypeEnum[AppEventTypeEnum["PROPERTY_VALUATION_DOCUMENT_CREATED"] = 30] = "PROPERTY_VALUATION_DOCUMENT_CREATED";
7664
- AppEventTypeEnum[AppEventTypeEnum["SERVICE_SUBSCRIPTION_UPDATED"] = 31] = "SERVICE_SUBSCRIPTION_UPDATED";
7665
- AppEventTypeEnum[AppEventTypeEnum["TAX_REVIEW_UPDATED"] = 32] = "TAX_REVIEW_UPDATED";
7666
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_CREATED"] = 33] = "TRANSACTION_CREATED";
7667
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_DELETED"] = 34] = "TRANSACTION_DELETED";
7668
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_UPDATED"] = 35] = "TRANSACTION_UPDATED";
7669
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTIONS_CREATED"] = 36] = "TRANSACTIONS_CREATED";
7670
- AppEventTypeEnum[AppEventTypeEnum["USER_UPDATED"] = 37] = "USER_UPDATED";
7671
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_UPDATED"] = 38] = "VEHICLE_CLAIM_UPDATED";
7672
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_CREATED"] = 39] = "VEHICLE_CLAIM_CREATED";
7673
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_CREATED"] = 40] = "VEHICLE_LOGBOOK_CREATED";
7674
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_UPDATED"] = 41] = "VEHICLE_LOGBOOK_UPDATED";
7675
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_DELETED"] = 42] = "VEHICLE_LOGBOOK_DELETED";
7676
- })(exports.AppEventTypeEnum || (exports.AppEventTypeEnum = {}));
7677
-
7678
7752
  exports.ExportFormatEnum = void 0;
7679
7753
  (function (ExportFormatEnum) {
7680
7754
  ExportFormatEnum["PDF"] = "PDF";
@@ -8143,6 +8217,7 @@
8143
8217
  this.buildActualItem();
8144
8218
  this.buildForecastedItems();
8145
8219
  this.checkZeroLoanBalance();
8220
+ this.checkZeroMarketValue();
8146
8221
  }
8147
8222
  /**
8148
8223
  * get items list in chart series format
@@ -8275,6 +8350,16 @@
8275
8350
  }
8276
8351
  });
8277
8352
  };
8353
+ /**
8354
+ * Check if market value is 0 and set it as null (to not to draw point on the chart)
8355
+ */
8356
+ PropertyEquityChartData.prototype.checkZeroMarketValue = function () {
8357
+ this.list.forEach(function (item) {
8358
+ if (item.marketValue === 0) {
8359
+ item.marketValue = null;
8360
+ }
8361
+ });
8362
+ };
8278
8363
  return PropertyEquityChartData;
8279
8364
  }());
8280
8365
 
@@ -9039,33 +9124,6 @@
9039
9124
  }] }];
9040
9125
  } });
9041
9126
 
9042
- var EventDispatcherService = /** @class */ (function () {
9043
- function EventDispatcherService() {
9044
- this.eventSubject = new rxjs.Subject();
9045
- }
9046
- /**
9047
- * subscription to specific event type
9048
- */
9049
- EventDispatcherService.prototype.on = function (eventType) {
9050
- return this.eventSubject.pipe(operators.filter(function (event) { return [].concat(eventType).includes(event.type); }), operators.map(function (event) { return event.payload; }));
9051
- };
9052
- /**
9053
- * deliver new event
9054
- */
9055
- EventDispatcherService.prototype.dispatch = function (event) {
9056
- this.eventSubject.next(event);
9057
- };
9058
- return EventDispatcherService;
9059
- }());
9060
- EventDispatcherService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: EventDispatcherService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
9061
- EventDispatcherService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: EventDispatcherService, providedIn: 'root' });
9062
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: EventDispatcherService, decorators: [{
9063
- type: i0.Injectable,
9064
- args: [{
9065
- providedIn: 'root'
9066
- }]
9067
- }] });
9068
-
9069
9127
  /**
9070
9128
  * popup notifications service (toast, snackbar).
9071
9129
  */
@@ -9394,7 +9452,7 @@
9394
9452
  */
9395
9453
  PropertyService.prototype.activate = function (property) {
9396
9454
  var _this = this;
9397
- return this.http.post(this.environment.apiV2 + "/property-subscriptions", { user: property.user, property: property })
9455
+ return this.http.post(this.environment.apiV2 + "/property-subscriptions", { property: property })
9398
9456
  .pipe(operators.map(function (propertySubscriptionBase) {
9399
9457
  var newPropertySubscription = classTransformer.plainToClass(PropertySubscription, propertySubscriptionBase);
9400
9458
  var activatedProperty = classTransformer.plainToClass(Property, Object.assign({}, property, { subscriptions: [newPropertySubscription] }));
@@ -11446,32 +11504,6 @@
11446
11504
  return response || 0;
11447
11505
  }));
11448
11506
  };
11449
- /**
11450
- * @TODO wrong place, move to collection model
11451
- */
11452
- DepreciationService.prototype.calculateSummaryAmount = function (depreciationList) {
11453
- return depreciationList.reduce(function (sum, depreciation) {
11454
- // depreciation may not have forecast item for current financial year
11455
- if (!depreciation.currentYearForecast) {
11456
- return sum;
11457
- }
11458
- return sum + depreciation.currentYearForecast.claimAmount;
11459
- }, 0);
11460
- };
11461
- DepreciationService.prototype.calculateBorrowingExpenses = function (depreciationList) {
11462
- var _this = this;
11463
- return this.getByIds(depreciationList)
11464
- .pipe(operators.map(function (depreciations) {
11465
- return _this.calculateSummaryAmount(depreciations.filter(function (depreciation) { return depreciation.isBorrowingExpense(); }));
11466
- }));
11467
- };
11468
- DepreciationService.prototype.calculateDepreciations = function (depreciationList) {
11469
- var _this = this;
11470
- return this.getByIds(depreciationList)
11471
- .pipe(operators.map(function (depreciations) {
11472
- return _this.calculateSummaryAmount(depreciations.filter(function (depreciation) { return !depreciation.isBorrowingExpense(); }));
11473
- }));
11474
- };
11475
11507
  /**
11476
11508
  * Upload depreciation receipt
11477
11509
  * @param depreciation for which will be uploaded receipt
@@ -13367,8 +13399,14 @@
13367
13399
  this.listenBasiqConcentUpdated();
13368
13400
  };
13369
13401
  UserService.prototype.get = function () {
13402
+ var _this = this;
13370
13403
  if (!this.cache) {
13371
- this.fetch().subscribe();
13404
+ this.fetch().subscribe(function () { }, function (error) {
13405
+ // force logout user (clear localStorage) when get current user return error
13406
+ if (error.status === 500) {
13407
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.CURRENT_USER_GET_FAILED, null));
13408
+ }
13409
+ });
13372
13410
  }
13373
13411
  return this.cacheSubject.asObservable();
13374
13412
  };