shareneus 1.6.6 → 1.6.8

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.
@@ -121,11 +121,9 @@ function resolvePageMargins(value) {
121
121
  function buildDocumentHeaderSection(PrintConfig, DocumentData = {}) {
122
122
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8;
123
123
  const entity = (_a = DocumentData === null || DocumentData === void 0 ? void 0 : DocumentData.Entity) !== null && _a !== void 0 ? _a : {};
124
- console.log('DocumentData Entity', entity);
125
124
  const documentLogoDataUrl = resolveDocumentLogoDataUrl(DocumentData);
126
125
  const headerData = normalizeHeaderData((_b = PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.headerData) !== null && _b !== void 0 ? _b : {});
127
- 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), taxIds: (0, pdf_shared_utils_1.firstValue)(entity === null || entity === void 0 ? void 0 : entity.TaxIds, (_k = headerData === null || headerData === void 0 ? void 0 : headerData.organization) === null || _k === void 0 ? void 0 : _k.taxIds), city: (0, pdf_shared_utils_1.firstValue)(entity === null || entity === void 0 ? void 0 : entity.City, (_l = headerData === null || headerData === void 0 ? void 0 : headerData.organization) === null || _l === void 0 ? void 0 : _l.city), state: (0, pdf_shared_utils_1.firstValue)(entity === null || entity === void 0 ? void 0 : entity.State, (_m = headerData === null || headerData === void 0 ? void 0 : headerData.organization) === null || _m === void 0 ? void 0 : _m.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, (_o = headerData === null || headerData === void 0 ? void 0 : headerData.organization) === null || _o === void 0 ? void 0 : _o.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, (_p = headerData === null || headerData === void 0 ? void 0 : headerData.organization) === null || _p === void 0 ? void 0 : _p.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, (_q = headerData === null || headerData === void 0 ? void 0 : headerData.organization) === null || _q === void 0 ? void 0 : _q.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, (_r = headerData === null || headerData === void 0 ? void 0 : headerData.organization) === null || _r === void 0 ? void 0 : _r.phone2) }) }));
128
- console.log('Merged Header Data', mergedHeaderData);
126
+ 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), taxIds: Array.isArray(entity === null || entity === void 0 ? void 0 : entity.TaxIds) ? entity.TaxIds : (_k = headerData === null || headerData === void 0 ? void 0 : headerData.organization) === null || _k === void 0 ? void 0 : _k.taxIds, city: (0, pdf_shared_utils_1.firstValue)(entity === null || entity === void 0 ? void 0 : entity.City, (_l = headerData === null || headerData === void 0 ? void 0 : headerData.organization) === null || _l === void 0 ? void 0 : _l.city), state: (0, pdf_shared_utils_1.firstValue)(entity === null || entity === void 0 ? void 0 : entity.State, (_m = headerData === null || headerData === void 0 ? void 0 : headerData.organization) === null || _m === void 0 ? void 0 : _m.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, (_o = headerData === null || headerData === void 0 ? void 0 : headerData.organization) === null || _o === void 0 ? void 0 : _o.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, (_p = headerData === null || headerData === void 0 ? void 0 : headerData.organization) === null || _p === void 0 ? void 0 : _p.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, (_q = headerData === null || headerData === void 0 ? void 0 : headerData.organization) === null || _q === void 0 ? void 0 : _q.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, (_r = headerData === null || headerData === void 0 ? void 0 : headerData.organization) === null || _r === void 0 ? void 0 : _r.phone2) }) }));
129
127
  const headerStyles = normalizeHeaderStyle((_s = PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.headerStyles) !== null && _s !== void 0 ? _s : {
130
128
  OrgNameFsize: PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.OrgNameFsize,
131
129
  OrgNameClr: PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.OrgNameClr,
@@ -147,7 +145,8 @@ function buildDocumentHeaderSection(PrintConfig, DocumentData = {}) {
147
145
  return [];
148
146
  }
149
147
  const textAlignment = toPdfAlignment(headerSettings.Position);
150
- const organizationStack = buildOrganizationStack(mergedHeaderData.organization, headerStyles, textAlignment);
148
+ const builtOrganizationStack = buildOrganizationStack(mergedHeaderData.organization, headerStyles, textAlignment);
149
+ const organizationStack = Array.isArray(builtOrganizationStack) ? builtOrganizationStack : [{ text: (0, pdf_shared_utils_1.toStr)(builtOrganizationStack) }];
151
150
  const headerContent = buildHeaderContentWithLogo(mergedHeaderData.logoDataUrl, hasLogo, organizationStack, headerSettings.LogoPosition, textAlignment);
152
151
  return [{
153
152
  columns: [
@@ -280,29 +279,34 @@ function buildOrganizationStack(organization, headerStyles, alignment) {
280
279
  if (cityStatePin) {
281
280
  stack.push({ text: cityStatePin, fontSize: orgAddressFontSize, color: orgAddressFontColor, lineHeight: 1.05, alignment });
282
281
  }
283
- if (organization === null || organization === void 0 ? void 0 : organization.gstin) {
284
- stack.push({ text: `GSTIN: ${organization.gstin}`, fontSize: orgAddressFontSize, color: orgAddressFontColor, lineHeight: 1.05, alignment });
285
- }
286
- if (organization === null || organization === void 0 ? void 0 : organization.gst) {
287
- stack.push({ text: `GST: ${organization.gst}`, fontSize: orgAddressFontSize, color: orgAddressFontColor, lineHeight: 1.05, alignment });
288
- }
289
- if (organization === null || organization === void 0 ? void 0 : organization.cst) {
290
- stack.push({ text: `CST: ${organization.cst}`, fontSize: orgAddressFontSize, color: orgAddressFontColor, lineHeight: 1.05, alignment });
291
- }
292
- if (organization === null || organization === void 0 ? void 0 : organization.cin) {
293
- stack.push({ text: `CIN: ${organization.cin}`, fontSize: orgAddressFontSize, color: orgAddressFontColor, lineHeight: 1.05, alignment });
282
+ const hasTaxIdsConfig = Array.isArray(organization === null || organization === void 0 ? void 0 : organization.taxIds) && organization.taxIds.length > 0;
283
+ const printedTaxIdsText = buildPrintedTaxIdsText(organization === null || organization === void 0 ? void 0 : organization.taxIds);
284
+ if (hasTaxIdsConfig) {
285
+ console.log('printedTaxIdsText:', printedTaxIdsText);
286
+ if (printedTaxIdsText) {
287
+ stack.push({ text: printedTaxIdsText, fontSize: orgAddressFontSize, color: orgAddressFontColor, lineHeight: 1.05, alignment });
288
+ }
294
289
  }
295
- if (organization === null || organization === void 0 ? void 0 : organization.pan) {
296
- stack.push({ text: `PAN: ${organization.pan}`, fontSize: orgAddressFontSize, color: orgAddressFontColor, lineHeight: 1.05, alignment });
290
+ else {
291
+ if (organization === null || organization === void 0 ? void 0 : organization.gstin) {
292
+ stack.push({ text: `GSTIN: ${organization.gstin}`, fontSize: orgAddressFontSize, color: orgAddressFontColor, lineHeight: 1.05, alignment });
293
+ }
294
+ if (organization === null || organization === void 0 ? void 0 : organization.gst) {
295
+ stack.push({ text: `GST: ${organization.gst}`, fontSize: orgAddressFontSize, color: orgAddressFontColor, lineHeight: 1.05, alignment });
296
+ }
297
+ if (organization === null || organization === void 0 ? void 0 : organization.cst) {
298
+ stack.push({ text: `CST: ${organization.cst}`, fontSize: orgAddressFontSize, color: orgAddressFontColor, lineHeight: 1.05, alignment });
299
+ }
300
+ if (organization === null || organization === void 0 ? void 0 : organization.cin) {
301
+ stack.push({ text: `CIN: ${organization.cin}`, fontSize: orgAddressFontSize, color: orgAddressFontColor, lineHeight: 1.05, alignment });
302
+ }
303
+ if (organization === null || organization === void 0 ? void 0 : organization.pan) {
304
+ stack.push({ text: `PAN: ${organization.pan}`, fontSize: orgAddressFontSize, color: orgAddressFontColor, lineHeight: 1.05, alignment });
305
+ }
297
306
  }
298
307
  if (organization === null || organization === void 0 ? void 0 : organization.dlNo) {
299
308
  stack.push({ text: `DLNo: ${organization.dlNo}`, fontSize: orgAddressFontSize, color: orgAddressFontColor, lineHeight: 1.05, alignment });
300
309
  }
301
- console.log('organization taxIds', organization === null || organization === void 0 ? void 0 : organization.taxIds);
302
- // const printedTaxIdsText = buildPrintedTaxIdsText(organization?.taxIds);
303
- // if (printedTaxIdsText) {
304
- // stack.push({ text: printedTaxIdsText, fontSize: orgAddressFontSize, color: orgAddressFontColor, lineHeight: 1.05, alignment });
305
- // }
306
310
  if (organization === null || organization === void 0 ? void 0 : organization.email) {
307
311
  stack.push({ text: `Email: ${organization.email}`, fontSize: orgAddressFontSize, color: orgAddressFontColor, lineHeight: 1.05, alignment });
308
312
  }
@@ -408,8 +412,9 @@ function toPdfAlignment(position) {
408
412
  return 'left';
409
413
  }
410
414
  function buildHeaderContentWithLogo(logoDataUrl, hasLogo, organizationStack, logoPosition, textAlignment) {
415
+ const safeOrganizationStack = Array.isArray(organizationStack) ? organizationStack : [{ text: (0, pdf_shared_utils_1.toStr)(organizationStack) }];
411
416
  if (!hasLogo || !logoDataUrl) {
412
- return { stack: organizationStack };
417
+ return { stack: safeOrganizationStack };
413
418
  }
414
419
  const logoBlock = {
415
420
  width: 80,
@@ -421,7 +426,7 @@ function buildHeaderContentWithLogo(logoDataUrl, hasLogo, organizationStack, log
421
426
  return {
422
427
  stack: [
423
428
  { image: logoDataUrl, fit: [72, 72], alignment: textAlignment, margin: [0, 2, 0, 6] },
424
- ...organizationStack
429
+ ...safeOrganizationStack
425
430
  ]
426
431
  };
427
432
  }
@@ -430,7 +435,7 @@ function buildHeaderContentWithLogo(logoDataUrl, hasLogo, organizationStack, log
430
435
  columns: [
431
436
  {
432
437
  width: '*',
433
- stack: organizationStack
438
+ stack: safeOrganizationStack
434
439
  },
435
440
  Object.assign(Object.assign({}, logoBlock), { margin: [6, 2, 0, 0] })
436
441
  ],
@@ -442,7 +447,7 @@ function buildHeaderContentWithLogo(logoDataUrl, hasLogo, organizationStack, log
442
447
  logoBlock,
443
448
  {
444
449
  width: '*',
445
- stack: organizationStack
450
+ stack: safeOrganizationStack
446
451
  }
447
452
  ],
448
453
  columnGap: 8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shareneus",
3
- "version": "1.6.06",
3
+ "version": "1.6.08",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",