taxtank-core 0.21.19 → 0.22.2

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.
@@ -166,7 +166,8 @@
166
166
  });
167
167
  // clone request to add new parameters
168
168
  var clonedReq = request.clone();
169
- if (!params.get('financialYear')) {
169
+ // @TODO query params should be passed using second param of get request and HttpParams object
170
+ if (!params.get('financialYear') && !request.urlWithParams.includes('?financialYear') && !request.urlWithParams.includes('&financialYear')) {
170
171
  params = params.set('financialYear', localStorage.getItem('financialYear'));
171
172
  clonedReq = request.clone({
172
173
  params: params
@@ -575,21 +576,23 @@
575
576
  AppEventTypeEnum[AppEventTypeEnum["PROPERTY_MOVEMENT_UPDATED"] = 27] = "PROPERTY_MOVEMENT_UPDATED";
576
577
  AppEventTypeEnum[AppEventTypeEnum["PROPERTY_MOVEMENT_DELETED"] = 28] = "PROPERTY_MOVEMENT_DELETED";
577
578
  AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SHARE_UPDATED"] = 29] = "PROPERTY_SHARE_UPDATED";
578
- AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SUBSCRIPTION_ADDED"] = 30] = "PROPERTY_SUBSCRIPTION_ADDED";
579
- AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SUBSCRIPTION_DELETED"] = 31] = "PROPERTY_SUBSCRIPTION_DELETED";
580
- AppEventTypeEnum[AppEventTypeEnum["PROPERTY_VALUATION_DOCUMENT_CREATED"] = 32] = "PROPERTY_VALUATION_DOCUMENT_CREATED";
581
- AppEventTypeEnum[AppEventTypeEnum["SERVICE_SUBSCRIPTION_UPDATED"] = 33] = "SERVICE_SUBSCRIPTION_UPDATED";
582
- AppEventTypeEnum[AppEventTypeEnum["TAX_REVIEW_UPDATED"] = 34] = "TAX_REVIEW_UPDATED";
583
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_CREATED"] = 35] = "TRANSACTION_CREATED";
584
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_DELETED"] = 36] = "TRANSACTION_DELETED";
585
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_UPDATED"] = 37] = "TRANSACTION_UPDATED";
586
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTIONS_CREATED"] = 38] = "TRANSACTIONS_CREATED";
587
- AppEventTypeEnum[AppEventTypeEnum["USER_UPDATED"] = 39] = "USER_UPDATED";
588
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_UPDATED"] = 40] = "VEHICLE_CLAIM_UPDATED";
589
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_CREATED"] = 41] = "VEHICLE_CLAIM_CREATED";
590
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_CREATED"] = 42] = "VEHICLE_LOGBOOK_CREATED";
591
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_UPDATED"] = 43] = "VEHICLE_LOGBOOK_UPDATED";
592
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_DELETED"] = 44] = "VEHICLE_LOGBOOK_DELETED";
579
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SALE_ADDED"] = 30] = "PROPERTY_SALE_ADDED";
580
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SALE_DELETED"] = 31] = "PROPERTY_SALE_DELETED";
581
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SUBSCRIPTION_ADDED"] = 32] = "PROPERTY_SUBSCRIPTION_ADDED";
582
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SUBSCRIPTION_DELETED"] = 33] = "PROPERTY_SUBSCRIPTION_DELETED";
583
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_VALUATION_DOCUMENT_CREATED"] = 34] = "PROPERTY_VALUATION_DOCUMENT_CREATED";
584
+ AppEventTypeEnum[AppEventTypeEnum["SERVICE_SUBSCRIPTION_UPDATED"] = 35] = "SERVICE_SUBSCRIPTION_UPDATED";
585
+ AppEventTypeEnum[AppEventTypeEnum["TAX_REVIEW_UPDATED"] = 36] = "TAX_REVIEW_UPDATED";
586
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_CREATED"] = 37] = "TRANSACTION_CREATED";
587
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_DELETED"] = 38] = "TRANSACTION_DELETED";
588
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_UPDATED"] = 39] = "TRANSACTION_UPDATED";
589
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTIONS_CREATED"] = 40] = "TRANSACTIONS_CREATED";
590
+ AppEventTypeEnum[AppEventTypeEnum["USER_UPDATED"] = 41] = "USER_UPDATED";
591
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_UPDATED"] = 42] = "VEHICLE_CLAIM_UPDATED";
592
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_CREATED"] = 43] = "VEHICLE_CLAIM_CREATED";
593
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_CREATED"] = 44] = "VEHICLE_LOGBOOK_CREATED";
594
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_UPDATED"] = 45] = "VEHICLE_LOGBOOK_UPDATED";
595
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_DELETED"] = 46] = "VEHICLE_LOGBOOK_DELETED";
593
596
  })(exports.AppEventTypeEnum || (exports.AppEventTypeEnum = {}));
594
597
 
595
598
  var EventDispatcherService = /** @class */ (function () {
@@ -1316,6 +1319,9 @@
1316
1319
  return items.find(function (item) { return item['id'] === id; });
1317
1320
  }));
1318
1321
  };
1322
+ RestService.prototype.find = function (id) {
1323
+ return this.cache.find(function (item) { return item['id'] === id; });
1324
+ };
1319
1325
  /**
1320
1326
  * add new instance and update cache
1321
1327
  * @TODO rename to post
@@ -2934,6 +2940,9 @@
2934
2940
  Property.prototype.isOwn = function () {
2935
2941
  return this.user.id === +localStorage.getItem('userId');
2936
2942
  };
2943
+ Property.prototype.isSold = function () {
2944
+ return !!this.myShare.sale;
2945
+ };
2937
2946
  /**
2938
2947
  * Get initials of property. Required by Photoable interface
2939
2948
  */
@@ -4939,6 +4948,9 @@
4939
4948
  PropertyCollection.prototype.getSharedProperties = function () {
4940
4949
  return new PropertyCollection(this.items.filter(function (property) { return !property.isOwn(); }));
4941
4950
  };
4951
+ PropertyCollection.prototype.getUnsold = function () {
4952
+ return this.create(this.items.filter(function (property) { return !property.isSold(); }));
4953
+ };
4942
4954
  Object.defineProperty(PropertyCollection.prototype, "purchasePrice", {
4943
4955
  /**
4944
4956
  * Get total purchase price for all properties in the collection
@@ -10445,6 +10457,7 @@
10445
10457
  } });
10446
10458
 
10447
10459
  /**
10460
+ * @Todo Alex remove functionality related to PropertyShare
10448
10461
  * Service for work with Property
10449
10462
  */
10450
10463
  var PropertyService = /** @class */ (function (_super) {
@@ -10459,6 +10472,8 @@
10459
10472
  this.listenShareInviteAccepted();
10460
10473
  // @TODO Alex: consider to refactor property movements logic similar to client-movements
10461
10474
  this.listenMovementsChanged();
10475
+ this.listenSalesAdded();
10476
+ this.listenSalesDeleted();
10462
10477
  };
10463
10478
  /**
10464
10479
  * Update cache when share invitation accepted
@@ -10477,6 +10492,27 @@
10477
10492
  this.eventDispatcherService.on(exports.AppEventTypeEnum.PROPERTY_MOVEMENT_UPDATED).subscribe(function () { return _this.resetCache(); });
10478
10493
  this.eventDispatcherService.on(exports.AppEventTypeEnum.PROPERTY_MOVEMENT_DELETED).subscribe(function () { return _this.resetCache(); });
10479
10494
  };
10495
+ /**
10496
+ * @Todo Alex refactor after PropertyShare will be cleared up
10497
+ */
10498
+ PropertyService.prototype.listenSalesAdded = function () {
10499
+ var _this = this;
10500
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.PROPERTY_SALE_ADDED).subscribe(function (propertySale) {
10501
+ var propertyToReplace = _this.cache.find(function (property) { return property.myShare.id === propertySale.share.id; });
10502
+ propertyToReplace.myShare.sale = classTransformer.plainToClass(PropertySale, { id: propertySale.id });
10503
+ replace(_this.cache, propertyToReplace);
10504
+ _this.updateCache();
10505
+ });
10506
+ };
10507
+ PropertyService.prototype.listenSalesDeleted = function () {
10508
+ var _this = this;
10509
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.PROPERTY_SALE_DELETED).subscribe(function (propertySale) {
10510
+ var propertyToReplace = _this.cache.find(function (property) { return property.myShare.id === propertySale.share.id; });
10511
+ propertyToReplace.myShare.sale = null;
10512
+ replace(_this.cache, propertyToReplace);
10513
+ _this.updateCache();
10514
+ });
10515
+ };
10480
10516
  PropertyService.prototype.update = function (property) {
10481
10517
  var _this = this;
10482
10518
  return _super.prototype.update.call(this, property).pipe(operators.map(function (updatedProperty) {
@@ -13853,6 +13889,8 @@
13853
13889
  */
13854
13890
  PropertyShareService.prototype.listenEvents = function () {
13855
13891
  this.listenUserUpdated();
13892
+ this.listenSalesAdded();
13893
+ this.listenSalesDeleted();
13856
13894
  };
13857
13895
  /**
13858
13896
  * Updated loan
@@ -13930,6 +13968,27 @@
13930
13968
  });
13931
13969
  });
13932
13970
  };
13971
+ /**
13972
+ * @Todo Alex refactor after PropertyShare functionality in PropertyService will be cleared up
13973
+ */
13974
+ PropertyShareService.prototype.listenSalesAdded = function () {
13975
+ var _this = this;
13976
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.PROPERTY_SALE_ADDED).subscribe(function (propertySale) {
13977
+ var shareToReplace = _this.find(propertySale.share.id);
13978
+ shareToReplace.sale = classTransformer.plainToClass(PropertySale, { id: propertySale.id });
13979
+ replace(_this.cache, shareToReplace);
13980
+ _this.updateCache();
13981
+ });
13982
+ };
13983
+ PropertyShareService.prototype.listenSalesDeleted = function () {
13984
+ var _this = this;
13985
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.PROPERTY_SALE_DELETED).subscribe(function (propertySale) {
13986
+ var shareToReplace = _this.find(propertySale.share.id);
13987
+ shareToReplace.sale = null;
13988
+ replace(_this.cache, shareToReplace);
13989
+ _this.updateCache();
13990
+ });
13991
+ };
13933
13992
  return PropertyShareService;
13934
13993
  }(RestService));
13935
13994
  PropertyShareService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyShareService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
@@ -13949,6 +14008,25 @@
13949
14008
  _this.url = 'properties/sales';
13950
14009
  return _this;
13951
14010
  }
14011
+ /**
14012
+ * @Todo should be extended from the RestService
14013
+ */
14014
+ PropertySaleService.prototype.add = function (model) {
14015
+ var _this = this;
14016
+ return _super.prototype.add.call(this, model).pipe(operators.map(function (newPropertySale) {
14017
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.PROPERTY_SALE_ADDED, newPropertySale));
14018
+ return newPropertySale;
14019
+ }));
14020
+ };
14021
+ /**
14022
+ * @Todo should be extended from the RestService
14023
+ */
14024
+ PropertySaleService.prototype.delete = function (model) {
14025
+ var _this = this;
14026
+ return _super.prototype.delete.call(this, model).pipe(operators.map(function () {
14027
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.PROPERTY_SALE_DELETED, model));
14028
+ }));
14029
+ };
13952
14030
  return PropertySaleService;
13953
14031
  }(RestService));
13954
14032
  PropertySaleService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertySaleService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
@@ -14590,11 +14668,11 @@
14590
14668
  _this.cacheSubject.next(_this.cache);
14591
14669
  }));
14592
14670
  };
14593
- /**
14594
- * Run forecast update script on backend when user switched financial year
14595
- */
14596
- UserService.prototype.switchFinancialYear = function () {
14597
- return this.http.get(this.environment.apiV2 + "/financial-year/switch");
14671
+ UserService.prototype.switchFinancialYear = function (year) {
14672
+ return this.http.get(this.environment.apiV2 + "/financial-year/switch", { params: new i1.HttpParams({ fromString: "financialYear=" + year }) }).pipe(operators.map(function () {
14673
+ localStorage.setItem('financialYear', year.toString());
14674
+ window.location.reload();
14675
+ }));
14598
14676
  };
14599
14677
  /**
14600
14678
  * clear service cache