taxtank-core 0.3.0 → 0.3.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 (62) hide show
  1. package/bundles/taxtank-core.umd.js +102 -56
  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 +3 -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/models/data-table/data-table.js +6 -4
  26. package/esm2015/lib/models/logbook/vehicle-claim.js +7 -1
  27. package/esm2015/lib/models/transaction/transaction.js +7 -1
  28. package/esm2015/lib/services/pdf/pdf.service.js +39 -6
  29. package/esm2015/lib/services/xlsx/xlsx.service.js +1 -1
  30. package/esm2015/public-api.js +2 -2
  31. package/fesm2015/taxtank-core.js +79 -40
  32. package/fesm2015/taxtank-core.js.map +1 -1
  33. package/lib/collections/bank-account.collection.d.ts +2 -2
  34. package/lib/collections/bank-transaction.collection.d.ts +2 -2
  35. package/lib/collections/client-movement.collection.d.ts +2 -2
  36. package/lib/collections/client-portfolio-report.collection.d.ts +2 -2
  37. package/lib/collections/client.collection.d.ts +2 -2
  38. package/lib/collections/collection-dictionary.d.ts +2 -2
  39. package/lib/collections/{abstract.collection.d.ts → collection.d.ts} +3 -9
  40. package/lib/collections/depreciation-forecast.collection.d.ts +2 -2
  41. package/lib/collections/depreciation.collection.d.ts +2 -2
  42. package/lib/collections/employee.collection.d.ts +2 -2
  43. package/lib/collections/income-source.collection.d.ts +2 -2
  44. package/lib/collections/loan.collection.d.ts +2 -2
  45. package/lib/collections/message-document.collection.d.ts +2 -2
  46. package/lib/collections/message.collection.d.ts +2 -2
  47. package/lib/collections/property.collection.d.ts +2 -2
  48. package/lib/collections/service-price.collection.d.ts +2 -2
  49. package/lib/collections/service-subscription.collection.d.ts +2 -2
  50. package/lib/collections/tax-return-category-item.collection.d.ts +2 -2
  51. package/lib/collections/tax-review.collection.d.ts +2 -2
  52. package/lib/collections/transaction-allocation.collection.d.ts +2 -2
  53. package/lib/collections/transaction.collection.d.ts +2 -2
  54. package/lib/collections/user-event-setting.collection.d.ts +2 -2
  55. package/lib/models/data-table/data-table.d.ts +2 -2
  56. package/lib/models/logbook/vehicle-claim.d.ts +4 -0
  57. package/lib/models/transaction/transaction.d.ts +2 -0
  58. package/lib/services/pdf/pdf.service.d.ts +10 -1
  59. package/lib/services/xlsx/xlsx.service.d.ts +1 -1
  60. package/package.json +1 -1
  61. package/public-api.d.ts +1 -1
  62. 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) {
@@ -1849,7 +1840,7 @@
1849
1840
  })), 'id');
1850
1841
  };
1851
1842
  return DepreciationCollection;
1852
- }(AbstractCollection));
1843
+ }(Collection));
1853
1844
 
1854
1845
  /**
1855
1846
  * Collection of depreciations
@@ -1867,20 +1858,20 @@
1867
1858
  };
1868
1859
  Object.defineProperty(DepreciationForecastCollection.prototype, "amount", {
1869
1860
  get: function () {
1870
- return this.getSummary('amount');
1861
+ return this.sumBy('amount');
1871
1862
  },
1872
1863
  enumerable: false,
1873
1864
  configurable: true
1874
1865
  });
1875
1866
  Object.defineProperty(DepreciationForecastCollection.prototype, "claimAmount", {
1876
1867
  get: function () {
1877
- return this.getSummary('claimAmount');
1868
+ return this.sumBy('claimAmount');
1878
1869
  },
1879
1870
  enumerable: false,
1880
1871
  configurable: true
1881
1872
  });
1882
1873
  return DepreciationForecastCollection;
1883
- }(AbstractCollection));
1874
+ }(Collection));
1884
1875
 
1885
1876
  /**
1886
1877
  * Collection of income sources
@@ -1925,7 +1916,7 @@
1925
1916
  configurable: true
1926
1917
  });
1927
1918
  return IncomeSourceCollection;
1928
- }(AbstractCollection));
1919
+ }(Collection));
1929
1920
 
1930
1921
  var LoanCollection = /** @class */ (function (_super) {
1931
1922
  __extends(LoanCollection, _super);
@@ -1947,7 +1938,7 @@
1947
1938
  return this.items.find(function (loan) { var _a; return ((_a = loan.bankAccount) === null || _a === void 0 ? void 0 : _a.id) === id; });
1948
1939
  };
1949
1940
  return LoanCollection;
1950
- }(AbstractCollection));
1941
+ }(Collection));
1951
1942
 
1952
1943
  var FinancialYear = /** @class */ (function () {
1953
1944
  function FinancialYear(date) {
@@ -2141,7 +2132,7 @@
2141
2132
  return !!this.getUnread().length;
2142
2133
  };
2143
2134
  return MessageCollection;
2144
- }(AbstractCollection));
2135
+ }(Collection));
2145
2136
 
2146
2137
  /**
2147
2138
  * Collection of MessageDocument instances
@@ -2158,7 +2149,7 @@
2158
2149
  return new MessageDocumentCollection(this.items.filter(function (doc) { return !doc.message; }));
2159
2150
  };
2160
2151
  return MessageDocumentCollection;
2161
- }(AbstractCollection));
2152
+ }(Collection));
2162
2153
 
2163
2154
  var PropertyCollection = /** @class */ (function (_super) {
2164
2155
  __extends(PropertyCollection, _super);
@@ -2264,7 +2255,7 @@
2264
2255
  return uniqBy__default["default"](this.items.map(function (property) { return property.category; }), 'id');
2265
2256
  };
2266
2257
  return PropertyCollection;
2267
- }(AbstractCollection));
2258
+ }(Collection));
2268
2259
 
2269
2260
  var ServicePriceCollection = /** @class */ (function (_super) {
2270
2261
  __extends(ServicePriceCollection, _super);
@@ -2286,7 +2277,7 @@
2286
2277
  configurable: true
2287
2278
  });
2288
2279
  return ServicePriceCollection;
2289
- }(AbstractCollection));
2280
+ }(Collection));
2290
2281
 
2291
2282
  var ServiceSubscriptionCollection = /** @class */ (function (_super) {
2292
2283
  __extends(ServiceSubscriptionCollection, _super);
@@ -2319,7 +2310,7 @@
2319
2310
  return (_a = this.items.filter(function (subscription) { return subscription.propertyQuantity === properties; })[0]) !== null && _a !== void 0 ? _a : this.investor;
2320
2311
  };
2321
2312
  return ServiceSubscriptionCollection;
2322
- }(AbstractCollection));
2313
+ }(Collection));
2323
2314
 
2324
2315
  exports.TaxReturnCategoryListEnum = void 0;
2325
2316
  (function (TaxReturnCategoryListEnum) {
@@ -2579,7 +2570,7 @@
2579
2570
  return this.items.find(function (item) { return item.taxReturnCategory.id === category; });
2580
2571
  };
2581
2572
  return TaxReturnCategoryItemCollection;
2582
- }(AbstractCollection));
2573
+ }(Collection));
2583
2574
 
2584
2575
  /**
2585
2576
  * Collection of tax review
@@ -2637,7 +2628,7 @@
2637
2628
  return uniqBy__default["default"](this.items.map(function (review) { return review.employee; }), 'id');
2638
2629
  };
2639
2630
  return TaxReviewCollection;
2640
- }(AbstractCollection));
2631
+ }(Collection));
2641
2632
 
2642
2633
  var TransactionAllocationCollection = /** @class */ (function (_super) {
2643
2634
  __extends(TransactionAllocationCollection, _super);
@@ -2685,7 +2676,7 @@
2685
2676
  return !!this.items.find(function (allocation) { return allocation.bankTransaction.id === bankTransaction.id; });
2686
2677
  };
2687
2678
  return TransactionAllocationCollection;
2688
- }(AbstractCollection));
2679
+ }(Collection));
2689
2680
 
2690
2681
  /**
2691
2682
  * Collection of transactions
@@ -2833,7 +2824,7 @@
2833
2824
  return new TransactionCollection(this.items.filter(function (transaction) { return allocations.hasTransaction(transaction); }));
2834
2825
  };
2835
2826
  return TransactionCollection;
2836
- }(AbstractCollection));
2827
+ }(Collection));
2837
2828
 
2838
2829
  /**
2839
2830
  * Collection of user event settings
@@ -2847,7 +2838,7 @@
2847
2838
  return new UserEventSettingCollection(this.items.filter(function (setting) { return setting[field] !== null; }));
2848
2839
  };
2849
2840
  return UserEventSettingCollection;
2850
- }(AbstractCollection));
2841
+ }(Collection));
2851
2842
 
2852
2843
  exports.ChartAccountsCategoryEnum = void 0;
2853
2844
  (function (ChartAccountsCategoryEnum) {
@@ -5648,6 +5639,20 @@
5648
5639
  enumerable: false,
5649
5640
  configurable: true
5650
5641
  });
5642
+ Object.defineProperty(Transaction.prototype, "debit", {
5643
+ get: function () {
5644
+ return this.isDebit() ? Math.abs(this.amount) : null;
5645
+ },
5646
+ enumerable: false,
5647
+ configurable: true
5648
+ });
5649
+ Object.defineProperty(Transaction.prototype, "credit", {
5650
+ get: function () {
5651
+ return this.isCredit() ? Math.abs(this.amount) : null;
5652
+ },
5653
+ enumerable: false,
5654
+ configurable: true
5655
+ });
5651
5656
  /**
5652
5657
  * Get value of transaction metadata field
5653
5658
  * @param field for which value should be returned
@@ -6442,9 +6447,11 @@
6442
6447
  if (!column.total) {
6443
6448
  return '';
6444
6449
  }
6445
- return collection.items
6446
- .reduce(function (sum, item) { return sum + Number(item[column.key]); }, 0)
6447
- .toString();
6450
+ var totalValue = collection.items.reduce(function (sum, item) {
6451
+ // check if current collection item has value. If not - don't add it to the sum
6452
+ return item[column.key] !== null ? sum + Number(item[column.key]) : sum;
6453
+ }, null);
6454
+ return (totalValue !== null && totalValue !== void 0 ? totalValue : '-').toString();
6448
6455
  });
6449
6456
  };
6450
6457
  return DataTable;
@@ -6924,6 +6931,12 @@
6924
6931
  enumerable: false,
6925
6932
  configurable: true
6926
6933
  });
6934
+ /**
6935
+ * Claim amount for Kms method
6936
+ */
6937
+ VehicleClaim.prototype.getKmsClaimAmount = function (vehicleClaimRate) {
6938
+ return +(this.kilometers * vehicleClaimRate).toFixed(2);
6939
+ };
6927
6940
  return VehicleClaim;
6928
6941
  }(VehicleClaim$1));
6929
6942
 
@@ -10343,14 +10356,47 @@
10343
10356
  document.save(fileName + ".pdf");
10344
10357
  };
10345
10358
  /**
10359
+ * @Todo rename when all DataTable dependent methods will be cleared-up
10360
+ */
10361
+ PdfService.prototype.exportTables = function (tables, title, fileName) {
10362
+ var document = this.generateFromTables(tables, title);
10363
+ document.save(fileName + ".pdf");
10364
+ };
10365
+ /**
10366
+ * @Todo rename when all DataTable dependent methods will be cleared-up
10367
+ */
10368
+ PdfService.prototype.generateFromTables = function (tables, title) {
10369
+ var pdf = new jsPDF__default["default"]();
10370
+ // set document title
10371
+ pdf.setFontSize(PDF_CONFIG.text.fontSize)
10372
+ .setFont(PDF_CONFIG.text.fontName, PDF_CONFIG.text.fontStyle, PDF_CONFIG.text.fontWeight)
10373
+ .text(title, PDF_CONFIG.text.positionX, PDF_CONFIG.text.positionY);
10374
+ tables.forEach(function (table) {
10375
+ // coords of last table
10376
+ var lastTableCoords = pdf['lastAutoTable'].finalY || PDF_CONFIG.contentCoords.marginTop;
10377
+ // table options
10378
+ var options = {
10379
+ html: table,
10380
+ startY: lastTableCoords + PDF_CONFIG.contentTitleCoords.marginTop,
10381
+ footStyles: {
10382
+ fillColor: PDF_CONFIG.text.fillColor,
10383
+ textColor: PDF_CONFIG.text.textColor
10384
+ }
10385
+ };
10386
+ autoTable__default["default"](pdf, options);
10387
+ });
10388
+ return pdf;
10389
+ };
10390
+ /**
10391
+ * @Todo remove/refactor when all DataTable dependent methods will be cleared-up
10346
10392
  * Generate PDF file from provided data
10347
10393
  */
10348
10394
  PdfService.prototype.generatePdfFile = function (tables, title) {
10349
10395
  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);
10396
+ // set document font params
10397
+ pdf.setFontSize(PDF_CONFIG.text.fontSize)
10398
+ .setFont(PDF_CONFIG.text.fontName, PDF_CONFIG.text.fontStyle, PDF_CONFIG.text.fontWeight)
10399
+ .text(title, PDF_CONFIG.text.positionX, PDF_CONFIG.text.positionY);
10354
10400
  tables.forEach(function (table) {
10355
10401
  // coords of last table
10356
10402
  var lastTableCoords = pdf['lastAutoTable'].finalY || PDF_CONFIG.contentCoords.marginTop;
@@ -12351,7 +12397,6 @@
12351
12397
  * Generated bundle index. Do not edit.
12352
12398
  */
12353
12399
 
12354
- exports.AbstractCollection = AbstractCollection;
12355
12400
  exports.Address = Address;
12356
12401
  exports.AddressService = AddressService;
12357
12402
  exports.AppEvent = AppEvent;
@@ -12404,6 +12449,7 @@
12404
12449
  exports.ClientPortfolioReport = ClientPortfolioReport;
12405
12450
  exports.ClientPortfolioReportCollection = ClientPortfolioReportCollection;
12406
12451
  exports.ClientPortfolioReportService = ClientPortfolioReportService;
12452
+ exports.Collection = Collection;
12407
12453
  exports.CollectionDictionary = CollectionDictionary;
12408
12454
  exports.CorelogicService = CorelogicService;
12409
12455
  exports.CorelogicSuggestion = CorelogicSuggestion;