taxtank-core 0.21.18 → 0.22.1

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 (25) hide show
  1. package/bundles/taxtank-core.umd.js +99 -22
  2. package/bundles/taxtank-core.umd.js.map +1 -1
  3. package/esm2015/lib/collections/property/property.collection.js +4 -1
  4. package/esm2015/lib/db/Models/property/property-share.js +1 -1
  5. package/esm2015/lib/interceptors/financial-year-interceptor.js +2 -2
  6. package/esm2015/lib/models/event/app-event-type.enum.js +18 -16
  7. package/esm2015/lib/models/property/property.js +4 -1
  8. package/esm2015/lib/models/report/my-tax/my-tax-rent/my-tax-rent.js +2 -2
  9. package/esm2015/lib/services/http/property/property-sale/property-sale.service.js +21 -1
  10. package/esm2015/lib/services/http/property/property-share/property-share.service.js +23 -1
  11. package/esm2015/lib/services/http/property/property.service.js +24 -1
  12. package/esm2015/lib/services/http/rest/rest.service.js +4 -1
  13. package/esm2015/lib/services/http/user/user.service.js +7 -6
  14. package/fesm2015/taxtank-core.js +93 -22
  15. package/fesm2015/taxtank-core.js.map +1 -1
  16. package/lib/collections/property/property.collection.d.ts +1 -0
  17. package/lib/db/Models/property/property-share.d.ts +2 -0
  18. package/lib/models/event/app-event-type.enum.d.ts +17 -15
  19. package/lib/models/property/property.d.ts +1 -0
  20. package/lib/services/http/property/property-sale/property-sale.service.d.ts +9 -0
  21. package/lib/services/http/property/property-share/property-share.service.d.ts +5 -0
  22. package/lib/services/http/property/property.service.d.ts +6 -0
  23. package/lib/services/http/rest/rest.service.d.ts +1 -0
  24. package/lib/services/http/user/user.service.d.ts +1 -4
  25. package/package.json +1 -1
@@ -166,7 +166,7 @@
166
166
  });
167
167
  // clone request to add new parameters
168
168
  var clonedReq = request.clone();
169
- if (!params.get('financialYear')) {
169
+ if (!params.get('financialYear') && !request.urlWithParams.includes('?financialYear')) {
170
170
  params = params.set('financialYear', localStorage.getItem('financialYear'));
171
171
  clonedReq = request.clone({
172
172
  params: params
@@ -575,21 +575,23 @@
575
575
  AppEventTypeEnum[AppEventTypeEnum["PROPERTY_MOVEMENT_UPDATED"] = 27] = "PROPERTY_MOVEMENT_UPDATED";
576
576
  AppEventTypeEnum[AppEventTypeEnum["PROPERTY_MOVEMENT_DELETED"] = 28] = "PROPERTY_MOVEMENT_DELETED";
577
577
  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";
578
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SALE_ADDED"] = 30] = "PROPERTY_SALE_ADDED";
579
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SALE_DELETED"] = 31] = "PROPERTY_SALE_DELETED";
580
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SUBSCRIPTION_ADDED"] = 32] = "PROPERTY_SUBSCRIPTION_ADDED";
581
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SUBSCRIPTION_DELETED"] = 33] = "PROPERTY_SUBSCRIPTION_DELETED";
582
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_VALUATION_DOCUMENT_CREATED"] = 34] = "PROPERTY_VALUATION_DOCUMENT_CREATED";
583
+ AppEventTypeEnum[AppEventTypeEnum["SERVICE_SUBSCRIPTION_UPDATED"] = 35] = "SERVICE_SUBSCRIPTION_UPDATED";
584
+ AppEventTypeEnum[AppEventTypeEnum["TAX_REVIEW_UPDATED"] = 36] = "TAX_REVIEW_UPDATED";
585
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_CREATED"] = 37] = "TRANSACTION_CREATED";
586
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_DELETED"] = 38] = "TRANSACTION_DELETED";
587
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_UPDATED"] = 39] = "TRANSACTION_UPDATED";
588
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTIONS_CREATED"] = 40] = "TRANSACTIONS_CREATED";
589
+ AppEventTypeEnum[AppEventTypeEnum["USER_UPDATED"] = 41] = "USER_UPDATED";
590
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_UPDATED"] = 42] = "VEHICLE_CLAIM_UPDATED";
591
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_CREATED"] = 43] = "VEHICLE_CLAIM_CREATED";
592
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_CREATED"] = 44] = "VEHICLE_LOGBOOK_CREATED";
593
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_UPDATED"] = 45] = "VEHICLE_LOGBOOK_UPDATED";
594
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_DELETED"] = 46] = "VEHICLE_LOGBOOK_DELETED";
593
595
  })(exports.AppEventTypeEnum || (exports.AppEventTypeEnum = {}));
594
596
 
595
597
  var EventDispatcherService = /** @class */ (function () {
@@ -1316,6 +1318,9 @@
1316
1318
  return items.find(function (item) { return item['id'] === id; });
1317
1319
  }));
1318
1320
  };
1321
+ RestService.prototype.find = function (id) {
1322
+ return this.cache.find(function (item) { return item['id'] === id; });
1323
+ };
1319
1324
  /**
1320
1325
  * add new instance and update cache
1321
1326
  * @TODO rename to post
@@ -2934,6 +2939,9 @@
2934
2939
  Property.prototype.isOwn = function () {
2935
2940
  return this.user.id === +localStorage.getItem('userId');
2936
2941
  };
2942
+ Property.prototype.isSold = function () {
2943
+ return !!this.myShare.sale;
2944
+ };
2937
2945
  /**
2938
2946
  * Get initials of property. Required by Photoable interface
2939
2947
  */
@@ -4939,6 +4947,9 @@
4939
4947
  PropertyCollection.prototype.getSharedProperties = function () {
4940
4948
  return new PropertyCollection(this.items.filter(function (property) { return !property.isOwn(); }));
4941
4949
  };
4950
+ PropertyCollection.prototype.getUnsold = function () {
4951
+ return this.create(this.items.filter(function (property) { return !property.isSold(); }));
4952
+ };
4942
4953
  Object.defineProperty(PropertyCollection.prototype, "purchasePrice", {
4943
4954
  /**
4944
4955
  * Get total purchase price for all properties in the collection
@@ -9796,7 +9807,7 @@
9796
9807
  .getIncomeTransactions()
9797
9808
  .filterBy('chartAccounts.id', exports.ChartAccountsListEnum.OTHER_RENTAL_INCOME)
9798
9809
  .sumBy('claimAmount');
9799
- this.interestDeductionsAmount = Math.abs(transactions.getInterestTransactions().sumBy('amount'));
9810
+ this.interestDeductionsAmount = Math.abs(transactions.getInterestTransactions().sumBy('claimAmount'));
9800
9811
  this.capitalWorksDeductionsAmount = Math.abs(depreciations.getCapitalDepreciations().sumBy('claimAmount'));
9801
9812
  this.otherRentalDeductionsAmount = this.calculateOtherRentalDeductionsAmount();
9802
9813
  /**
@@ -10445,6 +10456,7 @@
10445
10456
  } });
10446
10457
 
10447
10458
  /**
10459
+ * @Todo Alex remove functionality related to PropertyShare
10448
10460
  * Service for work with Property
10449
10461
  */
10450
10462
  var PropertyService = /** @class */ (function (_super) {
@@ -10459,6 +10471,8 @@
10459
10471
  this.listenShareInviteAccepted();
10460
10472
  // @TODO Alex: consider to refactor property movements logic similar to client-movements
10461
10473
  this.listenMovementsChanged();
10474
+ this.listenSalesAdded();
10475
+ this.listenSalesDeleted();
10462
10476
  };
10463
10477
  /**
10464
10478
  * Update cache when share invitation accepted
@@ -10477,6 +10491,27 @@
10477
10491
  this.eventDispatcherService.on(exports.AppEventTypeEnum.PROPERTY_MOVEMENT_UPDATED).subscribe(function () { return _this.resetCache(); });
10478
10492
  this.eventDispatcherService.on(exports.AppEventTypeEnum.PROPERTY_MOVEMENT_DELETED).subscribe(function () { return _this.resetCache(); });
10479
10493
  };
10494
+ /**
10495
+ * @Todo Alex refactor after PropertyShare will be cleared up
10496
+ */
10497
+ PropertyService.prototype.listenSalesAdded = function () {
10498
+ var _this = this;
10499
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.PROPERTY_SALE_ADDED).subscribe(function (propertySale) {
10500
+ var propertyToReplace = _this.cache.find(function (property) { return property.myShare.id === propertySale.share.id; });
10501
+ propertyToReplace.myShare.sale = classTransformer.plainToClass(PropertySale, { id: propertySale.id });
10502
+ replace(_this.cache, propertyToReplace);
10503
+ _this.updateCache();
10504
+ });
10505
+ };
10506
+ PropertyService.prototype.listenSalesDeleted = function () {
10507
+ var _this = this;
10508
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.PROPERTY_SALE_DELETED).subscribe(function (propertySale) {
10509
+ var propertyToReplace = _this.cache.find(function (property) { return property.myShare.id === propertySale.share.id; });
10510
+ propertyToReplace.myShare.sale = null;
10511
+ replace(_this.cache, propertyToReplace);
10512
+ _this.updateCache();
10513
+ });
10514
+ };
10480
10515
  PropertyService.prototype.update = function (property) {
10481
10516
  var _this = this;
10482
10517
  return _super.prototype.update.call(this, property).pipe(operators.map(function (updatedProperty) {
@@ -13853,6 +13888,8 @@
13853
13888
  */
13854
13889
  PropertyShareService.prototype.listenEvents = function () {
13855
13890
  this.listenUserUpdated();
13891
+ this.listenSalesAdded();
13892
+ this.listenSalesDeleted();
13856
13893
  };
13857
13894
  /**
13858
13895
  * Updated loan
@@ -13930,6 +13967,27 @@
13930
13967
  });
13931
13968
  });
13932
13969
  };
13970
+ /**
13971
+ * @Todo Alex refactor after PropertyShare functionality in PropertyService will be cleared up
13972
+ */
13973
+ PropertyShareService.prototype.listenSalesAdded = function () {
13974
+ var _this = this;
13975
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.PROPERTY_SALE_ADDED).subscribe(function (propertySale) {
13976
+ var shareToReplace = _this.find(propertySale.share.id);
13977
+ shareToReplace.sale = classTransformer.plainToClass(PropertySale, { id: propertySale.id });
13978
+ replace(_this.cache, shareToReplace);
13979
+ _this.updateCache();
13980
+ });
13981
+ };
13982
+ PropertyShareService.prototype.listenSalesDeleted = function () {
13983
+ var _this = this;
13984
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.PROPERTY_SALE_DELETED).subscribe(function (propertySale) {
13985
+ var shareToReplace = _this.find(propertySale.share.id);
13986
+ shareToReplace.sale = null;
13987
+ replace(_this.cache, shareToReplace);
13988
+ _this.updateCache();
13989
+ });
13990
+ };
13933
13991
  return PropertyShareService;
13934
13992
  }(RestService));
13935
13993
  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 +14007,25 @@
13949
14007
  _this.url = 'properties/sales';
13950
14008
  return _this;
13951
14009
  }
14010
+ /**
14011
+ * @Todo should be extended from the RestService
14012
+ */
14013
+ PropertySaleService.prototype.add = function (model) {
14014
+ var _this = this;
14015
+ return _super.prototype.add.call(this, model).pipe(operators.map(function (newPropertySale) {
14016
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.PROPERTY_SALE_ADDED, newPropertySale));
14017
+ return newPropertySale;
14018
+ }));
14019
+ };
14020
+ /**
14021
+ * @Todo should be extended from the RestService
14022
+ */
14023
+ PropertySaleService.prototype.delete = function (model) {
14024
+ var _this = this;
14025
+ return _super.prototype.delete.call(this, model).pipe(operators.map(function () {
14026
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.PROPERTY_SALE_DELETED, model));
14027
+ }));
14028
+ };
13952
14029
  return PropertySaleService;
13953
14030
  }(RestService));
13954
14031
  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 +14667,11 @@
14590
14667
  _this.cacheSubject.next(_this.cache);
14591
14668
  }));
14592
14669
  };
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");
14670
+ UserService.prototype.switchFinancialYear = function (year) {
14671
+ return this.http.get(this.environment.apiV2 + "/financial-year/switch", { params: new i1.HttpParams({ fromString: "financialYear=" + year }) }).pipe(operators.map(function () {
14672
+ localStorage.setItem('financialYear', year.toString());
14673
+ window.location.reload();
14674
+ }));
14598
14675
  };
14599
14676
  /**
14600
14677
  * clear service cache