shareneus 1.6.3 → 1.6.5

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,12 @@ export declare function normalizeHeaderData(headerData: any): {
42
42
  email: string;
43
43
  phone: string;
44
44
  phone2: string;
45
+ taxIds: {
46
+ Label: string;
47
+ Value: string;
48
+ Print: boolean;
49
+ Primary: boolean;
50
+ }[];
45
51
  };
46
52
  };
47
53
  export declare function normalizeHeaderStyle(headerStyles: any): {
@@ -85,7 +85,8 @@ function normalizeHeaderData(headerData) {
85
85
  dlNo: (0, pdf_shared_utils_1.toStr)(organization === null || organization === void 0 ? void 0 : organization.dlNo),
86
86
  email: (0, pdf_shared_utils_1.toStr)(organization === null || organization === void 0 ? void 0 : organization.email),
87
87
  phone: (0, pdf_shared_utils_1.toStr)(organization === null || organization === void 0 ? void 0 : organization.phone),
88
- phone2: (0, pdf_shared_utils_1.toStr)(organization === null || organization === void 0 ? void 0 : organization.phone2)
88
+ phone2: (0, pdf_shared_utils_1.toStr)(organization === null || organization === void 0 ? void 0 : organization.phone2),
89
+ taxIds: normalizeTaxIds(organization === null || organization === void 0 ? void 0 : organization.taxIds)
89
90
  }
90
91
  };
91
92
  }
@@ -118,26 +119,29 @@ function resolvePageMargins(value) {
118
119
  return DEFAULT_PAGE_MARGINS;
119
120
  }
120
121
  function buildDocumentHeaderSection(PrintConfig, DocumentData = {}) {
121
- 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;
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;
122
123
  const entity = (_a = DocumentData === null || DocumentData === void 0 ? void 0 : DocumentData.Entity) !== null && _a !== void 0 ? _a : {};
124
+ console.log('DocumentData Entity', entity);
123
125
  const documentLogoDataUrl = resolveDocumentLogoDataUrl(DocumentData);
124
126
  const headerData = normalizeHeaderData((_b = PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.headerData) !== null && _b !== void 0 ? _b : {});
125
- 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) }) }));
126
- const headerStyles = normalizeHeaderStyle((_r = PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.headerStyles) !== null && _r !== void 0 ? _r : {
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);
129
+ const headerStyles = normalizeHeaderStyle((_s = PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.headerStyles) !== null && _s !== void 0 ? _s : {
127
130
  OrgNameFsize: PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.OrgNameFsize,
128
131
  OrgNameClr: PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.OrgNameClr,
129
132
  AdrsFsize: PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.AdrsFsize,
130
133
  AdrsClr: PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.AdrsClr
131
134
  });
132
- 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 : {});
135
+ const headerSettings = normalizeHeaderSettings((_u = (_t = PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.Header) !== null && _t !== void 0 ? _t : PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.Header) !== null && _u !== void 0 ? _u : {});
133
136
  if (!headerSettings.Show) {
134
137
  return [];
135
138
  }
136
- const hasOrganizationData = !!(((_u = mergedHeaderData.organization) === null || _u === void 0 ? void 0 : _u.cName) || ((_v = mergedHeaderData.organization) === null || _v === void 0 ? void 0 : _v.address1)
137
- || ((_w = mergedHeaderData.organization) === null || _w === void 0 ? void 0 : _w.address2) || ((_x = mergedHeaderData.organization) === null || _x === void 0 ? void 0 : _x.city) || ((_y = mergedHeaderData.organization) === null || _y === void 0 ? void 0 : _y.state)
138
- || ((_z = mergedHeaderData.organization) === null || _z === void 0 ? void 0 : _z.pin) || ((_0 = mergedHeaderData.organization) === null || _0 === void 0 ? void 0 : _0.gstin) || ((_1 = mergedHeaderData.organization) === null || _1 === void 0 ? void 0 : _1.email)
139
- || ((_2 = mergedHeaderData.organization) === null || _2 === void 0 ? void 0 : _2.phone) || ((_3 = mergedHeaderData.organization) === null || _3 === void 0 ? void 0 : _3.phone2) || ((_4 = mergedHeaderData.organization) === null || _4 === void 0 ? void 0 : _4.dlNo)
140
- || ((_5 = mergedHeaderData.organization) === null || _5 === void 0 ? void 0 : _5.cin) || ((_6 = mergedHeaderData.organization) === null || _6 === void 0 ? void 0 : _6.pan));
139
+ const hasPrintedTaxIds = !!buildPrintedTaxIdsText((_v = mergedHeaderData.organization) === null || _v === void 0 ? void 0 : _v.taxIds);
140
+ const hasOrganizationData = !!(((_w = mergedHeaderData.organization) === null || _w === void 0 ? void 0 : _w.cName) || ((_x = mergedHeaderData.organization) === null || _x === void 0 ? void 0 : _x.address1)
141
+ || ((_y = mergedHeaderData.organization) === null || _y === void 0 ? void 0 : _y.address2) || ((_z = mergedHeaderData.organization) === null || _z === void 0 ? void 0 : _z.city) || ((_0 = mergedHeaderData.organization) === null || _0 === void 0 ? void 0 : _0.state)
142
+ || ((_1 = mergedHeaderData.organization) === null || _1 === void 0 ? void 0 : _1.pin) || ((_2 = mergedHeaderData.organization) === null || _2 === void 0 ? void 0 : _2.gstin) || ((_3 = mergedHeaderData.organization) === null || _3 === void 0 ? void 0 : _3.email)
143
+ || ((_4 = mergedHeaderData.organization) === null || _4 === void 0 ? void 0 : _4.phone) || ((_5 = mergedHeaderData.organization) === null || _5 === void 0 ? void 0 : _5.phone2) || ((_6 = mergedHeaderData.organization) === null || _6 === void 0 ? void 0 : _6.dlNo)
144
+ || ((_7 = mergedHeaderData.organization) === null || _7 === void 0 ? void 0 : _7.cin) || ((_8 = mergedHeaderData.organization) === null || _8 === void 0 ? void 0 : _8.pan) || hasPrintedTaxIds);
141
145
  const hasLogo = !!mergedHeaderData.logoDataUrl && headerSettings.ShowLogo;
142
146
  if (!hasOrganizationData && !hasLogo) {
143
147
  return [];
@@ -294,6 +298,11 @@ function buildOrganizationStack(organization, headerStyles, alignment) {
294
298
  if (organization === null || organization === void 0 ? void 0 : organization.dlNo) {
295
299
  stack.push({ text: `DLNo: ${organization.dlNo}`, fontSize: orgAddressFontSize, color: orgAddressFontColor, lineHeight: 1.05, alignment });
296
300
  }
301
+ console.log('organization taxIds', organization === null || organization === void 0 ? void 0 : organization.taxIds);
302
+ const printedTaxIdsText = buildPrintedTaxIdsText(organization === null || organization === void 0 ? void 0 : organization.taxIds);
303
+ if (printedTaxIdsText) {
304
+ stack.push({ text: printedTaxIdsText, fontSize: orgAddressFontSize, color: orgAddressFontColor, lineHeight: 1.05, alignment });
305
+ }
297
306
  if (organization === null || organization === void 0 ? void 0 : organization.email) {
298
307
  stack.push({ text: `Email: ${organization.email}`, fontSize: orgAddressFontSize, color: orgAddressFontColor, lineHeight: 1.05, alignment });
299
308
  }
@@ -308,6 +317,51 @@ function buildOrganizationStack(organization, headerStyles, alignment) {
308
317
  }
309
318
  return stack;
310
319
  }
320
+ function normalizeTaxIds(value) {
321
+ if (!Array.isArray(value)) {
322
+ return [];
323
+ }
324
+ return value.map((taxId) => {
325
+ var _a, _b, _c, _d;
326
+ return ({
327
+ Label: (0, pdf_shared_utils_1.toStr)((_a = taxId === null || taxId === void 0 ? void 0 : taxId.Label) !== null && _a !== void 0 ? _a : taxId === null || taxId === void 0 ? void 0 : taxId.label),
328
+ Value: (0, pdf_shared_utils_1.toStr)((_b = taxId === null || taxId === void 0 ? void 0 : taxId.Value) !== null && _b !== void 0 ? _b : taxId === null || taxId === void 0 ? void 0 : taxId.value),
329
+ Print: normalizeBooleanLike((_c = taxId === null || taxId === void 0 ? void 0 : taxId.Print) !== null && _c !== void 0 ? _c : taxId === null || taxId === void 0 ? void 0 : taxId.print),
330
+ Primary: normalizeBooleanLike((_d = taxId === null || taxId === void 0 ? void 0 : taxId.Primary) !== null && _d !== void 0 ? _d : taxId === null || taxId === void 0 ? void 0 : taxId.primary)
331
+ });
332
+ });
333
+ }
334
+ function buildPrintedTaxIdsText(value) {
335
+ const taxIds = normalizeTaxIds(value);
336
+ const primary = [];
337
+ const secondary = [];
338
+ for (const taxId of taxIds) {
339
+ if (!(taxId === null || taxId === void 0 ? void 0 : taxId.Print) || !(taxId === null || taxId === void 0 ? void 0 : taxId.Value)) {
340
+ continue;
341
+ }
342
+ const text = (taxId === null || taxId === void 0 ? void 0 : taxId.Label) ? `${taxId.Label}:${taxId.Value}` : taxId.Value;
343
+ if (taxId === null || taxId === void 0 ? void 0 : taxId.Primary) {
344
+ primary.push(text);
345
+ }
346
+ else {
347
+ secondary.push(text);
348
+ }
349
+ }
350
+ return [...primary, ...secondary].join(', ');
351
+ }
352
+ function normalizeBooleanLike(value) {
353
+ if (typeof value === 'boolean') {
354
+ return value;
355
+ }
356
+ if (typeof value === 'number') {
357
+ return value !== 0;
358
+ }
359
+ if (typeof value === 'string') {
360
+ const normalized = value.trim().toLowerCase();
361
+ return normalized === 'true' || normalized === '1' || normalized === 'yes' || normalized === 'y';
362
+ }
363
+ return false;
364
+ }
311
365
  function normalizeHeaderSettings(value) {
312
366
  const Position = normalizePosition(value === null || value === void 0 ? void 0 : value.Position, DEFAULT_HEADER_POSITION);
313
367
  const LogoPosition = normalizeLogoPosition(value === null || value === void 0 ? void 0 : value.LogoPosition, DEFAULT_LOGO_POSITION);
@@ -61,6 +61,9 @@ class PrintSharedService {
61
61
  else {
62
62
  Entity.RegNo = tempEntity.Settings.Common.RegNo;
63
63
  }
64
+ if (!tr_utils_1.TrUtils.IsNull(tempEntity.Settings.Common.Tax)) {
65
+ Entity.TaxIds = tempEntity.Settings.Common.Tax.TaxIds;
66
+ }
64
67
  if (tr_utils_1.TrUtils.IsNull(tempEntity.Settings.Common.Tax.GSTType)) {
65
68
  Entity.GSTType = '';
66
69
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shareneus",
3
- "version": "1.6.03",
3
+ "version": "1.6.05",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",