shareneus 1.5.81 → 1.5.83

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.
@@ -75,7 +75,7 @@ function buildPdfDocDefinition(PDFInvoiceData = {}, PrintConfigData = {}, printC
75
75
  copyLabels.forEach((copyLabel, index) => {
76
76
  const invoiceHeaderContent = (0, pdf_header_footer_section_1.buildDocumentHeaderSection)(PrintConfig, PDFInvoiceData);
77
77
  const invoiceHeadingContent = (0, pdf_header_footer_section_1.buildDocumentHeadingSection)(PDFInvoiceData, PrintConfig, availableWidth);
78
- const invoicePartyDetailsContent = (0, pdf_party_details_section_1.buildInvoicePartyDetailsSection)(PDFInvoiceData, PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.Customer);
78
+ const invoicePartyDetailsContent = (0, pdf_party_details_section_1.buildInvoicePartyDetailsSection)(PDFInvoiceData, PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.Customer, PrintConfig);
79
79
  const invoiceTotalsAndNotesContent = (0, pdf_totals_section_1.buildInvoiceTotalsAndNotesSection)(PDFInvoiceData, availableWidth, PrintConfigData);
80
80
  const signatureContent = (0, pdf_totals_section_1.buildSignatureSection)(PrintConfig, PDFInvoiceData, availableWidth);
81
81
  const tableData = (0, pdf_table_section_1.buildInvoiceTableData)(PDFInvoiceData, PrintConfig, availableWidth);
@@ -75,7 +75,7 @@ function buildPdfDocDefinition(PDFInvoiceData = {}, PrintConfigData = {}, printC
75
75
  copyLabels.forEach((copyLabel, index) => {
76
76
  const invoiceHeaderContent = (0, pdf_header_footer_section_1.buildDocumentHeaderSection)(PrintConfig, PDFInvoiceData);
77
77
  const invoiceHeadingContent = (0, pdf_header_footer_section_1.buildDocumentHeadingSection)(PDFInvoiceData, PrintConfig, availableWidth);
78
- const invoicePartyDetailsContent = (0, pdf_party_details_section_1.buildPurchasePartyDetailsSection)(PDFInvoiceData, PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.Customer);
78
+ const invoicePartyDetailsContent = (0, pdf_party_details_section_1.buildPurchasePartyDetailsSection)(PDFInvoiceData, PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.Customer, PrintConfig);
79
79
  const invoiceTotalsAndNotesContent = (0, pdf_totals_section_1.buildInvoiceTotalsAndNotesSection)(PDFInvoiceData, availableWidth, PrintConfigData);
80
80
  const signatureContent = (0, pdf_totals_section_1.buildSignatureSection)(PrintConfig, PDFInvoiceData, availableWidth);
81
81
  const tableData = (0, pdf_table_section_1.buildInvoiceTableData)(PDFInvoiceData, PrintConfig, availableWidth);
@@ -1,4 +1,4 @@
1
- export declare function buildInvoicePartyDetailsSection(PDFInvoiceData: any, customerLayout: any): {
1
+ export declare function buildInvoicePartyDetailsSection(PDFInvoiceData: any, customerLayout: any, printConfig?: any): {
2
2
  text: string;
3
3
  margin: number[];
4
4
  }[] | {
@@ -9,7 +9,7 @@ export declare function buildInvoicePartyDetailsSection(PDFInvoiceData: any, cus
9
9
  columnGap: number;
10
10
  margin: number[];
11
11
  }[];
12
- export declare function buildSalesPartyDetailsSection(PDFInvoiceData: any, customerLayout: any): {
12
+ export declare function buildSalesPartyDetailsSection(PDFInvoiceData: any, customerLayout: any, printConfig?: any): {
13
13
  text: string;
14
14
  margin: number[];
15
15
  }[] | {
@@ -20,7 +20,7 @@ export declare function buildSalesPartyDetailsSection(PDFInvoiceData: any, custo
20
20
  columnGap: number;
21
21
  margin: number[];
22
22
  }[];
23
- export declare function buildPurchasePartyDetailsSection(PDFInvoiceData: any, customerLayout: any): {
23
+ export declare function buildPurchasePartyDetailsSection(PDFInvoiceData: any, customerLayout: any, printConfig?: any): {
24
24
  text: string;
25
25
  margin: number[];
26
26
  }[] | {
@@ -8,10 +8,10 @@ exports.buildSalesPartyDetailsSection = buildSalesPartyDetailsSection;
8
8
  exports.buildPurchasePartyDetailsSection = buildPurchasePartyDetailsSection;
9
9
  const jsbarcode_1 = __importDefault(require("jsbarcode"));
10
10
  const pdf_shared_utils_1 = require("../header-footer-section/pdf-shared.utils");
11
- function buildInvoicePartyDetailsSection(PDFInvoiceData, customerLayout) {
12
- return buildSalesPartyDetailsSection(PDFInvoiceData, customerLayout);
11
+ function buildInvoicePartyDetailsSection(PDFInvoiceData, customerLayout, printConfig = {}) {
12
+ return buildSalesPartyDetailsSection(PDFInvoiceData, customerLayout, printConfig);
13
13
  }
14
- function buildSalesPartyDetailsSection(PDFInvoiceData, customerLayout) {
14
+ function buildSalesPartyDetailsSection(PDFInvoiceData, customerLayout, printConfig = {}) {
15
15
  const transactionData = PDFInvoiceData || {};
16
16
  const billTo = resolveSalesBillToDetails(transactionData);
17
17
  const shipTo = resolveSalesShipToDetails(transactionData);
@@ -20,7 +20,7 @@ function buildSalesPartyDetailsSection(PDFInvoiceData, customerLayout) {
20
20
  const secondaryParty = useInsurance ? insurance : shipTo;
21
21
  const showBarCode = resolveShowBarCode(transactionData);
22
22
  const billToCode = resolveBillToCode(transactionData);
23
- const otherDetails = resolveOtherDetails(transactionData);
23
+ const otherDetails = resolveOtherDetails(transactionData, printConfig);
24
24
  const shouldShowSecondaryBarcode = !secondaryParty.hasData && showBarCode && !!billToCode;
25
25
  const secondaryTitle = useInsurance ? 'Insurance' : 'Ship To';
26
26
  return buildPartyDetailsSectionLayout({
@@ -34,13 +34,13 @@ function buildSalesPartyDetailsSection(PDFInvoiceData, customerLayout) {
34
34
  secondaryBarcodeCode: billToCode
35
35
  });
36
36
  }
37
- function buildPurchasePartyDetailsSection(PDFInvoiceData, customerLayout) {
37
+ function buildPurchasePartyDetailsSection(PDFInvoiceData, customerLayout, printConfig = {}) {
38
38
  const transactionData = PDFInvoiceData || {};
39
39
  const billTo = resolvePurchaseBFromDetails(transactionData);
40
40
  const shipFrom = resolvePurchaseShipFromDetails(transactionData);
41
41
  const showBarCode = resolveShowBarCode(transactionData);
42
42
  const billToCode = resolvePurchaseBillToCode(transactionData);
43
- const otherDetails = resolvePurchaseOtherDetails(transactionData);
43
+ const otherDetails = resolvePurchaseOtherDetails(transactionData, printConfig);
44
44
  const shouldShowSecondaryBarcode = !shipFrom.hasData && showBarCode && !!billToCode;
45
45
  return buildPartyDetailsSectionLayout({
46
46
  primaryTitle: 'Vendor Details',
@@ -149,9 +149,10 @@ function resolvePurchaseBFromDetails(transactionData) {
149
149
  hasData: !!(name || gstin || contactInfo.number || directPhone || hasAddress(address))
150
150
  };
151
151
  }
152
- function resolvePurchaseOtherDetails(transactionData) {
152
+ function resolvePurchaseOtherDetails(transactionData, printConfig = {}) {
153
153
  const billDate = (0, pdf_shared_utils_1.firstValue)(transactionData === null || transactionData === void 0 ? void 0 : transactionData.CrDate, transactionData === null || transactionData === void 0 ? void 0 : transactionData.InvDt, transactionData === null || transactionData === void 0 ? void 0 : transactionData.Date, transactionData === null || transactionData === void 0 ? void 0 : transactionData.CrDate);
154
154
  const billNumber = (0, pdf_shared_utils_1.firstValue)(transactionData === null || transactionData === void 0 ? void 0 : transactionData.Id, transactionData === null || transactionData === void 0 ? void 0 : transactionData.Code, transactionData === null || transactionData === void 0 ? void 0 : transactionData.InvNo, transactionData === null || transactionData === void 0 ? void 0 : transactionData.No);
155
+ const documentNumberLabel = resolveDocumentNumberLabel(printConfig, 'Bill');
155
156
  // const productName = [
156
157
  // transactionData?.Product?.Make,
157
158
  // transactionData?.Product?.Model,
@@ -174,7 +175,7 @@ function resolvePurchaseOtherDetails(transactionData) {
174
175
  // const EngNo = transactionData?.Product?.EngNo;
175
176
  // const ChassisNo = transactionData?.Product?.VIN;
176
177
  const lines = [
177
- { label: 'Bill#', value: billNumber },
178
+ { label: documentNumberLabel, value: billNumber },
178
179
  { label: 'Date', value: billDate ? formatDisplayDate(billDate) : '' },
179
180
  // { label: 'Vehicle', value: vehicleDetails },
180
181
  // { label: 'Regn. No', value: firstValue(RegnNo) },
@@ -214,10 +215,11 @@ function resolveInsuranceDetails(transactionData) {
214
215
  hasData: !!(name || gstin || hasAddress(address))
215
216
  };
216
217
  }
217
- function resolveOtherDetails(transactionData) {
218
+ function resolveOtherDetails(transactionData, printConfig = {}) {
218
219
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
219
220
  const invoiceDate = (0, pdf_shared_utils_1.firstValue)(transactionData === null || transactionData === void 0 ? void 0 : transactionData.DDate, transactionData === null || transactionData === void 0 ? void 0 : transactionData.InvDt, transactionData === null || transactionData === void 0 ? void 0 : transactionData.Date, transactionData === null || transactionData === void 0 ? void 0 : transactionData.CrDate);
220
221
  const invoiceNumber = (0, pdf_shared_utils_1.firstValue)(transactionData === null || transactionData === void 0 ? void 0 : transactionData._id, transactionData === null || transactionData === void 0 ? void 0 : transactionData.Code, transactionData === null || transactionData === void 0 ? void 0 : transactionData.InvNo, transactionData === null || transactionData === void 0 ? void 0 : transactionData.No);
222
+ const documentNumberLabel = resolveDocumentNumberLabel(printConfig, 'Invoice');
221
223
  const productName = [
222
224
  (_a = transactionData === null || transactionData === void 0 ? void 0 : transactionData.Product) === null || _a === void 0 ? void 0 : _a.Make,
223
225
  (_b = transactionData === null || transactionData === void 0 ? void 0 : transactionData.Product) === null || _b === void 0 ? void 0 : _b.Model,
@@ -232,7 +234,7 @@ function resolveOtherDetails(transactionData) {
232
234
  const EngNo = (_h = transactionData === null || transactionData === void 0 ? void 0 : transactionData.Product) === null || _h === void 0 ? void 0 : _h.EngNo;
233
235
  const ChassisNo = (_j = transactionData === null || transactionData === void 0 ? void 0 : transactionData.Product) === null || _j === void 0 ? void 0 : _j.VIN;
234
236
  const lines = [
235
- { label: 'Invoice#', value: invoiceNumber },
237
+ { label: documentNumberLabel, value: invoiceNumber },
236
238
  { label: 'Date', value: invoiceDate ? formatDisplayDate(invoiceDate) : '' },
237
239
  { label: 'Vehicle', value: vehicleDetails },
238
240
  { label: 'Regn. No', value: (0, pdf_shared_utils_1.firstValue)(RegnNo) },
@@ -413,6 +415,15 @@ function resolvePurchaseBillToCode(transactionData) {
413
415
  var _a, _b, _c, _d, _e;
414
416
  return (0, pdf_shared_utils_1.firstValue)((_a = transactionData === null || transactionData === void 0 ? void 0 : transactionData.BFrom) === null || _a === void 0 ? void 0 : _a.Code, (_b = transactionData === null || transactionData === void 0 ? void 0 : transactionData.BillTo) === null || _b === void 0 ? void 0 : _b.Code, (_c = transactionData === null || transactionData === void 0 ? void 0 : transactionData.Vendor) === null || _c === void 0 ? void 0 : _c.Code, (_d = transactionData === null || transactionData === void 0 ? void 0 : transactionData.Vnd) === null || _d === void 0 ? void 0 : _d.Code, (_e = transactionData === null || transactionData === void 0 ? void 0 : transactionData.Supplier) === null || _e === void 0 ? void 0 : _e.Code);
415
417
  }
418
+ function resolveDocumentNumberLabel(printConfig, fallbackType) {
419
+ const typeValue = (0, pdf_shared_utils_1.firstValue)(printConfig === null || printConfig === void 0 ? void 0 : printConfig.Type, fallbackType);
420
+ const normalizedType = String(typeValue !== null && typeValue !== void 0 ? typeValue : '').trim();
421
+ if (!normalizedType) {
422
+ return `${fallbackType}#`;
423
+ }
424
+ const withoutHash = normalizedType.replace(/#+$/g, '').trim();
425
+ return `${withoutHash || fallbackType}#`;
426
+ }
416
427
  function isTruthy(value) {
417
428
  if (typeof value === 'boolean') {
418
429
  return value;
@@ -16,9 +16,11 @@ function buildInvoiceTotalsAndNotesSection(invoiceData, availableWidth, PrintCon
16
16
  const notes = (0, pdf_shared_utils_1.firstValue)(normalizedInvoice === null || normalizedInvoice === void 0 ? void 0 : normalizedInvoice.Notes, normalizedInvoice === null || normalizedInvoice === void 0 ? void 0 : normalizedInvoice.Note, normalizedInvoice === null || normalizedInvoice === void 0 ? void 0 : normalizedInvoice.Remarks, normalizedInvoice === null || normalizedInvoice === void 0 ? void 0 : normalizedInvoice.Remark);
17
17
  const terms = (0, pdf_shared_utils_1.firstValue)(normalizedInvoice === null || normalizedInvoice === void 0 ? void 0 : normalizedInvoice.TermsAndConditions, normalizedInvoice === null || normalizedInvoice === void 0 ? void 0 : normalizedInvoice.TermsCondition, normalizedInvoice === null || normalizedInvoice === void 0 ? void 0 : normalizedInvoice.Terms, normalizedInvoice === null || normalizedInvoice === void 0 ? void 0 : normalizedInvoice.TC);
18
18
  const dueInfo = resolveDueInfo(normalizedInvoice, totals);
19
+ console.log('Due Info:', dueInfo);
19
20
  const qrPayload = resolveQrPayload(normalizedInvoice);
20
21
  const hasTopSection = taxSummary.hasData || bankDetails.hasData || totals.hasData;
21
22
  const hasBottomSection = !!(notes || terms || totalInWords || (showDueSection && dueInfo.hasData) || qrPayload);
23
+ console.log('hasTopSection:', hasTopSection, 'hasBottomSection:', hasBottomSection);
22
24
  if (!hasTopSection && !hasBottomSection) {
23
25
  return [];
24
26
  }
@@ -29,11 +31,7 @@ function buildInvoiceTotalsAndNotesSection(invoiceData, availableWidth, PrintCon
29
31
  margin: [0, 10, 0, 10]
30
32
  };
31
33
  const topColumns = {
32
- columns: [
33
- { width: '42%', stack: buildTaxSummaryTableStack(null, taxSummary.rows) },
34
- { width: '28%', stack: showBankDetails ? buildInfoCardStack('Bank Details', bankDetails.lines) : [{ text: '' }] },
35
- { width: '30%', stack: buildInfoCardStack(null, totals.lines, { rightAlign: true }) }
36
- ],
34
+ columns: buildTopSectionColumns(taxSummary, showBankDetails, bankDetails, totals),
37
35
  columnGap: 20,
38
36
  margin: [0, 0, 0, 8]
39
37
  };
@@ -54,6 +52,24 @@ function buildInvoiceTotalsAndNotesSection(invoiceData, availableWidth, PrintCon
54
52
  }
55
53
  return [dividerLine, bottomColumns];
56
54
  }
55
+ function buildTopSectionColumns(taxSummary, showBankDetails, bankDetails, totals) {
56
+ if (taxSummary.hasData) {
57
+ return [
58
+ { width: '42%', stack: buildTaxSummaryTableStack(null, taxSummary.rows) },
59
+ { width: '28%', stack: showBankDetails ? buildInfoCardStack('Bank Details', bankDetails.lines) : [{ text: '' }] },
60
+ { width: '30%', stack: buildInfoCardStack(null, totals.lines, { rightAlign: true }) }
61
+ ];
62
+ }
63
+ if (showBankDetails) {
64
+ return [
65
+ { width: '40%', stack: buildInfoCardStack('Bank Details', bankDetails.lines) },
66
+ { width: '60%', stack: buildInfoCardStack(null, totals.lines, { rightAlign: true }) }
67
+ ];
68
+ }
69
+ return [
70
+ { width: '*', stack: buildInfoCardStack(null, totals.lines, { rightAlign: true }) }
71
+ ];
72
+ }
57
73
  function buildPostTotalsInfoSection(data) {
58
74
  const hasQr = !!(0, pdf_shared_utils_1.firstValue)(data.qrPayload);
59
75
  const inWords = data.totalInWords || '-';
@@ -406,12 +422,14 @@ function resolveShowBankDetails(invoiceData, printConfigData = {}) {
406
422
  return isTruthy(value);
407
423
  }
408
424
  function shouldShowDueSection(printConfigData = {}) {
425
+ console.log('printCOnfigData?.Type', printConfigData === null || printConfigData === void 0 ? void 0 : printConfigData.Type);
409
426
  const type = (0, pdf_shared_utils_1.firstValue)(printConfigData === null || printConfigData === void 0 ? void 0 : printConfigData.Type);
427
+ console.log('Normalized Type:', type);
410
428
  if (!type) {
411
429
  return false;
412
430
  }
413
431
  const normalizedType = String(type).trim().toLowerCase();
414
- return normalizedType === 'invoice' || normalizedType === 'bill';
432
+ return normalizedType === 'Invoice' || normalizedType === 'Bill';
415
433
  }
416
434
  function isTruthy(value) {
417
435
  if (typeof value === 'boolean') {
@@ -500,6 +518,7 @@ function resolveDueInfo(invoiceData, totals) {
500
518
  const dueFromInvoice = (0, pdf_table_section_1.readNumericValue)(invoiceData, ['Due', 'DueAmount', 'DueAmt', 'Balance', 'BalAmt']);
501
519
  const finalTotal = parseNumber((0, pdf_shared_utils_1.firstValue)(invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.FinalTotal, invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.Total, invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.GrandTotal, invoiceData === null || invoiceData === void 0 ? void 0 : invoiceData.NetTotal));
502
520
  const due = dueFromInvoice !== 0 ? dueFromInvoice : Math.max(0, finalTotal - paid);
521
+ console.log('Due Info:', { paid, due, finalTotal });
503
522
  return {
504
523
  paid,
505
524
  due,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shareneus",
3
- "version": "1.5.81",
3
+ "version": "1.5.83",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",