taxtank-core 0.21.17 → 0.22.0

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 (24) hide show
  1. package/bundles/taxtank-core.umd.js +100 -17
  2. package/bundles/taxtank-core.umd.js.map +1 -1
  3. package/esm2015/lib/collections/depreciation.collection.js +7 -2
  4. package/esm2015/lib/collections/property/property.collection.js +4 -1
  5. package/esm2015/lib/db/Models/property/property-share.js +1 -1
  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/fesm2015/taxtank-core.js +93 -17
  14. package/fesm2015/taxtank-core.js.map +1 -1
  15. package/lib/collections/depreciation.collection.d.ts +1 -0
  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/package.json +1 -1
@@ -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
  */
@@ -4644,12 +4652,18 @@
4644
4652
  enumerable: false,
4645
4653
  configurable: true
4646
4654
  });
4647
- DepreciationCollection.prototype.getClaimAmountByYear = function (year) {
4655
+ DepreciationCollection.prototype.getClaimedAmountByYear = function (year) {
4648
4656
  if (year === void 0) { year = +localStorage.getItem('financialYear'); }
4649
4657
  return +Math.round(this.amount - this.items.reduce(function (sum, depreciation) {
4650
4658
  return sum + depreciation.getCloseBalanceByYear(year);
4651
4659
  }, 0)).toFixed(2);
4652
4660
  };
4661
+ DepreciationCollection.prototype.getClaimAmountByYear = function (year) {
4662
+ if (year === void 0) { year = +localStorage.getItem('financialYear'); }
4663
+ return this.items.reduce(function (sum, depreciation) {
4664
+ return sum + depreciation.getClaimAmountByYear(year);
4665
+ }, 0);
4666
+ };
4653
4667
  DepreciationCollection.prototype.getCloseBalanceByYear = function (year) {
4654
4668
  if (year === void 0) { year = +localStorage.getItem('financialYear'); }
4655
4669
  return this.items.reduce(function (sum, depreciation) {
@@ -4933,6 +4947,9 @@
4933
4947
  PropertyCollection.prototype.getSharedProperties = function () {
4934
4948
  return new PropertyCollection(this.items.filter(function (property) { return !property.isOwn(); }));
4935
4949
  };
4950
+ PropertyCollection.prototype.getUnsold = function () {
4951
+ return this.create(this.items.filter(function (property) { return !property.isSold(); }));
4952
+ };
4936
4953
  Object.defineProperty(PropertyCollection.prototype, "purchasePrice", {
4937
4954
  /**
4938
4955
  * Get total purchase price for all properties in the collection
@@ -9790,7 +9807,7 @@
9790
9807
  .getIncomeTransactions()
9791
9808
  .filterBy('chartAccounts.id', exports.ChartAccountsListEnum.OTHER_RENTAL_INCOME)
9792
9809
  .sumBy('claimAmount');
9793
- this.interestDeductionsAmount = Math.abs(transactions.getInterestTransactions().sumBy('amount'));
9810
+ this.interestDeductionsAmount = Math.abs(transactions.getInterestTransactions().sumBy('claimAmount'));
9794
9811
  this.capitalWorksDeductionsAmount = Math.abs(depreciations.getCapitalDepreciations().sumBy('claimAmount'));
9795
9812
  this.otherRentalDeductionsAmount = this.calculateOtherRentalDeductionsAmount();
9796
9813
  /**
@@ -10439,6 +10456,7 @@
10439
10456
  } });
10440
10457
 
10441
10458
  /**
10459
+ * @Todo Alex remove functionality related to PropertyShare
10442
10460
  * Service for work with Property
10443
10461
  */
10444
10462
  var PropertyService = /** @class */ (function (_super) {
@@ -10453,6 +10471,8 @@
10453
10471
  this.listenShareInviteAccepted();
10454
10472
  // @TODO Alex: consider to refactor property movements logic similar to client-movements
10455
10473
  this.listenMovementsChanged();
10474
+ this.listenSalesAdded();
10475
+ this.listenSalesDeleted();
10456
10476
  };
10457
10477
  /**
10458
10478
  * Update cache when share invitation accepted
@@ -10471,6 +10491,27 @@
10471
10491
  this.eventDispatcherService.on(exports.AppEventTypeEnum.PROPERTY_MOVEMENT_UPDATED).subscribe(function () { return _this.resetCache(); });
10472
10492
  this.eventDispatcherService.on(exports.AppEventTypeEnum.PROPERTY_MOVEMENT_DELETED).subscribe(function () { return _this.resetCache(); });
10473
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
+ };
10474
10515
  PropertyService.prototype.update = function (property) {
10475
10516
  var _this = this;
10476
10517
  return _super.prototype.update.call(this, property).pipe(operators.map(function (updatedProperty) {
@@ -13847,6 +13888,8 @@
13847
13888
  */
13848
13889
  PropertyShareService.prototype.listenEvents = function () {
13849
13890
  this.listenUserUpdated();
13891
+ this.listenSalesAdded();
13892
+ this.listenSalesDeleted();
13850
13893
  };
13851
13894
  /**
13852
13895
  * Updated loan
@@ -13924,6 +13967,27 @@
13924
13967
  });
13925
13968
  });
13926
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
+ };
13927
13991
  return PropertyShareService;
13928
13992
  }(RestService));
13929
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 });
@@ -13943,6 +14007,25 @@
13943
14007
  _this.url = 'properties/sales';
13944
14008
  return _this;
13945
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
+ };
13946
14029
  return PropertySaleService;
13947
14030
  }(RestService));
13948
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 });