shareneus 1.6.11 → 1.6.13
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,7 +121,6 @@ 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('Building header with 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
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) }) }));
|
|
@@ -282,9 +281,7 @@ function buildOrganizationStack(organization, headerStyles, alignment) {
|
|
|
282
281
|
}
|
|
283
282
|
const hasTaxIdsConfig = Array.isArray(organization === null || organization === void 0 ? void 0 : organization.taxIds) && organization.taxIds.length > 0;
|
|
284
283
|
const printedTaxIdsText = buildPrintedTaxIdsText(organization === null || organization === void 0 ? void 0 : organization.taxIds);
|
|
285
|
-
console.log('Printed tax IDs text:', printedTaxIdsText, 'for tax IDs config:', organization === null || organization === void 0 ? void 0 : organization.taxIds);
|
|
286
284
|
if (hasTaxIdsConfig) {
|
|
287
|
-
console.log('inside printedTaxIdsText', printedTaxIdsText);
|
|
288
285
|
if (printedTaxIdsText) {
|
|
289
286
|
stack.push({ text: printedTaxIdsText, fontSize: orgAddressFontSize, color: orgAddressFontColor, lineHeight: 1.05, alignment });
|
|
290
287
|
}
|
|
@@ -338,7 +335,6 @@ function normalizeTaxIds(value) {
|
|
|
338
335
|
});
|
|
339
336
|
}
|
|
340
337
|
function buildPrintedTaxIdsText(value) {
|
|
341
|
-
console.log('Building printed tax IDs text with value:', value);
|
|
342
338
|
const taxIds = normalizeTaxIds(value);
|
|
343
339
|
const primary = [];
|
|
344
340
|
const secondary = [];
|
|
@@ -17,17 +17,19 @@ function buildSalesPartyDetailsSection(PDFInvoiceData, customerLayout, printConf
|
|
|
17
17
|
const shipTo = resolveSalesShipToDetails(transactionData);
|
|
18
18
|
const insurance = resolveInsuranceDetails(transactionData);
|
|
19
19
|
const useInsurance = !!insurance.name;
|
|
20
|
+
const shouldShowBillTo = resolvePartyVisibility(printConfig, 'ShowBillTo');
|
|
21
|
+
const shouldShowShipTo = useInsurance ? true : resolvePartyVisibility(printConfig, 'ShowShipTo');
|
|
20
22
|
const secondaryParty = useInsurance ? insurance : shipTo;
|
|
21
23
|
const showBarCode = resolveShowBarCode(transactionData, printConfig);
|
|
22
24
|
const billToCode = resolveBillToCode(transactionData);
|
|
23
25
|
const otherDetails = resolveOtherDetails(transactionData, printConfig);
|
|
24
|
-
const shouldShowSecondaryBarcode = !secondaryParty.hasData && showBarCode && !!billToCode;
|
|
26
|
+
const shouldShowSecondaryBarcode = shouldShowShipTo && !secondaryParty.hasData && showBarCode && !!billToCode;
|
|
25
27
|
const secondaryTitle = useInsurance ? 'Insurance' : 'Ship To';
|
|
26
28
|
return buildPartyDetailsSectionLayout({
|
|
27
29
|
primaryTitle: 'Bill To',
|
|
28
|
-
primaryParty: billTo,
|
|
30
|
+
primaryParty: shouldShowBillTo ? billTo : { hasData: false },
|
|
29
31
|
secondaryTitle,
|
|
30
|
-
secondaryParty,
|
|
32
|
+
secondaryParty: shouldShowShipTo ? secondaryParty : { hasData: false },
|
|
31
33
|
customerLayout,
|
|
32
34
|
otherDetails,
|
|
33
35
|
shouldShowSecondaryBarcode,
|
|
@@ -230,6 +232,8 @@ function resolveOtherDetails(transactionData, printConfig = {}) {
|
|
|
230
232
|
const RegnNo = (_g = transactionData === null || transactionData === void 0 ? void 0 : transactionData.Product) === null || _g === void 0 ? void 0 : _g.RegNo;
|
|
231
233
|
const EngNo = (_h = transactionData === null || transactionData === void 0 ? void 0 : transactionData.Product) === null || _h === void 0 ? void 0 : _h.EngNo;
|
|
232
234
|
const ChassisNo = (_j = transactionData === null || transactionData === void 0 ? void 0 : transactionData.Product) === null || _j === void 0 ? void 0 : _j.VIN;
|
|
235
|
+
const DoctorName = (0, pdf_shared_utils_1.firstValue)(transactionData === null || transactionData === void 0 ? void 0 : transactionData.Name, transactionData === null || transactionData === void 0 ? void 0 : transactionData.DoctorName);
|
|
236
|
+
const shouldShowDoctorName = documentNumberLabel === 'Sales Receipt#';
|
|
233
237
|
const lines = [
|
|
234
238
|
{ label: documentNumberLabel, value: invoiceNumber },
|
|
235
239
|
{ label: 'Date', value: invoiceDate ? formatDisplayDate(invoiceDate) : '' },
|
|
@@ -237,7 +241,8 @@ function resolveOtherDetails(transactionData, printConfig = {}) {
|
|
|
237
241
|
{ label: 'Regn. No', value: (0, pdf_shared_utils_1.firstValue)(RegnNo) },
|
|
238
242
|
{ label: 'Engine No', value: (0, pdf_shared_utils_1.firstValue)(EngNo) },
|
|
239
243
|
{ label: 'Chassis No', value: (0, pdf_shared_utils_1.firstValue)(ChassisNo) },
|
|
240
|
-
{ label: 'Milage', value: Milage }
|
|
244
|
+
{ label: 'Milage', value: Milage },
|
|
245
|
+
...(shouldShowDoctorName ? [{ label: 'Doctor Name', value: DoctorName }] : [])
|
|
241
246
|
].filter((line) => !!line.value);
|
|
242
247
|
return {
|
|
243
248
|
lines,
|
|
@@ -320,7 +325,7 @@ function buildBarcodeStack(code) {
|
|
|
320
325
|
return [
|
|
321
326
|
{
|
|
322
327
|
svg,
|
|
323
|
-
width:
|
|
328
|
+
width: 55,
|
|
324
329
|
alignment: 'center',
|
|
325
330
|
margin: [0, 0, 0, 0]
|
|
326
331
|
}
|
|
@@ -427,6 +432,12 @@ function resolveShowBarCode(transactionData, printConfig = {}) {
|
|
|
427
432
|
|| isTruthy((_b = transactionData === null || transactionData === void 0 ? void 0 : transactionData.Entity) === null || _b === void 0 ? void 0 : _b.PrCustBar)
|
|
428
433
|
|| isTruthy(transactionData === null || transactionData === void 0 ? void 0 : transactionData.PrCustBar);
|
|
429
434
|
}
|
|
435
|
+
function resolvePartyVisibility(printConfig, key) {
|
|
436
|
+
if (Object.prototype.hasOwnProperty.call(printConfig || {}, key)) {
|
|
437
|
+
return isTruthy(printConfig === null || printConfig === void 0 ? void 0 : printConfig[key]);
|
|
438
|
+
}
|
|
439
|
+
return true;
|
|
440
|
+
}
|
|
430
441
|
function resolveBillToCode(transactionData) {
|
|
431
442
|
var _a, _b, _c;
|
|
432
443
|
return (0, pdf_shared_utils_1.firstValue)((_a = transactionData === null || transactionData === void 0 ? void 0 : transactionData.BillTo) === null || _a === void 0 ? void 0 : _a.Code, (_b = transactionData === null || transactionData === void 0 ? void 0 : transactionData.Customer) === null || _b === void 0 ? void 0 : _b.Code, (_c = transactionData === null || transactionData === void 0 ? void 0 : transactionData.Cust) === null || _c === void 0 ? void 0 : _c.Code);
|
|
@@ -464,12 +475,12 @@ function textToSvgBarcode(text) {
|
|
|
464
475
|
const svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
465
476
|
(0, jsbarcode_1.default)(svgElement, text, {
|
|
466
477
|
format: "CODE128",
|
|
467
|
-
width: 0.
|
|
468
|
-
height:
|
|
478
|
+
width: 0.8,
|
|
479
|
+
height: 18,
|
|
469
480
|
margin: 0,
|
|
470
481
|
marginTop: 0,
|
|
471
482
|
displayValue: true,
|
|
472
|
-
fontSize:
|
|
483
|
+
fontSize: 6,
|
|
473
484
|
textMargin: 0,
|
|
474
485
|
fontOptions: 'bold'
|
|
475
486
|
});
|
|
@@ -9,7 +9,8 @@ function buildInvoiceTotalsAndNotesSection(invoiceData, availableWidth, PrintCon
|
|
|
9
9
|
var _a;
|
|
10
10
|
const normalizedInvoice = invoiceData || {};
|
|
11
11
|
const hideTopSection = isTruthy((_a = normalizedInvoice === null || normalizedInvoice === void 0 ? void 0 : normalizedInvoice.Settings) === null || _a === void 0 ? void 0 : _a.NoPr);
|
|
12
|
-
const
|
|
12
|
+
const shouldShowTaxSummary = resolveShowTaxSummary(normalizedInvoice, PrintConfigData);
|
|
13
|
+
const taxSummary = resolveTaxSummary(normalizedInvoice, shouldShowTaxSummary);
|
|
13
14
|
const showBankDetails = resolveShowBankDetails(normalizedInvoice, PrintConfigData);
|
|
14
15
|
const showDueSection = shouldShowDueSection(PrintConfigData);
|
|
15
16
|
const bankDetails = showBankDetails ? resolveBankDetails(normalizedInvoice) : { lines: [], hasData: false };
|
|
@@ -372,7 +373,14 @@ function buildTaxSummaryTableStack(title, rows) {
|
|
|
372
373
|
}
|
|
373
374
|
];
|
|
374
375
|
}
|
|
375
|
-
function resolveTaxSummary(invoiceData) {
|
|
376
|
+
function resolveTaxSummary(invoiceData, shouldShowTaxSummary) {
|
|
377
|
+
if (!shouldShowTaxSummary) {
|
|
378
|
+
return {
|
|
379
|
+
rows: [],
|
|
380
|
+
totalTax: 0,
|
|
381
|
+
hasData: false
|
|
382
|
+
};
|
|
383
|
+
}
|
|
376
384
|
const sourceRows = Array.isArray(invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.TaxSummary) ? invoiceData.TaxSummary : [];
|
|
377
385
|
const rows = sourceRows.map((entry) => {
|
|
378
386
|
const taxRate = (0, pdf_shared_utils_1.firstValue)(entry === null || entry === void 0 ? void 0 : entry.Tax, entry === null || entry === void 0 ? void 0 : entry.TaxRate, entry === null || entry === void 0 ? void 0 : entry.CombinedTaxPercentage, entry === null || entry === void 0 ? void 0 : entry.Perc, entry === null || entry === void 0 ? void 0 : entry.Percentage);
|
|
@@ -396,6 +404,10 @@ function resolveTaxSummary(invoiceData) {
|
|
|
396
404
|
hasData: rows.length > 0
|
|
397
405
|
};
|
|
398
406
|
}
|
|
407
|
+
function resolveShowTaxSummary(invoiceData, printConfigData = {}) {
|
|
408
|
+
const value = (0, pdf_shared_utils_1.firstValue)(printConfigData === null || printConfigData === void 0 ? void 0 : printConfigData.ShowTaxSummary, invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.ShowTaxSummary);
|
|
409
|
+
return isTruthy(value);
|
|
410
|
+
}
|
|
399
411
|
function resolveBankDetails(invoiceData) {
|
|
400
412
|
var _a, _b;
|
|
401
413
|
const bank = ((_a = invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Entity) === null || _a === void 0 ? void 0 : _a.Bank)
|