shareneus 1.5.59 → 1.5.61

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.
@@ -30,7 +30,7 @@ export declare function CreateInvoicePDFService(PDFInvoiceData?: any, PrintConfi
30
30
  subject: string;
31
31
  };
32
32
  };
33
- export declare function DownloadPDFService(filename?: string, PDFInvoiceData?: any, PrintConfigData?: any, printCopies?: string[]): {
33
+ export declare function DownloadInvoicePDFService(filename?: string, PDFInvoiceData?: any, PrintConfigData?: any, printCopies?: string[]): {
34
34
  footer?: ((_currentPage: number, pageCount: number) => {
35
35
  margin: number[];
36
36
  columns: {
@@ -62,7 +62,7 @@ export declare function DownloadPDFService(filename?: string, PDFInvoiceData?: a
62
62
  subject: string;
63
63
  };
64
64
  };
65
- export declare function GetPdfDataUrl(PDFInvoiceData?: any, PrintConfigData?: any, printCopies?: string[]): {
65
+ export declare function GetInvoicePdfDataUrl(PDFInvoiceData?: any, PrintConfigData?: any, printCopies?: string[]): {
66
66
  footer?: ((_currentPage: number, pageCount: number) => {
67
67
  margin: number[];
68
68
  columns: {
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CreateInvoicePDFService = CreateInvoicePDFService;
4
- exports.DownloadPDFService = DownloadPDFService;
5
- exports.GetPdfDataUrl = GetPdfDataUrl;
4
+ exports.DownloadInvoicePDFService = DownloadInvoicePDFService;
5
+ exports.GetInvoicePdfDataUrl = GetInvoicePdfDataUrl;
6
6
  const pdf_party_details_section_1 = require("../../../shared/party-details-section/pdf-party-details.section");
7
7
  const pdf_table_section_1 = require("../../../shared/table-section/pdf-table.section");
8
8
  const pdf_totals_section_1 = require("../../../shared/totals-section/pdf-totals.section");
@@ -19,14 +19,13 @@ function CreateInvoicePDFService(PDFInvoiceData = {}, PrintConfigData = {}, prin
19
19
  // pdfMake.createPdf(dd).open();
20
20
  return dd;
21
21
  }
22
- function DownloadPDFService(filename = 'invoice.pdf', PDFInvoiceData = {}, PrintConfigData = {}, printCopies = []) {
22
+ function DownloadInvoicePDFService(filename = 'invoice.pdf', PDFInvoiceData = {}, PrintConfigData = {}, printCopies = []) {
23
23
  const dd = buildPdfDocDefinition(PDFInvoiceData, PrintConfigData, printCopies);
24
24
  // pdfMake.createPdf(dd).download(filename);
25
25
  return dd;
26
26
  }
27
- function GetPdfDataUrl(PDFInvoiceData = {}, PrintConfigData = {}, printCopies = []) {
27
+ function GetInvoicePdfDataUrl(PDFInvoiceData = {}, PrintConfigData = {}, printCopies = []) {
28
28
  const dd = buildPdfDocDefinition(PDFInvoiceData, PrintConfigData, printCopies);
29
- // const pdfDoc: any = pdfMake.createPdf(dd);
30
29
  return dd;
31
30
  // return new Promise((resolve, reject) => {
32
31
  // let settled = false;
@@ -71,7 +70,7 @@ function buildPdfDocDefinition(PDFInvoiceData = {}, PrintConfigData = {}, printC
71
70
  const availableWidth = (0, pdf_table_section_1.getAvailablePageWidth)(PAGE_SIZE, pageOrientation, pageMargins);
72
71
  const copyLabels = normalizeCopyLabels(printCopies);
73
72
  const watermark = (0, pdf_header_footer_section_1.buildWatermark)(PrintConfig);
74
- const background = (0, pdf_header_footer_section_1.buildLogoWatermarkBackground)(PrintConfig);
73
+ const background = (0, pdf_header_footer_section_1.buildLogoWatermarkBackground)(PrintConfig, PDFInvoiceData);
75
74
  const footer = (0, pdf_header_footer_section_1.buildFooter)(PrintConfig);
76
75
  const content = [];
77
76
  copyLabels.forEach((copyLabel, index) => {
@@ -127,14 +126,19 @@ function normalizeCopyLabels(printCopies = []) {
127
126
  function normalizePrintConfig(PDFInvoiceData, PrintConfigData) {
128
127
  var _a, _b;
129
128
  const config = PrintConfigData || {};
130
- const itemsHeader = Array.isArray(config === null || config === void 0 ? void 0 : config.itemsHeader) ? config.itemsHeader : [];
129
+ const itemsHeader = Array.isArray(config === null || config === void 0 ? void 0 : config.TableConfig) ? config.TableConfig : [];
131
130
  const headerData = (config === null || config === void 0 ? void 0 : config.headerData) ? config.headerData : (0, pdf_header_footer_section_1.deriveHeaderDataFromInvoice)(PDFInvoiceData);
132
131
  const pageMargins = (0, pdf_header_footer_section_1.resolvePageMargins)((_a = config === null || config === void 0 ? void 0 : config.pageMargins) !== null && _a !== void 0 ? _a : PAGE_MARGINS);
133
132
  const watermarkText = (0, pdf_shared_utils_1.toStr)(config === null || config === void 0 ? void 0 : config.watermarkText);
134
133
  const watermark = !!(config === null || config === void 0 ? void 0 : config.watermark);
135
134
  const watermarkEnabled = !!(config === null || config === void 0 ? void 0 : config.watermarkEnabled);
136
135
  const footerText = (0, pdf_shared_utils_1.toStr)(config === null || config === void 0 ? void 0 : config.footerText);
137
- const headerStyles = (0, pdf_header_footer_section_1.normalizeHeaderStyle)((_b = config === null || config === void 0 ? void 0 : config.headerStyles) !== null && _b !== void 0 ? _b : {});
136
+ const headerStyles = (0, pdf_header_footer_section_1.normalizeHeaderStyle)((_b = config === null || config === void 0 ? void 0 : config.headerStyles) !== null && _b !== void 0 ? _b : {
137
+ OrgNameFsize: config === null || config === void 0 ? void 0 : config.OrgNameFsize,
138
+ OrgNameClr: config === null || config === void 0 ? void 0 : config.OrgNameClr,
139
+ AdrsFsize: config === null || config === void 0 ? void 0 : config.AdrsFsize,
140
+ AdrsClr: config === null || config === void 0 ? void 0 : config.AdrsClr
141
+ });
138
142
  const fixedTo = normalizeFixedTo(config === null || config === void 0 ? void 0 : config.fixedTo);
139
143
  return Object.assign(Object.assign({}, config), { itemsHeader,
140
144
  headerData,
@@ -12,7 +12,6 @@ const PAGE_SIZE = 'A4';
12
12
  const PAGE_MARGINS = [20, 20, 20, 20];
13
13
  function CreateReceiptPDFService(DocumentData = {}, PrintConfigData = {}) {
14
14
  const dd = buildPdfDocDefinition(DocumentData, PrintConfigData);
15
- // pdfMake.createPdf(dd).open();
16
15
  return dd;
17
16
  }
18
17
  function DownloadReceiptPDFService(filename = 'receipt.pdf', DocumentData = {}, PrintConfigData = {}) {
@@ -62,10 +61,10 @@ function GetReceiptPdfDataUrl(DocumentData = {}, PrintConfigData = {}) {
62
61
  function buildPdfDocDefinition(DocumentData = {}, PrintConfigData = {}) {
63
62
  const PrintConfig = normalizePrintConfig(DocumentData, PrintConfigData);
64
63
  const pageOrientation = (0, pdf_header_footer_section_1.resolvePageOrientation)(PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.pageOrientation);
65
- const pageMargins = (0, pdf_header_footer_section_1.resolvePageMargins)(PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.pageMargins);
64
+ const pageMargins = (0, pdf_header_footer_section_1.resolvePageMargins)(PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.Margin);
66
65
  const availableWidth = (0, pdf_table_section_1.getAvailablePageWidth)(PAGE_SIZE, pageOrientation, pageMargins);
67
66
  const watermark = (0, pdf_header_footer_section_1.buildWatermark)(PrintConfig);
68
- const background = (0, pdf_header_footer_section_1.buildLogoWatermarkBackground)(PrintConfig);
67
+ const background = (0, pdf_header_footer_section_1.buildLogoWatermarkBackground)(PrintConfig, DocumentData);
69
68
  const footer = (0, pdf_header_footer_section_1.buildFooter)(PrintConfig);
70
69
  const invoiceHeaderContent = (0, pdf_header_footer_section_1.buildDocumentHeaderSection)(PrintConfig, DocumentData);
71
70
  const invoiceHeadingContent = (0, pdf_header_footer_section_1.buildDocumentHeadingSection)(DocumentData, PrintConfig, availableWidth);
@@ -408,7 +407,12 @@ function normalizePrintConfig(DocumentData, PrintConfigData) {
408
407
  const watermark = !!(config === null || config === void 0 ? void 0 : config.watermark);
409
408
  const watermarkEnabled = !!(config === null || config === void 0 ? void 0 : config.watermarkEnabled);
410
409
  const footerText = (0, pdf_shared_utils_1.toStr)(config === null || config === void 0 ? void 0 : config.footerText);
411
- const headerStyles = (0, pdf_header_footer_section_1.normalizeHeaderStyle)((_b = config === null || config === void 0 ? void 0 : config.headerStyles) !== null && _b !== void 0 ? _b : {});
410
+ const headerStyles = (0, pdf_header_footer_section_1.normalizeHeaderStyle)((_b = config === null || config === void 0 ? void 0 : config.headerStyles) !== null && _b !== void 0 ? _b : {
411
+ OrgNameFsize: config === null || config === void 0 ? void 0 : config.OrgNameFsize,
412
+ OrgNameClr: config === null || config === void 0 ? void 0 : config.OrgNameClr,
413
+ AdrsFsize: config === null || config === void 0 ? void 0 : config.AdrsFsize,
414
+ AdrsClr: config === null || config === void 0 ? void 0 : config.AdrsClr
415
+ });
412
416
  return Object.assign(Object.assign({}, config), { headerData,
413
417
  pageMargins,
414
418
  watermarkText,
@@ -71,14 +71,16 @@ function normalizeHeaderData(headerData) {
71
71
  };
72
72
  }
73
73
  function normalizeHeaderStyle(headerStyles) {
74
+ var _a, _b, _c, _d;
74
75
  return {
75
- orgNameFontSize: (0, pdf_shared_utils_1.readPositiveNumber)(headerStyles === null || headerStyles === void 0 ? void 0 : headerStyles.orgNameFontSize, DEFAULT_ORG_NAME_FONT_SIZE),
76
- orgNameFontColor: (0, pdf_shared_utils_1.normalizeColor)(headerStyles === null || headerStyles === void 0 ? void 0 : headerStyles.orgNameFontColor, DEFAULT_ORG_NAME_FONT_COLOR),
77
- orgAddressFontSize: (0, pdf_shared_utils_1.readPositiveNumber)(headerStyles === null || headerStyles === void 0 ? void 0 : headerStyles.orgAddressFontSize, DEFAULT_ORG_ADDRESS_FONT_SIZE),
78
- orgAddressFontColor: (0, pdf_shared_utils_1.normalizeColor)(headerStyles === null || headerStyles === void 0 ? void 0 : headerStyles.orgAddressFontColor, DEFAULT_ORG_ADDRESS_FONT_COLOR)
76
+ orgNameFontSize: (0, pdf_shared_utils_1.readPositiveNumber)((_a = headerStyles === null || headerStyles === void 0 ? void 0 : headerStyles.orgNameFontSize) !== null && _a !== void 0 ? _a : headerStyles === null || headerStyles === void 0 ? void 0 : headerStyles.OrgNameFsize, DEFAULT_ORG_NAME_FONT_SIZE),
77
+ orgNameFontColor: (0, pdf_shared_utils_1.normalizeColor)((_b = headerStyles === null || headerStyles === void 0 ? void 0 : headerStyles.orgNameFontColor) !== null && _b !== void 0 ? _b : headerStyles === null || headerStyles === void 0 ? void 0 : headerStyles.OrgNameClr, DEFAULT_ORG_NAME_FONT_COLOR),
78
+ orgAddressFontSize: (0, pdf_shared_utils_1.readPositiveNumber)((_c = headerStyles === null || headerStyles === void 0 ? void 0 : headerStyles.orgAddressFontSize) !== null && _c !== void 0 ? _c : headerStyles === null || headerStyles === void 0 ? void 0 : headerStyles.AdrsFsize, DEFAULT_ORG_ADDRESS_FONT_SIZE),
79
+ orgAddressFontColor: (0, pdf_shared_utils_1.normalizeColor)((_d = headerStyles === null || headerStyles === void 0 ? void 0 : headerStyles.orgAddressFontColor) !== null && _d !== void 0 ? _d : headerStyles === null || headerStyles === void 0 ? void 0 : headerStyles.AdrsClr, DEFAULT_ORG_ADDRESS_FONT_COLOR)
79
80
  };
80
81
  }
81
82
  function resolvePageMargins(value) {
83
+ var _a, _b, _c, _d;
82
84
  if (Array.isArray(value) && value.length === 4) {
83
85
  return [
84
86
  (0, pdf_shared_utils_1.readPositiveNumber)(value[0], DEFAULT_PAGE_MARGINS[0]),
@@ -87,6 +89,13 @@ function resolvePageMargins(value) {
87
89
  (0, pdf_shared_utils_1.readPositiveNumber)(value[3], DEFAULT_PAGE_MARGINS[3])
88
90
  ];
89
91
  }
92
+ if (value && typeof value === 'object') {
93
+ const left = (0, pdf_shared_utils_1.readPositiveNumber)((_a = value === null || value === void 0 ? void 0 : value.Left) !== null && _a !== void 0 ? _a : value === null || value === void 0 ? void 0 : value.left, DEFAULT_PAGE_MARGINS[0]);
94
+ const top = (0, pdf_shared_utils_1.readPositiveNumber)((_b = value === null || value === void 0 ? void 0 : value.Top) !== null && _b !== void 0 ? _b : value === null || value === void 0 ? void 0 : value.top, DEFAULT_PAGE_MARGINS[1]);
95
+ const right = (0, pdf_shared_utils_1.readPositiveNumber)((_c = value === null || value === void 0 ? void 0 : value.Right) !== null && _c !== void 0 ? _c : value === null || value === void 0 ? void 0 : value.right, DEFAULT_PAGE_MARGINS[2]);
96
+ const bottom = (0, pdf_shared_utils_1.readPositiveNumber)((_d = value === null || value === void 0 ? void 0 : value.Bottom) !== null && _d !== void 0 ? _d : value === null || value === void 0 ? void 0 : value.bottom, DEFAULT_PAGE_MARGINS[3]);
97
+ return [left, top, right, bottom];
98
+ }
90
99
  return DEFAULT_PAGE_MARGINS;
91
100
  }
92
101
  function buildDocumentHeaderSection(PrintConfig, DocumentData = {}) {
@@ -95,7 +104,12 @@ function buildDocumentHeaderSection(PrintConfig, DocumentData = {}) {
95
104
  const documentLogoDataUrl = resolveDocumentLogoDataUrl(DocumentData);
96
105
  const headerData = normalizeHeaderData((_b = PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.headerData) !== null && _b !== void 0 ? _b : {});
97
106
  const mergedHeaderData = normalizeHeaderData(Object.assign(Object.assign({}, headerData), { logoDataUrl: (0, pdf_shared_utils_1.firstValue)(documentLogoDataUrl, headerData === null || headerData === void 0 ? void 0 : headerData.logoDataUrl), organization: Object.assign(Object.assign({}, ((_c = headerData === null || headerData === void 0 ? void 0 : headerData.organization) !== null && _c !== void 0 ? _c : {})), { cName: (0, pdf_shared_utils_1.firstValue)(entity === null || entity === void 0 ? void 0 : entity.CName, (_d = headerData === null || headerData === void 0 ? void 0 : headerData.organization) === null || _d === void 0 ? void 0 : _d.cName), address1: (0, pdf_shared_utils_1.firstValue)(entity === null || entity === void 0 ? void 0 : entity.Adrs1, (_e = headerData === null || headerData === void 0 ? void 0 : headerData.organization) === null || _e === void 0 ? void 0 : _e.address1), address2: (0, pdf_shared_utils_1.firstValue)(entity === null || entity === void 0 ? void 0 : entity.Adrs2, (_f = headerData === null || headerData === void 0 ? void 0 : headerData.organization) === null || _f === void 0 ? void 0 : _f.address2), dlNo: (0, pdf_shared_utils_1.firstValue)(entity === null || entity === void 0 ? void 0 : entity.DLNo, entity === null || entity === void 0 ? void 0 : entity.DLNO, (_g = headerData === null || headerData === void 0 ? void 0 : headerData.organization) === null || _g === void 0 ? void 0 : _g.dlNo), gstin: (0, pdf_shared_utils_1.firstValue)(entity === null || entity === void 0 ? void 0 : entity.GSTIN, (_h = headerData === null || headerData === void 0 ? void 0 : headerData.organization) === null || _h === void 0 ? void 0 : _h.gstin), pan: (0, pdf_shared_utils_1.firstValue)(entity === null || entity === void 0 ? void 0 : entity.PAN, (_j = headerData === null || headerData === void 0 ? void 0 : headerData.organization) === null || _j === void 0 ? void 0 : _j.pan), city: (0, pdf_shared_utils_1.firstValue)(entity === null || entity === void 0 ? void 0 : entity.City, (_k = headerData === null || headerData === void 0 ? void 0 : headerData.organization) === null || _k === void 0 ? void 0 : _k.city), state: (0, pdf_shared_utils_1.firstValue)(entity === null || entity === void 0 ? void 0 : entity.State, (_l = headerData === null || headerData === void 0 ? void 0 : headerData.organization) === null || _l === void 0 ? void 0 : _l.state), pin: (0, pdf_shared_utils_1.firstValue)(entity === null || entity === void 0 ? void 0 : entity.PIN, entity === null || entity === void 0 ? void 0 : entity.Pin, (_m = headerData === null || headerData === void 0 ? void 0 : headerData.organization) === null || _m === void 0 ? void 0 : _m.pin), email: (0, pdf_shared_utils_1.firstValue)(entity === null || entity === void 0 ? void 0 : entity.Email, entity === null || entity === void 0 ? void 0 : entity.EMail, (_o = headerData === null || headerData === void 0 ? void 0 : headerData.organization) === null || _o === void 0 ? void 0 : _o.email), phone: (0, pdf_shared_utils_1.firstValue)(entity === null || entity === void 0 ? void 0 : entity.Phone, entity === null || entity === void 0 ? void 0 : entity.Ph, (_p = headerData === null || headerData === void 0 ? void 0 : headerData.organization) === null || _p === void 0 ? void 0 : _p.phone), phone2: (0, pdf_shared_utils_1.firstValue)(entity === null || entity === void 0 ? void 0 : entity.Phone2, entity === null || entity === void 0 ? void 0 : entity.Ph2, (_q = headerData === null || headerData === void 0 ? void 0 : headerData.organization) === null || _q === void 0 ? void 0 : _q.phone2) }) }));
98
- const headerStyles = normalizeHeaderStyle((_r = PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.headerStyles) !== null && _r !== void 0 ? _r : {});
107
+ const headerStyles = normalizeHeaderStyle((_r = PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.headerStyles) !== null && _r !== void 0 ? _r : {
108
+ OrgNameFsize: PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.OrgNameFsize,
109
+ OrgNameClr: PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.OrgNameClr,
110
+ AdrsFsize: PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.AdrsFsize,
111
+ AdrsClr: PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.AdrsClr
112
+ });
99
113
  const headerSettings = normalizeHeaderSettings((_t = (_s = PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.header) !== null && _s !== void 0 ? _s : PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.Header) !== null && _t !== void 0 ? _t : {});
100
114
  if (!headerSettings.show) {
101
115
  return [];
@@ -108,6 +108,7 @@ class PrintSharedService {
108
108
  Entity.Adrs1 = tempEntity.Address.A1;
109
109
  Entity.Adrs2 = tempEntity.Address.A2;
110
110
  Entity.City = tempEntity.Address.Ct;
111
+ Entity.State = tempEntity.Address.St;
111
112
  Entity.PIN = tempEntity.Address.Pin;
112
113
  let Email = this.GetEntityEmailDetails(tempEntity);
113
114
  if (!tr_utils_1.TrUtils.IsEmpty(Email)) {
@@ -7,31 +7,47 @@ const pdf_table_config_1 = require("./pdf-table.config");
7
7
  function GetTableHeader(itemsHeader) {
8
8
  const orderedHeaders = getHeadersBySequence(itemsHeader);
9
9
  const toHeaderObject = (item) => {
10
- var _a, _b, _c, _d, _e, _f;
10
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
11
+ const itemTitle = (_c = (_b = (_a = item === null || item === void 0 ? void 0 : item.title) !== null && _a !== void 0 ? _a : item === null || item === void 0 ? void 0 : item.CustTitle) !== null && _b !== void 0 ? _b : item === null || item === void 0 ? void 0 : item.Tital) !== null && _c !== void 0 ? _c : '';
12
+ const itemWidth = (_d = item === null || item === void 0 ? void 0 : item.width) !== null && _d !== void 0 ? _d : item === null || item === void 0 ? void 0 : item.Width;
13
+ const itemDbFields = (_f = (_e = item === null || item === void 0 ? void 0 : item.dbFields) !== null && _e !== void 0 ? _e : item === null || item === void 0 ? void 0 : item.DBFields) !== null && _f !== void 0 ? _f : [];
14
+ const stackSource = (_g = item === null || item === void 0 ? void 0 : item.stackFields) !== null && _g !== void 0 ? _g : item === null || item === void 0 ? void 0 : item.Stacked;
15
+ const stackTitle = (_j = (_h = stackSource === null || stackSource === void 0 ? void 0 : stackSource.title) !== null && _h !== void 0 ? _h : stackSource === null || stackSource === void 0 ? void 0 : stackSource.Tital) !== null && _j !== void 0 ? _j : null;
16
+ const stackSeq = (_k = stackSource === null || stackSource === void 0 ? void 0 : stackSource.seq) !== null && _k !== void 0 ? _k : stackSource === null || stackSource === void 0 ? void 0 : stackSource.Seq;
11
17
  return {
12
- text: (_a = item.title) !== null && _a !== void 0 ? _a : '',
13
- width: item.width,
14
- bold: (_b = item.bold) !== null && _b !== void 0 ? _b : true,
15
- dbFields: (_c = item.dbFields) !== null && _c !== void 0 ? _c : [],
16
- stackParent: (_e = (_d = item.stackFields) === null || _d === void 0 ? void 0 : _d.title) !== null && _e !== void 0 ? _e : null,
17
- stackSeq: typeof ((_f = item.stackFields) === null || _f === void 0 ? void 0 : _f.seq) === 'number' ? item.stackFields.seq : Number.MAX_SAFE_INTEGER
18
+ text: itemTitle,
19
+ width: itemWidth,
20
+ bold: (_l = item.bold) !== null && _l !== void 0 ? _l : true,
21
+ dbFields: itemDbFields,
22
+ stackParent: stackTitle,
23
+ stackSeq: typeof stackSeq === 'number' ? stackSeq : Number.MAX_SAFE_INTEGER
18
24
  };
19
25
  };
20
- const visibleHeaders = orderedHeaders.filter((item) => item.show !== false);
26
+ const visibleHeaders = orderedHeaders.filter((item) => { var _a; return ((_a = item === null || item === void 0 ? void 0 : item.show) !== null && _a !== void 0 ? _a : item === null || item === void 0 ? void 0 : item.Show) !== false; });
21
27
  const headerRow = visibleHeaders
22
- .filter((item) => !item.stackFields)
28
+ .filter((item) => { var _a; return !((_a = item === null || item === void 0 ? void 0 : item.stackFields) !== null && _a !== void 0 ? _a : item === null || item === void 0 ? void 0 : item.Stacked); })
23
29
  .map((item) => {
30
+ var _a, _b;
31
+ const parentTitle = (_b = (_a = item === null || item === void 0 ? void 0 : item.title) !== null && _a !== void 0 ? _a : item === null || item === void 0 ? void 0 : item.CustTitle) !== null && _b !== void 0 ? _b : item === null || item === void 0 ? void 0 : item.Tital;
24
32
  const stackFields = visibleHeaders
25
- .filter((stackedItem) => { var _a; return ((_a = stackedItem.stackFields) === null || _a === void 0 ? void 0 : _a.title) === item.title; })
33
+ .filter((stackedItem) => {
34
+ var _a, _b, _c, _d, _e, _f, _g;
35
+ const stackedParent = (_f = (_d = (_b = (_a = stackedItem === null || stackedItem === void 0 ? void 0 : stackedItem.stackFields) === null || _a === void 0 ? void 0 : _a.title) !== null && _b !== void 0 ? _b : (_c = stackedItem === null || stackedItem === void 0 ? void 0 : stackedItem.stackFields) === null || _c === void 0 ? void 0 : _c.Tital) !== null && _d !== void 0 ? _d : (_e = stackedItem === null || stackedItem === void 0 ? void 0 : stackedItem.Stacked) === null || _e === void 0 ? void 0 : _e.title) !== null && _f !== void 0 ? _f : (_g = stackedItem === null || stackedItem === void 0 ? void 0 : stackedItem.Stacked) === null || _g === void 0 ? void 0 : _g.Tital;
36
+ return stackedParent === parentTitle;
37
+ })
26
38
  .sort((a, b) => {
27
- var _a, _b;
28
- const aSeq = typeof ((_a = a.stackFields) === null || _a === void 0 ? void 0 : _a.seq) === 'number' ? a.stackFields.seq : Number.MAX_SAFE_INTEGER;
29
- const bSeq = typeof ((_b = b.stackFields) === null || _b === void 0 ? void 0 : _b.seq) === 'number' ? b.stackFields.seq : Number.MAX_SAFE_INTEGER;
39
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
40
+ const aSeqRaw = (_f = (_d = (_b = (_a = a === null || a === void 0 ? void 0 : a.stackFields) === null || _a === void 0 ? void 0 : _a.seq) !== null && _b !== void 0 ? _b : (_c = a === null || a === void 0 ? void 0 : a.stackFields) === null || _c === void 0 ? void 0 : _c.Seq) !== null && _d !== void 0 ? _d : (_e = a === null || a === void 0 ? void 0 : a.Stacked) === null || _e === void 0 ? void 0 : _e.seq) !== null && _f !== void 0 ? _f : (_g = a === null || a === void 0 ? void 0 : a.Stacked) === null || _g === void 0 ? void 0 : _g.Seq;
41
+ const bSeqRaw = (_o = (_l = (_j = (_h = b === null || b === void 0 ? void 0 : b.stackFields) === null || _h === void 0 ? void 0 : _h.seq) !== null && _j !== void 0 ? _j : (_k = b === null || b === void 0 ? void 0 : b.stackFields) === null || _k === void 0 ? void 0 : _k.Seq) !== null && _l !== void 0 ? _l : (_m = b === null || b === void 0 ? void 0 : b.Stacked) === null || _m === void 0 ? void 0 : _m.seq) !== null && _o !== void 0 ? _o : (_p = b === null || b === void 0 ? void 0 : b.Stacked) === null || _p === void 0 ? void 0 : _p.Seq;
42
+ const aSeq = typeof aSeqRaw === 'number' ? aSeqRaw : Number.MAX_SAFE_INTEGER;
43
+ const bSeq = typeof bSeqRaw === 'number' ? bSeqRaw : Number.MAX_SAFE_INTEGER;
30
44
  if (aSeq !== bSeq) {
31
45
  return aSeq - bSeq;
32
46
  }
33
- const aHeaderSeq = typeof a.seq === 'number' ? a.seq : Number.MAX_SAFE_INTEGER;
34
- const bHeaderSeq = typeof b.seq === 'number' ? b.seq : Number.MAX_SAFE_INTEGER;
47
+ const aHeaderSeqRaw = (_q = a === null || a === void 0 ? void 0 : a.seq) !== null && _q !== void 0 ? _q : a === null || a === void 0 ? void 0 : a.Seq;
48
+ const bHeaderSeqRaw = (_r = b === null || b === void 0 ? void 0 : b.seq) !== null && _r !== void 0 ? _r : b === null || b === void 0 ? void 0 : b.Seq;
49
+ const aHeaderSeq = typeof aHeaderSeqRaw === 'number' ? aHeaderSeqRaw : Number.MAX_SAFE_INTEGER;
50
+ const bHeaderSeq = typeof bHeaderSeqRaw === 'number' ? bHeaderSeqRaw : Number.MAX_SAFE_INTEGER;
35
51
  return aHeaderSeq - bHeaderSeq;
36
52
  })
37
53
  .map((stackedItem) => toHeaderObject(stackedItem));
@@ -44,8 +60,11 @@ function getHeadersBySequence(headers) {
44
60
  return headers
45
61
  .map((header, index) => ({ header, index }))
46
62
  .sort((a, b) => {
47
- const aSeq = typeof a.header.seq === 'number' ? a.header.seq : Number.MAX_SAFE_INTEGER;
48
- const bSeq = typeof b.header.seq === 'number' ? b.header.seq : Number.MAX_SAFE_INTEGER;
63
+ var _a, _b, _c, _d, _e, _f;
64
+ const aSeqRaw = (_b = (_a = a === null || a === void 0 ? void 0 : a.header) === null || _a === void 0 ? void 0 : _a.seq) !== null && _b !== void 0 ? _b : (_c = a === null || a === void 0 ? void 0 : a.header) === null || _c === void 0 ? void 0 : _c.Seq;
65
+ const bSeqRaw = (_e = (_d = b === null || b === void 0 ? void 0 : b.header) === null || _d === void 0 ? void 0 : _d.seq) !== null && _e !== void 0 ? _e : (_f = b === null || b === void 0 ? void 0 : b.header) === null || _f === void 0 ? void 0 : _f.Seq;
66
+ const aSeq = typeof aSeqRaw === 'number' ? aSeqRaw : Number.MAX_SAFE_INTEGER;
67
+ const bSeq = typeof bSeqRaw === 'number' ? bSeqRaw : Number.MAX_SAFE_INTEGER;
49
68
  if (aSeq !== bSeq) {
50
69
  return aSeq - bSeq;
51
70
  }
@@ -18,10 +18,10 @@ function buildDataRow(item, index, headerConfig, fixedTo = 2) {
18
18
  const serial = String(index + 1);
19
19
  return { text: serial, fontSize: pdf_table_config_1.pdfTableStyleConfig.bodyFontSize, alignment: getNumericAlignment(serial) };
20
20
  }
21
- const mainValue = formatNumericLikeValue(getFirstFieldValue(item, header.dbFields), fixedTo);
21
+ const mainValue = formatNumericLikeValue(getFirstFieldValue(item, header.dbFields), fixedTo, shouldSkipFixedTo(header));
22
22
  const stackedLines = ((_a = header.stackFields) !== null && _a !== void 0 ? _a : [])
23
23
  .map((stackField) => {
24
- const stackValue = formatNumericLikeValue(getFirstFieldValue(item, stackField.dbFields), fixedTo);
24
+ const stackValue = formatNumericLikeValue(getFirstFieldValue(item, stackField.dbFields), fixedTo, shouldSkipFixedTo(stackField));
25
25
  if (!stackValue) {
26
26
  return null;
27
27
  }
@@ -113,7 +113,10 @@ function isNumericLike(value) {
113
113
  function isLeftAlignedHeader(headerText) {
114
114
  return headerText === 'Qty' || headerText === 'Offer Qty';
115
115
  }
116
- function formatNumericLikeValue(value, fixedTo) {
116
+ function formatNumericLikeValue(value, fixedTo, skipFixedTo = false) {
117
+ if (skipFixedTo) {
118
+ return value;
119
+ }
117
120
  if (!isNumericLike(value)) {
118
121
  return value;
119
122
  }
@@ -123,3 +126,15 @@ function formatNumericLikeValue(value, fixedTo) {
123
126
  }
124
127
  return normalized.toFixed(fixedTo);
125
128
  }
129
+ function shouldSkipFixedTo(header) {
130
+ var _a;
131
+ const text = String((_a = header === null || header === void 0 ? void 0 : header.text) !== null && _a !== void 0 ? _a : '').trim().toUpperCase();
132
+ if (text === 'HSN/SAC' || text === 'BN' || text === 'BNO') {
133
+ return true;
134
+ }
135
+ const dbFields = Array.isArray(header === null || header === void 0 ? void 0 : header.dbFields) ? header.dbFields : [];
136
+ return dbFields.some((field) => {
137
+ const normalized = String(field !== null && field !== void 0 ? field : '').trim().toUpperCase();
138
+ return normalized === 'BN' || normalized === 'BNO' || normalized.endsWith('.BN');
139
+ });
140
+ }
@@ -14,7 +14,7 @@ const BORDER_WIDTH = 0.5;
14
14
  function buildInvoiceTableData(PDFInvoiceData, PrintConfig, availableWidth) {
15
15
  const items = Array.isArray(PDFInvoiceData === null || PDFInvoiceData === void 0 ? void 0 : PDFInvoiceData.Items) ? PDFInvoiceData.Items : [];
16
16
  const services = Array.isArray(PDFInvoiceData === null || PDFInvoiceData === void 0 ? void 0 : PDFInvoiceData.Ops) ? PDFInvoiceData.Ops : [];
17
- const headerConfig = (0, pdf_table_header_1.GetTableHeader)(PrintConfig.itemsHeader)[0];
17
+ const headerConfig = (0, pdf_table_header_1.GetTableHeader)(PrintConfig.TableConfig)[0];
18
18
  const renderColumns = (0, pdf_table_header_1.getRenderableColumns)(headerConfig);
19
19
  const headerRows = (0, pdf_table_header_1.buildHeaderRows)(headerConfig);
20
20
  const fixedTo = resolveFixedTo(PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.fixedTo);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shareneus",
3
- "version": "1.5.59",
3
+ "version": "1.5.61",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",