shareneus 1.6.91 → 1.6.93

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.
@@ -17,6 +17,7 @@ function buildInvoiceTableData(PDFInvoiceData, PrintConfig, availableWidth) {
17
17
  const items = Array.isArray(PDFInvoiceData === null || PDFInvoiceData === void 0 ? void 0 : PDFInvoiceData.Items) ? PDFInvoiceData.Items : [];
18
18
  const services = Array.isArray(PDFInvoiceData === null || PDFInvoiceData === void 0 ? void 0 : PDFInvoiceData.Ops) ? PDFInvoiceData.Ops : [];
19
19
  const sType = (_a = PDFInvoiceData === null || PDFInvoiceData === void 0 ? void 0 : PDFInvoiceData.SType) !== null && _a !== void 0 ? _a : '';
20
+ const showSectionSummaryRows = !resolveIsPoSPrint(PrintConfig);
20
21
  const headerConfig = (0, pdf_table_header_1.GetTableHeader)(PrintConfig.TableConfig)[0];
21
22
  const renderColumns = (0, pdf_table_header_1.getRenderableColumns)(headerConfig, sType);
22
23
  const headerRows = (0, pdf_table_header_1.buildHeaderRows)(headerConfig, sType);
@@ -29,18 +30,32 @@ function buildInvoiceTableData(PDFInvoiceData, PrintConfig, availableWidth) {
29
30
  const itemTotals = calculateSectionTotals(items);
30
31
  const serviceTotals = calculateSectionTotals(services);
31
32
  const itemSectionRows = items.length > 0
32
- ? [
33
- buildSectionLabelRow(fallbackHeaderRow.length, descriptionColumnIndex, 'Items'),
34
- ...items.map((item, index) => buildFallbackDataRow(item, index, fallbackHeaderRow, fixedTo)),
35
- buildFallbackSectionTotalRow(fallbackHeaderRow, 'Items Total', itemTotals, fixedTo)
36
- ]
33
+ ? buildSectionRows({
34
+ rows: items,
35
+ columnsOrHeaders: fallbackHeaderRow,
36
+ descriptionColumnIndex,
37
+ label: 'Items',
38
+ totalLabel: 'Items Total',
39
+ totals: itemTotals,
40
+ fixedTo,
41
+ buildRow: (item, index) => buildFallbackDataRow(item, index, fallbackHeaderRow, fixedTo),
42
+ buildTotalRow: () => buildFallbackSectionTotalRow(fallbackHeaderRow, 'Items Total', itemTotals, fixedTo),
43
+ showSectionSummaryRows
44
+ })
37
45
  : [];
38
46
  const serviceSectionRows = services.length > 0
39
- ? [
40
- buildSectionLabelRow(fallbackHeaderRow.length, descriptionColumnIndex, 'Services'),
41
- ...services.map((service, index) => buildFallbackDataRow(service, index, fallbackHeaderRow, fixedTo)),
42
- buildFallbackSectionTotalRow(fallbackHeaderRow, 'Services Total', serviceTotals, fixedTo)
43
- ]
47
+ ? buildSectionRows({
48
+ rows: services,
49
+ columnsOrHeaders: fallbackHeaderRow,
50
+ descriptionColumnIndex,
51
+ label: 'Services',
52
+ totalLabel: 'Services Total',
53
+ totals: serviceTotals,
54
+ fixedTo,
55
+ buildRow: (service, index) => buildFallbackDataRow(service, index, fallbackHeaderRow, fixedTo),
56
+ buildTotalRow: () => buildFallbackSectionTotalRow(fallbackHeaderRow, 'Services Total', serviceTotals, fixedTo),
57
+ showSectionSummaryRows
58
+ })
44
59
  : [];
45
60
  body = [
46
61
  fallbackHeaderRow,
@@ -54,18 +69,32 @@ function buildInvoiceTableData(PDFInvoiceData, PrintConfig, availableWidth) {
54
69
  const itemTotals = calculateSectionTotals(items);
55
70
  const serviceTotals = calculateSectionTotals(services);
56
71
  const itemSectionRows = items.length > 0
57
- ? [
58
- buildSectionLabelRow(renderColumns.length, descriptionColumnIndex, 'Items'),
59
- ...items.map((item, index) => (0, pdf_table_row_1.buildDataRow)(item, index, renderColumns, fixedTo)),
60
- buildSectionTotalRow(renderColumns, 'Items Total', itemTotals, fixedTo)
61
- ]
72
+ ? buildSectionRows({
73
+ rows: items,
74
+ columnsOrHeaders: renderColumns,
75
+ descriptionColumnIndex,
76
+ label: 'Items',
77
+ totalLabel: 'Items Total',
78
+ totals: itemTotals,
79
+ fixedTo,
80
+ buildRow: (item, index) => (0, pdf_table_row_1.buildDataRow)(item, index, renderColumns, fixedTo),
81
+ buildTotalRow: () => buildSectionTotalRow(renderColumns, 'Items Total', itemTotals, fixedTo),
82
+ showSectionSummaryRows
83
+ })
62
84
  : [];
63
85
  const serviceSectionRows = services.length > 0
64
- ? [
65
- buildSectionLabelRow(renderColumns.length, descriptionColumnIndex, 'Services'),
66
- ...services.map((service, index) => (0, pdf_table_row_1.buildDataRow)(service, index, renderColumns, fixedTo)),
67
- buildSectionTotalRow(renderColumns, 'Services Total', serviceTotals, fixedTo)
68
- ]
86
+ ? buildSectionRows({
87
+ rows: services,
88
+ columnsOrHeaders: renderColumns,
89
+ descriptionColumnIndex,
90
+ label: 'Services',
91
+ totalLabel: 'Services Total',
92
+ totals: serviceTotals,
93
+ fixedTo,
94
+ buildRow: (service, index) => (0, pdf_table_row_1.buildDataRow)(service, index, renderColumns, fixedTo),
95
+ buildTotalRow: () => buildSectionTotalRow(renderColumns, 'Services Total', serviceTotals, fixedTo),
96
+ showSectionSummaryRows
97
+ })
69
98
  : [];
70
99
  body = [
71
100
  ...headerRows,
@@ -329,6 +358,21 @@ function resolveFixedTo(value) {
329
358
  }
330
359
  return Math.floor(parsed);
331
360
  }
361
+ function resolveIsPoSPrint(printConfig) {
362
+ var _a;
363
+ return Boolean((_a = printConfig === null || printConfig === void 0 ? void 0 : printConfig.IsPoSPrint) !== null && _a !== void 0 ? _a : printConfig === null || printConfig === void 0 ? void 0 : printConfig.isPoSPrint);
364
+ }
365
+ function buildSectionRows({ rows, columnsOrHeaders, descriptionColumnIndex, label, buildRow, buildTotalRow, showSectionSummaryRows }) {
366
+ const sectionRows = rows.map((row, index) => buildRow(row, index));
367
+ if (!showSectionSummaryRows) {
368
+ return sectionRows;
369
+ }
370
+ return [
371
+ buildSectionLabelRow(columnsOrHeaders.length, descriptionColumnIndex, label),
372
+ ...sectionRows,
373
+ buildTotalRow()
374
+ ];
375
+ }
332
376
  function shouldNegateFallbackHeaderValue(item, headerText) {
333
377
  if (!(item === null || item === void 0 ? void 0 : item.Ret)) {
334
378
  return false;
@@ -169,9 +169,10 @@ function buildPostTotalsInfoSection(data) {
169
169
  };
170
170
  }
171
171
  function buildSignatureSection(PrintConfig, invoiceData, availableWidth) {
172
- var _a, _b, _c, _d;
172
+ var _a, _b, _c, _d, _e;
173
173
  const headerData = (0, pdf_header_footer_section_1.normalizeHeaderData)((_a = PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.headerData) !== null && _a !== void 0 ? _a : {});
174
- const companyName = (0, pdf_shared_utils_1.firstValue)((_b = headerData === null || headerData === void 0 ? void 0 : headerData.organization) === null || _b === void 0 ? void 0 : _b.cName, (_c = invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Entity) === null || _c === void 0 ? void 0 : _c.CName, (_d = invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Entity) === null || _d === void 0 ? void 0 : _d.Name, invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.CName);
174
+ const isPoSPrint = isTruthy((_b = PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.IsPoSPrint) !== null && _b !== void 0 ? _b : PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.isPoSPrint);
175
+ const companyName = (0, pdf_shared_utils_1.firstValue)((_c = headerData === null || headerData === void 0 ? void 0 : headerData.organization) === null || _c === void 0 ? void 0 : _c.cName, (_d = invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Entity) === null || _d === void 0 ? void 0 : _d.CName, (_e = invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Entity) === null || _e === void 0 ? void 0 : _e.Name, invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.CName);
175
176
  const withPass = !!((PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.withPass) || (invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.withPass) || (invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.WithPass));
176
177
  const signatureRows = [
177
178
  {
@@ -180,19 +181,21 @@ function buildSignatureSection(PrintConfig, invoiceData, availableWidth) {
180
181
  { width: '*', text: `For ${companyName || ''}`.trim(), fontSize: 9, bold: true, color: '#111827', alignment: 'right' }
181
182
  ],
182
183
  margin: [0, 8, 0, 0]
183
- },
184
- {
184
+ }
185
+ ];
186
+ if (!isPoSPrint) {
187
+ signatureRows.push({
185
188
  text: '',
186
189
  margin: [0, 10, 0, 0]
187
- },
188
- {
190
+ });
191
+ signatureRows.push({
189
192
  columns: [
190
193
  { width: '*', text: 'Customer Signature', fontSize: 9, color: '#111827', alignment: 'left' },
191
194
  { width: '*', text: 'Authorised Signatory', fontSize: 9, color: '#111827', alignment: 'right' }
192
195
  ],
193
196
  margin: [0, 0, 0, 0]
194
- }
195
- ];
197
+ });
198
+ }
196
199
  if (!withPass) {
197
200
  return signatureRows;
198
201
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shareneus",
3
- "version": "1.6.91",
3
+ "version": "1.6.93",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",