taxtank-core 0.10.4 → 0.10.7

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 (31) hide show
  1. package/bundles/taxtank-core.umd.js +247 -139
  2. package/bundles/taxtank-core.umd.js.map +1 -1
  3. package/esm2015/lib/collections/collection.js +8 -1
  4. package/esm2015/lib/collections/report/property/property-report-item-depreciation.collection.js +12 -9
  5. package/esm2015/lib/collections/report/property/property-report-item-transaction.collection.js +12 -9
  6. package/esm2015/lib/collections/report/property/property-report-item.collection.js +13 -0
  7. package/esm2015/lib/db/Enums/property/property-category-list.enum.js +2 -1
  8. package/esm2015/lib/models/export/export-data-table.js +6 -0
  9. package/esm2015/lib/models/report/property/property-report-item-depreciation.js +10 -4
  10. package/esm2015/lib/models/report/property/property-report-item-transaction.js +2 -2
  11. package/esm2015/lib/models/report/property/property-report-item.js +10 -1
  12. package/esm2015/lib/services/http/transaction/transaction.service.js +11 -1
  13. package/esm2015/lib/services/pdf/pdf.service.js +47 -22
  14. package/esm2015/lib/services/property/property-holding-costs/property-holding-costs.service.js +53 -0
  15. package/esm2015/lib/services/report/property/property-transaction-report.service.js +14 -50
  16. package/esm2015/public-api.js +5 -1
  17. package/fesm2015/taxtank-core.js +221 -131
  18. package/fesm2015/taxtank-core.js.map +1 -1
  19. package/lib/collections/collection.d.ts +4 -0
  20. package/lib/collections/report/property/property-report-item-depreciation.collection.d.ts +4 -4
  21. package/lib/collections/report/property/property-report-item-transaction.collection.d.ts +4 -4
  22. package/lib/collections/report/property/property-report-item.collection.d.ts +9 -0
  23. package/lib/db/Enums/property/property-category-list.enum.d.ts +2 -1
  24. package/lib/models/export/export-data-table.d.ts +9 -0
  25. package/lib/models/report/property/property-report-item.d.ts +4 -0
  26. package/lib/services/http/transaction/transaction.service.d.ts +4 -0
  27. package/lib/services/pdf/pdf.service.d.ts +14 -1
  28. package/lib/services/property/property-holding-costs/property-holding-costs.service.d.ts +24 -0
  29. package/lib/services/report/property/property-transaction-report.service.d.ts +5 -12
  30. package/package.json +1 -1
  31. package/public-api.d.ts +4 -0
@@ -2,7 +2,7 @@
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/common/http'), require('rxjs'), require('rxjs/operators'), require('class-transformer'), require('@auth0/angular-jwt'), require('lodash/has'), require('lodash/get'), require('lodash/flatten'), require('lodash/first'), require('lodash/last'), require('lodash/uniqBy'), require('lodash/concat'), require('lodash/compact'), require('moment'), require('moment-range'), require('lodash/cloneDeep'), require('@angular/forms'), require('lodash'), require('event-source-polyfill/src/eventsource.min.js'), require('@angular/router'), require('lodash/clone'), require('jspdf'), require('jspdf-autotable'), require('@stripe/stripe-js'), require('xlsx'), require('file-saver')) :
3
3
  typeof define === 'function' && define.amd ? define('taxtank-core', ['exports', '@angular/core', '@angular/common', '@angular/common/http', 'rxjs', 'rxjs/operators', 'class-transformer', '@auth0/angular-jwt', 'lodash/has', 'lodash/get', 'lodash/flatten', 'lodash/first', 'lodash/last', 'lodash/uniqBy', 'lodash/concat', 'lodash/compact', 'moment', 'moment-range', 'lodash/cloneDeep', '@angular/forms', 'lodash', 'event-source-polyfill/src/eventsource.min.js', '@angular/router', 'lodash/clone', 'jspdf', 'jspdf-autotable', '@stripe/stripe-js', 'xlsx', 'file-saver'], factory) :
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["taxtank-core"] = {}, global.ng.core, global.ng.common, global.ng.common.http, global.rxjs, global.rxjs.operators, global.classTransformer, global.angularJwt, global.has, global.get, global.flatten, global.first, global.last, global.uniqBy, global.concat, global.compact, global.moment, global.momentRange, global.cloneDeep$1, global.ng.forms, global._, global.eventsource_min_js, global.ng.router, global.clone, global.jsPDF, global.autoTable, global.stripeJs, global.xlsx, global.FileSaver));
5
- })(this, (function (exports, i0, common, i1, rxjs, operators, classTransformer, angularJwt, has, get, flatten, first, last, uniqBy, concat, compact, moment, momentRange, cloneDeep$1, forms, _, eventsource_min_js, i1$1, clone, jsPDF, autoTable, stripeJs, xlsx, FileSaver) { 'use strict';
5
+ })(this, (function (exports, i0, i2, i1, rxjs, operators, classTransformer, angularJwt, has, get, flatten, first, last, uniqBy, concat, compact, moment, momentRange, cloneDeep$1, forms, _, eventsource_min_js, i1$1, clone, jsPDF, autoTable, stripeJs, xlsx, FileSaver) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -25,6 +25,7 @@
25
25
  }
26
26
 
27
27
  var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
28
+ var i2__namespace = /*#__PURE__*/_interopNamespace(i2);
28
29
  var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
29
30
  var has__default = /*#__PURE__*/_interopDefaultLegacy(has);
30
31
  var get__default = /*#__PURE__*/_interopDefaultLegacy(get);
@@ -1103,10 +1104,10 @@
1103
1104
  return TtCoreModule;
1104
1105
  }());
1105
1106
  TtCoreModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TtCoreModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1106
- TtCoreModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TtCoreModule, imports: [common.CommonModule,
1107
+ TtCoreModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TtCoreModule, imports: [i2.CommonModule,
1107
1108
  InterceptorsModule] });
1108
1109
  TtCoreModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TtCoreModule, imports: [[
1109
- common.CommonModule,
1110
+ i2.CommonModule,
1110
1111
  InterceptorsModule
1111
1112
  ]] });
1112
1113
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TtCoreModule, decorators: [{
@@ -1114,7 +1115,7 @@
1114
1115
  args: [{
1115
1116
  declarations: [],
1116
1117
  imports: [
1117
- common.CommonModule,
1118
+ i2.CommonModule,
1118
1119
  InterceptorsModule
1119
1120
  ]
1120
1121
  }]
@@ -1212,6 +1213,52 @@
1212
1213
  return CollectionDictionary;
1213
1214
  }());
1214
1215
 
1216
+ // replace array element with the new one (only arrays of objects)
1217
+ function replace(array, item, matchField) {
1218
+ if (matchField === void 0) { matchField = 'id'; }
1219
+ var index = array.findIndex(function (i) { return i[matchField] === item[matchField]; });
1220
+ array.splice(index, 1, item);
1221
+ }
1222
+
1223
+ // sort array of objects by field
1224
+ function sort(array, field, isDesc) {
1225
+ if (field === void 0) { field = 'id'; }
1226
+ if (isDesc === void 0) { isDesc = true; }
1227
+ array.sort(function (a, b) {
1228
+ if (a[field] > b[field]) {
1229
+ return !isDesc ? 1 : -1;
1230
+ }
1231
+ if (a[field] < b[field]) {
1232
+ return !isDesc ? -1 : 1;
1233
+ }
1234
+ return 0;
1235
+ });
1236
+ }
1237
+
1238
+ // sort array of objects by field
1239
+ function sortDeep(array, fieldsQueue, isDesc) {
1240
+ if (fieldsQueue === void 0) { fieldsQueue = ['id']; }
1241
+ if (isDesc === void 0) { isDesc = true; }
1242
+ array.sort(function (a, b) {
1243
+ var aValue = getValue(a, fieldsQueue);
1244
+ var bValue = getValue(b, fieldsQueue);
1245
+ if (aValue > bValue) {
1246
+ return !isDesc ? 1 : -1;
1247
+ }
1248
+ if (aValue < bValue) {
1249
+ return !isDesc ? -1 : 1;
1250
+ }
1251
+ return 0;
1252
+ });
1253
+ }
1254
+ function getValue(obj, fields) {
1255
+ var value = obj;
1256
+ fields.forEach(function (field) {
1257
+ value = value[field];
1258
+ });
1259
+ return value;
1260
+ }
1261
+
1215
1262
  var DEFAULT_INDEX = 'other';
1216
1263
  /**
1217
1264
  * Base collection class. Contains common properties and methods for all collections
@@ -1290,6 +1337,14 @@
1290
1337
  Collection.prototype.filter = function (callback) {
1291
1338
  return new Collection(this.items.filter(callback));
1292
1339
  };
1340
+ /**
1341
+ * Sort collection items by provided field
1342
+ */
1343
+ Collection.prototype.sortBy = function (filed, isDesc) {
1344
+ if (filed === void 0) { filed = 'id'; }
1345
+ if (isDesc === void 0) { isDesc = true; }
1346
+ sort(this.items, filed, isDesc);
1347
+ };
1293
1348
  Object.defineProperty(Collection.prototype, "first", {
1294
1349
  get: function () {
1295
1350
  return first__default["default"](this.items);
@@ -3790,10 +3845,11 @@
3790
3845
  TaxExemptionEnum[TaxExemptionEnum["OTHER"] = 7] = "OTHER";
3791
3846
  })(exports.TaxExemptionEnum || (exports.TaxExemptionEnum = {}));
3792
3847
 
3793
- var PropertyCategoryListEnum;
3848
+ exports.PropertyCategoryListEnum = void 0;
3794
3849
  (function (PropertyCategoryListEnum) {
3795
3850
  PropertyCategoryListEnum[PropertyCategoryListEnum["OWNER_OCCUPIED"] = 3] = "OWNER_OCCUPIED";
3796
- })(PropertyCategoryListEnum || (PropertyCategoryListEnum = {}));
3851
+ PropertyCategoryListEnum[PropertyCategoryListEnum["VACANT_LAND"] = 5] = "VACANT_LAND";
3852
+ })(exports.PropertyCategoryListEnum || (exports.PropertyCategoryListEnum = {}));
3797
3853
 
3798
3854
  exports.TaxExemptionMetadataEnum = void 0;
3799
3855
  (function (TaxExemptionMetadataEnum) {
@@ -4018,7 +4074,7 @@
4018
4074
  }
4019
4075
  switch (true) {
4020
4076
  // exemption for main residence properties
4021
- case this.category.id === PropertyCategoryListEnum.OWNER_OCCUPIED:
4077
+ case this.category.id === exports.PropertyCategoryListEnum.OWNER_OCCUPIED:
4022
4078
  return exports.TaxExemptionEnum.PPR;
4023
4079
  // exemption for investment properties owned for at least one year
4024
4080
  case this.isOneYearExemptionApplicable(sale):
@@ -5059,11 +5115,30 @@
5059
5115
  return DepreciationReportItemCollection;
5060
5116
  }(DepreciationCollection));
5061
5117
 
5118
+ /**
5119
+ * Base collection to work with property report items
5120
+ */
5121
+ var PropertyReportItemCollection = /** @class */ (function (_super) {
5122
+ __extends(PropertyReportItemCollection, _super);
5123
+ function PropertyReportItemCollection() {
5124
+ return _super !== null && _super.apply(this, arguments) || this;
5125
+ }
5126
+ PropertyReportItemCollection.prototype.getIncomes = function () {
5127
+ return this.create(this.items.filter(function (item) { return item.isIncome(); }));
5128
+ };
5129
+ PropertyReportItemCollection.prototype.getExpenses = function () {
5130
+ return this.create(this.items.filter(function (item) { return item.isExpense(); }));
5131
+ };
5132
+ return PropertyReportItemCollection;
5133
+ }(Collection));
5134
+
5062
5135
  /**
5063
5136
  * Class with property transactions report entities
5064
5137
  */
5065
5138
  var PropertyReportItem = /** @class */ (function () {
5066
5139
  function PropertyReportItem(property, chartAccounts) {
5140
+ this.chartAccounts = chartAccounts;
5141
+ this.propertyId = property.id;
5067
5142
  this.claimPercent = property.claimPercent;
5068
5143
  this.sharePercent = property.sharePercent;
5069
5144
  this.subCode = chartAccounts.taxReturnItem.subCode;
@@ -5083,6 +5158,12 @@
5083
5158
  enumerable: false,
5084
5159
  configurable: true
5085
5160
  });
5161
+ PropertyReportItem.prototype.isIncome = function () {
5162
+ return CHART_ACCOUNTS_CATEGORIES.income.includes(this.chartAccounts.category);
5163
+ };
5164
+ PropertyReportItem.prototype.isExpense = function () {
5165
+ return CHART_ACCOUNTS_CATEGORIES.expense.includes(this.chartAccounts.category);
5166
+ };
5086
5167
  return PropertyReportItem;
5087
5168
  }());
5088
5169
 
@@ -5093,7 +5174,7 @@
5093
5174
  __extends(PropertyReportItemTransaction, _super);
5094
5175
  function PropertyReportItemTransaction(transactions, property, chartAccounts) {
5095
5176
  var _this = _super.call(this, property, chartAccounts) || this;
5096
- _this.amount = transactions.amount;
5177
+ _this.amount = Math.abs(transactions.amount);
5097
5178
  _this.description = chartAccounts.name;
5098
5179
  return _this;
5099
5180
  }
@@ -5105,20 +5186,31 @@
5105
5186
  */
5106
5187
  var PropertyReportItemTransactionCollection = /** @class */ (function (_super) {
5107
5188
  __extends(PropertyReportItemTransactionCollection, _super);
5108
- function PropertyReportItemTransactionCollection(transactions, property, chartAccounts) {
5189
+ function PropertyReportItemTransactionCollection(transactions, properties, chartAccounts) {
5109
5190
  var _this = _super.call(this) || this;
5110
- _this.setItems(transactions, property, chartAccounts);
5191
+ _this.setItems(transactions, properties, chartAccounts);
5111
5192
  return _this;
5112
5193
  }
5113
- PropertyReportItemTransactionCollection.prototype.setItems = function (transactions, property, chartAccounts) {
5114
- var transactionsDictionary = new CollectionDictionary(transactions, 'chartAccounts.id');
5115
- this.items = transactionsDictionary.keys.map(function (chartAccountId) {
5116
- return new PropertyReportItemTransaction(transactionsDictionary.get(chartAccountId), property, chartAccounts.getById(+chartAccountId));
5194
+ PropertyReportItemTransactionCollection.prototype.setItems = function (transactions, properties, chartAccounts) {
5195
+ var _this = this;
5196
+ this.items = [];
5197
+ properties.items.forEach(function (property) {
5198
+ var transactionsDictionary = new CollectionDictionary(transactions.getByPropertiesIds([property.id]), 'chartAccounts.id');
5199
+ transactionsDictionary.keys.map(function (chartAccountId) {
5200
+ _this.items.push(new PropertyReportItemTransaction(transactionsDictionary.get(chartAccountId), property, chartAccounts.getById(+chartAccountId)));
5201
+ });
5117
5202
  });
5118
5203
  };
5119
5204
  return PropertyReportItemTransactionCollection;
5120
- }(Collection));
5205
+ }(PropertyReportItemCollection));
5121
5206
 
5207
+ /**
5208
+ * Const with labels based on depreciation type
5209
+ */
5210
+ var DEPRECIATION_TYPE_LABELS = {
5211
+ 1: 'Plant & Equipment',
5212
+ 2: 'Building & Improvements'
5213
+ };
5122
5214
  /**
5123
5215
  * Class with depreciation-based property transactions report entities
5124
5216
  */
@@ -5126,8 +5218,8 @@
5126
5218
  __extends(PropertyReportItemDepreciation, _super);
5127
5219
  function PropertyReportItemDepreciation(depreciations, property, chartAccounts) {
5128
5220
  var _this = _super.call(this, property, chartAccounts) || this;
5129
- _this.amount = depreciations.getCurrentYearForecastAmount();
5130
- _this.description = exports.DepreciationTypeEnum[depreciations.first.type];
5221
+ _this.amount = Math.abs(depreciations.getCurrentYearForecastAmount());
5222
+ _this.description = DEPRECIATION_TYPE_LABELS[depreciations.first.type];
5131
5223
  return _this;
5132
5224
  }
5133
5225
  return PropertyReportItemDepreciation;
@@ -5138,19 +5230,23 @@
5138
5230
  */
5139
5231
  var PropertyReportItemDepreciationCollection = /** @class */ (function (_super) {
5140
5232
  __extends(PropertyReportItemDepreciationCollection, _super);
5141
- function PropertyReportItemDepreciationCollection(depreciations, property, chartAccounts) {
5233
+ function PropertyReportItemDepreciationCollection(depreciations, properties, chartAccounts) {
5142
5234
  var _this = _super.call(this) || this;
5143
- _this.setItems(depreciations, property, chartAccounts);
5235
+ _this.setItems(depreciations, properties, chartAccounts);
5144
5236
  return _this;
5145
5237
  }
5146
- PropertyReportItemDepreciationCollection.prototype.setItems = function (depreciations, property, chartAccounts) {
5147
- var depreciationsbyType = new CollectionDictionary(depreciations, 'type');
5148
- this.items = depreciationsbyType.keys.map(function (type) {
5149
- return new PropertyReportItemDepreciation(depreciationsbyType.get(type), property, chartAccounts.getById(depreciationsbyType.get(type).first.chartAccounts.id));
5238
+ PropertyReportItemDepreciationCollection.prototype.setItems = function (depreciations, properties, chartAccounts) {
5239
+ var _this = this;
5240
+ this.items = [];
5241
+ properties.items.forEach(function (property) {
5242
+ var depreciationsByType = new CollectionDictionary(depreciations, 'type');
5243
+ depreciationsByType.keys.map(function (type) {
5244
+ _this.items.push(new PropertyReportItemDepreciation(depreciationsByType.get(type), property, chartAccounts.getById(depreciationsByType.get(type).first.chartAccounts.id)));
5245
+ });
5150
5246
  });
5151
5247
  };
5152
5248
  return PropertyReportItemDepreciationCollection;
5153
- }(Collection));
5249
+ }(PropertyReportItemCollection));
5154
5250
 
5155
5251
  var ServicePriceCollection = /** @class */ (function (_super) {
5156
5252
  __extends(ServicePriceCollection, _super);
@@ -7120,6 +7216,15 @@
7120
7216
  AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_CREATED"] = 37] = "VEHICLE_CLAIM_CREATED";
7121
7217
  })(exports.AppEventTypeEnum || (exports.AppEventTypeEnum = {}));
7122
7218
 
7219
+ /**
7220
+ * Data table structure suitable for export
7221
+ */
7222
+ var ExportDataTable = /** @class */ (function () {
7223
+ function ExportDataTable() {
7224
+ }
7225
+ return ExportDataTable;
7226
+ }());
7227
+
7123
7228
  exports.ExportFormatEnum = void 0;
7124
7229
  (function (ExportFormatEnum) {
7125
7230
  ExportFormatEnum["PDF"] = "PDF";
@@ -8357,52 +8462,6 @@
8357
8462
  }] }];
8358
8463
  } });
8359
8464
 
8360
- // replace array element with the new one (only arrays of objects)
8361
- function replace(array, item, matchField) {
8362
- if (matchField === void 0) { matchField = 'id'; }
8363
- var index = array.findIndex(function (i) { return i[matchField] === item[matchField]; });
8364
- array.splice(index, 1, item);
8365
- }
8366
-
8367
- // sort array of objects by field
8368
- function sort(array, field, isDesc) {
8369
- if (field === void 0) { field = 'id'; }
8370
- if (isDesc === void 0) { isDesc = true; }
8371
- array.sort(function (a, b) {
8372
- if (a[field] > b[field]) {
8373
- return !isDesc ? 1 : -1;
8374
- }
8375
- if (a[field] < b[field]) {
8376
- return !isDesc ? -1 : 1;
8377
- }
8378
- return 0;
8379
- });
8380
- }
8381
-
8382
- // sort array of objects by field
8383
- function sortDeep(array, fieldsQueue, isDesc) {
8384
- if (fieldsQueue === void 0) { fieldsQueue = ['id']; }
8385
- if (isDesc === void 0) { isDesc = true; }
8386
- array.sort(function (a, b) {
8387
- var aValue = getValue(a, fieldsQueue);
8388
- var bValue = getValue(b, fieldsQueue);
8389
- if (aValue > bValue) {
8390
- return !isDesc ? 1 : -1;
8391
- }
8392
- if (aValue < bValue) {
8393
- return !isDesc ? -1 : 1;
8394
- }
8395
- return 0;
8396
- });
8397
- }
8398
- function getValue(obj, fields) {
8399
- var value = obj;
8400
- fields.forEach(function (field) {
8401
- value = value[field];
8402
- });
8403
- return value;
8404
- }
8405
-
8406
8465
  var EventDispatcherService = /** @class */ (function () {
8407
8466
  function EventDispatcherService() {
8408
8467
  this.eventSubject = new rxjs.Subject();
@@ -10955,45 +11014,73 @@
10955
11014
  function PdfService() {
10956
11015
  }
10957
11016
  /**
10958
- * Export file form provided HTML tables
11017
+ * Export file from provided HTML tables
10959
11018
  */
10960
11019
  PdfService.prototype.exportTables = function (tables, title, fileName) {
10961
11020
  var document = this.generateFromTables(tables, title);
10962
11021
  document.save(fileName + ".pdf");
10963
11022
  };
11023
+ /**
11024
+ * Export file from provided array-like table data
11025
+ */
11026
+ PdfService.prototype.exportFromDataTables = function (dataTables, title, fileName) {
11027
+ var document = this.generateFromDataTables(title, dataTables);
11028
+ document.save(fileName + ".pdf");
11029
+ };
11030
+ /**
11031
+ * Generate file from array-like table data
11032
+ */
11033
+ PdfService.prototype.generateFromDataTables = function (title, dataTables) {
11034
+ var _this = this;
11035
+ var pdf = new jsPDF__default["default"]();
11036
+ this.setDocumentTitle(pdf, title);
11037
+ this.setDocumentLogo(pdf);
11038
+ dataTables.forEach(function (dataTable) {
11039
+ autoTable__default["default"](pdf, Object.assign({ head: [dataTable.header], body: dataTable.rows, foot: [dataTable.footer] }, _this.setTableOptions(pdf, dataTable.caption)));
11040
+ });
11041
+ return pdf;
11042
+ };
10964
11043
  PdfService.prototype.generateFromTables = function (tables, title) {
11044
+ var _this = this;
10965
11045
  var pdf = new jsPDF__default["default"]();
10966
11046
  this.setDocumentTitle(pdf, title);
10967
11047
  this.setDocumentLogo(pdf);
10968
11048
  tables.forEach(function (table) {
10969
- var _a;
10970
11049
  // Add table caption if not provided
10971
11050
  if (!table.caption) {
10972
11051
  table.createCaption();
10973
11052
  table.caption.innerText = '';
10974
11053
  }
10975
- // coords of last table
10976
- var lastTableCoords = pdf['lastAutoTable'].finalY || PDF_CONFIG.contentCoords.marginTop;
10977
- pdf.text(table.caption.innerText, PDF_CONFIG.contentCoords.marginLeft, lastTableCoords + PDF_CONFIG.contentCoords.marginTop);
10978
- // get caption height based on caption content height
10979
- var captionHeight = pdf.getTextDimensions(pdf.splitTextToSize((_a = table.caption) === null || _a === void 0 ? void 0 : _a.innerText, pdf.internal.pageSize.width)).h;
10980
- // table options
10981
- var options = {
10982
- html: table,
10983
- startY: lastTableCoords + captionHeight + PDF_CONFIG.contentTitleCoords.marginTop,
10984
- headStyles: PDF_CONFIG.table.headStyles,
10985
- footStyles: PDF_CONFIG.table.footStyles,
10986
- didParseCell: function (data) {
10987
- // Align last column content to right
10988
- if (data.table.columns.length > 1 && (data.column.index === data.table.columns.length - 1)) {
10989
- data.cell.styles.halign = 'right';
10990
- }
10991
- }
10992
- };
10993
- autoTable__default["default"](pdf, options);
11054
+ autoTable__default["default"](pdf, Object.assign({ html: table }, _this.setTableOptions(pdf, table.caption.innerText)));
10994
11055
  });
10995
11056
  return pdf;
10996
11057
  };
11058
+ /**
11059
+ * Set basic options for PDF table
11060
+ */
11061
+ PdfService.prototype.setTableOptions = function (pdf, tableCaption) {
11062
+ if (tableCaption === void 0) { tableCaption = ''; }
11063
+ var lastTableCoords = pdf['lastAutoTable'].finalY || PDF_CONFIG.contentCoords.marginTop;
11064
+ // get caption height based on caption content height
11065
+ var captionHeight = pdf.getTextDimensions(pdf.splitTextToSize(tableCaption, pdf.internal.pageSize.width)).h;
11066
+ pdf.text(tableCaption, PDF_CONFIG.contentCoords.marginLeft, lastTableCoords + PDF_CONFIG.contentCoords.marginTop);
11067
+ return {
11068
+ headStyles: {
11069
+ fillColor: PDF_CONFIG.text.colorPrimary,
11070
+ },
11071
+ footStyles: {
11072
+ fillColor: PDF_CONFIG.text.colorWhite,
11073
+ textColor: PDF_CONFIG.text.colorBlack
11074
+ },
11075
+ startY: lastTableCoords + captionHeight + PDF_CONFIG.contentTitleCoords.marginTop,
11076
+ didParseCell: function (data) {
11077
+ // Align last column content to right
11078
+ if (data.table.columns.length > 1 && (data.column.index === data.table.columns.length - 1)) {
11079
+ data.cell.styles.halign = 'right';
11080
+ }
11081
+ }
11082
+ };
11083
+ };
10997
11084
  PdfService.prototype.setDocumentTitle = function (doc, title) {
10998
11085
  doc.setFontSize(PDF_CONFIG.text.fontSize)
10999
11086
  .setFont(PDF_CONFIG.text.fontName, PDF_CONFIG.text.fontStyle, PDF_CONFIG.text.fontWeight)
@@ -11299,6 +11386,15 @@
11299
11386
  return transactions.filter(function (transaction) { return transaction.isWorkTank(); });
11300
11387
  }));
11301
11388
  };
11389
+ /**
11390
+ * Get list of property holding costs (transactions related to vacant land property)
11391
+ */
11392
+ TransactionService.prototype.getPropertyHoldingCosts = function (propertyId) {
11393
+ return this.http.get(this.environment.apiV2 + "/" + this.url + "?propertyId=" + propertyId + "&propertyCategoryId=" + exports.PropertyCategoryListEnum.VACANT_LAND)
11394
+ .pipe(operators.map(function (transactionsBase) {
11395
+ return transactionsBase.map(function (transactionBase) { return classTransformer.plainToClass(Transaction, transactionBase); });
11396
+ }));
11397
+ };
11302
11398
  /**
11303
11399
  * get list of taxable transactions with tank type 'Work'
11304
11400
  */
@@ -11550,55 +11646,25 @@
11550
11646
  this.chartAccountsService = chartAccountsService;
11551
11647
  }
11552
11648
  /**
11553
- * Get collections dictionary of income report items, grouped by property id
11554
- */
11555
- PropertyTransactionReportService.prototype.getIncomes = function () {
11556
- var _this = this;
11557
- return rxjs.combineLatest([
11558
- this.getProperties(),
11559
- this.getTransactions(),
11560
- this.getChartAccounts(),
11561
- ]).pipe(operators.map(function (_a) {
11562
- var _b = __read(_a, 3), properties = _b[0], transactions = _b[1], chartAccounts = _b[2];
11563
- return _this.initIncomeItemsData(transactions, properties, chartAccounts);
11564
- }));
11565
- };
11566
- /**
11567
- * Get collections dictionary of expense report items, grouped by property id
11649
+ * Get collection of report items based on transactions & depreciations
11568
11650
  */
11569
- PropertyTransactionReportService.prototype.getExpenses = function () {
11651
+ PropertyTransactionReportService.prototype.get = function () {
11570
11652
  var _this = this;
11571
11653
  return rxjs.combineLatest([
11572
- this.getProperties(),
11654
+ this.propertyService.get(),
11573
11655
  this.getTransactions(),
11574
11656
  this.getDepreciations(),
11575
- this.getChartAccounts()
11657
+ this.chartAccountsService.getChartAccounts()
11576
11658
  ]).pipe(operators.map(function (_a) {
11577
11659
  var _b = __read(_a, 4), properties = _b[0], transactions = _b[1], depreciations = _b[2], chartAccounts = _b[3];
11578
- return _this.initExpenseItemsData(transactions, depreciations, properties, chartAccounts);
11660
+ return new CollectionDictionary(_this.create(transactions, depreciations, new PropertyCollection(properties), new Collection(chartAccounts)), 'propertyId');
11579
11661
  }));
11580
11662
  };
11581
- PropertyTransactionReportService.prototype.initIncomeItemsData = function (transactions, properties, chartAccounts) {
11582
- // empty collection dictionary to be filled with income report items
11583
- var incomesByProperty = new CollectionDictionary(new Collection([]), 'property.id');
11584
- var incomeTransactionsByProperty = new CollectionDictionary(transactions.getIncomeTransactions(), 'property.id');
11585
- incomeTransactionsByProperty.keys.forEach(function (propertyId) {
11586
- incomesByProperty.add(propertyId, new PropertyReportItemTransactionCollection(incomeTransactionsByProperty.get(propertyId), properties.getById(+propertyId), chartAccounts));
11587
- });
11588
- return incomesByProperty;
11589
- };
11590
- PropertyTransactionReportService.prototype.initExpenseItemsData = function (transactions, depreciations, properties, chartAccounts) {
11591
- // empty collection dictionary to be filled with expense report items
11592
- var expensesByProperty = new CollectionDictionary(new Collection([]), 'property.id');
11593
- var transactionsByProperty = new CollectionDictionary(transactions.getExpenseTransactions(), 'property.id');
11594
- var depreciationsByProperty = new CollectionDictionary(depreciations, 'property.id');
11595
- transactionsByProperty.keys.forEach(function (propertyId) {
11596
- expensesByProperty.add(propertyId, new Collection(__spreadArray(__spreadArray([], __read(new PropertyReportItemTransactionCollection(transactionsByProperty.get(propertyId), properties.getById(+propertyId), chartAccounts).items)), __read(new PropertyReportItemDepreciationCollection(depreciationsByProperty.get(propertyId), properties.getById(+propertyId), chartAccounts).items))));
11597
- });
11598
- return expensesByProperty;
11663
+ PropertyTransactionReportService.prototype.create = function (transactions, depreciations, properties, chartAccounts) {
11664
+ return new PropertyReportItemCollection(__spreadArray(__spreadArray([], __read(new PropertyReportItemTransactionCollection(transactions, properties, chartAccounts).items)), __read(new PropertyReportItemDepreciationCollection(depreciations, properties, chartAccounts).items)));
11599
11665
  };
11600
11666
  /**
11601
- * Get colection of property transactions
11667
+ * Get collection of property transactions
11602
11668
  */
11603
11669
  PropertyTransactionReportService.prototype.getTransactions = function () {
11604
11670
  return this.transactionService.get().pipe(operators.map(function (transactions) {
@@ -11613,19 +11679,10 @@
11613
11679
  return this.depreciationService.get().pipe(operators.map(function (depreciations) {
11614
11680
  return new DepreciationCollection(depreciations)
11615
11681
  .getByChartAccountsCategories(CHART_ACCOUNTS_CATEGORIES.property)
11682
+ // we don't need borrowing expenses for this report
11616
11683
  .getWithoutBorrowingExpenses();
11617
11684
  }));
11618
11685
  };
11619
- PropertyTransactionReportService.prototype.getProperties = function () {
11620
- return this.propertyService.get().pipe(operators.map(function (properties) {
11621
- return new PropertyCollection(properties);
11622
- }));
11623
- };
11624
- PropertyTransactionReportService.prototype.getChartAccounts = function () {
11625
- return this.chartAccountsService.getChartAccounts().pipe(operators.map(function (chartAccounts) {
11626
- return new Collection(chartAccounts);
11627
- }));
11628
- };
11629
11686
  return PropertyTransactionReportService;
11630
11687
  }());
11631
11688
  PropertyTransactionReportService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyTransactionReportService, deps: [{ token: PropertyService }, { token: TransactionService }, { token: DepreciationService }, { token: ChartAccountsService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
@@ -11767,6 +11824,54 @@
11767
11824
  }]
11768
11825
  }] });
11769
11826
 
11827
+ /**
11828
+ * Service to work with holding costs (transactions related to vacant land property)
11829
+ */
11830
+ var PropertyHoldingCostsService = /** @class */ (function () {
11831
+ function PropertyHoldingCostsService(pdfService, currencyPipe, datePipe) {
11832
+ this.pdfService = pdfService;
11833
+ this.currencyPipe = currencyPipe;
11834
+ this.datePipe = datePipe;
11835
+ this.url = 'transactions';
11836
+ this.modelClass = Transaction;
11837
+ }
11838
+ PropertyHoldingCostsService.prototype.initDataTable = function (holdingCosts) {
11839
+ return classTransformer.plainToClass(ExportDataTable, {
11840
+ header: ['Date', 'Description', 'Debit', 'Credit'],
11841
+ rows: this.getDataTableRows(holdingCosts),
11842
+ footer: [
11843
+ 'Total',
11844
+ '',
11845
+ this.currencyPipe.transform(holdingCosts.sumBy('debit')).toString(),
11846
+ this.currencyPipe.transform(holdingCosts.sumBy('credit')).toString(),
11847
+ ]
11848
+ });
11849
+ };
11850
+ /**
11851
+ * Get data for the exporting table rows
11852
+ */
11853
+ PropertyHoldingCostsService.prototype.getDataTableRows = function (holdingCosts) {
11854
+ var _this = this;
11855
+ return holdingCosts.items.map(function (transaction) {
11856
+ return [
11857
+ _this.datePipe.transform(transaction.date, 'dd/MM/YYYY').toString(),
11858
+ transaction.description,
11859
+ _this.currencyPipe.transform(transaction.debit).toString(),
11860
+ _this.currencyPipe.transform(transaction.credit).toString()
11861
+ ];
11862
+ });
11863
+ };
11864
+ return PropertyHoldingCostsService;
11865
+ }());
11866
+ PropertyHoldingCostsService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyHoldingCostsService, deps: [{ token: PdfService }, { token: i2__namespace.CurrencyPipe }, { token: i2__namespace.DatePipe }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
11867
+ PropertyHoldingCostsService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyHoldingCostsService, providedIn: 'root' });
11868
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyHoldingCostsService, decorators: [{
11869
+ type: i0.Injectable,
11870
+ args: [{
11871
+ providedIn: 'root'
11872
+ }]
11873
+ }], ctorParameters: function () { return [{ type: PdfService }, { type: i2__namespace.CurrencyPipe }, { type: i2__namespace.DatePipe }]; } });
11874
+
11770
11875
  /**
11771
11876
  * Service for work with Property Categories
11772
11877
  */
@@ -13378,6 +13483,7 @@
13378
13483
  exports.Endpoint = Endpoint;
13379
13484
  exports.EquityPositionChartService = EquityPositionChartService;
13380
13485
  exports.EventDispatcherService = EventDispatcherService;
13486
+ exports.ExportDataTable = ExportDataTable;
13381
13487
  exports.FinancialYear = FinancialYear;
13382
13488
  exports.Firm = Firm;
13383
13489
  exports.FirmService = FirmService;
@@ -13430,7 +13536,9 @@
13430
13536
  exports.PropertyEquityChartData = PropertyEquityChartData;
13431
13537
  exports.PropertyEquityChartItem = PropertyEquityChartItem;
13432
13538
  exports.PropertyForecast = PropertyForecast;
13539
+ exports.PropertyHoldingCostsService = PropertyHoldingCostsService;
13433
13540
  exports.PropertyReportItem = PropertyReportItem;
13541
+ exports.PropertyReportItemCollection = PropertyReportItemCollection;
13434
13542
  exports.PropertyReportItemDepreciationCollection = PropertyReportItemDepreciationCollection;
13435
13543
  exports.PropertyReportItemTransaction = PropertyReportItemTransaction;
13436
13544
  exports.PropertyReportItemTransactionCollection = PropertyReportItemTransactionCollection;