taxtank-core 0.10.6 → 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.
@@ -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
  }]
@@ -3844,10 +3845,11 @@
3844
3845
  TaxExemptionEnum[TaxExemptionEnum["OTHER"] = 7] = "OTHER";
3845
3846
  })(exports.TaxExemptionEnum || (exports.TaxExemptionEnum = {}));
3846
3847
 
3847
- var PropertyCategoryListEnum;
3848
+ exports.PropertyCategoryListEnum = void 0;
3848
3849
  (function (PropertyCategoryListEnum) {
3849
3850
  PropertyCategoryListEnum[PropertyCategoryListEnum["OWNER_OCCUPIED"] = 3] = "OWNER_OCCUPIED";
3850
- })(PropertyCategoryListEnum || (PropertyCategoryListEnum = {}));
3851
+ PropertyCategoryListEnum[PropertyCategoryListEnum["VACANT_LAND"] = 5] = "VACANT_LAND";
3852
+ })(exports.PropertyCategoryListEnum || (exports.PropertyCategoryListEnum = {}));
3851
3853
 
3852
3854
  exports.TaxExemptionMetadataEnum = void 0;
3853
3855
  (function (TaxExemptionMetadataEnum) {
@@ -4072,7 +4074,7 @@
4072
4074
  }
4073
4075
  switch (true) {
4074
4076
  // exemption for main residence properties
4075
- case this.category.id === PropertyCategoryListEnum.OWNER_OCCUPIED:
4077
+ case this.category.id === exports.PropertyCategoryListEnum.OWNER_OCCUPIED:
4076
4078
  return exports.TaxExemptionEnum.PPR;
4077
4079
  // exemption for investment properties owned for at least one year
4078
4080
  case this.isOneYearExemptionApplicable(sale):
@@ -7214,6 +7216,15 @@
7214
7216
  AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_CREATED"] = 37] = "VEHICLE_CLAIM_CREATED";
7215
7217
  })(exports.AppEventTypeEnum || (exports.AppEventTypeEnum = {}));
7216
7218
 
7219
+ /**
7220
+ * Data table structure suitable for export
7221
+ */
7222
+ var ExportDataTable = /** @class */ (function () {
7223
+ function ExportDataTable() {
7224
+ }
7225
+ return ExportDataTable;
7226
+ }());
7227
+
7217
7228
  exports.ExportFormatEnum = void 0;
7218
7229
  (function (ExportFormatEnum) {
7219
7230
  ExportFormatEnum["PDF"] = "PDF";
@@ -11003,45 +11014,73 @@
11003
11014
  function PdfService() {
11004
11015
  }
11005
11016
  /**
11006
- * Export file form provided HTML tables
11017
+ * Export file from provided HTML tables
11007
11018
  */
11008
11019
  PdfService.prototype.exportTables = function (tables, title, fileName) {
11009
11020
  var document = this.generateFromTables(tables, title);
11010
11021
  document.save(fileName + ".pdf");
11011
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
+ };
11012
11043
  PdfService.prototype.generateFromTables = function (tables, title) {
11044
+ var _this = this;
11013
11045
  var pdf = new jsPDF__default["default"]();
11014
11046
  this.setDocumentTitle(pdf, title);
11015
11047
  this.setDocumentLogo(pdf);
11016
11048
  tables.forEach(function (table) {
11017
- var _a;
11018
11049
  // Add table caption if not provided
11019
11050
  if (!table.caption) {
11020
11051
  table.createCaption();
11021
11052
  table.caption.innerText = '';
11022
11053
  }
11023
- // coords of last table
11024
- var lastTableCoords = pdf['lastAutoTable'].finalY || PDF_CONFIG.contentCoords.marginTop;
11025
- pdf.text(table.caption.innerText, PDF_CONFIG.contentCoords.marginLeft, lastTableCoords + PDF_CONFIG.contentCoords.marginTop);
11026
- // get caption height based on caption content height
11027
- var captionHeight = pdf.getTextDimensions(pdf.splitTextToSize((_a = table.caption) === null || _a === void 0 ? void 0 : _a.innerText, pdf.internal.pageSize.width)).h;
11028
- // table options
11029
- var options = {
11030
- html: table,
11031
- startY: lastTableCoords + captionHeight + PDF_CONFIG.contentTitleCoords.marginTop,
11032
- headStyles: PDF_CONFIG.table.headStyles,
11033
- footStyles: PDF_CONFIG.table.footStyles,
11034
- didParseCell: function (data) {
11035
- // Align last column content to right
11036
- if (data.table.columns.length > 1 && (data.column.index === data.table.columns.length - 1)) {
11037
- data.cell.styles.halign = 'right';
11038
- }
11039
- }
11040
- };
11041
- autoTable__default["default"](pdf, options);
11054
+ autoTable__default["default"](pdf, Object.assign({ html: table }, _this.setTableOptions(pdf, table.caption.innerText)));
11042
11055
  });
11043
11056
  return pdf;
11044
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
+ };
11045
11084
  PdfService.prototype.setDocumentTitle = function (doc, title) {
11046
11085
  doc.setFontSize(PDF_CONFIG.text.fontSize)
11047
11086
  .setFont(PDF_CONFIG.text.fontName, PDF_CONFIG.text.fontStyle, PDF_CONFIG.text.fontWeight)
@@ -11347,6 +11386,15 @@
11347
11386
  return transactions.filter(function (transaction) { return transaction.isWorkTank(); });
11348
11387
  }));
11349
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
+ };
11350
11398
  /**
11351
11399
  * get list of taxable transactions with tank type 'Work'
11352
11400
  */
@@ -11776,6 +11824,54 @@
11776
11824
  }]
11777
11825
  }] });
11778
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
+
11779
11875
  /**
11780
11876
  * Service for work with Property Categories
11781
11877
  */
@@ -13387,6 +13483,7 @@
13387
13483
  exports.Endpoint = Endpoint;
13388
13484
  exports.EquityPositionChartService = EquityPositionChartService;
13389
13485
  exports.EventDispatcherService = EventDispatcherService;
13486
+ exports.ExportDataTable = ExportDataTable;
13390
13487
  exports.FinancialYear = FinancialYear;
13391
13488
  exports.Firm = Firm;
13392
13489
  exports.FirmService = FirmService;
@@ -13439,6 +13536,7 @@
13439
13536
  exports.PropertyEquityChartData = PropertyEquityChartData;
13440
13537
  exports.PropertyEquityChartItem = PropertyEquityChartItem;
13441
13538
  exports.PropertyForecast = PropertyForecast;
13539
+ exports.PropertyHoldingCostsService = PropertyHoldingCostsService;
13442
13540
  exports.PropertyReportItem = PropertyReportItem;
13443
13541
  exports.PropertyReportItemCollection = PropertyReportItemCollection;
13444
13542
  exports.PropertyReportItemDepreciationCollection = PropertyReportItemDepreciationCollection;