shareneus 1.7.18 → 1.7.20

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.
@@ -42,6 +42,20 @@ export declare function CreateReceiptPDFService(DocumentData?: any, PrintConfigD
42
42
  columnGap: number;
43
43
  stack?: undefined;
44
44
  width: string;
45
+ } | {
46
+ columns: ({
47
+ width: number;
48
+ image: string;
49
+ fit: number[];
50
+ margin: number[];
51
+ } | {
52
+ width: string;
53
+ marginLeft: number;
54
+ stack: any[];
55
+ })[];
56
+ columnGap: number;
57
+ stack?: undefined;
58
+ width: string;
45
59
  })[];
46
60
  columnGap: number;
47
61
  margin: number[];
@@ -290,6 +304,20 @@ export declare function DownloadReceiptPDFService(filename?: string, DocumentDat
290
304
  columnGap: number;
291
305
  stack?: undefined;
292
306
  width: string;
307
+ } | {
308
+ columns: ({
309
+ width: number;
310
+ image: string;
311
+ fit: number[];
312
+ margin: number[];
313
+ } | {
314
+ width: string;
315
+ marginLeft: number;
316
+ stack: any[];
317
+ })[];
318
+ columnGap: number;
319
+ stack?: undefined;
320
+ width: string;
293
321
  })[];
294
322
  columnGap: number;
295
323
  margin: number[];
@@ -538,6 +566,20 @@ export declare function GetReceiptPdfDataUrl(DocumentData?: any, PrintConfigData
538
566
  columnGap: number;
539
567
  stack?: undefined;
540
568
  width: string;
569
+ } | {
570
+ columns: ({
571
+ width: number;
572
+ image: string;
573
+ fit: number[];
574
+ margin: number[];
575
+ } | {
576
+ width: string;
577
+ marginLeft: number;
578
+ stack: any[];
579
+ })[];
580
+ columnGap: number;
581
+ stack?: undefined;
582
+ width: string;
541
583
  })[];
542
584
  columnGap: number;
543
585
  margin: number[];
@@ -786,6 +828,20 @@ export declare function buildPdfDocDefinition(DocumentData?: any, PrintConfigDat
786
828
  columnGap: number;
787
829
  stack?: undefined;
788
830
  width: string;
831
+ } | {
832
+ columns: ({
833
+ width: number;
834
+ image: string;
835
+ fit: number[];
836
+ margin: number[];
837
+ } | {
838
+ width: string;
839
+ marginLeft: number;
840
+ stack: any[];
841
+ })[];
842
+ columnGap: number;
843
+ stack?: undefined;
844
+ width: string;
789
845
  })[];
790
846
  columnGap: number;
791
847
  margin: number[];
@@ -77,6 +77,20 @@ export declare function buildDocumentHeaderSection(PrintConfig: any, DocumentDat
77
77
  columnGap: number;
78
78
  stack?: undefined;
79
79
  width: string;
80
+ } | {
81
+ columns: ({
82
+ width: number;
83
+ image: string;
84
+ fit: number[];
85
+ margin: number[];
86
+ } | {
87
+ width: string;
88
+ marginLeft: number;
89
+ stack: any[];
90
+ })[];
91
+ columnGap: number;
92
+ stack?: undefined;
93
+ width: string;
80
94
  })[];
81
95
  columnGap: number;
82
96
  margin: number[];
@@ -447,6 +447,7 @@ function buildHeaderContentWithLogo(logoDataUrl, hasLogo, organizationStack, log
447
447
  logoBlock,
448
448
  {
449
449
  width: '*',
450
+ marginLeft: -25,
450
451
  stack: safeOrganizationStack
451
452
  }
452
453
  ],
@@ -14,7 +14,7 @@ function buildDataRow(item, index, headerConfig, fixedTo = 2) {
14
14
  const signedTaxValue = shouldRenderNegativeTaxAmount(item, column)
15
15
  ? negateNumericLikeValue(taxValue)
16
16
  : taxValue;
17
- const renderedTaxValue = formatNumericLikeValue(signedTaxValue, fixedTo);
17
+ const renderedTaxValue = formatNumericLikeValue(signedTaxValue, fixedTo, column.taxKind === 'rate');
18
18
  return { text: renderedTaxValue, fontSize: pdf_table_config_1.pdfTableStyleConfig.bodyFontSize, color: pdf_table_config_1.pdfTableStyleConfig.bodyFontColor, alignment: getNumericAlignment(renderedTaxValue) };
19
19
  }
20
20
  const header = column.header;
@@ -208,12 +208,16 @@ function formatExpiryDateValue(value) {
208
208
  function shouldSkipFixedTo(header) {
209
209
  var _a;
210
210
  const text = String((_a = header === null || header === void 0 ? void 0 : header.text) !== null && _a !== void 0 ? _a : '').trim().toUpperCase();
211
- if (text === 'HSN/SAC' || text === 'BN' || text === 'BNO') {
211
+ if (text === 'HSN/SAC' || text === 'BN' || text === 'BNO' || text.includes('%')) {
212
212
  return true;
213
213
  }
214
214
  const dbFields = Array.isArray(header === null || header === void 0 ? void 0 : header.dbFields) ? header.dbFields : [];
215
215
  return dbFields.some((field) => {
216
216
  const normalized = String(field !== null && field !== void 0 ? field : '').trim().toUpperCase();
217
- return normalized === 'BN' || normalized === 'BNO' || normalized.endsWith('.BN');
217
+ return normalized === 'BN'
218
+ || normalized === 'BNO'
219
+ || normalized.endsWith('.BN')
220
+ || normalized.endsWith('PERC')
221
+ || normalized.endsWith('.PERC');
218
222
  });
219
223
  }
@@ -19,7 +19,10 @@ function buildInvoiceTableData(PDFInvoiceData, PrintConfig, availableWidth) {
19
19
  const sType = (_a = PDFInvoiceData === null || PDFInvoiceData === void 0 ? void 0 : PDFInvoiceData.SType) !== null && _a !== void 0 ? _a : '';
20
20
  const taxMode = resolveInvoiceTaxMode(PDFInvoiceData);
21
21
  const showSectionSummaryRows = !resolveIsPoSPrint(PrintConfig);
22
- const headerConfig = (0, pdf_table_header_1.GetTableHeader)(PrintConfig.TableConfig, taxMode)[0];
22
+ const tableConfig = normalizeTableConfig(PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.TableConfig, PDFInvoiceData);
23
+ console.log('tableConfig:', tableConfig);
24
+ console.log('ShowDiscountColumn:', PDFInvoiceData === null || PDFInvoiceData === void 0 ? void 0 : PDFInvoiceData.ShowDiscountColumn);
25
+ const headerConfig = (0, pdf_table_header_1.GetTableHeader)(tableConfig, taxMode)[0];
23
26
  const renderColumns = (0, pdf_table_header_1.getRenderableColumns)(headerConfig, sType);
24
27
  const headerRows = (0, pdf_table_header_1.buildHeaderRows)(headerConfig, sType);
25
28
  const fixedTo = resolveFixedTo(PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.fixedTo);
@@ -187,7 +190,7 @@ function buildFallbackDataRow(item, index, fallbackHeaderRow, fixedTo) {
187
190
  if (header.text === 'CGST') {
188
191
  if (header.taxKind === 'rate') {
189
192
  const value = (0, pdf_table_row_1.getFirstFieldValue)(item, ['CGSTPerc']);
190
- const renderedValue = formatNumericLikeValue(value, fixedTo);
193
+ const renderedValue = formatNumericLikeValue(value, fixedTo, true);
191
194
  return { text: renderedValue, fontSize: pdf_table_config_1.pdfTableStyleConfig.bodyFontSize, color: pdf_table_config_1.pdfTableStyleConfig.bodyFontColor, alignment: (0, pdf_table_row_1.getNumericAlignment)(renderedValue) };
192
195
  }
193
196
  else if (header.taxKind === 'amount') {
@@ -199,7 +202,7 @@ function buildFallbackDataRow(item, index, fallbackHeaderRow, fixedTo) {
199
202
  if (header.text === 'SGST') {
200
203
  if (header.taxKind === 'rate') {
201
204
  const value = (0, pdf_table_row_1.getFirstFieldValue)(item, ['SGSTPerc']);
202
- const renderedValue = formatNumericLikeValue(value, fixedTo);
205
+ const renderedValue = formatNumericLikeValue(value, fixedTo, true);
203
206
  return { text: renderedValue, fontSize: pdf_table_config_1.pdfTableStyleConfig.bodyFontSize, color: pdf_table_config_1.pdfTableStyleConfig.bodyFontColor, alignment: (0, pdf_table_row_1.getNumericAlignment)(renderedValue) };
204
207
  }
205
208
  else if (header.taxKind === 'amount') {
@@ -210,7 +213,7 @@ function buildFallbackDataRow(item, index, fallbackHeaderRow, fixedTo) {
210
213
  }
211
214
  if (header.text === 'IGST %') {
212
215
  const value = (0, pdf_table_row_1.getFirstFieldValue)(item, ['IGSTPerc']);
213
- const renderedValue = formatNumericLikeValue(value, fixedTo);
216
+ const renderedValue = formatNumericLikeValue(value, fixedTo, true);
214
217
  return { text: renderedValue, fontSize: pdf_table_config_1.pdfTableStyleConfig.bodyFontSize, color: pdf_table_config_1.pdfTableStyleConfig.bodyFontColor, alignment: (0, pdf_table_row_1.getNumericAlignment)(renderedValue) };
215
218
  }
216
219
  if (header.text === 'IGST Amt') {
@@ -222,10 +225,10 @@ function buildFallbackDataRow(item, index, fallbackHeaderRow, fixedTo) {
222
225
  const value = String(index + 1);
223
226
  return { text: value, fontSize: pdf_table_config_1.pdfTableStyleConfig.bodyFontSize, color: pdf_table_config_1.pdfTableStyleConfig.bodyFontColor, alignment: (0, pdf_table_row_1.getNumericAlignment)(value) };
224
227
  }
225
- const mainValue = formatNumericLikeValue(getDisplayValueForFallbackRow(item, header.dbFields, shouldNegateFallbackHeaderValue(item, header.text)), fixedTo);
228
+ const mainValue = formatNumericLikeValue(getDisplayValueForFallbackRow(item, header.dbFields, shouldNegateFallbackHeaderValue(item, header.text)), fixedTo, shouldSkipFixedTo(header));
226
229
  const stackedLines = ((_a = header.stackFields) !== null && _a !== void 0 ? _a : [])
227
230
  .map((stackField) => {
228
- const stackValue = formatNumericLikeValue((0, pdf_table_row_1.getFirstFieldValue)(item, stackField.dbFields), fixedTo);
231
+ const stackValue = formatNumericLikeValue((0, pdf_table_row_1.getFirstFieldValue)(item, stackField.dbFields), fixedTo, shouldSkipFixedTo(stackField));
229
232
  if (!stackValue) {
230
233
  return null;
231
234
  }
@@ -355,6 +358,26 @@ function resolveInvoiceTaxMode(pdfInvoiceData) {
355
358
  var _a, _b;
356
359
  return String((_b = (_a = pdfInvoiceData === null || pdfInvoiceData === void 0 ? void 0 : pdfInvoiceData.Settings) === null || _a === void 0 ? void 0 : _a.Tax) !== null && _b !== void 0 ? _b : '').trim().toUpperCase();
357
360
  }
361
+ function normalizeTableConfig(tableConfig, pdfInvoiceData) {
362
+ if (!Array.isArray(tableConfig) || tableConfig.length === 0) {
363
+ return Array.isArray(tableConfig) ? tableConfig : [];
364
+ }
365
+ console.log('Original Table Config:', pdfInvoiceData === null || pdfInvoiceData === void 0 ? void 0 : pdfInvoiceData.ShowDiscountColumn);
366
+ if (!(pdfInvoiceData === null || pdfInvoiceData === void 0 ? void 0 : pdfInvoiceData.ShowDiscountColumn)) {
367
+ return tableConfig;
368
+ }
369
+ return tableConfig.map((column) => {
370
+ if (!isDiscountColumnConfig(column)) {
371
+ return column;
372
+ }
373
+ return Object.assign(Object.assign({}, column), { show: true, Show: true });
374
+ });
375
+ }
376
+ function isDiscountColumnConfig(column) {
377
+ var _a, _b, _c;
378
+ const title = String((_c = (_b = (_a = column === null || column === void 0 ? void 0 : column.title) !== null && _a !== void 0 ? _a : column === null || column === void 0 ? void 0 : column.CustTitle) !== null && _b !== void 0 ? _b : column === null || column === void 0 ? void 0 : column.Tital) !== null && _c !== void 0 ? _c : '').trim();
379
+ return title === 'Disc %' || title === 'Disc Amount' || title === 'Adisc Amount';
380
+ }
358
381
  function buildSectionRows({ rows, columnsOrHeaders, descriptionColumnIndex, label, buildRow, buildTotalRow, showSectionSummaryRows }) {
359
382
  const sectionRows = rows.map((row, index) => buildRow(row, index));
360
383
  if (!showSectionSummaryRows) {
@@ -376,6 +399,22 @@ function shouldNegateFallbackHeaderValue(item, headerText) {
376
399
  || normalized === 'PRICE'
377
400
  || normalized === 'LINE TOTAL';
378
401
  }
402
+ function shouldSkipFixedTo(header) {
403
+ var _a;
404
+ const text = String((_a = header === null || header === void 0 ? void 0 : header.text) !== null && _a !== void 0 ? _a : '').trim().toUpperCase();
405
+ if (text === 'HSN/SAC' || text === 'BN' || text === 'BNO' || text.includes('%')) {
406
+ return true;
407
+ }
408
+ const dbFields = Array.isArray(header === null || header === void 0 ? void 0 : header.dbFields) ? header.dbFields : [];
409
+ return dbFields.some((field) => {
410
+ const normalized = String(field !== null && field !== void 0 ? field : '').trim().toUpperCase();
411
+ return normalized === 'BN'
412
+ || normalized === 'BNO'
413
+ || normalized.endsWith('.BN')
414
+ || normalized.endsWith('PERC')
415
+ || normalized.endsWith('.PERC');
416
+ });
417
+ }
379
418
  function getDisplayValueForFallbackRow(item, dbFields = [], shouldNegate = false) {
380
419
  const value = (0, pdf_table_row_1.getFirstFieldValue)(item, dbFields);
381
420
  if (!shouldNegate) {
@@ -387,7 +426,10 @@ function getDisplayValueForFallbackRow(item, dbFields = [], shouldNegate = false
387
426
  }
388
427
  return String(normalized === 0 ? 0 : -Math.abs(normalized));
389
428
  }
390
- function formatNumericLikeValue(value, fixedTo) {
429
+ function formatNumericLikeValue(value, fixedTo, skipFixedTo = false) {
430
+ if (skipFixedTo) {
431
+ return value;
432
+ }
391
433
  if (!value) {
392
434
  return value;
393
435
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shareneus",
3
- "version": "1.7.18",
3
+ "version": "1.7.20",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -511,6 +511,7 @@ function buildHeaderContentWithLogo(
511
511
  logoBlock,
512
512
  {
513
513
  width: '*',
514
+ marginLeft: -25,
514
515
  stack: safeOrganizationStack
515
516
  }
516
517
  ],
@@ -8,7 +8,7 @@ export function buildDataRow(item: any, index: number, headerConfig: any[], fixe
8
8
  const signedTaxValue = shouldRenderNegativeTaxAmount(item, column)
9
9
  ? negateNumericLikeValue(taxValue)
10
10
  : taxValue;
11
- const renderedTaxValue = formatNumericLikeValue(signedTaxValue, fixedTo);
11
+ const renderedTaxValue = formatNumericLikeValue(signedTaxValue, fixedTo, column.taxKind === 'rate');
12
12
  return { text: renderedTaxValue, fontSize: pdfTableStyleConfig.bodyFontSize, color: pdfTableStyleConfig.bodyFontColor, alignment: getNumericAlignment(renderedTaxValue) };
13
13
  }
14
14
 
@@ -236,13 +236,17 @@ function formatExpiryDateValue(value: string) {
236
236
 
237
237
  function shouldSkipFixedTo(header: any) {
238
238
  const text = String(header?.text ?? '').trim().toUpperCase();
239
- if (text === 'HSN/SAC' || text === 'BN' || text === 'BNO') {
239
+ if (text === 'HSN/SAC' || text === 'BN' || text === 'BNO' || text.includes('%')) {
240
240
  return true;
241
241
  }
242
242
 
243
243
  const dbFields = Array.isArray(header?.dbFields) ? header.dbFields : [];
244
244
  return dbFields.some((field: any) => {
245
245
  const normalized = String(field ?? '').trim().toUpperCase();
246
- return normalized === 'BN' || normalized === 'BNO' || normalized.endsWith('.BN');
246
+ return normalized === 'BN'
247
+ || normalized === 'BNO'
248
+ || normalized.endsWith('.BN')
249
+ || normalized.endsWith('PERC')
250
+ || normalized.endsWith('.PERC');
247
251
  });
248
252
  }
@@ -13,7 +13,10 @@ export function buildInvoiceTableData(PDFInvoiceData: any, PrintConfig: any, ava
13
13
  const sType = PDFInvoiceData?.SType ?? '';
14
14
  const taxMode = resolveInvoiceTaxMode(PDFInvoiceData);
15
15
  const showSectionSummaryRows = !resolveIsPoSPrint(PrintConfig);
16
- const headerConfig = GetTableHeader(PrintConfig.TableConfig, taxMode)[0];
16
+ const tableConfig = normalizeTableConfig(PrintConfig?.TableConfig, PDFInvoiceData);
17
+ console.log('tableConfig:', tableConfig);
18
+ console.log('ShowDiscountColumn:', PDFInvoiceData?.ShowDiscountColumn);
19
+ const headerConfig = GetTableHeader(tableConfig, taxMode)[0];
17
20
  const renderColumns = getRenderableColumns(headerConfig, sType);
18
21
  const headerRows = buildHeaderRows(headerConfig, sType);
19
22
  const fixedTo = resolveFixedTo(PrintConfig?.fixedTo);
@@ -201,7 +204,7 @@ function buildFallbackDataRow(item: any, index: number, fallbackHeaderRow: any[]
201
204
  if (header.text === 'CGST') {
202
205
  if (header.taxKind === 'rate') {
203
206
  const value = getFirstFieldValue(item, ['CGSTPerc']);
204
- const renderedValue = formatNumericLikeValue(value, fixedTo);
207
+ const renderedValue = formatNumericLikeValue(value, fixedTo, true);
205
208
  return { text: renderedValue, fontSize: pdfTableStyleConfig.bodyFontSize, color: pdfTableStyleConfig.bodyFontColor, alignment: getNumericAlignment(renderedValue) };
206
209
  } else if (header.taxKind === 'amount') {
207
210
  const value = getDisplayValueForFallbackRow(item, ['CGSTAmt'], true);
@@ -212,7 +215,7 @@ function buildFallbackDataRow(item: any, index: number, fallbackHeaderRow: any[]
212
215
  if (header.text === 'SGST') {
213
216
  if (header.taxKind === 'rate') {
214
217
  const value = getFirstFieldValue(item, ['SGSTPerc']);
215
- const renderedValue = formatNumericLikeValue(value, fixedTo);
218
+ const renderedValue = formatNumericLikeValue(value, fixedTo, true);
216
219
  return { text: renderedValue, fontSize: pdfTableStyleConfig.bodyFontSize, color: pdfTableStyleConfig.bodyFontColor, alignment: getNumericAlignment(renderedValue) };
217
220
  } else if (header.taxKind === 'amount') {
218
221
  const value = getDisplayValueForFallbackRow(item, ['SGSTAmt'], true);
@@ -222,7 +225,7 @@ function buildFallbackDataRow(item: any, index: number, fallbackHeaderRow: any[]
222
225
  }
223
226
  if (header.text === 'IGST %') {
224
227
  const value = getFirstFieldValue(item, ['IGSTPerc']);
225
- const renderedValue = formatNumericLikeValue(value, fixedTo);
228
+ const renderedValue = formatNumericLikeValue(value, fixedTo, true);
226
229
  return { text: renderedValue, fontSize: pdfTableStyleConfig.bodyFontSize, color: pdfTableStyleConfig.bodyFontColor, alignment: getNumericAlignment(renderedValue) };
227
230
  }
228
231
  if (header.text === 'IGST Amt') {
@@ -236,11 +239,12 @@ function buildFallbackDataRow(item: any, index: number, fallbackHeaderRow: any[]
236
239
  }
237
240
  const mainValue = formatNumericLikeValue(
238
241
  getDisplayValueForFallbackRow(item, header.dbFields, shouldNegateFallbackHeaderValue(item, header.text)),
239
- fixedTo
242
+ fixedTo,
243
+ shouldSkipFixedTo(header)
240
244
  );
241
245
  const stackedLines = (header.stackFields ?? [])
242
246
  .map((stackField: any) => {
243
- const stackValue = formatNumericLikeValue(getFirstFieldValue(item, stackField.dbFields), fixedTo);
247
+ const stackValue = formatNumericLikeValue(getFirstFieldValue(item, stackField.dbFields), fixedTo, shouldSkipFixedTo(stackField));
244
248
  if (!stackValue) {
245
249
  return null;
246
250
  }
@@ -379,6 +383,35 @@ function resolveInvoiceTaxMode(pdfInvoiceData: any) {
379
383
  return String(pdfInvoiceData?.Settings?.Tax ?? '').trim().toUpperCase();
380
384
  }
381
385
 
386
+ function normalizeTableConfig(tableConfig: any[], pdfInvoiceData: any) {
387
+ if (!Array.isArray(tableConfig) || tableConfig.length === 0) {
388
+ return Array.isArray(tableConfig) ? tableConfig : [];
389
+ }
390
+
391
+ console.log('Original Table Config:', pdfInvoiceData?.ShowDiscountColumn);
392
+
393
+ if (!pdfInvoiceData?.ShowDiscountColumn) {
394
+ return tableConfig;
395
+ }
396
+
397
+ return tableConfig.map((column: any) => {
398
+ if (!isDiscountColumnConfig(column)) {
399
+ return column;
400
+ }
401
+
402
+ return {
403
+ ...column,
404
+ show: true,
405
+ Show: true
406
+ };
407
+ });
408
+ }
409
+
410
+ function isDiscountColumnConfig(column: any) {
411
+ const title = String(column?.title ?? column?.CustTitle ?? column?.Tital ?? '').trim();
412
+ return title === 'Disc %' || title === 'Disc Amount' || title === 'Adisc Amount';
413
+ }
414
+
382
415
  function buildSectionRows({
383
416
  rows,
384
417
  columnsOrHeaders,
@@ -420,6 +453,23 @@ function shouldNegateFallbackHeaderValue(item: any, headerText: string) {
420
453
  || normalized === 'LINE TOTAL';
421
454
  }
422
455
 
456
+ function shouldSkipFixedTo(header: any) {
457
+ const text = String(header?.text ?? '').trim().toUpperCase();
458
+ if (text === 'HSN/SAC' || text === 'BN' || text === 'BNO' || text.includes('%')) {
459
+ return true;
460
+ }
461
+
462
+ const dbFields = Array.isArray(header?.dbFields) ? header.dbFields : [];
463
+ return dbFields.some((field: any) => {
464
+ const normalized = String(field ?? '').trim().toUpperCase();
465
+ return normalized === 'BN'
466
+ || normalized === 'BNO'
467
+ || normalized.endsWith('.BN')
468
+ || normalized.endsWith('PERC')
469
+ || normalized.endsWith('.PERC');
470
+ });
471
+ }
472
+
423
473
  function getDisplayValueForFallbackRow(item: any, dbFields: string[] = [], shouldNegate: boolean = false) {
424
474
  const value = getFirstFieldValue(item, dbFields);
425
475
  if (!shouldNegate) {
@@ -434,7 +484,10 @@ function getDisplayValueForFallbackRow(item: any, dbFields: string[] = [], shoul
434
484
  return String(normalized === 0 ? 0 : -Math.abs(normalized));
435
485
  }
436
486
 
437
- function formatNumericLikeValue(value: string, fixedTo: number) {
487
+ function formatNumericLikeValue(value: string, fixedTo: number, skipFixedTo: boolean = false) {
488
+ if (skipFixedTo) {
489
+ return value;
490
+ }
438
491
  if (!value) {
439
492
  return value;
440
493
  }