taxtank-core 0.3.0 → 0.4.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 (72) hide show
  1. package/bundles/taxtank-core.umd.js +195 -70
  2. package/bundles/taxtank-core.umd.js.map +1 -1
  3. package/esm2015/lib/collections/bank-account.collection.js +3 -3
  4. package/esm2015/lib/collections/bank-transaction.collection.js +3 -3
  5. package/esm2015/lib/collections/client-movement.collection.js +3 -3
  6. package/esm2015/lib/collections/client-portfolio-report.collection.js +3 -3
  7. package/esm2015/lib/collections/client.collection.js +3 -3
  8. package/esm2015/lib/collections/collection-dictionary.js +1 -1
  9. package/esm2015/lib/collections/collection.js +75 -0
  10. package/esm2015/lib/collections/depreciation-forecast.collection.js +5 -5
  11. package/esm2015/lib/collections/depreciation.collection.js +8 -3
  12. package/esm2015/lib/collections/employee.collection.js +3 -3
  13. package/esm2015/lib/collections/income-source.collection.js +3 -3
  14. package/esm2015/lib/collections/loan.collection.js +3 -3
  15. package/esm2015/lib/collections/message-document.collection.js +3 -3
  16. package/esm2015/lib/collections/message.collection.js +3 -3
  17. package/esm2015/lib/collections/property.collection.js +3 -3
  18. package/esm2015/lib/collections/service-price.collection.js +3 -3
  19. package/esm2015/lib/collections/service-subscription.collection.js +3 -3
  20. package/esm2015/lib/collections/tax-return-category-item.collection.js +3 -3
  21. package/esm2015/lib/collections/tax-review.collection.js +3 -3
  22. package/esm2015/lib/collections/transaction-allocation.collection.js +3 -3
  23. package/esm2015/lib/collections/transaction.collection.js +3 -3
  24. package/esm2015/lib/collections/user-event-setting.collection.js +3 -3
  25. package/esm2015/lib/db/Enums/chart-accounts-metadata-list.enum.js +2 -1
  26. package/esm2015/lib/models/data-table/data-table.js +6 -4
  27. package/esm2015/lib/models/depreciation/depreciation.js +5 -1
  28. package/esm2015/lib/models/event/app-event-type.enum.js +17 -14
  29. package/esm2015/lib/models/logbook/vehicle-claim.js +7 -1
  30. package/esm2015/lib/models/transaction/transaction.js +11 -2
  31. package/esm2015/lib/services/pdf/pdf.service.js +39 -6
  32. package/esm2015/lib/services/property/property-category-movement.service.js +47 -0
  33. package/esm2015/lib/services/property/property.service.js +12 -1
  34. package/esm2015/lib/services/xlsx/xlsx.service.js +1 -1
  35. package/esm2015/public-api.js +3 -2
  36. package/fesm2015/taxtank-core.js +160 -54
  37. package/fesm2015/taxtank-core.js.map +1 -1
  38. package/lib/collections/bank-account.collection.d.ts +2 -2
  39. package/lib/collections/bank-transaction.collection.d.ts +2 -2
  40. package/lib/collections/client-movement.collection.d.ts +2 -2
  41. package/lib/collections/client-portfolio-report.collection.d.ts +2 -2
  42. package/lib/collections/client.collection.d.ts +2 -2
  43. package/lib/collections/collection-dictionary.d.ts +2 -2
  44. package/lib/collections/{abstract.collection.d.ts → collection.d.ts} +3 -9
  45. package/lib/collections/depreciation-forecast.collection.d.ts +2 -2
  46. package/lib/collections/depreciation.collection.d.ts +3 -2
  47. package/lib/collections/employee.collection.d.ts +2 -2
  48. package/lib/collections/income-source.collection.d.ts +2 -2
  49. package/lib/collections/loan.collection.d.ts +2 -2
  50. package/lib/collections/message-document.collection.d.ts +2 -2
  51. package/lib/collections/message.collection.d.ts +2 -2
  52. package/lib/collections/property.collection.d.ts +2 -2
  53. package/lib/collections/service-price.collection.d.ts +2 -2
  54. package/lib/collections/service-subscription.collection.d.ts +2 -2
  55. package/lib/collections/tax-return-category-item.collection.d.ts +2 -2
  56. package/lib/collections/tax-review.collection.d.ts +2 -2
  57. package/lib/collections/transaction-allocation.collection.d.ts +2 -2
  58. package/lib/collections/transaction.collection.d.ts +2 -2
  59. package/lib/collections/user-event-setting.collection.d.ts +2 -2
  60. package/lib/db/Enums/chart-accounts-metadata-list.enum.d.ts +1 -0
  61. package/lib/models/data-table/data-table.d.ts +2 -2
  62. package/lib/models/depreciation/depreciation.d.ts +1 -0
  63. package/lib/models/event/app-event-type.enum.d.ts +16 -13
  64. package/lib/models/logbook/vehicle-claim.d.ts +4 -0
  65. package/lib/models/transaction/transaction.d.ts +3 -0
  66. package/lib/services/pdf/pdf.service.d.ts +10 -1
  67. package/lib/services/property/property-category-movement.service.d.ts +15 -0
  68. package/lib/services/property/property.service.d.ts +4 -0
  69. package/lib/services/xlsx/xlsx.service.d.ts +1 -1
  70. package/package.json +1 -1
  71. package/public-api.d.ts +2 -1
  72. package/esm2015/lib/collections/abstract.collection.js +0 -83
@@ -1216,25 +1216,25 @@
1216
1216
 
1217
1217
  var DEFAULT_INDEX = 'other';
1218
1218
  /**
1219
- * collection abstract class. Contains common properties and methods for all collections
1219
+ * Base collection class. Contains common properties and methods for all collections
1220
1220
  */
1221
- var AbstractCollection = /** @class */ (function () {
1222
- function AbstractCollection(items) {
1221
+ var Collection = /** @class */ (function () {
1222
+ function Collection(items) {
1223
1223
  if (items === void 0) { items = []; }
1224
1224
  this.items = items;
1225
1225
  }
1226
- AbstractCollection.prototype.create = function (items) {
1226
+ Collection.prototype.create = function (items) {
1227
1227
  if (items === void 0) { items = []; }
1228
1228
  return new this.constructor(items);
1229
1229
  };
1230
- AbstractCollection.prototype.getBy = function (field, value) {
1230
+ Collection.prototype.getBy = function (field, value) {
1231
1231
  return this.create(this.items.filter(function (item) { return item[field] === value; }));
1232
1232
  };
1233
- AbstractCollection.prototype.groupBy = function (path) {
1233
+ Collection.prototype.groupBy = function (path) {
1234
1234
  if (path === void 0) { path = ''; }
1235
1235
  return new CollectionDictionary(this, path);
1236
1236
  };
1237
- AbstractCollection.prototype.indexBy = function (path) {
1237
+ Collection.prototype.indexBy = function (path) {
1238
1238
  // Create empty initial object for groups
1239
1239
  var result = {};
1240
1240
  this.toArray().forEach(function (model) {
@@ -1245,11 +1245,11 @@
1245
1245
  /**
1246
1246
  * Iterator that allow to iterate collection items
1247
1247
  */
1248
- AbstractCollection.prototype[Symbol.iterator] = function () {
1248
+ Collection.prototype[Symbol.iterator] = function () {
1249
1249
  // .values() returns Iterator instance for array
1250
1250
  return this.items.values();
1251
1251
  };
1252
- Object.defineProperty(AbstractCollection.prototype, "length", {
1252
+ Object.defineProperty(Collection.prototype, "length", {
1253
1253
  /**
1254
1254
  * get collection length
1255
1255
  */
@@ -1259,55 +1259,46 @@
1259
1259
  enumerable: false,
1260
1260
  configurable: true
1261
1261
  });
1262
- /**
1263
- * method returns amount of fields from passed items
1264
- * @param field Name of field for calculation
1265
- * @param items (optional) Array of items need to be calculated. All collection's items by default
1266
- */
1267
- AbstractCollection.prototype.getSummary = function (field, items) {
1268
- if (items === void 0) { items = this.toArray(); }
1269
- return items.reduce(function (sum, item) { return sum += item[field]; }, 0);
1270
- };
1271
1262
  /**
1272
1263
  * Get list of items ids
1273
1264
  */
1274
- AbstractCollection.prototype.getIds = function () {
1265
+ Collection.prototype.getIds = function () {
1275
1266
  return this.items.map(function (item) { return item['id']; });
1276
1267
  };
1277
1268
  /**
1278
1269
  * Get single item by id
1279
1270
  */
1280
- AbstractCollection.prototype.getById = function (id) {
1271
+ Collection.prototype.getById = function (id) {
1281
1272
  return this.items.find(function (item) { return item['id'] === id; });
1282
1273
  };
1283
- AbstractCollection.prototype.getByIds = function (ids) {
1274
+ Collection.prototype.getByIds = function (ids) {
1284
1275
  return this.items.filter(function (item) { return ids.includes(item['id']); });
1285
1276
  };
1286
1277
  /**
1287
1278
  * Get total sum of items by field
1288
1279
  * @param field Name of the field for sum
1289
1280
  */
1290
- AbstractCollection.prototype.sumBy = function (field) {
1281
+ Collection.prototype.sumBy = function (field) {
1291
1282
  return +this.items.reduce(function (sum, item) { return sum + Number(item[field]); }, 0).toFixed(2);
1292
1283
  };
1293
- AbstractCollection.prototype.toArray = function () {
1284
+ Collection.prototype.toArray = function () {
1294
1285
  return __spreadArray([], __read(this.items));
1295
1286
  };
1296
- Object.defineProperty(AbstractCollection.prototype, "first", {
1287
+ Object.defineProperty(Collection.prototype, "first", {
1297
1288
  get: function () {
1298
1289
  return first__default["default"](this.items);
1299
1290
  },
1300
1291
  enumerable: false,
1301
1292
  configurable: true
1302
1293
  });
1303
- Object.defineProperty(AbstractCollection.prototype, "last", {
1294
+ Object.defineProperty(Collection.prototype, "last", {
1304
1295
  get: function () {
1305
1296
  return last__default["default"](this.items);
1306
1297
  },
1307
1298
  enumerable: false,
1308
1299
  configurable: true
1309
1300
  });
1310
- return AbstractCollection;
1301
+ return Collection;
1311
1302
  }());
1312
1303
 
1313
1304
  exports.BankAccountTypeEnum = void 0;
@@ -1466,7 +1457,7 @@
1466
1457
  }, 0);
1467
1458
  };
1468
1459
  return BankAccountCollection;
1469
- }(AbstractCollection));
1460
+ }(Collection));
1470
1461
 
1471
1462
  exports.TransactionOperationEnum = void 0;
1472
1463
  (function (TransactionOperationEnum) {
@@ -1607,7 +1598,7 @@
1607
1598
  return new BankTransactionCollection(this.items.filter(function (bankTransaction) { return !bankTransaction.isAllocated(allocations); }));
1608
1599
  };
1609
1600
  return BankTransactionCollection;
1610
- }(AbstractCollection));
1601
+ }(Collection));
1611
1602
 
1612
1603
  var ClientCollection = /** @class */ (function (_super) {
1613
1604
  __extends(ClientCollection, _super);
@@ -1615,7 +1606,7 @@
1615
1606
  return _super !== null && _super.apply(this, arguments) || this;
1616
1607
  }
1617
1608
  return ClientCollection;
1618
- }(AbstractCollection));
1609
+ }(Collection));
1619
1610
 
1620
1611
  exports.FirmTypeEnum = void 0;
1621
1612
  (function (FirmTypeEnum) {
@@ -1644,7 +1635,7 @@
1644
1635
  configurable: true
1645
1636
  });
1646
1637
  return EmployeeCollection;
1647
- }(AbstractCollection));
1638
+ }(Collection));
1648
1639
 
1649
1640
  /**
1650
1641
  * Collection of tax review
@@ -1697,7 +1688,7 @@
1697
1688
  return new ClientMovementCollection(this.items.filter(function (clientMovement) { return clientMovement.firm.type === firmType; }));
1698
1689
  };
1699
1690
  return ClientMovementCollection;
1700
- }(AbstractCollection));
1691
+ }(Collection));
1701
1692
 
1702
1693
  var ClientPortfolioReportCollection = /** @class */ (function (_super) {
1703
1694
  __extends(ClientPortfolioReportCollection, _super);
@@ -1762,7 +1753,7 @@
1762
1753
  return this.items.find(function (item) { return item.category === name; });
1763
1754
  };
1764
1755
  return ClientPortfolioReportCollection;
1765
- }(AbstractCollection));
1756
+ }(Collection));
1766
1757
 
1767
1758
  exports.TankTypeEnum = void 0;
1768
1759
  (function (TankTypeEnum) {
@@ -1800,6 +1791,11 @@
1800
1791
  return sum + depreciation.getClaimAmountByYear(year);
1801
1792
  }, 0);
1802
1793
  };
1794
+ DepreciationCollection.prototype.getCurrentYearForecastAmount = function () {
1795
+ return this.items.reduce(function (sum, depreciation) {
1796
+ return sum + depreciation.getCurrentYearForecastAmount();
1797
+ }, 0);
1798
+ };
1803
1799
  Object.defineProperty(DepreciationCollection.prototype, "assetValue", {
1804
1800
  get: function () {
1805
1801
  return this.sumBy('assetValue');
@@ -1849,7 +1845,7 @@
1849
1845
  })), 'id');
1850
1846
  };
1851
1847
  return DepreciationCollection;
1852
- }(AbstractCollection));
1848
+ }(Collection));
1853
1849
 
1854
1850
  /**
1855
1851
  * Collection of depreciations
@@ -1867,20 +1863,20 @@
1867
1863
  };
1868
1864
  Object.defineProperty(DepreciationForecastCollection.prototype, "amount", {
1869
1865
  get: function () {
1870
- return this.getSummary('amount');
1866
+ return this.sumBy('amount');
1871
1867
  },
1872
1868
  enumerable: false,
1873
1869
  configurable: true
1874
1870
  });
1875
1871
  Object.defineProperty(DepreciationForecastCollection.prototype, "claimAmount", {
1876
1872
  get: function () {
1877
- return this.getSummary('claimAmount');
1873
+ return this.sumBy('claimAmount');
1878
1874
  },
1879
1875
  enumerable: false,
1880
1876
  configurable: true
1881
1877
  });
1882
1878
  return DepreciationForecastCollection;
1883
- }(AbstractCollection));
1879
+ }(Collection));
1884
1880
 
1885
1881
  /**
1886
1882
  * Collection of income sources
@@ -1925,7 +1921,7 @@
1925
1921
  configurable: true
1926
1922
  });
1927
1923
  return IncomeSourceCollection;
1928
- }(AbstractCollection));
1924
+ }(Collection));
1929
1925
 
1930
1926
  var LoanCollection = /** @class */ (function (_super) {
1931
1927
  __extends(LoanCollection, _super);
@@ -1947,7 +1943,7 @@
1947
1943
  return this.items.find(function (loan) { var _a; return ((_a = loan.bankAccount) === null || _a === void 0 ? void 0 : _a.id) === id; });
1948
1944
  };
1949
1945
  return LoanCollection;
1950
- }(AbstractCollection));
1946
+ }(Collection));
1951
1947
 
1952
1948
  var FinancialYear = /** @class */ (function () {
1953
1949
  function FinancialYear(date) {
@@ -2141,7 +2137,7 @@
2141
2137
  return !!this.getUnread().length;
2142
2138
  };
2143
2139
  return MessageCollection;
2144
- }(AbstractCollection));
2140
+ }(Collection));
2145
2141
 
2146
2142
  /**
2147
2143
  * Collection of MessageDocument instances
@@ -2158,7 +2154,7 @@
2158
2154
  return new MessageDocumentCollection(this.items.filter(function (doc) { return !doc.message; }));
2159
2155
  };
2160
2156
  return MessageDocumentCollection;
2161
- }(AbstractCollection));
2157
+ }(Collection));
2162
2158
 
2163
2159
  var PropertyCollection = /** @class */ (function (_super) {
2164
2160
  __extends(PropertyCollection, _super);
@@ -2264,7 +2260,7 @@
2264
2260
  return uniqBy__default["default"](this.items.map(function (property) { return property.category; }), 'id');
2265
2261
  };
2266
2262
  return PropertyCollection;
2267
- }(AbstractCollection));
2263
+ }(Collection));
2268
2264
 
2269
2265
  var ServicePriceCollection = /** @class */ (function (_super) {
2270
2266
  __extends(ServicePriceCollection, _super);
@@ -2286,7 +2282,7 @@
2286
2282
  configurable: true
2287
2283
  });
2288
2284
  return ServicePriceCollection;
2289
- }(AbstractCollection));
2285
+ }(Collection));
2290
2286
 
2291
2287
  var ServiceSubscriptionCollection = /** @class */ (function (_super) {
2292
2288
  __extends(ServiceSubscriptionCollection, _super);
@@ -2319,7 +2315,7 @@
2319
2315
  return (_a = this.items.filter(function (subscription) { return subscription.propertyQuantity === properties; })[0]) !== null && _a !== void 0 ? _a : this.investor;
2320
2316
  };
2321
2317
  return ServiceSubscriptionCollection;
2322
- }(AbstractCollection));
2318
+ }(Collection));
2323
2319
 
2324
2320
  exports.TaxReturnCategoryListEnum = void 0;
2325
2321
  (function (TaxReturnCategoryListEnum) {
@@ -2579,7 +2575,7 @@
2579
2575
  return this.items.find(function (item) { return item.taxReturnCategory.id === category; });
2580
2576
  };
2581
2577
  return TaxReturnCategoryItemCollection;
2582
- }(AbstractCollection));
2578
+ }(Collection));
2583
2579
 
2584
2580
  /**
2585
2581
  * Collection of tax review
@@ -2637,7 +2633,7 @@
2637
2633
  return uniqBy__default["default"](this.items.map(function (review) { return review.employee; }), 'id');
2638
2634
  };
2639
2635
  return TaxReviewCollection;
2640
- }(AbstractCollection));
2636
+ }(Collection));
2641
2637
 
2642
2638
  var TransactionAllocationCollection = /** @class */ (function (_super) {
2643
2639
  __extends(TransactionAllocationCollection, _super);
@@ -2685,7 +2681,7 @@
2685
2681
  return !!this.items.find(function (allocation) { return allocation.bankTransaction.id === bankTransaction.id; });
2686
2682
  };
2687
2683
  return TransactionAllocationCollection;
2688
- }(AbstractCollection));
2684
+ }(Collection));
2689
2685
 
2690
2686
  /**
2691
2687
  * Collection of transactions
@@ -2833,7 +2829,7 @@
2833
2829
  return new TransactionCollection(this.items.filter(function (transaction) { return allocations.hasTransaction(transaction); }));
2834
2830
  };
2835
2831
  return TransactionCollection;
2836
- }(AbstractCollection));
2832
+ }(Collection));
2837
2833
 
2838
2834
  /**
2839
2835
  * Collection of user event settings
@@ -2847,7 +2843,7 @@
2847
2843
  return new UserEventSettingCollection(this.items.filter(function (setting) { return setting[field] !== null; }));
2848
2844
  };
2849
2845
  return UserEventSettingCollection;
2850
- }(AbstractCollection));
2846
+ }(Collection));
2851
2847
 
2852
2848
  exports.ChartAccountsCategoryEnum = void 0;
2853
2849
  (function (ChartAccountsCategoryEnum) {
@@ -3050,6 +3046,7 @@
3050
3046
  (function (ChartAccountsMetadataListEnum) {
3051
3047
  ChartAccountsMetadataListEnum[ChartAccountsMetadataListEnum["TAX_INSTALMENTS"] = 4] = "TAX_INSTALMENTS";
3052
3048
  ChartAccountsMetadataListEnum[ChartAccountsMetadataListEnum["FRANKING_CREDIT"] = 5] = "FRANKING_CREDIT";
3049
+ ChartAccountsMetadataListEnum[ChartAccountsMetadataListEnum["ELIGIBLE_FOR_REDUCTION"] = 6] = "ELIGIBLE_FOR_REDUCTION";
3053
3050
  ChartAccountsMetadataListEnum[ChartAccountsMetadataListEnum["SHARE_PERCENTAGE"] = 7] = "SHARE_PERCENTAGE";
3054
3051
  ChartAccountsMetadataListEnum[ChartAccountsMetadataListEnum["TAX_OFFSETS"] = 8] = "TAX_OFFSETS";
3055
3052
  ChartAccountsMetadataListEnum[ChartAccountsMetadataListEnum["HOURS"] = 11] = "HOURS";
@@ -5483,6 +5480,10 @@
5483
5480
  var _a;
5484
5481
  return (_a = this.currentYearForecast) === null || _a === void 0 ? void 0 : _a.claimPercent;
5485
5482
  };
5483
+ Depreciation.prototype.getCurrentYearForecastAmount = function () {
5484
+ var _a;
5485
+ return ((_a = this.currentYearForecast) === null || _a === void 0 ? void 0 : _a.amount) || 0;
5486
+ };
5486
5487
  Depreciation.prototype.isBuildingAtCost = function () {
5487
5488
  return this.chartAccounts.id === exports.ChartAccountsListEnum.BUILDING_AT_COST;
5488
5489
  };
@@ -5630,6 +5631,13 @@
5630
5631
  enumerable: false,
5631
5632
  configurable: true
5632
5633
  });
5634
+ Object.defineProperty(Transaction.prototype, "eligibleForReduction", {
5635
+ get: function () {
5636
+ return this.getMetadataFieldValue(exports.ChartAccountsMetadataListEnum.ELIGIBLE_FOR_REDUCTION);
5637
+ },
5638
+ enumerable: false,
5639
+ configurable: true
5640
+ });
5633
5641
  Object.defineProperty(Transaction.prototype, "untaxedElement", {
5634
5642
  get: function () {
5635
5643
  return this.getMetadataFieldValue(exports.ChartAccountsMetadataListEnum.UNTAXED_ELEMENT);
@@ -5648,6 +5656,20 @@
5648
5656
  enumerable: false,
5649
5657
  configurable: true
5650
5658
  });
5659
+ Object.defineProperty(Transaction.prototype, "debit", {
5660
+ get: function () {
5661
+ return this.isDebit() ? Math.abs(this.amount) : null;
5662
+ },
5663
+ enumerable: false,
5664
+ configurable: true
5665
+ });
5666
+ Object.defineProperty(Transaction.prototype, "credit", {
5667
+ get: function () {
5668
+ return this.isCredit() ? Math.abs(this.amount) : null;
5669
+ },
5670
+ enumerable: false,
5671
+ configurable: true
5672
+ });
5651
5673
  /**
5652
5674
  * Get value of transaction metadata field
5653
5675
  * @param field for which value should be returned
@@ -5671,7 +5693,7 @@
5671
5693
  (this.transactions
5672
5694
  .reduce(function (sum, transaction) { return sum + Math.abs(transaction.amount); }, 0) * modifier);
5673
5695
  case this.isWorkTank():
5674
- return this.amount + ((this.tax + this.frankingCredit - this.taxFreeComponent) * modifier);
5696
+ return this.amount + ((this.tax + this.frankingCredit - this.taxFreeComponent - this.eligibleForReduction) * modifier);
5675
5697
  default:
5676
5698
  return this.amount || 0;
5677
5699
  }
@@ -6442,9 +6464,11 @@
6442
6464
  if (!column.total) {
6443
6465
  return '';
6444
6466
  }
6445
- return collection.items
6446
- .reduce(function (sum, item) { return sum + Number(item[column.key]); }, 0)
6447
- .toString();
6467
+ var totalValue = collection.items.reduce(function (sum, item) {
6468
+ // check if current collection item has value. If not - don't add it to the sum
6469
+ return item[column.key] !== null ? sum + Number(item[column.key]) : sum;
6470
+ }, null);
6471
+ return (totalValue !== null && totalValue !== void 0 ? totalValue : '-').toString();
6448
6472
  });
6449
6473
  };
6450
6474
  return DataTable;
@@ -6684,19 +6708,22 @@
6684
6708
  AppEventTypeEnum[AppEventTypeEnum["NOTIFICATION_ADDED"] = 19] = "NOTIFICATION_ADDED";
6685
6709
  AppEventTypeEnum[AppEventTypeEnum["PROPERTY_UPDATED_WITH_DOCUMENT"] = 20] = "PROPERTY_UPDATED_WITH_DOCUMENT";
6686
6710
  AppEventTypeEnum[AppEventTypeEnum["PROPERTY_DOCUMENT_ADDED"] = 21] = "PROPERTY_DOCUMENT_ADDED";
6687
- AppEventTypeEnum[AppEventTypeEnum["PROPERTY_OWNER_UPDATED"] = 22] = "PROPERTY_OWNER_UPDATED";
6688
- AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SUBSCRIPTION_ADDED"] = 23] = "PROPERTY_SUBSCRIPTION_ADDED";
6689
- AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SUBSCRIPTION_DELETED"] = 24] = "PROPERTY_SUBSCRIPTION_DELETED";
6690
- AppEventTypeEnum[AppEventTypeEnum["PROPERTY_VALUATION_DOCUMENT_CREATED"] = 25] = "PROPERTY_VALUATION_DOCUMENT_CREATED";
6691
- AppEventTypeEnum[AppEventTypeEnum["SERVICE_SUBSCRIPTION_UPDATED"] = 26] = "SERVICE_SUBSCRIPTION_UPDATED";
6692
- AppEventTypeEnum[AppEventTypeEnum["TAX_REVIEW_UPDATED"] = 27] = "TAX_REVIEW_UPDATED";
6693
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_CREATED"] = 28] = "TRANSACTION_CREATED";
6694
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_DELETED"] = 29] = "TRANSACTION_DELETED";
6695
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_UPDATED"] = 30] = "TRANSACTION_UPDATED";
6696
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTIONS_CREATED"] = 31] = "TRANSACTIONS_CREATED";
6697
- AppEventTypeEnum[AppEventTypeEnum["USER_UPDATED"] = 32] = "USER_UPDATED";
6698
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_UPDATED"] = 33] = "VEHICLE_CLAIM_UPDATED";
6699
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_CREATED"] = 34] = "VEHICLE_CLAIM_CREATED";
6711
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_MOVEMENT_CREATED"] = 22] = "PROPERTY_MOVEMENT_CREATED";
6712
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_MOVEMENT_UPDATED"] = 23] = "PROPERTY_MOVEMENT_UPDATED";
6713
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_MOVEMENT_DELETED"] = 24] = "PROPERTY_MOVEMENT_DELETED";
6714
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_OWNER_UPDATED"] = 25] = "PROPERTY_OWNER_UPDATED";
6715
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SUBSCRIPTION_ADDED"] = 26] = "PROPERTY_SUBSCRIPTION_ADDED";
6716
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SUBSCRIPTION_DELETED"] = 27] = "PROPERTY_SUBSCRIPTION_DELETED";
6717
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_VALUATION_DOCUMENT_CREATED"] = 28] = "PROPERTY_VALUATION_DOCUMENT_CREATED";
6718
+ AppEventTypeEnum[AppEventTypeEnum["SERVICE_SUBSCRIPTION_UPDATED"] = 29] = "SERVICE_SUBSCRIPTION_UPDATED";
6719
+ AppEventTypeEnum[AppEventTypeEnum["TAX_REVIEW_UPDATED"] = 30] = "TAX_REVIEW_UPDATED";
6720
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_CREATED"] = 31] = "TRANSACTION_CREATED";
6721
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_DELETED"] = 32] = "TRANSACTION_DELETED";
6722
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_UPDATED"] = 33] = "TRANSACTION_UPDATED";
6723
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTIONS_CREATED"] = 34] = "TRANSACTIONS_CREATED";
6724
+ AppEventTypeEnum[AppEventTypeEnum["USER_UPDATED"] = 35] = "USER_UPDATED";
6725
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_UPDATED"] = 36] = "VEHICLE_CLAIM_UPDATED";
6726
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_CREATED"] = 37] = "VEHICLE_CLAIM_CREATED";
6700
6727
  })(exports.AppEventTypeEnum || (exports.AppEventTypeEnum = {}));
6701
6728
 
6702
6729
  exports.IconsFileEnum = void 0;
@@ -6924,6 +6951,12 @@
6924
6951
  enumerable: false,
6925
6952
  configurable: true
6926
6953
  });
6954
+ /**
6955
+ * Claim amount for Kms method
6956
+ */
6957
+ VehicleClaim.prototype.getKmsClaimAmount = function (vehicleClaimRate) {
6958
+ return +(this.kilometers * vehicleClaimRate).toFixed(2);
6959
+ };
6927
6960
  return VehicleClaim;
6928
6961
  }(VehicleClaim$1));
6929
6962
 
@@ -10343,14 +10376,47 @@
10343
10376
  document.save(fileName + ".pdf");
10344
10377
  };
10345
10378
  /**
10379
+ * @Todo rename when all DataTable dependent methods will be cleared-up
10380
+ */
10381
+ PdfService.prototype.exportTables = function (tables, title, fileName) {
10382
+ var document = this.generateFromTables(tables, title);
10383
+ document.save(fileName + ".pdf");
10384
+ };
10385
+ /**
10386
+ * @Todo rename when all DataTable dependent methods will be cleared-up
10387
+ */
10388
+ PdfService.prototype.generateFromTables = function (tables, title) {
10389
+ var pdf = new jsPDF__default["default"]();
10390
+ // set document title
10391
+ pdf.setFontSize(PDF_CONFIG.text.fontSize)
10392
+ .setFont(PDF_CONFIG.text.fontName, PDF_CONFIG.text.fontStyle, PDF_CONFIG.text.fontWeight)
10393
+ .text(title, PDF_CONFIG.text.positionX, PDF_CONFIG.text.positionY);
10394
+ tables.forEach(function (table) {
10395
+ // coords of last table
10396
+ var lastTableCoords = pdf['lastAutoTable'].finalY || PDF_CONFIG.contentCoords.marginTop;
10397
+ // table options
10398
+ var options = {
10399
+ html: table,
10400
+ startY: lastTableCoords + PDF_CONFIG.contentTitleCoords.marginTop,
10401
+ footStyles: {
10402
+ fillColor: PDF_CONFIG.text.fillColor,
10403
+ textColor: PDF_CONFIG.text.textColor
10404
+ }
10405
+ };
10406
+ autoTable__default["default"](pdf, options);
10407
+ });
10408
+ return pdf;
10409
+ };
10410
+ /**
10411
+ * @Todo remove/refactor when all DataTable dependent methods will be cleared-up
10346
10412
  * Generate PDF file from provided data
10347
10413
  */
10348
10414
  PdfService.prototype.generatePdfFile = function (tables, title) {
10349
10415
  var pdf = new jsPDF__default["default"]();
10350
- // set document title
10351
- pdf.setFontSize(PDF_CONFIG.text.fontSize);
10352
- pdf.setFont(PDF_CONFIG.text.fontName, PDF_CONFIG.text.fontStyle, PDF_CONFIG.text.fontWeight);
10353
- pdf.text(title, PDF_CONFIG.text.positionX, PDF_CONFIG.text.positionY);
10416
+ // set document font params
10417
+ pdf.setFontSize(PDF_CONFIG.text.fontSize)
10418
+ .setFont(PDF_CONFIG.text.fontName, PDF_CONFIG.text.fontStyle, PDF_CONFIG.text.fontWeight)
10419
+ .text(title, PDF_CONFIG.text.positionX, PDF_CONFIG.text.positionY);
10354
10420
  tables.forEach(function (table) {
10355
10421
  // coords of last table
10356
10422
  var lastTableCoords = pdf['lastAutoTable'].finalY || PDF_CONFIG.contentCoords.marginTop;
@@ -10440,6 +10506,8 @@
10440
10506
  PropertyService.prototype.listenEvents = function () {
10441
10507
  this.listenCoOwnerInviteAccepted();
10442
10508
  this.listenServiceSubscriptionUpdated();
10509
+ // @TODO Alex: consider to refactor property movements logic similar to client-movements
10510
+ this.listenMovementsChanged();
10443
10511
  };
10444
10512
  /**
10445
10513
  * Update cache when owner invitation accepted
@@ -10455,6 +10523,16 @@
10455
10523
  var _this = this;
10456
10524
  this.eventDispatcherService.on(exports.AppEventTypeEnum.SERVICE_SUBSCRIPTION_UPDATED).subscribe(function () { return _this.resetCache(); });
10457
10525
  };
10526
+ /**
10527
+ * Update cache when property category changed
10528
+ */
10529
+ PropertyService.prototype.listenMovementsChanged = function () {
10530
+ var _this = this;
10531
+ // @TODO change dispatcher logic to work with multiple events
10532
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.PROPERTY_MOVEMENT_CREATED).subscribe(function () { return _this.resetCache(); });
10533
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.PROPERTY_MOVEMENT_UPDATED).subscribe(function () { return _this.resetCache(); });
10534
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.PROPERTY_MOVEMENT_DELETED).subscribe(function () { return _this.resetCache(); });
10535
+ };
10458
10536
  PropertyService.prototype.update = function (property) {
10459
10537
  var _this = this;
10460
10538
  return _super.prototype.update.call(this, property).pipe(operators.map(function (updatedProperty) {
@@ -10731,6 +10809,52 @@
10731
10809
  }]
10732
10810
  }] });
10733
10811
 
10812
+ var PropertyCategoryMovementService = /** @class */ (function (_super) {
10813
+ __extends(PropertyCategoryMovementService, _super);
10814
+ function PropertyCategoryMovementService() {
10815
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
10816
+ _this.modelClass = PropertyCategoryMovement;
10817
+ _this.url = 'properties/category-movements';
10818
+ return _this;
10819
+ }
10820
+ PropertyCategoryMovementService.prototype.add = function (model) {
10821
+ var _this = this;
10822
+ return _super.prototype.add.call(this, model).pipe(operators.map(function (newMovement) {
10823
+ // @TODO Alex: we need to teach restService to dispatch events + limit list of methods (not all services have all 4 or even more considering batch requests) + collections
10824
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.PROPERTY_MOVEMENT_CREATED, null));
10825
+ return newMovement;
10826
+ }));
10827
+ };
10828
+ PropertyCategoryMovementService.prototype.update = function (model) {
10829
+ var _this = this;
10830
+ return _super.prototype.update.call(this, model).pipe(operators.map(function (updatedMovement) {
10831
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.PROPERTY_MOVEMENT_CREATED, null));
10832
+ return updatedMovement;
10833
+ }));
10834
+ };
10835
+ PropertyCategoryMovementService.prototype.delete = function (model) {
10836
+ var _this = this;
10837
+ return _super.prototype.delete.call(this, model).pipe(operators.map(function () {
10838
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.PROPERTY_MOVEMENT_CREATED, null));
10839
+ }));
10840
+ };
10841
+ // @TODO Alex: Move to collection
10842
+ PropertyCategoryMovementService.prototype.getByPropertyId = function (id) {
10843
+ return this.get().pipe(operators.map(function (movements) {
10844
+ return movements.filter(function (movement) { return movement.property.id === id; });
10845
+ }));
10846
+ };
10847
+ return PropertyCategoryMovementService;
10848
+ }(BaseRestService));
10849
+ PropertyCategoryMovementService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyCategoryMovementService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
10850
+ PropertyCategoryMovementService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyCategoryMovementService, providedIn: 'root' });
10851
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyCategoryMovementService, decorators: [{
10852
+ type: i0.Injectable,
10853
+ args: [{
10854
+ providedIn: 'root'
10855
+ }]
10856
+ }] });
10857
+
10734
10858
  /**
10735
10859
  * Class for work with Property Documents
10736
10860
  */
@@ -12351,7 +12475,6 @@
12351
12475
  * Generated bundle index. Do not edit.
12352
12476
  */
12353
12477
 
12354
- exports.AbstractCollection = AbstractCollection;
12355
12478
  exports.Address = Address;
12356
12479
  exports.AddressService = AddressService;
12357
12480
  exports.AppEvent = AppEvent;
@@ -12404,6 +12527,7 @@
12404
12527
  exports.ClientPortfolioReport = ClientPortfolioReport;
12405
12528
  exports.ClientPortfolioReportCollection = ClientPortfolioReportCollection;
12406
12529
  exports.ClientPortfolioReportService = ClientPortfolioReportService;
12530
+ exports.Collection = Collection;
12407
12531
  exports.CollectionDictionary = CollectionDictionary;
12408
12532
  exports.CorelogicService = CorelogicService;
12409
12533
  exports.CorelogicSuggestion = CorelogicSuggestion;
@@ -12478,6 +12602,7 @@
12478
12602
  exports.PropertyCapitalCostService = PropertyCapitalCostService;
12479
12603
  exports.PropertyCategory = PropertyCategory;
12480
12604
  exports.PropertyCategoryMovement = PropertyCategoryMovement;
12605
+ exports.PropertyCategoryMovementService = PropertyCategoryMovementService;
12481
12606
  exports.PropertyCategoryService = PropertyCategoryService;
12482
12607
  exports.PropertyCollection = PropertyCollection;
12483
12608
  exports.PropertyDocument = PropertyDocument;