taxtank-core 0.9.2 → 0.9.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.
@@ -5906,14 +5906,14 @@
5906
5906
  });
5907
5907
  Object.defineProperty(Transaction.prototype, "debit", {
5908
5908
  get: function () {
5909
- return this.isDebit() ? Math.abs(this.amount) : null;
5909
+ return this.isDebit() ? Math.abs(this.amount) : 0;
5910
5910
  },
5911
5911
  enumerable: false,
5912
5912
  configurable: true
5913
5913
  });
5914
5914
  Object.defineProperty(Transaction.prototype, "credit", {
5915
5915
  get: function () {
5916
- return this.isCredit() ? Math.abs(this.amount) : null;
5916
+ return this.isCredit() ? Math.abs(this.amount) : 0;
5917
5917
  },
5918
5918
  enumerable: false,
5919
5919
  configurable: true
@@ -6691,64 +6691,6 @@
6691
6691
  AlphabetColorsEnum["Z"] = "#E3C9CE";
6692
6692
  })(exports.AlphabetColorsEnum || (exports.AlphabetColorsEnum = {}));
6693
6693
 
6694
- /**
6695
- * Class to generate data-table structure based on provided collection.
6696
- * Use to work with HTML/PDF/XLSX tables
6697
- */
6698
- var DataTable = /** @class */ (function () {
6699
- function DataTable(collection, columns, caption, footerCaption) {
6700
- this.caption = caption;
6701
- this.columns = columns;
6702
- this.setRows(collection);
6703
- if (footerCaption) {
6704
- this.setFooterRow(collection, footerCaption);
6705
- }
6706
- }
6707
- DataTable.prototype.setRows = function (collection) {
6708
- var _this = this;
6709
- this.rows = collection.items.map(function (item) {
6710
- // parse table columns to return items based on column properties
6711
- return _this.columns.map(function (column) {
6712
- // if the pipe is provided - transform the return value
6713
- if (column.pipe) {
6714
- return column.pipe.transform(item[column.key]);
6715
- }
6716
- return (item[column.key] ? item[column.key] : '-').toString();
6717
- });
6718
- });
6719
- };
6720
- DataTable.prototype.setFooterRow = function (collection, footerCaption) {
6721
- this.footerRow = this.columns.map(function (column, index) {
6722
- if (index === 0) {
6723
- return footerCaption.toString();
6724
- }
6725
- if (!column.total) {
6726
- return '';
6727
- }
6728
- var totalValue = collection.items.reduce(function (sum, item) {
6729
- // check if current collection item has value. If not - don't add it to the sum
6730
- return item[column.key] !== null ? sum + Number(item[column.key]) : sum;
6731
- }, null);
6732
- return (totalValue !== null && totalValue !== void 0 ? totalValue : '-').toString();
6733
- });
6734
- };
6735
- return DataTable;
6736
- }());
6737
-
6738
- var DataTableColumn = /** @class */ (function () {
6739
- function DataTableColumn(name, key, total, pipe) {
6740
- /**
6741
- * Flag that shows should the column be in the total calculation or not
6742
- */
6743
- this.total = false;
6744
- this.name = name;
6745
- this.key = key;
6746
- this.total = total;
6747
- this.pipe = pipe;
6748
- }
6749
- return DataTableColumn;
6750
- }());
6751
-
6752
6694
  exports.DepreciationLvpRateEnum = void 0;
6753
6695
  (function (DepreciationLvpRateEnum) {
6754
6696
  DepreciationLvpRateEnum[DepreciationLvpRateEnum["FIRST_YEAR"] = 0.1875] = "FIRST_YEAR";
@@ -6993,6 +6935,12 @@
6993
6935
  AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_CREATED"] = 37] = "VEHICLE_CLAIM_CREATED";
6994
6936
  })(exports.AppEventTypeEnum || (exports.AppEventTypeEnum = {}));
6995
6937
 
6938
+ exports.ExportFormatEnum = void 0;
6939
+ (function (ExportFormatEnum) {
6940
+ ExportFormatEnum["PDF"] = "PDF";
6941
+ ExportFormatEnum["XLSX"] = "XLSX";
6942
+ })(exports.ExportFormatEnum || (exports.ExportFormatEnum = {}));
6943
+
6996
6944
  exports.IconsFileEnum = void 0;
6997
6945
  (function (IconsFileEnum) {
6998
6946
  IconsFileEnum["JPG"] = "icon-image-jpg";
@@ -10782,24 +10730,13 @@
10782
10730
  var PdfService = /** @class */ (function () {
10783
10731
  function PdfService() {
10784
10732
  }
10785
- // @Todo remove 'any' type
10786
10733
  /**
10787
- * Download generated PDF file
10788
- */
10789
- PdfService.prototype.download = function (tables, title, fileName) {
10790
- var document = this.generatePdfFile(tables, title);
10791
- document.save(fileName + ".pdf");
10792
- };
10793
- /**
10794
- * @Todo rename when all DataTable dependent methods will be cleared-up
10734
+ * Export file form provided HTML tables
10795
10735
  */
10796
10736
  PdfService.prototype.exportTables = function (tables, title, fileName) {
10797
10737
  var document = this.generateFromTables(tables, title);
10798
10738
  document.save(fileName + ".pdf");
10799
10739
  };
10800
- /**
10801
- * @Todo rename when all DataTable dependent methods will be cleared-up
10802
- */
10803
10740
  PdfService.prototype.generateFromTables = function (tables, title) {
10804
10741
  var pdf = new jsPDF__default["default"]();
10805
10742
  this.setDocumentTitle(pdf, title);
@@ -10848,35 +10785,6 @@
10848
10785
  logo.src = PDF_CONFIG.logo.src;
10849
10786
  doc.addImage(logo, 'PNG', PDF_CONFIG.logo.positionX, PDF_CONFIG.logo.positionY, PDF_CONFIG.logo.width, PDF_CONFIG.logo.height);
10850
10787
  };
10851
- /**
10852
- * @Todo remove/refactor when all DataTable dependent methods will be cleared-up
10853
- * Generate PDF file from provided data
10854
- */
10855
- PdfService.prototype.generatePdfFile = function (tables, title) {
10856
- var pdf = new jsPDF__default["default"]();
10857
- // set document font params
10858
- pdf.setFontSize(PDF_CONFIG.text.fontSize)
10859
- .setFont(PDF_CONFIG.text.fontName, PDF_CONFIG.text.fontStyle, PDF_CONFIG.text.fontWeight)
10860
- .text(title, PDF_CONFIG.text.positionX, PDF_CONFIG.text.positionY);
10861
- tables.forEach(function (table) {
10862
- // coords of last table
10863
- var lastTableCoords = pdf['lastAutoTable'].finalY || PDF_CONFIG.contentCoords.marginTop;
10864
- pdf.text(table.caption, PDF_CONFIG.contentCoords.marginLeft, lastTableCoords + PDF_CONFIG.contentCoords.marginTop);
10865
- // table options
10866
- var options = {
10867
- startY: lastTableCoords + PDF_CONFIG.contentTitleCoords.marginTop,
10868
- head: [table['columns'].map(function (column) { return column.name; })],
10869
- body: table['rows'],
10870
- foot: [table['footerRow']],
10871
- footStyles: {
10872
- fillColor: PDF_CONFIG.text.fillColor,
10873
- textColor: PDF_CONFIG.text.textColor
10874
- }
10875
- };
10876
- autoTable__default["default"](pdf, options);
10877
- });
10878
- return pdf;
10879
- };
10880
10788
  return PdfService;
10881
10789
  }());
10882
10790
  PdfService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PdfService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
@@ -12829,18 +12737,17 @@
12829
12737
  var XlsxService = /** @class */ (function () {
12830
12738
  function XlsxService() {
12831
12739
  }
12832
- // @Todo remove 'any' type
12833
- /**s
12834
- * Download generated Excel file
12740
+ /**
12741
+ * Export file form provided HTML tables
12835
12742
  */
12836
- XlsxService.prototype.download = function (tables, title, fileName) {
12837
- var excelFile = this.generateFile(tables, title);
12743
+ XlsxService.prototype.exportTables = function (tables, title, fileName) {
12744
+ var excelFile = this.generateFromTables(tables, title);
12838
12745
  var data = new Blob([excelFile], {
12839
12746
  type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8'
12840
12747
  });
12841
12748
  FileSaver__namespace.saveAs(data, fileName + ".xlsx");
12842
12749
  };
12843
- XlsxService.prototype.generateFile = function (tables, title) {
12750
+ XlsxService.prototype.generateFromTables = function (tables, title) {
12844
12751
  // create new workbook
12845
12752
  var workbook = xlsx__namespace.utils.book_new();
12846
12753
  // create empty worksheet
@@ -12848,19 +12755,13 @@
12848
12755
  SheetNames: [],
12849
12756
  Sheets: {}
12850
12757
  };
12851
- var sheetData = tables.map(function (table) {
12852
- // add caption, columns, rows and footer rows
12853
- return __spreadArray(__spreadArray([
12854
- [table.caption],
12855
- table.columns.map(function (column) { return column.name; })
12856
- ], __read(table.rows)), [
12857
- table.footerRow,
12858
- ]);
12859
- });
12860
- sheetData.forEach(function (data) {
12861
- xlsx__namespace.utils.sheet_add_json(worksheet, data, { origin: -1, skipHeader: true });
12862
- // set empty row after each table
12863
- xlsx__namespace.utils.sheet_add_json(worksheet, [], { origin: -1 });
12758
+ tables.forEach(function (data) {
12759
+ // add caption for the current table
12760
+ xlsx__namespace.utils.sheet_add_aoa(worksheet, [[data.caption.innerText]], { origin: -1 });
12761
+ // add table table data to the worksheet
12762
+ xlsx__namespace.utils.sheet_add_dom(worksheet, data, { origin: -1, raw: true });
12763
+ // set empty row after current table
12764
+ xlsx__namespace.utils.sheet_add_aoa(worksheet, [], { origin: -1 });
12864
12765
  });
12865
12766
  xlsx__namespace.utils.book_append_sheet(workbook, worksheet);
12866
12767
  return xlsx__namespace.write(workbook, { bookType: 'xlsx', type: 'array' });
@@ -13134,8 +13035,6 @@
13134
13035
  exports.DEFAULT_VEHICLE_EXPENSE = DEFAULT_VEHICLE_EXPENSE;
13135
13036
  exports.DEPRECIATION_GROUPS = DEPRECIATION_GROUPS;
13136
13037
  exports.DOCUMENT_FILE_TYPES = DOCUMENT_FILE_TYPES;
13137
- exports.DataTable = DataTable;
13138
- exports.DataTableColumn = DataTableColumn;
13139
13038
  exports.Depreciation = Depreciation;
13140
13039
  exports.DepreciationCapitalProject = DepreciationCapitalProject;
13141
13040
  exports.DepreciationCapitalProjectService = DepreciationCapitalProjectService;