taxtank-core 2.1.63 → 2.1.64

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.
@@ -1768,6 +1768,18 @@ class AllocationGroup extends AbstractModel {
1768
1768
  get isAutoAllocated() {
1769
1769
  return this.allocations.first?.isAutoAllocated;
1770
1770
  }
1771
+ get operationLabel() {
1772
+ switch (this.operation) {
1773
+ case TransactionOperationEnum.ALLOCATE:
1774
+ return 'Allocate';
1775
+ case TransactionOperationEnum.ALLOCATE_INVOICE:
1776
+ return 'Match Invoice';
1777
+ case TransactionOperationEnum.FIND_AND_MATCH:
1778
+ return 'Find and Match';
1779
+ case TransactionOperationEnum.TRANSFER:
1780
+ return 'Transfer';
1781
+ }
1782
+ }
1771
1783
  }
1772
1784
 
1773
1785
  /**
@@ -2391,12 +2403,6 @@ class ExportableCollection extends Collection {
2391
2403
  }
2392
2404
  }
2393
2405
 
2394
- /**
2395
- * export table column
2396
- */
2397
- class ExportCell {
2398
- }
2399
-
2400
2406
  /**
2401
2407
  * type of export table column value
2402
2408
  */
@@ -2408,6 +2414,15 @@ var ExportCellTypeEnum;
2408
2414
  ExportCellTypeEnum[ExportCellTypeEnum["PERCENT"] = 3] = "PERCENT";
2409
2415
  })(ExportCellTypeEnum || (ExportCellTypeEnum = {}));
2410
2416
 
2417
+ /**
2418
+ * export table column
2419
+ */
2420
+ class ExportCell {
2421
+ constructor() {
2422
+ this.type = ExportCellTypeEnum.STRING;
2423
+ }
2424
+ }
2425
+
2411
2426
  class LoanPaymentCollection extends ExportableCollection {
2412
2427
  getExportHeader() {
2413
2428
  return [
@@ -9938,12 +9953,40 @@ class DocumentFolderCollection extends Collection {
9938
9953
  }
9939
9954
  }
9940
9955
 
9941
- class AllocationGroupCollection extends Collection {
9956
+ class AllocationGroupCollection extends ExportableCollection {
9942
9957
  constructor(items) {
9943
9958
  super(items);
9944
9959
  // @TODO Alex: could be useful for other collections, move to base class
9945
9960
  this.sortBy('date');
9946
9961
  }
9962
+ getExportHeader() {
9963
+ const header = ['Type', 'Date', 'Description', 'Category', 'Amount', 'Currency'];
9964
+ if (this.first?.exchangeRate) {
9965
+ header.push('Conversion Rate', 'Amount AUD');
9966
+ }
9967
+ return header;
9968
+ }
9969
+ getExportFooter() {
9970
+ return [
9971
+ plainToClass(ExportCell, { value: '', type: ExportCellTypeEnum.STRING }),
9972
+ ];
9973
+ }
9974
+ getExportBody() {
9975
+ return this.items.map((group) => {
9976
+ const cell = [
9977
+ plainToClass(ExportCell, { value: group.operationLabel }),
9978
+ plainToClass(ExportCell, { value: group.date, type: ExportCellTypeEnum.DATE }),
9979
+ plainToClass(ExportCell, { value: group.description }),
9980
+ plainToClass(ExportCell, { value: group.category }),
9981
+ plainToClass(ExportCell, { value: group.allocations.sumBy('amount'), type: ExportCellTypeEnum.CURRENCY }),
9982
+ plainToClass(ExportCell, { value: group.bankTransactions.first.currency }),
9983
+ ];
9984
+ if (this.first?.exchangeRate) {
9985
+ cell.push(plainToClass(ExportCell, { value: group.exchangeRate }), plainToClass(ExportCell, { value: group.amount, type: ExportCellTypeEnum.CURRENCY }));
9986
+ }
9987
+ return cell;
9988
+ });
9989
+ }
9947
9990
  }
9948
9991
 
9949
9992
  class AllocationRuleCollection extends Collection {
@@ -22531,24 +22574,19 @@ class XlsxService {
22531
22574
  */
22532
22575
  exportArrayToExcel(exportableCollection, name, params) {
22533
22576
  const workbook = xlsx.utils.book_new();
22534
- // create empty worksheet
22535
- const worksheet = {
22536
- SheetNames: [],
22537
- Sheets: {}
22538
- };
22539
22577
  const exportData = exportableCollection.export(params);
22540
- const exportAoa = exportableCollection.getBodyAoa(exportData);
22541
22578
  const { sheetName, fileName } = this.getFileName(name);
22542
- xlsx.utils.sheet_add_aoa(worksheet, [exportData.header], { origin: -1 });
22543
- // add table table data to the worksheet
22544
- xlsx.utils.sheet_add_aoa(worksheet, exportAoa, { origin: -1 });
22545
- // set empty row after current table
22546
- xlsx.utils.sheet_add_aoa(worksheet, [], { origin: -1 });
22547
- xlsx.utils.book_append_sheet(workbook, worksheet);
22548
- const excelFile = xlsx.write(workbook, { bookType: 'xlsx', type: 'array', compression: true });
22549
- const data = new Blob([excelFile], {
22550
- type: EXCEL_TYPE
22579
+ const worksheet = xlsx.utils.aoa_to_sheet([
22580
+ exportData.header,
22581
+ ...exportableCollection.getBodyAoa(exportData)
22582
+ ]);
22583
+ xlsx.utils.book_append_sheet(workbook, worksheet, sheetName);
22584
+ const excelFile = xlsx.write(workbook, {
22585
+ bookType: 'xlsx',
22586
+ type: 'array',
22587
+ compression: true
22551
22588
  });
22589
+ const data = new Blob([excelFile], { type: EXCEL_TYPE });
22552
22590
  FileSaver.saveAs(data, `${fileName}.xlsx`);
22553
22591
  }
22554
22592
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: XlsxService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }