taxtank-core 0.4.1 → 0.5.3

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 (44) hide show
  1. package/bundles/taxtank-core.umd.js +307 -156
  2. package/bundles/taxtank-core.umd.js.map +1 -1
  3. package/esm2015/lib/collections/depreciation.collection.js +8 -1
  4. package/esm2015/lib/collections/income-source.collection.js +1 -1
  5. package/esm2015/lib/collections/transaction.collection.js +4 -1
  6. package/esm2015/lib/db/Enums/chart-accounts-category.enum.js +4 -1
  7. package/esm2015/lib/db/Enums/income-source-type.enum.js +2 -1
  8. package/esm2015/lib/db/Enums/tank-type.enum.js +2 -1
  9. package/esm2015/lib/db/Models/income-source.js +1 -1
  10. package/esm2015/lib/db/Models/sole-forecast.js +3 -0
  11. package/esm2015/lib/interfaces/income-source-forecast.interface.js +1 -1
  12. package/esm2015/lib/models/depreciation/depreciation.js +9 -2
  13. package/esm2015/lib/models/income-source/income-source-forecast.js +1 -1
  14. package/esm2015/lib/models/income-source/income-source-type.js +6 -1
  15. package/esm2015/lib/models/income-source/income-source.js +9 -2
  16. package/esm2015/lib/models/income-source/salary-forecast.js +1 -1
  17. package/esm2015/lib/models/income-source/sole-forecast.js +14 -0
  18. package/esm2015/lib/models/pdf/pdf-config.js +3 -3
  19. package/esm2015/lib/services/income-source/sole-forecast.service.js +87 -0
  20. package/esm2015/lib/services/pdf/pdf.service.js +12 -6
  21. package/esm2015/public-api.js +3 -2
  22. package/fesm2015/taxtank-core.js +254 -128
  23. package/fesm2015/taxtank-core.js.map +1 -1
  24. package/lib/collections/depreciation.collection.d.ts +5 -0
  25. package/lib/collections/income-source.collection.d.ts +2 -2
  26. package/lib/collections/transaction.collection.d.ts +1 -0
  27. package/lib/db/Enums/chart-accounts-category.enum.d.ts +4 -1
  28. package/lib/db/Enums/income-source-type.enum.d.ts +2 -1
  29. package/lib/db/Enums/tank-type.enum.d.ts +2 -1
  30. package/lib/db/Models/income-source.d.ts +2 -0
  31. package/lib/db/Models/sole-forecast.d.ts +8 -0
  32. package/lib/interfaces/income-source-forecast.interface.d.ts +5 -2
  33. package/lib/models/depreciation/depreciation.d.ts +5 -0
  34. package/lib/models/income-source/income-source-forecast.d.ts +1 -5
  35. package/lib/models/income-source/income-source-type.d.ts +1 -0
  36. package/lib/models/income-source/income-source.d.ts +4 -2
  37. package/lib/models/income-source/salary-forecast.d.ts +1 -10
  38. package/lib/models/income-source/sole-forecast.d.ts +7 -0
  39. package/lib/services/income-source/sole-forecast.service.d.ts +33 -0
  40. package/lib/services/pdf/pdf.service.d.ts +1 -0
  41. package/package.json +1 -1
  42. package/public-api.d.ts +2 -1
  43. package/esm2015/lib/interfaces/salary-forecast.interface.js +0 -2
  44. package/lib/interfaces/salary-forecast.interface.d.ts +0 -16
@@ -1255,8 +1255,131 @@ var TankTypeEnum;
1255
1255
  TankTypeEnum[TankTypeEnum["PROPERTY"] = 1] = "PROPERTY";
1256
1256
  TankTypeEnum[TankTypeEnum["WORK"] = 2] = "WORK";
1257
1257
  TankTypeEnum[TankTypeEnum["OTHER"] = 3] = "OTHER";
1258
+ TankTypeEnum[TankTypeEnum["SOLE"] = 4] = "SOLE";
1258
1259
  })(TankTypeEnum || (TankTypeEnum = {}));
1259
1260
 
1261
+ /**
1262
+ * Collection of transactions
1263
+ */
1264
+ class TransactionCollection extends Collection {
1265
+ /**
1266
+ * Get total amount of all transactions in the collection
1267
+ */
1268
+ get amount() {
1269
+ return +this.items.reduce((sum, transaction) => sum + transaction.getNetAmount(), 0).toFixed(2);
1270
+ }
1271
+ /**
1272
+ * Difference between allocated amount and total amount
1273
+ */
1274
+ getUnallocatedAmount(allocations) {
1275
+ return +(this.amount - allocations.getByTransactionsIds(this.getIds()).amount).toFixed(2);
1276
+ }
1277
+ /**
1278
+ * Get cash position
1279
+ * Cash Position = Income - Expenses
1280
+ * Cash position is equal to Total Amount because income is positive and expense is negative,
1281
+ */
1282
+ get cashPosition() {
1283
+ return this.claimAmount;
1284
+ }
1285
+ /**
1286
+ * Get new collection of transactions filtered by tank type
1287
+ * @param tankType
1288
+ */
1289
+ getByTankType(tankType) {
1290
+ return new TransactionCollection(this.items.filter((transaction) => transaction.tankType === tankType));
1291
+ }
1292
+ /**
1293
+ * get date of the last transaction
1294
+ */
1295
+ getLastTransactionDate() {
1296
+ return new Date(Math.max.apply(Math, this.items.map((transaction) => transaction.date)));
1297
+ }
1298
+ /**
1299
+ * Get summary of claim amounts
1300
+ */
1301
+ get claimAmount() {
1302
+ return this.items.reduce((sum, transaction) => sum + transaction.claimAmount, 0);
1303
+ }
1304
+ get grossAmount() {
1305
+ return +this.items.reduce((sum, transaction) => sum + transaction.amount, 0).toFixed(2);
1306
+ }
1307
+ getByCategories(categories) {
1308
+ return new TransactionCollection(this.items.filter((transaction) => categories.includes(transaction.chartAccounts.category)));
1309
+ }
1310
+ /**
1311
+ * Get transactions by month
1312
+ * @param monthIndex by which desired month should be taken
1313
+ */
1314
+ getByMonth(monthIndex) {
1315
+ return new TransactionCollection(this.items.filter((transaction) => transaction.date.getMonth() === monthIndex));
1316
+ }
1317
+ /**
1318
+ * get list of transactions filtered by chart accounts id
1319
+ * @param chartAccountsId chart accounts id for filtering
1320
+ */
1321
+ getByChartAccountsId(chartAccountsId) {
1322
+ return this.items.filter((transaction) => transaction.chartAccounts.id === chartAccountsId);
1323
+ }
1324
+ getIncomeTransactions() {
1325
+ return new TransactionCollection(this.items.filter((transaction) => transaction.isIncome()));
1326
+ }
1327
+ get claimIncome() {
1328
+ return this.getIncomeTransactions().claimAmount;
1329
+ }
1330
+ getExpenseTransactions() {
1331
+ return new TransactionCollection(this.items.filter((transaction) => transaction.isExpense() && !transaction.isInterest()));
1332
+ }
1333
+ get claimExpense() {
1334
+ return this.getExpenseTransactions().claimAmount;
1335
+ }
1336
+ getInterestTransactions() {
1337
+ return new TransactionCollection(this.items.filter((transaction) => transaction.isInterest()));
1338
+ }
1339
+ get claimInterest() {
1340
+ return this.getInterestTransactions().claimAmount;
1341
+ }
1342
+ /**
1343
+ * Get collection of transactions and properties filtered by properties ids
1344
+ * @param ids Ids of properties for filter
1345
+ */
1346
+ getByPropertiesIds(ids) {
1347
+ return new TransactionCollection(this.items.filter((transaction) => {
1348
+ var _a;
1349
+ return ids.includes((_a = transaction.property) === null || _a === void 0 ? void 0 : _a.id);
1350
+ }));
1351
+ }
1352
+ /**
1353
+ * Get new collection filtered by income source id
1354
+ * @param id id of income source for filter
1355
+ */
1356
+ getByIncomeSourceId(id) {
1357
+ return new TransactionCollection(this.items.filter((transaction) => { var _a; return ((_a = transaction.incomeSource) === null || _a === void 0 ? void 0 : _a.id) === id; }));
1358
+ }
1359
+ /**
1360
+ * Get new collection filtered by chart accounts category
1361
+ * @param category Chart accounts category value
1362
+ */
1363
+ getByChartAccountsCategory(category) {
1364
+ return new TransactionCollection(this.items.filter((transaction) => transaction.chartAccounts.category === category));
1365
+ }
1366
+ /**
1367
+ * Get new collection of property transactions
1368
+ */
1369
+ getPropertyTransactions() {
1370
+ return new TransactionCollection(this.items.filter((transaction) => transaction.isPropertyTank()));
1371
+ }
1372
+ getDebitTransactions() {
1373
+ return new TransactionCollection(this.items.filter((transaction) => transaction.isDebit()));
1374
+ }
1375
+ getCreditTransactions() {
1376
+ return new TransactionCollection(this.items.filter((transaction) => transaction.isCredit()));
1377
+ }
1378
+ getByAllocations(allocations) {
1379
+ return new TransactionCollection(this.items.filter((transaction) => allocations.hasTransaction(transaction)));
1380
+ }
1381
+ }
1382
+
1260
1383
  class DepreciationCollection extends Collection {
1261
1384
  /**
1262
1385
  * Get total amount of all depreciations in the collection
@@ -1323,6 +1446,12 @@ class DepreciationCollection extends Collection {
1323
1446
  return depreciation.depreciationCapitalProject;
1324
1447
  })), 'id');
1325
1448
  }
1449
+ /**
1450
+ * Create TransactionCollection from depreciation items
1451
+ */
1452
+ toTransactions() {
1453
+ return new TransactionCollection(this.items.map((item) => item.toTransaction()));
1454
+ }
1326
1455
  }
1327
1456
 
1328
1457
  /**
@@ -1934,125 +2063,6 @@ class TransactionAllocationCollection extends Collection {
1934
2063
  }
1935
2064
  }
1936
2065
 
1937
- /**
1938
- * Collection of transactions
1939
- */
1940
- class TransactionCollection extends Collection {
1941
- /**
1942
- * Get total amount of all transactions in the collection
1943
- */
1944
- get amount() {
1945
- return +this.items.reduce((sum, transaction) => sum + transaction.getNetAmount(), 0).toFixed(2);
1946
- }
1947
- /**
1948
- * Difference between allocated amount and total amount
1949
- */
1950
- getUnallocatedAmount(allocations) {
1951
- return +(this.amount - allocations.getByTransactionsIds(this.getIds()).amount).toFixed(2);
1952
- }
1953
- /**
1954
- * Get cash position
1955
- * Cash Position = Income - Expenses
1956
- * Cash position is equal to Total Amount because income is positive and expense is negative,
1957
- */
1958
- get cashPosition() {
1959
- return this.claimAmount;
1960
- }
1961
- /**
1962
- * Get new collection of transactions filtered by tank type
1963
- * @param tankType
1964
- */
1965
- getByTankType(tankType) {
1966
- return new TransactionCollection(this.items.filter((transaction) => transaction.tankType === tankType));
1967
- }
1968
- /**
1969
- * get date of the last transaction
1970
- */
1971
- getLastTransactionDate() {
1972
- return new Date(Math.max.apply(Math, this.items.map((transaction) => transaction.date)));
1973
- }
1974
- /**
1975
- * Get summary of claim amounts
1976
- */
1977
- get claimAmount() {
1978
- return this.items.reduce((sum, transaction) => sum + transaction.claimAmount, 0);
1979
- }
1980
- getByCategories(categories) {
1981
- return new TransactionCollection(this.items.filter((transaction) => categories.includes(transaction.chartAccounts.category)));
1982
- }
1983
- /**
1984
- * Get transactions by month
1985
- * @param monthIndex by which desired month should be taken
1986
- */
1987
- getByMonth(monthIndex) {
1988
- return new TransactionCollection(this.items.filter((transaction) => transaction.date.getMonth() === monthIndex));
1989
- }
1990
- /**
1991
- * get list of transactions filtered by chart accounts id
1992
- * @param chartAccountsId chart accounts id for filtering
1993
- */
1994
- getByChartAccountsId(chartAccountsId) {
1995
- return this.items.filter((transaction) => transaction.chartAccounts.id === chartAccountsId);
1996
- }
1997
- getIncomeTransactions() {
1998
- return new TransactionCollection(this.items.filter((transaction) => transaction.isIncome()));
1999
- }
2000
- get claimIncome() {
2001
- return this.getIncomeTransactions().claimAmount;
2002
- }
2003
- getExpenseTransactions() {
2004
- return new TransactionCollection(this.items.filter((transaction) => transaction.isExpense() && !transaction.isInterest()));
2005
- }
2006
- get claimExpense() {
2007
- return this.getExpenseTransactions().claimAmount;
2008
- }
2009
- getInterestTransactions() {
2010
- return new TransactionCollection(this.items.filter((transaction) => transaction.isInterest()));
2011
- }
2012
- get claimInterest() {
2013
- return this.getInterestTransactions().claimAmount;
2014
- }
2015
- /**
2016
- * Get collection of transactions and properties filtered by properties ids
2017
- * @param ids Ids of properties for filter
2018
- */
2019
- getByPropertiesIds(ids) {
2020
- return new TransactionCollection(this.items.filter((transaction) => {
2021
- var _a;
2022
- return ids.includes((_a = transaction.property) === null || _a === void 0 ? void 0 : _a.id);
2023
- }));
2024
- }
2025
- /**
2026
- * Get new collection filtered by income source id
2027
- * @param id id of income source for filter
2028
- */
2029
- getByIncomeSourceId(id) {
2030
- return new TransactionCollection(this.items.filter((transaction) => { var _a; return ((_a = transaction.incomeSource) === null || _a === void 0 ? void 0 : _a.id) === id; }));
2031
- }
2032
- /**
2033
- * Get new collection filtered by chart accounts category
2034
- * @param category Chart accounts category value
2035
- */
2036
- getByChartAccountsCategory(category) {
2037
- return new TransactionCollection(this.items.filter((transaction) => transaction.chartAccounts.category === category));
2038
- }
2039
- /**
2040
- * Get new collection of property transactions
2041
- */
2042
- getPropertyTransactions() {
2043
- return new TransactionCollection(this.items.filter((transaction) => transaction.isPropertyTank()));
2044
- }
2045
- getDebitTransactions() {
2046
- return new TransactionCollection(this.items.filter((transaction) => transaction.isDebit()));
2047
- }
2048
- getCreditTransactions() {
2049
- return new TransactionCollection(this.items.filter((transaction) => transaction.isCredit()));
2050
- }
2051
- getByAllocations(allocations) {
2052
- return new TransactionCollection(this.items.filter((transaction) => allocations.hasTransaction(transaction)));
2053
- }
2054
- }
2055
-
2056
2066
  /**
2057
2067
  * Collection of user event settings
2058
2068
  */
@@ -2075,6 +2085,9 @@ var ChartAccountsCategoryEnum;
2075
2085
  ChartAccountsCategoryEnum[ChartAccountsCategoryEnum["OTHER_EXPENSE"] = 9] = "OTHER_EXPENSE";
2076
2086
  ChartAccountsCategoryEnum[ChartAccountsCategoryEnum["PERSONAL_INCOME"] = 10] = "PERSONAL_INCOME";
2077
2087
  ChartAccountsCategoryEnum[ChartAccountsCategoryEnum["PERSONAL_EXPENSE"] = 11] = "PERSONAL_EXPENSE";
2088
+ ChartAccountsCategoryEnum[ChartAccountsCategoryEnum["SOLE_INCOME"] = 12] = "SOLE_INCOME";
2089
+ ChartAccountsCategoryEnum[ChartAccountsCategoryEnum["SOLE_EXPENSE"] = 13] = "SOLE_EXPENSE";
2090
+ ChartAccountsCategoryEnum[ChartAccountsCategoryEnum["SOLE_DEPRECIATION"] = 14] = "SOLE_DEPRECIATION";
2078
2091
  })(ChartAccountsCategoryEnum || (ChartAccountsCategoryEnum = {}));
2079
2092
 
2080
2093
  const CHART_ACCOUNTS_CATEGORIES = {
@@ -2359,6 +2372,7 @@ var IncomeSourceTypeEnum;
2359
2372
  IncomeSourceTypeEnum[IncomeSourceTypeEnum["SALARY"] = 1] = "SALARY";
2360
2373
  IncomeSourceTypeEnum[IncomeSourceTypeEnum["WORK"] = 2] = "WORK";
2361
2374
  IncomeSourceTypeEnum[IncomeSourceTypeEnum["OTHER"] = 3] = "OTHER";
2375
+ IncomeSourceTypeEnum[IncomeSourceTypeEnum["SOLE"] = 4] = "SOLE";
2362
2376
  })(IncomeSourceTypeEnum || (IncomeSourceTypeEnum = {}));
2363
2377
 
2364
2378
  var IncomeSourceTypeListOtherEnum;
@@ -3904,6 +3918,19 @@ __decorate([
3904
3918
  Type(() => IncomeSource)
3905
3919
  ], SalaryForecast.prototype, "incomeSource", void 0);
3906
3920
 
3921
+ class SoleForecast$1 {
3922
+ }
3923
+
3924
+ class SoleForecast extends SoleForecast$1 {
3925
+ get netPay() {
3926
+ return this.amount;
3927
+ }
3928
+ ;
3929
+ }
3930
+ __decorate([
3931
+ Type(() => IncomeSource)
3932
+ ], SoleForecast.prototype, "incomeSource", void 0);
3933
+
3907
3934
  class IncomeSourceForecast$1 {
3908
3935
  }
3909
3936
 
@@ -3920,12 +3947,17 @@ class IncomeSourceType extends IncomeSourceType$1 {
3920
3947
  isOther() {
3921
3948
  return !!IncomeSourceTypeListOtherEnum[this.id];
3922
3949
  }
3950
+ isSole() {
3951
+ return !!IncomeSourceTypeListOtherEnum[this.id];
3952
+ }
3923
3953
  get type() {
3924
3954
  switch (true) {
3925
3955
  case this.isSalary():
3926
3956
  return IncomeSourceTypeEnum.SALARY;
3927
3957
  case this.isWork():
3928
3958
  return IncomeSourceTypeEnum.WORK;
3959
+ case this.isSole():
3960
+ return IncomeSourceTypeEnum.SOLE;
3929
3961
  default:
3930
3962
  return IncomeSourceTypeEnum.OTHER;
3931
3963
  }
@@ -3961,6 +3993,9 @@ class IncomeSource extends IncomeSource$1 {
3961
3993
  isSalaryIncome() {
3962
3994
  return this.type === IncomeSourceTypeEnum.SALARY;
3963
3995
  }
3996
+ isSoleIncome() {
3997
+ return this.type === IncomeSourceTypeEnum.SOLE;
3998
+ }
3964
3999
  isWorkIncome() {
3965
4000
  return this.type === IncomeSourceTypeEnum.WORK;
3966
4001
  }
@@ -3971,7 +4006,7 @@ class IncomeSource extends IncomeSource$1 {
3971
4006
  * Get salary and other income forecasts
3972
4007
  */
3973
4008
  get forecasts() {
3974
- return [...this.salaryForecasts, ...this.incomeSourceForecasts];
4009
+ return [...this.salaryForecasts, ...this.incomeSourceForecasts, ...this.soleForecasts];
3975
4010
  }
3976
4011
  /**
3977
4012
  * Get actual (1st from the list) forecast
@@ -3991,6 +4026,9 @@ class IncomeSource extends IncomeSource$1 {
3991
4026
  __decorate([
3992
4027
  Type(() => SalaryForecast)
3993
4028
  ], IncomeSource.prototype, "salaryForecasts", void 0);
4029
+ __decorate([
4030
+ Type(() => SoleForecast)
4031
+ ], IncomeSource.prototype, "soleForecasts", void 0);
3994
4032
  __decorate([
3995
4033
  Type(() => IncomeSourceForecast)
3996
4034
  ], IncomeSource.prototype, "incomeSourceForecasts", void 0);
@@ -4181,6 +4219,12 @@ class Depreciation extends Depreciation$1 {
4181
4219
  isBuildingAtCost() {
4182
4220
  return this.chartAccounts.id === ChartAccountsListEnum.BUILDING_AT_COST;
4183
4221
  }
4222
+ /**
4223
+ * Create a new transaction from current depreciation
4224
+ */
4225
+ toTransaction() {
4226
+ return plainToClass(Transaction, this);
4227
+ }
4184
4228
  }
4185
4229
  Depreciation.WRITTEN_OFF_THRESHOLD = 300;
4186
4230
  Depreciation.LOW_VALUE_POOL_THRESHOLD = 1000;
@@ -8180,6 +8224,82 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
8180
8224
  args: ['environment']
8181
8225
  }] }]; } });
8182
8226
 
8227
+ class SoleForecastService extends BaseRestService {
8228
+ constructor(http, eventDispatcherService, environment) {
8229
+ super(http, eventDispatcherService, environment);
8230
+ this.http = http;
8231
+ this.eventDispatcherService = eventDispatcherService;
8232
+ this.environment = environment;
8233
+ this.modelClass = SoleForecast;
8234
+ this.url = 'sole-forecasts';
8235
+ this.listenEvents();
8236
+ }
8237
+ /**
8238
+ * Listen to Income Sources events
8239
+ */
8240
+ listenEvents() {
8241
+ this.listenToAddedIncomeSources();
8242
+ this.listenToUpdatedIncomeSources();
8243
+ }
8244
+ /**
8245
+ * Listen to EventDispatcherService event related to added Income Sources
8246
+ */
8247
+ listenToAddedIncomeSources() {
8248
+ this.eventDispatcherService.on(AppEventTypeEnum.INCOME_SOURCES_CREATED)
8249
+ .pipe(map((incomeSources) => incomeSources
8250
+ .filter((incomeSource) => incomeSource.isSoleIncome())))
8251
+ .subscribe((incomeSources) => {
8252
+ const soleForecasts = this.assignSoleForecasts(incomeSources);
8253
+ if (soleForecasts.length) {
8254
+ this.addBatch(soleForecasts).subscribe((createdSoleForecasts) => {
8255
+ this.eventDispatcherService
8256
+ .dispatch(new AppEvent(AppEventTypeEnum.INCOME_SOURCES_FORECASTS_CREATED, createdSoleForecasts));
8257
+ });
8258
+ }
8259
+ });
8260
+ }
8261
+ /**
8262
+ * Listen to EventDispatcherService event related to updated Income Sources
8263
+ */
8264
+ listenToUpdatedIncomeSources() {
8265
+ this.eventDispatcherService.on(AppEventTypeEnum.INCOME_SOURCES_UPDATED)
8266
+ .subscribe((incomeSources) => {
8267
+ const soleForecasts = this.assignSoleForecasts(incomeSources);
8268
+ if (soleForecasts.length) {
8269
+ this.updateBatch(soleForecasts).subscribe((updatedSoleForecasts) => {
8270
+ this.eventDispatcherService
8271
+ .dispatch(new AppEvent(AppEventTypeEnum.INCOME_SOURCES_FORECASTS_UPDATED, updatedSoleForecasts));
8272
+ });
8273
+ }
8274
+ });
8275
+ }
8276
+ /**
8277
+ * Assign sole forecasts based on provided income sources
8278
+ * @param incomeSources by which sole forecasts will be assigned
8279
+ */
8280
+ assignSoleForecasts(incomeSources) {
8281
+ return incomeSources.map((incomeSource) => {
8282
+ incomeSource.soleForecasts = incomeSource.soleForecasts
8283
+ .map((soleForecast) => {
8284
+ soleForecast.incomeSource = plainToClass(IncomeSource, { id: incomeSource.id });
8285
+ return soleForecast;
8286
+ });
8287
+ return incomeSource.soleForecasts;
8288
+ }).flat();
8289
+ }
8290
+ }
8291
+ SoleForecastService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SoleForecastService, deps: [{ token: i1.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable });
8292
+ SoleForecastService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SoleForecastService, providedIn: 'root' });
8293
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SoleForecastService, decorators: [{
8294
+ type: Injectable,
8295
+ args: [{
8296
+ providedIn: 'root'
8297
+ }]
8298
+ }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
8299
+ type: Inject,
8300
+ args: ['environment']
8301
+ }] }]; } });
8302
+
8183
8303
  /**
8184
8304
  * Service to work with intercom
8185
8305
  */
@@ -8410,7 +8530,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
8410
8530
  */
8411
8531
  const PDF_CONFIG = {
8412
8532
  text: {
8413
- fontSize: 18,
8533
+ fontSize: 12,
8414
8534
  fontName: 'helvetica',
8415
8535
  fontStyle: '',
8416
8536
  fontWeight: 'bold',
@@ -8421,7 +8541,7 @@ const PDF_CONFIG = {
8421
8541
  },
8422
8542
  // coords for file section title (group, table, e.t.c.)
8423
8543
  contentTitleCoords: {
8424
- marginTop: 20
8544
+ marginTop: 15
8425
8545
  },
8426
8546
  contentCoords: {
8427
8547
  marginTop: 15,
@@ -8453,17 +8573,18 @@ class PdfService {
8453
8573
  */
8454
8574
  generateFromTables(tables, title) {
8455
8575
  const pdf = new jsPDF();
8456
- // set document title
8457
- pdf.setFontSize(PDF_CONFIG.text.fontSize)
8458
- .setFont(PDF_CONFIG.text.fontName, PDF_CONFIG.text.fontStyle, PDF_CONFIG.text.fontWeight)
8459
- .text(title, PDF_CONFIG.text.positionX, PDF_CONFIG.text.positionY);
8576
+ this.setDocumentTitle(pdf, title);
8460
8577
  tables.forEach((table) => {
8578
+ var _a, _b;
8461
8579
  // coords of last table
8462
8580
  const lastTableCoords = pdf['lastAutoTable'].finalY || PDF_CONFIG.contentCoords.marginTop;
8581
+ pdf.text((_a = table.caption) === null || _a === void 0 ? void 0 : _a.innerText, PDF_CONFIG.contentCoords.marginLeft, lastTableCoords + PDF_CONFIG.contentCoords.marginTop);
8582
+ // get caption height based on caption content height
8583
+ const captionHeight = pdf.getTextDimensions(pdf.splitTextToSize((_b = table.caption) === null || _b === void 0 ? void 0 : _b.innerText, pdf.internal.pageSize.width)).h;
8463
8584
  // table options
8464
8585
  const options = {
8465
8586
  html: table,
8466
- startY: lastTableCoords + PDF_CONFIG.contentTitleCoords.marginTop,
8587
+ startY: lastTableCoords + captionHeight + PDF_CONFIG.contentTitleCoords.marginTop,
8467
8588
  footStyles: {
8468
8589
  fillColor: PDF_CONFIG.text.fillColor,
8469
8590
  textColor: PDF_CONFIG.text.textColor
@@ -8473,6 +8594,11 @@ class PdfService {
8473
8594
  });
8474
8595
  return pdf;
8475
8596
  }
8597
+ setDocumentTitle(doc, title) {
8598
+ doc.setFontSize(PDF_CONFIG.text.fontSize)
8599
+ .setFont(PDF_CONFIG.text.fontName, PDF_CONFIG.text.fontStyle, PDF_CONFIG.text.fontWeight)
8600
+ .text(title, PDF_CONFIG.text.positionX, PDF_CONFIG.text.positionY);
8601
+ }
8476
8602
  /**
8477
8603
  * @Todo remove/refactor when all DataTable dependent methods will be cleared-up
8478
8604
  * Generate PDF file from provided data
@@ -10378,5 +10504,5 @@ function taxReviewFilterPredicate(data, filter) {
10378
10504
  * Generated bundle index. Do not edit.
10379
10505
  */
10380
10506
 
10381
- export { Address, AddressService, AddressTypeEnum, AlphabetColorsEnum, AppEvent, AppEventTypeEnum, AssetEntityTypeEnum, AssetTypeEnum, AssetsService, AuthService, BANK_ACCOUNT_TYPES, Bank, BankAccount, BankAccountCalculationService, BankAccountChartData, BankAccountCollection, BankAccountProperty, BankAccountService, BankAccountStatusEnum, BankAccountTypeEnum, BankConnection, BankConnectionService, BankConnectionStatusEnum, BankService, BankTransaction, BankTransactionCalculationService, BankTransactionChartData, BankTransactionCollection, BankTransactionService, BankTransactionSummaryFieldsEnum, BankTransactionTypeEnum, BasiqJob, BasiqService, BasiqToken, BorrowingExpense, BorrowingExpenseLoan, BorrowingExpenseService, CAPITAL_COSTS_ITEMS, CHART_ACCOUNTS_CATEGORIES, CalculationFormItem, CalculationFormTypeEnum, CapitalProjectService, ChartAccounts, ChartAccountsCategoryEnum, ChartAccountsDepreciation, ChartAccountsDepreciationService, ChartAccountsEtpEnum, ChartAccountsHeading, ChartAccountsHeadingTaxDeductibleEnum, ChartAccountsHeadingTaxableEnum, ChartAccountsHeadingVehicleListEnum, ChartAccountsListEnum, ChartAccountsMetadata, ChartAccountsMetadataListEnum, ChartAccountsMetadataTypeEnum, ChartAccountsService, ChartAccountsTaxLabelsEnum, ChartAccountsTypeEnum, ChartData, ChartSerie, Chat, ChatService, ChatStatusEnum, ChatViewTypeEnum, ClientCollection, ClientDetails, ClientDetailsMedicareExemptionEnum, ClientDetailsWorkDepreciationCalculationEnum, ClientDetailsWorkingHolidayMakerEnum, ClientInvite, ClientInviteService, ClientInviteStatusEnum, ClientInviteTypeEnum, ClientMovement, ClientMovementCollection, ClientMovementService, ClientPortfolioChartData, ClientPortfolioReport, ClientPortfolioReportCollection, ClientPortfolioReportService, Collection, CollectionDictionary, CorelogicService, CorelogicSuggestion, Country, DEFAULT_VEHICLE_EXPENSE, DEPRECIATION_GROUPS, DOCUMENT_FILE_TYPES, DataTable, DataTableColumn, Depreciation, DepreciationCalculationEnum, DepreciationCalculationPercentEnum, DepreciationCapitalProject, DepreciationCollection, DepreciationForecast, DepreciationForecastCollection, DepreciationGroup, DepreciationGroupEnum, DepreciationGroupItem, DepreciationReceipt, DepreciationService, DepreciationTypeEnum, DepreciationWriteOffAmountEnum, Document, DocumentApiUrlPrefixEnum, DocumentFolder, DocumentFolderService, ENDPOINTS, EmployeeCollection, EmployeeDetails, EmployeeInvite, EmployeeInviteService, EmployeeService, Endpoint, EquityPositionChartService, EventDispatcherService, FinancialYear, Firm, FirmService, FirmTypeEnum, HeaderTitleService, IconsFileEnum, IncomeAmountTypeEnum, IncomePosition, IncomeSource, IncomeSourceChartData, IncomeSourceCollection, IncomeSourceForecast, IncomeSourceForecastService, IncomeSourceService, IncomeSourceType, IncomeSourceTypeEnum, IncomeSourceTypeListOtherEnum, IncomeSourceTypeListSalaryEnum, IncomeSourceTypeListWorkEnum, InterceptorsModule, IntercomService, InviteStatusEnum, JwtService, Loan, LoanBankTypeEnum, LoanCollection, LoanFrequencyEnum, LoanInterestTypeEnum, LoanMaxNumberOfPaymentsEnum, LoanPayment, LoanPayout, LoanPayoutTypeEnum, LoanRepaymentFrequencyEnum, LoanRepaymentTypeEnum, LoanService, LoanTypeEnum, LoanVehicleTypeEnum, LogbookCollection, LogbookPeriod, MODULE_URL_LIST, MONTHS, Message, MessageCollection, MessageDocument, MessageDocumentCollection, MessageDocumentService, MessageService, MonthNameShortEnum, MonthNumberEnum, MyAccountHistory, MyAccountHistoryInitiatedByEnum, MyAccountHistoryStatusEnum, MyAccountHistoryTypeEnum, Notification, NotificationService, Occupation, OccupationService, OwnershipFilterOptionsEnum, PdfService, Phone, PhoneTypeEnum, PreloaderService, Property, PropertyCalculationService, PropertyCapitalCost, PropertyCapitalCostService, PropertyCategory, PropertyCategoryMovement, PropertyCategoryMovementService, PropertyCategoryService, PropertyCollection, PropertyDepreciationCalculationEnum, PropertyDocument, PropertyDocumentService, PropertyEquityChartData, PropertyEquityChartItem, PropertyForecast, PropertyOwner, PropertyOwnerAccessEnum, PropertyOwnerService, PropertyOwnerStatusEnum, PropertyService, PropertySold, PropertySoldService, PropertySubscription, PropertyValuation, RegistrationInvite, RegistrationInviteStatusEnum, SUBSCRIPTION_DESCRIPTION, SUBSCRIPTION_TITLE, SalaryForecast, SalaryForecastFrequencyEnum, SalaryForecastService, ServiceNotificationStatusEnum, ServiceNotificationTypeEnum, ServicePayment, ServicePaymentStatusEnum, ServicePrice, ServicePriceCollection, ServicePriceRecurringIntervalEnum, ServicePriceTypeEnum, ServiceProduct, ServiceSubscription, ServiceSubscriptionCollection, ServiceSubscriptionItem, ServiceSubscriptionStatusEnum, SpareDocumentSpareTypeEnum, SseService, SubscriptionService, SubscriptionTypeEnum, TYPE_LOAN, TankTypeEnum, TaxCalculationMedicareExemptionEnum, TaxCalculationTypeEnum, TaxReturnCategoryItem, TaxReturnCategoryItemCollection, TaxReturnCategoryItemDetails, TaxReturnCategoryListEnum, TaxReturnCategorySectionEnum, TaxReview, TaxReviewCollection, TaxReviewHistoryService, TaxReviewService, TaxReviewStatusEnum, TaxSummary, TaxSummaryListEnum, TaxSummarySection, TaxSummarySectionEnum, TaxSummaryService, TaxSummaryTaxSummaryEnum, TaxSummaryTypeEnum, TicketFeedbackEnum, TicketStatusEnum, TicketTypesEnum, Transaction, TransactionAllocation, TransactionAllocationCollection, TransactionAllocationService, TransactionBase, TransactionCalculationService, TransactionCollection, TransactionMetadata, TransactionOperationEnum, TransactionReceipt, TransactionService, TransactionSourceEnum, TransactionTypeEnum, TtCoreModule, USER_ROLES, USER_WORK_POSITION, User, UserEventSetting, UserEventSettingCollection, UserEventSettingFieldEnum, UserEventSettingService, UserEventStatusEnum, UserEventType, UserEventTypeCategory, UserEventTypeClientTypeEnum, UserEventTypeEmployeeTypeEnum, UserEventTypeFrequencyEnum, UserEventTypeService, UserEventTypeUserTypeEnum, UserMedicareExemptionEnum, UserRolesEnum, UserService, UserStatusEnum, UserSwitcherService, UserTitleEnum, UserToRegister, UserWorkDepreciationCalculationEnum, UserWorkingHolidayMakerEnum, Vehicle, VehicleClaim, VehicleClaimMethodEnum, VehicleLogbook, VehicleLogbookPurposeEnum, WORK_TANK_LOGBOOK_PURPOSE_OPTIONS, WorkTankService, XlsxService, cloneDeep, compare, compareMatOptions, createDate, displayMatOptions, enumToList, getDocIcon, replace, roundTo, sort, sortDeep, taxReviewFilterPredicate };
10507
+ export { Address, AddressService, AddressTypeEnum, AlphabetColorsEnum, AppEvent, AppEventTypeEnum, AssetEntityTypeEnum, AssetTypeEnum, AssetsService, AuthService, BANK_ACCOUNT_TYPES, Bank, BankAccount, BankAccountCalculationService, BankAccountChartData, BankAccountCollection, BankAccountProperty, BankAccountService, BankAccountStatusEnum, BankAccountTypeEnum, BankConnection, BankConnectionService, BankConnectionStatusEnum, BankService, BankTransaction, BankTransactionCalculationService, BankTransactionChartData, BankTransactionCollection, BankTransactionService, BankTransactionSummaryFieldsEnum, BankTransactionTypeEnum, BasiqJob, BasiqService, BasiqToken, BorrowingExpense, BorrowingExpenseLoan, BorrowingExpenseService, CAPITAL_COSTS_ITEMS, CHART_ACCOUNTS_CATEGORIES, CalculationFormItem, CalculationFormTypeEnum, CapitalProjectService, ChartAccounts, ChartAccountsCategoryEnum, ChartAccountsDepreciation, ChartAccountsDepreciationService, ChartAccountsEtpEnum, ChartAccountsHeading, ChartAccountsHeadingTaxDeductibleEnum, ChartAccountsHeadingTaxableEnum, ChartAccountsHeadingVehicleListEnum, ChartAccountsListEnum, ChartAccountsMetadata, ChartAccountsMetadataListEnum, ChartAccountsMetadataTypeEnum, ChartAccountsService, ChartAccountsTaxLabelsEnum, ChartAccountsTypeEnum, ChartData, ChartSerie, Chat, ChatService, ChatStatusEnum, ChatViewTypeEnum, ClientCollection, ClientDetails, ClientDetailsMedicareExemptionEnum, ClientDetailsWorkDepreciationCalculationEnum, ClientDetailsWorkingHolidayMakerEnum, ClientInvite, ClientInviteService, ClientInviteStatusEnum, ClientInviteTypeEnum, ClientMovement, ClientMovementCollection, ClientMovementService, ClientPortfolioChartData, ClientPortfolioReport, ClientPortfolioReportCollection, ClientPortfolioReportService, Collection, CollectionDictionary, CorelogicService, CorelogicSuggestion, Country, DEFAULT_VEHICLE_EXPENSE, DEPRECIATION_GROUPS, DOCUMENT_FILE_TYPES, DataTable, DataTableColumn, Depreciation, DepreciationCalculationEnum, DepreciationCalculationPercentEnum, DepreciationCapitalProject, DepreciationCollection, DepreciationForecast, DepreciationForecastCollection, DepreciationGroup, DepreciationGroupEnum, DepreciationGroupItem, DepreciationReceipt, DepreciationService, DepreciationTypeEnum, DepreciationWriteOffAmountEnum, Document, DocumentApiUrlPrefixEnum, DocumentFolder, DocumentFolderService, ENDPOINTS, EmployeeCollection, EmployeeDetails, EmployeeInvite, EmployeeInviteService, EmployeeService, Endpoint, EquityPositionChartService, EventDispatcherService, FinancialYear, Firm, FirmService, FirmTypeEnum, HeaderTitleService, IconsFileEnum, IncomeAmountTypeEnum, IncomePosition, IncomeSource, IncomeSourceChartData, IncomeSourceCollection, IncomeSourceForecast, IncomeSourceForecastService, IncomeSourceService, IncomeSourceType, IncomeSourceTypeEnum, IncomeSourceTypeListOtherEnum, IncomeSourceTypeListSalaryEnum, IncomeSourceTypeListWorkEnum, InterceptorsModule, IntercomService, InviteStatusEnum, JwtService, Loan, LoanBankTypeEnum, LoanCollection, LoanFrequencyEnum, LoanInterestTypeEnum, LoanMaxNumberOfPaymentsEnum, LoanPayment, LoanPayout, LoanPayoutTypeEnum, LoanRepaymentFrequencyEnum, LoanRepaymentTypeEnum, LoanService, LoanTypeEnum, LoanVehicleTypeEnum, LogbookCollection, LogbookPeriod, MODULE_URL_LIST, MONTHS, Message, MessageCollection, MessageDocument, MessageDocumentCollection, MessageDocumentService, MessageService, MonthNameShortEnum, MonthNumberEnum, MyAccountHistory, MyAccountHistoryInitiatedByEnum, MyAccountHistoryStatusEnum, MyAccountHistoryTypeEnum, Notification, NotificationService, Occupation, OccupationService, OwnershipFilterOptionsEnum, PdfService, Phone, PhoneTypeEnum, PreloaderService, Property, PropertyCalculationService, PropertyCapitalCost, PropertyCapitalCostService, PropertyCategory, PropertyCategoryMovement, PropertyCategoryMovementService, PropertyCategoryService, PropertyCollection, PropertyDepreciationCalculationEnum, PropertyDocument, PropertyDocumentService, PropertyEquityChartData, PropertyEquityChartItem, PropertyForecast, PropertyOwner, PropertyOwnerAccessEnum, PropertyOwnerService, PropertyOwnerStatusEnum, PropertyService, PropertySold, PropertySoldService, PropertySubscription, PropertyValuation, RegistrationInvite, RegistrationInviteStatusEnum, SUBSCRIPTION_DESCRIPTION, SUBSCRIPTION_TITLE, SalaryForecast, SalaryForecastFrequencyEnum, SalaryForecastService, ServiceNotificationStatusEnum, ServiceNotificationTypeEnum, ServicePayment, ServicePaymentStatusEnum, ServicePrice, ServicePriceCollection, ServicePriceRecurringIntervalEnum, ServicePriceTypeEnum, ServiceProduct, ServiceSubscription, ServiceSubscriptionCollection, ServiceSubscriptionItem, ServiceSubscriptionStatusEnum, SoleForecast, SoleForecastService, SpareDocumentSpareTypeEnum, SseService, SubscriptionService, SubscriptionTypeEnum, TYPE_LOAN, TankTypeEnum, TaxCalculationMedicareExemptionEnum, TaxCalculationTypeEnum, TaxReturnCategoryItem, TaxReturnCategoryItemCollection, TaxReturnCategoryItemDetails, TaxReturnCategoryListEnum, TaxReturnCategorySectionEnum, TaxReview, TaxReviewCollection, TaxReviewHistoryService, TaxReviewService, TaxReviewStatusEnum, TaxSummary, TaxSummaryListEnum, TaxSummarySection, TaxSummarySectionEnum, TaxSummaryService, TaxSummaryTaxSummaryEnum, TaxSummaryTypeEnum, TicketFeedbackEnum, TicketStatusEnum, TicketTypesEnum, Transaction, TransactionAllocation, TransactionAllocationCollection, TransactionAllocationService, TransactionBase, TransactionCalculationService, TransactionCollection, TransactionMetadata, TransactionOperationEnum, TransactionReceipt, TransactionService, TransactionSourceEnum, TransactionTypeEnum, TtCoreModule, USER_ROLES, USER_WORK_POSITION, User, UserEventSetting, UserEventSettingCollection, UserEventSettingFieldEnum, UserEventSettingService, UserEventStatusEnum, UserEventType, UserEventTypeCategory, UserEventTypeClientTypeEnum, UserEventTypeEmployeeTypeEnum, UserEventTypeFrequencyEnum, UserEventTypeService, UserEventTypeUserTypeEnum, UserMedicareExemptionEnum, UserRolesEnum, UserService, UserStatusEnum, UserSwitcherService, UserTitleEnum, UserToRegister, UserWorkDepreciationCalculationEnum, UserWorkingHolidayMakerEnum, Vehicle, VehicleClaim, VehicleClaimMethodEnum, VehicleLogbook, VehicleLogbookPurposeEnum, WORK_TANK_LOGBOOK_PURPOSE_OPTIONS, WorkTankService, XlsxService, cloneDeep, compare, compareMatOptions, createDate, displayMatOptions, enumToList, getDocIcon, replace, roundTo, sort, sortDeep, taxReviewFilterPredicate };
10382
10508
  //# sourceMappingURL=taxtank-core.js.map