shareneus 1.7.4 → 1.7.6
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.
- package/README.md +1 -0
- package/dist/accounting/invoice/invoice-pdf/invoice-pdf.service.js +18 -45
- package/dist/accounting/invoice/reports/excel/analysis-excel.service.js +17 -7
- package/dist/accounting/invoice/reports/excel/category-wise-item-excel.service.js +17 -7
- package/dist/accounting/invoice/reports/excel/cust-wise-sales-details.js +17 -7
- package/dist/accounting/invoice/reports/excel/cust-wise-sales-summary-excel.service.js +17 -7
- package/dist/accounting/invoice/reports/excel/invoice-wise-excel.service.js +17 -7
- package/dist/accounting/invoice/reports/excel/item-wise-doctor-sale-excel.service.js +17 -7
- package/dist/accounting/invoice/reports/excel/items-wise-sales-excel.service.js +17 -7
- package/dist/accounting/invoice/reports/excel/manf-wise-sales-excel.service.js +17 -7
- package/dist/accounting/invoice/reports/excel/operator-wise-details.js +17 -7
- package/dist/accounting/invoice/reports/excel/operator-wise-summary.js +17 -7
- package/dist/accounting/invoice/reports/excel/sa-wise-labor-sales-excel.service.js +17 -7
- package/dist/accounting/invoice/reports/excel/sa-wise-part-sales-excel.service.js +17 -7
- package/dist/accounting/invoice/reports/excel/sale-summary-excel.service.js +17 -7
- package/dist/accounting/invoice/reports/excel/sales-by-service-summary-excel.service.js +17 -7
- package/dist/accounting/invoice/reports/excel/scheduled-drug-summary-excel.service.js +17 -7
- package/dist/accounting/invoice/reports/excel/scheduled-drugs-excel.service.js +17 -7
- package/dist/accounting/invoice/unified-invoice-pdf.service.d.ts +1 -1
- package/dist/accounting/payment-receive/reports/excel/cust-balance-excel.service.js +17 -7
- package/dist/accounting/payment-receive/reports/excel/payment-receive-excel.service.js +17 -7
- package/dist/common/reports/excel/product-without-owner-excel.service.js +17 -7
- package/dist/gst/excel/GSTR-RO-excel.service.js +17 -7
- package/dist/gst/excel/GSTR1-excel.service.js +17 -7
- package/dist/gst/excel/GSTR2-excel.service.js +17 -7
- package/dist/gst/excel/hsn-summary.js +17 -7
- package/dist/gst/excel/tally-sales-import.service.js +17 -7
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -6
- package/dist/inventory/items/reports/excel/expiring-drugs-excel.service.js +17 -7
- package/dist/inventory/items/reports/excel/item-wise-mout-details.js +17 -7
- package/dist/inventory/items/reports/excel/item-wise-mout-summary.js +17 -7
- package/dist/inventory/items/reports/excel/spares-issue-excel.service.js +17 -7
- package/dist/inventory/items/reports/excel/stock-excel.service.js +17 -7
- package/dist/purchases/payment-made/reports/excel/payments-made-excel.service.js +17 -7
- package/dist/purchases/payment-made/reports/excel/ven-balance-excel.service.js +17 -7
- package/dist/services/reports/excel/insurance-expire-excel.service.js +17 -7
- package/dist/services/reports/excel/next-service-date-excel.service.js +17 -7
- package/dist/services/reports/excel/repair-orders-excel.service.js +17 -7
- package/dist/shared/table-section/pdf-table.header.d.ts +1 -1
- package/dist/shared/table-section/pdf-table.header.js +14 -2
- package/dist/shared/table-section/pdf-table.section.js +6 -13
- package/dist/{accounting/invoice/invoice-pdf.service.js → shared/transactions-pdf.service.js} +15 -15
- package/package.json +1 -1
- package/src/accounting/counter-sales/auto-sales-receipt-pdf.service.ts +569 -0
- package/src/accounting/counter-sales/pos-receipt-pdf.ts +577 -0
- package/src/accounting/counter-sales/sales-receipt-pdf.service.ts +628 -0
- package/src/accounting/counter-sales/sales-receipt-print.service.ts +506 -0
- package/src/accounting/credit-note/cn-print.service.ts +264 -0
- package/src/accounting/credit-note/credit-note-pdf.service.ts +602 -0
- package/src/accounting/credit-note/credit-note-totals.service.ts +424 -0
- package/src/accounting/debit-note/debit-note-pdf.service.ts +681 -0
- package/src/accounting/debit-note/debit-note-print.service.ts +276 -0
- package/src/accounting/debit-note/debit-note-totals.service.ts +361 -0
- package/src/accounting/invoice/hc-inv-pdf.service.ts +880 -0
- package/src/accounting/invoice/inv-pdf.service.ts +812 -0
- package/src/accounting/invoice/inv-print.service.ts +532 -0
- package/src/accounting/invoice/invoice-landscape-pdf.service.ts +947 -0
- package/src/accounting/invoice/invoice-letterhead-pdf.service.ts +813 -0
- package/src/accounting/invoice/invoice-pdf/invoice-pdf.service.ts +359 -0
- package/src/accounting/invoice/invoice-portrait-pdf.ts +972 -0
- package/src/accounting/invoice/invoice-print.service.ts +2906 -0
- package/src/accounting/invoice/invoice-total.service.ts +834 -0
- package/src/accounting/invoice/reports/excel/analysis-excel.service.ts +291 -0
- package/src/accounting/invoice/reports/excel/category-wise-item-excel.service.ts +267 -0
- package/src/accounting/invoice/reports/excel/cust-wise-sales-details.ts +321 -0
- package/src/accounting/invoice/reports/excel/cust-wise-sales-summary-excel.service.ts +300 -0
- package/src/accounting/invoice/reports/excel/invoice-wise-excel.service.ts +859 -0
- package/src/accounting/invoice/reports/excel/item-wise-doctor-sale-excel.service.ts +255 -0
- package/src/accounting/invoice/reports/excel/items-wise-sales-excel.service.ts +312 -0
- package/src/accounting/invoice/reports/excel/manf-wise-sales-excel.service.ts +273 -0
- package/src/accounting/invoice/reports/excel/operator-wise-details.ts +258 -0
- package/src/accounting/invoice/reports/excel/operator-wise-summary.ts +259 -0
- package/src/accounting/invoice/reports/excel/sa-wise-labor-sales-excel.service.ts +230 -0
- package/src/accounting/invoice/reports/excel/sa-wise-part-sales-excel.service.ts +231 -0
- package/src/accounting/invoice/reports/excel/sale-summary-excel.service.ts +326 -0
- package/src/accounting/invoice/reports/excel/sales-by-service-details-excel.service.ts +0 -0
- package/src/accounting/invoice/reports/excel/sales-by-service-summary-excel.service.ts +432 -0
- package/src/accounting/invoice/reports/excel/scheduled-drug-summary-excel.service.ts +373 -0
- package/src/accounting/invoice/reports/excel/scheduled-drugs-excel.service.ts +372 -0
- package/src/accounting/invoice/reports/pdf/analysis-pdf.service.ts +113 -0
- package/src/accounting/invoice/reports/pdf/category-wise-item-pdf.service.ts +107 -0
- package/src/accounting/invoice/reports/pdf/cust-wise-sales-details-pdf.service.ts +125 -0
- package/src/accounting/invoice/reports/pdf/cust-wise-sales-summary-pdf.service.ts +119 -0
- package/src/accounting/invoice/reports/pdf/item-wise-doctor-sale-pdf.service.ts +180 -0
- package/src/accounting/invoice/reports/pdf/item-wise-sales-pdf.service.ts +193 -0
- package/src/accounting/invoice/reports/pdf/manf-wise-sales-pdf.service.ts +188 -0
- package/src/accounting/invoice/reports/pdf/operator-wise-details-pdf.service.ts +118 -0
- package/src/accounting/invoice/reports/pdf/operator-wise-summary-pdf.ts +116 -0
- package/src/accounting/invoice/reports/pdf/sales-by-service-pdf.service.ts +132 -0
- package/src/accounting/invoice/reports/pdf/scheduled-drug-pdf.service.ts +191 -0
- package/src/accounting/invoice/reports/pdf/scheduled-drug-summary-pdf.service.ts +202 -0
- package/src/accounting/invoice/shared-inv-pdf.service.ts +787 -0
- package/src/accounting/invoice/unified-invoice-pdf.service.ts +937 -0
- package/src/accounting/payment-receive/payment-pdf.service.ts +410 -0
- package/src/accounting/payment-receive/payment-receipt-pdf/receipt-pdf.service.ts +470 -0
- package/src/accounting/payment-receive/receipt-print.service.ts +71 -0
- package/src/accounting/payment-receive/reports/excel/cust-balance-excel.service.ts +298 -0
- package/src/accounting/payment-receive/reports/excel/payment-receive-excel.service.ts +221 -0
- package/src/accounting/payment-receive/reports/pdf/customer-balances-pdf.service.ts +182 -0
- package/src/accounting/payment-receive/reports/pdf/payment-report-pdf.service.ts +116 -0
- package/src/aggregation/aggregation.ts +58 -0
- package/src/appointments/appointments/appointment-total.service.ts +298 -0
- package/src/appointments/consultations/consultation-fee-receipt.service.ts +407 -0
- package/src/appointments/consultations/consultation-full-pdf.service.ts +238 -0
- package/src/appointments/consultations/consultation-letterhead-pdf.service.ts +430 -0
- package/src/appointments/consultations/consultation-pdf.service.ts +417 -0
- package/src/common/reports/excel/product-without-owner-excel.service.ts +308 -0
- package/src/common/reports/pdf/product-without-owner-pdf.service.ts +146 -0
- package/src/enums/cache-enums.ts +33 -0
- package/src/enums/code-enums.ts +291 -0
- package/src/enums/country-enums.ts +9 -0
- package/src/enums/enums.ts +364 -0
- package/src/enums/industry-enums.ts +26 -0
- package/src/enums/treatment-enums.ts +9 -0
- package/src/gst/excel/GSTR-RO-excel.service.ts +926 -0
- package/src/gst/excel/GSTR1-excel.service.ts +313 -0
- package/src/gst/excel/GSTR2-excel.service.ts +314 -0
- package/src/gst/excel/hsn-summary.ts +314 -0
- package/src/gst/excel/tally-sales-import.service.ts +767 -0
- package/src/gst/pdf/hsn-summary-pdf.ts +176 -0
- package/src/index.ts +194 -0
- package/src/inventory/items/adjustment-pdf.service.ts +177 -0
- package/src/inventory/items/issue-parts-pdf.service.ts +795 -0
- package/src/inventory/items/item-bar-code-label-pdf.ts +194 -0
- package/src/inventory/items/item-detais-pdf.ts +141 -0
- package/src/inventory/items/item-price-for-pricelist.ts +368 -0
- package/src/inventory/items/reports/excel/expiring-drugs-excel.service.ts +290 -0
- package/src/inventory/items/reports/excel/item-wise-mout-details.ts +284 -0
- package/src/inventory/items/reports/excel/item-wise-mout-summary.ts +279 -0
- package/src/inventory/items/reports/excel/spares-issue-excel.service.ts +494 -0
- package/src/inventory/items/reports/excel/stock-excel.service.ts +319 -0
- package/src/inventory/items/reports/pdf/expiring-drugs-pdf.service.ts +172 -0
- package/src/inventory/items/reports/pdf/item-wise-mout-details-pdf.ts +122 -0
- package/src/inventory/items/reports/pdf/item-wise-mout-summary-pdf.ts +115 -0
- package/src/inventory/items/reports/pdf/reorder-point-pdf.service.ts +163 -0
- package/src/inventory/material-out/mout-pdf.service.ts +545 -0
- package/src/inventory/transfer-order/transfer-order-pdf.service.ts +154 -0
- package/src/purchases/bills/bill-pdf/bill-pdf.service.ts +211 -0
- package/src/purchases/bills/bill-pdf.service.ts +21 -0
- package/src/purchases/payment-made/reports/excel/payments-made-excel.service.ts +313 -0
- package/src/purchases/payment-made/reports/excel/ven-balance-excel.service.ts +307 -0
- package/src/purchases/payment-made/reports/pdf/vendor-balances-pdf.service.ts +114 -0
- package/src/purchases/purchase-order/po-totals.service.ts +343 -0
- package/src/purchases/purchase-order/purchase-order-pdf.service.ts +1016 -0
- package/src/purchases/purchase-order/purchase-order-print.service.ts +279 -0
- package/src/purchases/purchase-order/purchase-order-totals.service.ts +637 -0
- package/src/purchases/vendor-credit-note/vendor-credit-note-pdf.service.ts +1055 -0
- package/src/purchases/vendor-credit-note/vendor-credit-note-print.service.ts +145 -0
- package/src/purchases/vendor-credit-note/vendor-credit-note-totals.service.ts +399 -0
- package/src/purchases/vendor-debit-note/vendor-debit-note-pdf.service.ts +582 -0
- package/src/purchases/vendor-debit-note/vendor-debit-note-print.service.ts +295 -0
- package/src/purchases/vendor-debit-note/vendor-debit-note-totals.service.ts +377 -0
- package/src/sales/delivery-challan/dc-landscape-pdf.service.ts +922 -0
- package/src/sales/delivery-challan/dc-landscape-without-price-pdf.service.ts +869 -0
- package/src/sales/delivery-challan/dc-without-price-pdf.service.ts +505 -0
- package/src/sales/delivery-challan/delivery-challan-pdf.service.ts +461 -0
- package/src/sales/delivery-challan/delivery-challan-print.service.ts +229 -0
- package/src/sales/delivery-challan/delivery-challan-totals.ts +466 -0
- package/src/sales/sales/equipment-design-pdf.service.ts +153 -0
- package/src/sales/sales/pack-ship-pdf.service.ts +128 -0
- package/src/sales/sales/pack-ship-print.service.ts +198 -0
- package/src/sales/sales/sales-pdf.service.ts +658 -0
- package/src/sales/sales/sales-print.service.ts +376 -0
- package/src/sales/sales/sales-totals.service.ts +500 -0
- package/src/sales-receive/sales-receive-pdf.service.ts +602 -0
- package/src/sales-receive/sales-receive-print.service.ts +242 -0
- package/src/sales-receive/sales-receive-totals.service.ts +651 -0
- package/src/services/checklist-pdf.ts +151 -0
- package/src/services/checklists-pdf.ts +133 -0
- package/src/services/est.print-service.ts +1155 -0
- package/src/services/reports/excel/insurance-expire-excel.service.ts +292 -0
- package/src/services/reports/excel/next-service-date-excel.service.ts +317 -0
- package/src/services/reports/excel/repair-orders-excel.service.ts +249 -0
- package/src/services/reports/pdf/insurance-expire-pdf.service.ts +115 -0
- package/src/services/reports/pdf/next-service-date-pdf.service.ts +198 -0
- package/src/services/reports/pdf/repair-orders-pdf.service.ts +184 -0
- package/src/services/ro-pdf.service.ts +1917 -0
- package/src/services/ro-print-service.ts +881 -0
- package/src/services/ro-totals.service.ts +1314 -0
- package/src/services/separate-wo-print.service.ts +396 -0
- package/src/services/service-history-pdf.service.ts +145 -0
- package/src/services/service-price-for-pricelist.ts +649 -0
- package/src/services/technician-pdf.service.ts +234 -0
- package/src/services/technician-print.service.ts +95 -0
- package/src/shared/header-footer-section/pdf-header-footer.section.ts +519 -0
- package/src/shared/header-footer-section/pdf-shared.utils.ts +46 -0
- package/src/shared/math-operations.ts +208 -0
- package/src/shared/party-details-section/pdf-party-details.section.ts +602 -0
- package/src/shared/shared-pdf.service.ts +3042 -0
- package/src/shared/shared-print.service.ts +879 -0
- package/src/shared/table-section/pdf-table.config.ts +8 -0
- package/src/shared/table-section/pdf-table.header.ts +396 -0
- package/src/shared/table-section/pdf-table.row.ts +248 -0
- package/src/shared/table-section/pdf-table.section.ts +447 -0
- package/src/shared/totals-section/pdf-totals.section.ts +921 -0
- package/src/shared/transactions-pdf.service.ts +191 -0
- package/src/shared/util.ts +101 -0
- package/src/tasks/meetings/meeting-pdf.ts +410 -0
- package/src/tasks/tasks/task-pdf.service.ts +238 -0
- package/src/tasks/tasks/task-reports-pdf.service.ts +313 -0
- package/src/tax/index.ts +86 -0
- package/src/tax/tax-calculator.ts +1025 -0
- package/src/tax/tax.types.ts +535 -0
- package/src/transaction-calculations/discounts-distribution.ts +343 -0
- package/src/transaction-calculations/index.ts +3 -0
- package/src/transaction-calculations/total-calculation.ts +443 -0
- package/src/transaction-calculations/transaction-calculation-engine.ts +903 -0
- package/src/utils/my-date.ts +111 -0
- package/src/utils/tr-utils.ts +104 -0
- package/tsconfig.json +2 -2
- /package/dist/{accounting/invoice/invoice-pdf.service.d.ts → shared/transactions-pdf.service.d.ts} +0 -0
|
@@ -0,0 +1,602 @@
|
|
|
1
|
+
import JsBarcode from "jsbarcode";
|
|
2
|
+
import { firstValue } from "../header-footer-section/pdf-shared.utils";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export function buildInvoicePartyDetailsSection(PDFInvoiceData: any, customerLayout: any, printConfig: any = {}) {
|
|
6
|
+
return buildSalesPartyDetailsSection(PDFInvoiceData, customerLayout, printConfig);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function buildSalesPartyDetailsSection(PDFInvoiceData: any, customerLayout: any, printConfig: any = {}) {
|
|
10
|
+
const transactionData = PDFInvoiceData || {};
|
|
11
|
+
const billTo = resolveSalesBillToDetails(transactionData);
|
|
12
|
+
const shipTo = resolveSalesShipToDetails(transactionData);
|
|
13
|
+
const insurance = resolveInsuranceDetails(transactionData);
|
|
14
|
+
const useInsurance = !!insurance.name;
|
|
15
|
+
const shouldShowBillTo = resolvePartyVisibility(printConfig, 'ShowBillTo');
|
|
16
|
+
const shouldShowShipTo = useInsurance ? true : resolvePartyVisibility(printConfig, 'ShowShipTo');
|
|
17
|
+
const secondaryParty = useInsurance ? insurance : shipTo;
|
|
18
|
+
const showBarCode = resolveShowBarCode(transactionData, printConfig);
|
|
19
|
+
const billToCode = resolveBillToCode(transactionData);
|
|
20
|
+
const otherDetails = resolveOtherDetails(transactionData, printConfig);
|
|
21
|
+
const shouldShowSecondaryBarcode = shouldShowShipTo && !secondaryParty.hasData && showBarCode && !!billToCode;
|
|
22
|
+
const secondaryTitle = useInsurance ? 'Insurance' : 'Ship To';
|
|
23
|
+
|
|
24
|
+
return buildPartyDetailsSectionLayout({
|
|
25
|
+
primaryTitle: 'Bill To',
|
|
26
|
+
primaryParty: shouldShowBillTo ? billTo : { hasData: false },
|
|
27
|
+
secondaryTitle,
|
|
28
|
+
secondaryParty: shouldShowShipTo ? secondaryParty : { hasData: false },
|
|
29
|
+
customerLayout,
|
|
30
|
+
otherDetails,
|
|
31
|
+
shouldShowSecondaryBarcode,
|
|
32
|
+
secondaryBarcodeCode: billToCode
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function buildPurchasePartyDetailsSection(PDFInvoiceData: any, customerLayout: any, printConfig: any = {}) {
|
|
37
|
+
const transactionData = PDFInvoiceData || {};
|
|
38
|
+
const billTo = resolvePurchaseBFromDetails(transactionData);
|
|
39
|
+
const shipFrom = resolvePurchaseShipFromDetails(transactionData);
|
|
40
|
+
const showBarCode = resolveShowBarCode(transactionData, printConfig);
|
|
41
|
+
const billToCode = resolvePurchaseBillToCode(transactionData);
|
|
42
|
+
const otherDetails = resolvePurchaseOtherDetails(transactionData, printConfig);
|
|
43
|
+
const shouldShowSecondaryBarcode = !shipFrom.hasData && showBarCode && !!billToCode;
|
|
44
|
+
|
|
45
|
+
return buildPartyDetailsSectionLayout({
|
|
46
|
+
primaryTitle: 'Vendor Details',
|
|
47
|
+
primaryParty: billTo,
|
|
48
|
+
secondaryTitle: 'S From',
|
|
49
|
+
secondaryParty: shipFrom,
|
|
50
|
+
customerLayout,
|
|
51
|
+
otherDetails,
|
|
52
|
+
shouldShowSecondaryBarcode,
|
|
53
|
+
secondaryBarcodeCode: billToCode
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function buildPartyDetailsSectionLayout(config: any) {
|
|
58
|
+
const primaryStack = config?.primaryParty?.hasData
|
|
59
|
+
? buildPartyStack(config.primaryTitle, config.primaryParty, config.customerLayout)
|
|
60
|
+
: [{ text: '' }];
|
|
61
|
+
const secondaryStack = config?.secondaryParty?.hasData
|
|
62
|
+
? buildPartyStack(config.secondaryTitle, config.secondaryParty, config.customerLayout)
|
|
63
|
+
: (config?.shouldShowSecondaryBarcode ? buildBarcodeStack(config?.secondaryBarcodeCode) : [{ text: '' }]);
|
|
64
|
+
const otherDetailsStack = config?.otherDetails?.hasData ? buildOtherDetailsStack(config.otherDetails) : [{ text: '' }];
|
|
65
|
+
|
|
66
|
+
const hasAnyData = config?.primaryParty?.hasData
|
|
67
|
+
|| config?.secondaryParty?.hasData
|
|
68
|
+
|| config?.shouldShowSecondaryBarcode
|
|
69
|
+
|| config?.otherDetails?.hasData;
|
|
70
|
+
if (!hasAnyData) {
|
|
71
|
+
return [{
|
|
72
|
+
text: '',
|
|
73
|
+
margin: [0, 0, 0, 10]
|
|
74
|
+
}];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return [{
|
|
78
|
+
columns: [
|
|
79
|
+
{ width: '*', stack: primaryStack },
|
|
80
|
+
{ width: '*', stack: secondaryStack },
|
|
81
|
+
{ width: '*', stack: otherDetailsStack }
|
|
82
|
+
],
|
|
83
|
+
columnGap: 10,
|
|
84
|
+
margin: [0, 0, 0, 10]
|
|
85
|
+
}];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function resolveSalesBillToDetails(transactionData: any) {
|
|
89
|
+
const billTo = transactionData?.BillTo || transactionData?.Customer || transactionData?.Cust || {};
|
|
90
|
+
const address = normalizeAddress(
|
|
91
|
+
billTo?.Adrs
|
|
92
|
+
|| transactionData?.BillTo?.Adrs
|
|
93
|
+
|| transactionData?.BillAddress
|
|
94
|
+
|| transactionData?.BillToAddress
|
|
95
|
+
|| transactionData?.Customer?.Adrs
|
|
96
|
+
|| transactionData?.Cust?.Adrs
|
|
97
|
+
);
|
|
98
|
+
const name = firstValue(
|
|
99
|
+
billTo?.Name,
|
|
100
|
+
billTo?.CName,
|
|
101
|
+
transactionData?.BillTo?.Name,
|
|
102
|
+
transactionData?.Customer?.Name,
|
|
103
|
+
transactionData?.Cust?.Name,
|
|
104
|
+
transactionData?.CustomerName
|
|
105
|
+
);
|
|
106
|
+
const gstin = firstValue(
|
|
107
|
+
billTo?.GSTIN,
|
|
108
|
+
billTo?.GSTNo
|
|
109
|
+
);
|
|
110
|
+
const contactInfo = resolvePhoneFromContacts(billTo?.Cons);
|
|
111
|
+
const directPhone = firstValue(billTo?.Ph, billTo?.Phone, billTo?.Mobile);
|
|
112
|
+
const ownerName = firstValue(transactionData?.Cust?.Name);
|
|
113
|
+
return {
|
|
114
|
+
name,
|
|
115
|
+
addressLines: buildAddressLines(address),
|
|
116
|
+
gstin,
|
|
117
|
+
phoneType: contactInfo.type,
|
|
118
|
+
phoneNumber: contactInfo.number || directPhone,
|
|
119
|
+
ownerName,
|
|
120
|
+
hasData: !!(name || gstin || contactInfo.number || directPhone || hasAddress(address))
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function resolveSalesShipToDetails(transactionData: any) {
|
|
125
|
+
const shipTo = transactionData?.ShipTo || transactionData?.ShippmentTo || {};
|
|
126
|
+
const address = normalizeAddress(
|
|
127
|
+
shipTo?.Adrs
|
|
128
|
+
|| transactionData?.ShipAddress
|
|
129
|
+
|| transactionData?.ShipToAddress
|
|
130
|
+
);
|
|
131
|
+
const name = firstValue(shipTo?.Name, shipTo?.CName);
|
|
132
|
+
const gstin = firstValue(shipTo?.GSTIN, shipTo?.GSTNo);
|
|
133
|
+
return {
|
|
134
|
+
name,
|
|
135
|
+
addressLines: buildAddressLines(address),
|
|
136
|
+
gstin,
|
|
137
|
+
hasData: !!(name || gstin || hasAddress(address))
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function resolvePurchaseBFromDetails(transactionData: any) {
|
|
142
|
+
const billTo = transactionData?.BFrom || transactionData?.BillTo || transactionData?.Vendor || transactionData?.Vnd || transactionData?.Supplier || {};
|
|
143
|
+
const address = normalizeAddress(
|
|
144
|
+
billTo?.Adrs
|
|
145
|
+
|| transactionData?.BFrom?.Adrs
|
|
146
|
+
|| transactionData?.BillTo?.Adrs
|
|
147
|
+
|| transactionData?.BFromAddress
|
|
148
|
+
|| transactionData?.BillAddress
|
|
149
|
+
|| transactionData?.BillToAddress
|
|
150
|
+
|| transactionData?.Vendor?.Address
|
|
151
|
+
|| transactionData?.Vnd?.Adrs
|
|
152
|
+
|| transactionData?.Supplier?.Adrs
|
|
153
|
+
);
|
|
154
|
+
const name = firstValue(
|
|
155
|
+
billTo?.Name,
|
|
156
|
+
billTo?.CName,
|
|
157
|
+
transactionData?.BFrom?.Name,
|
|
158
|
+
transactionData?.BillTo?.Name,
|
|
159
|
+
transactionData?.Vendor?.Name,
|
|
160
|
+
transactionData?.Vnd?.Name,
|
|
161
|
+
transactionData?.Supplier?.Name,
|
|
162
|
+
transactionData?.BFromName,
|
|
163
|
+
transactionData?.VendorName
|
|
164
|
+
);
|
|
165
|
+
const gstin = firstValue(
|
|
166
|
+
billTo?.GSTIN,
|
|
167
|
+
billTo?.GSTNo
|
|
168
|
+
);
|
|
169
|
+
const contactInfo = resolvePhoneFromContacts(billTo?.Contact);
|
|
170
|
+
const directPhone = firstValue(billTo?.Ph, billTo?.Phone, billTo?.Mobile);
|
|
171
|
+
|
|
172
|
+
return {
|
|
173
|
+
name,
|
|
174
|
+
addressLines: buildAddressLines(address),
|
|
175
|
+
gstin,
|
|
176
|
+
phoneType: contactInfo.type,
|
|
177
|
+
phoneNumber: contactInfo.number || directPhone,
|
|
178
|
+
ownerName: '',
|
|
179
|
+
hasData: !!(name || gstin || contactInfo.number || directPhone || hasAddress(address))
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function resolvePurchaseOtherDetails(transactionData: any, printConfig: any = {}) {
|
|
184
|
+
const billDate = firstValue(transactionData?.CrDate, transactionData?.InvDt, transactionData?.Date, transactionData?.CrDate);
|
|
185
|
+
const billNumber = firstValue(transactionData?.Id, transactionData?.Code, transactionData?.InvNo, transactionData?.No);
|
|
186
|
+
const documentNumberLabel = resolveDocumentNumberLabel(printConfig, 'Bill');
|
|
187
|
+
// const productName = [
|
|
188
|
+
// transactionData?.Product?.Make,
|
|
189
|
+
// transactionData?.Product?.Model,
|
|
190
|
+
// transactionData?.Product?.Var
|
|
191
|
+
// ]
|
|
192
|
+
// .map((value: any) => String(value ?? '').trim())
|
|
193
|
+
// .filter((value: string) => !!value)
|
|
194
|
+
// .join(' ');
|
|
195
|
+
// const vehicleDetails = firstValue(
|
|
196
|
+
// productName,
|
|
197
|
+
// transactionData?.VehNo,
|
|
198
|
+
// transactionData?.VehicleNo,
|
|
199
|
+
// transactionData?.Vehicle?.RegNo,
|
|
200
|
+
// transactionData?.Vehicle?.No,
|
|
201
|
+
// transactionData?.Vehicle?.Details,
|
|
202
|
+
// transactionData?.VehicleDetails
|
|
203
|
+
// );
|
|
204
|
+
// const Milage = firstValue(transactionData?.MIn, transactionData?.MOut, transactionData?.Milage);
|
|
205
|
+
// const RegnNo = transactionData?.Product?.RegNo;
|
|
206
|
+
// const EngNo = transactionData?.Product?.EngNo;
|
|
207
|
+
// const ChassisNo = transactionData?.Product?.VIN;
|
|
208
|
+
|
|
209
|
+
const lines = [
|
|
210
|
+
{ label: documentNumberLabel, value: billNumber },
|
|
211
|
+
{ label: 'Date', value: billDate ? billDate : '' },
|
|
212
|
+
// { label: 'Vehicle', value: vehicleDetails },
|
|
213
|
+
// { label: 'Regn. No', value: firstValue(RegnNo) },
|
|
214
|
+
// { label: 'Engine No', value: firstValue(EngNo) },
|
|
215
|
+
// { label: 'Chassis No', value: firstValue(ChassisNo) },
|
|
216
|
+
// { label: 'Milage', value: Milage }
|
|
217
|
+
].filter((line) => !!line.value);
|
|
218
|
+
|
|
219
|
+
return {
|
|
220
|
+
lines,
|
|
221
|
+
hasData: lines.length > 0
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function resolvePurchaseShipFromDetails(transactionData: any) {
|
|
226
|
+
const shipFrom = transactionData?.SFrom || transactionData?.ShipFrom || transactionData?.From || {};
|
|
227
|
+
const address = normalizeAddress(
|
|
228
|
+
shipFrom?.Adrs
|
|
229
|
+
|| transactionData?.SFromAddress
|
|
230
|
+
|| transactionData?.ShipFromAddress
|
|
231
|
+
|| transactionData?.FromAddress
|
|
232
|
+
);
|
|
233
|
+
const name = firstValue(
|
|
234
|
+
shipFrom?.Name,
|
|
235
|
+
shipFrom?.CName,
|
|
236
|
+
shipFrom?.WhName,
|
|
237
|
+
transactionData?.SFromName,
|
|
238
|
+
transactionData?.ShipFromName
|
|
239
|
+
);
|
|
240
|
+
const gstin = firstValue(shipFrom?.GSTIN, shipFrom?.GSTNo);
|
|
241
|
+
|
|
242
|
+
return {
|
|
243
|
+
name,
|
|
244
|
+
addressLines: buildAddressLines(address),
|
|
245
|
+
gstin,
|
|
246
|
+
hasData: !!(name || gstin || hasAddress(address))
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function resolveInsuranceDetails(transactionData: any) {
|
|
251
|
+
const insurance = transactionData?.Insurance || transactionData?.Ins || transactionData?.Insurer || {};
|
|
252
|
+
const address = normalizeAddress(insurance?.Adrs || insurance?.Address);
|
|
253
|
+
const name = firstValue(
|
|
254
|
+
insurance?.Name,
|
|
255
|
+
insurance?.Company,
|
|
256
|
+
insurance?.Provider,
|
|
257
|
+
insurance?.InsName
|
|
258
|
+
);
|
|
259
|
+
const gstin = firstValue(insurance?.GSTIN, insurance?.GSTNo);
|
|
260
|
+
return {
|
|
261
|
+
name,
|
|
262
|
+
addressLines: buildAddressLines(address),
|
|
263
|
+
gstin,
|
|
264
|
+
hasData: !!(name || gstin || hasAddress(address))
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function resolveOtherDetails(transactionData: any, printConfig: any = {}) {
|
|
269
|
+
const invoiceDate = firstValue(transactionData?.CrDate, transactionData?.DDate, transactionData?.InvDt, transactionData?.Date);
|
|
270
|
+
const invoiceNumber = firstValue(transactionData?._id, transactionData?.Code, transactionData?.InvNo, transactionData?.No);
|
|
271
|
+
const documentNumberLabel = resolveDocumentNumberLabel(printConfig, 'Invoice');
|
|
272
|
+
const productName = [
|
|
273
|
+
transactionData?.Product?.Make,
|
|
274
|
+
transactionData?.Product?.Model,
|
|
275
|
+
transactionData?.Product?.Var
|
|
276
|
+
]
|
|
277
|
+
.map((value: any) => String(value ?? '').trim())
|
|
278
|
+
.filter((value: string) => !!value)
|
|
279
|
+
.join(' ');
|
|
280
|
+
const vehicleDetails = firstValue(
|
|
281
|
+
productName,
|
|
282
|
+
transactionData?.VehNo,
|
|
283
|
+
transactionData?.VehicleNo,
|
|
284
|
+
transactionData?.Vehicle?.RegNo,
|
|
285
|
+
transactionData?.Vehicle?.No,
|
|
286
|
+
transactionData?.Vehicle?.Details,
|
|
287
|
+
transactionData?.VehicleDetails
|
|
288
|
+
);
|
|
289
|
+
const Milage = firstValue(transactionData?.MIn, transactionData?.MOut, transactionData?.Milage);
|
|
290
|
+
const RegnNo = transactionData?.Product?.RegNo;
|
|
291
|
+
const EngNo = transactionData?.Product?.EngNo;
|
|
292
|
+
const ChassisNo = transactionData?.Product?.VIN;
|
|
293
|
+
const DoctorName = firstValue(transactionData?.Name, transactionData?.DoctorName);
|
|
294
|
+
const shouldShowDoctorName = documentNumberLabel === 'Sales Receipt#';
|
|
295
|
+
|
|
296
|
+
const lines = [
|
|
297
|
+
{ label: documentNumberLabel, value: invoiceNumber },
|
|
298
|
+
{ label: 'Date', value: invoiceDate ? invoiceDate : '' },
|
|
299
|
+
{ label: 'Vehicle', value: vehicleDetails },
|
|
300
|
+
{ label: 'Regn. No', value: firstValue(RegnNo) },
|
|
301
|
+
{ label: 'Engine No', value: firstValue(EngNo) },
|
|
302
|
+
{ label: 'Chassis No', value: firstValue(ChassisNo) },
|
|
303
|
+
{ label: 'Milage', value: Milage },
|
|
304
|
+
...(shouldShowDoctorName ? [{ label: 'Doctor Name', value: DoctorName }] : [])
|
|
305
|
+
].filter((line) => !!line.value);
|
|
306
|
+
|
|
307
|
+
return {
|
|
308
|
+
lines,
|
|
309
|
+
hasData: lines.length > 0
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function buildPartyStack(title: string, party: any, customerLayout: any) {
|
|
314
|
+
const stack: any[] = [
|
|
315
|
+
{ text: title, bold: true, fontSize: 9, color: '#374151', margin: [0, 0, 0, 4] }
|
|
316
|
+
];
|
|
317
|
+
|
|
318
|
+
if (party?.name) {
|
|
319
|
+
stack.push({
|
|
320
|
+
text: party.name,
|
|
321
|
+
bold: true,
|
|
322
|
+
fontSize: customerLayout?.NameFsize || 9,
|
|
323
|
+
color: customerLayout?.NameClr || '#111827',
|
|
324
|
+
// background: '#e5e7eb',
|
|
325
|
+
margin: [0, 0, 0, 2]
|
|
326
|
+
});
|
|
327
|
+
} else {
|
|
328
|
+
stack.push({ text: '-', fontSize: 8, color: '#6b7280', margin: [0, 0, 0, 2] });
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
const addressLines = Array.isArray(party?.addressLines) ? party.addressLines : [];
|
|
332
|
+
if (addressLines.length > 0) {
|
|
333
|
+
addressLines.forEach((line: string) => {
|
|
334
|
+
stack.push({ text: line, fontSize: 8, lineHeight: 1.05 });
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
if (party?.gstin) {
|
|
339
|
+
stack.push({ text: `GSTIN: ${party.gstin}`, fontSize: 8, lineHeight: 1.05 });
|
|
340
|
+
}
|
|
341
|
+
if (party?.phoneNumber) {
|
|
342
|
+
const phoneLabel = party?.phoneType ? `Phone(${party.phoneType})` : 'Phone';
|
|
343
|
+
stack.push({ text: `${phoneLabel} : ${party.phoneNumber}`, fontSize: 8, lineHeight: 1.05 });
|
|
344
|
+
}
|
|
345
|
+
if (title === 'Bill To' && party?.ownerName) {
|
|
346
|
+
stack.push({
|
|
347
|
+
text: [
|
|
348
|
+
{ text: 'Owner Details', bold: true },
|
|
349
|
+
{ text: ' : ', bold: true },
|
|
350
|
+
{ text: party.ownerName, bold: false }
|
|
351
|
+
],
|
|
352
|
+
fontSize: 8.5,
|
|
353
|
+
color: '#111827',
|
|
354
|
+
margin: [0, 3, 0, 1]
|
|
355
|
+
});
|
|
356
|
+
// stack.push({
|
|
357
|
+
// canvas: [
|
|
358
|
+
// { type: 'line', x1: 0, y1: 0, x2: 170, y2: 0, lineWidth: 0.5, lineColor: '#111827' }
|
|
359
|
+
// ],
|
|
360
|
+
// margin: [0, 2, 0, 0]
|
|
361
|
+
// });
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
return stack;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
function buildOtherDetailsStack(otherDetails: any) {
|
|
368
|
+
const stack: any[] = [];
|
|
369
|
+
const lines = Array.isArray(otherDetails?.lines) ? otherDetails.lines : [];
|
|
370
|
+
|
|
371
|
+
if (lines.length > 0) {
|
|
372
|
+
stack.push({
|
|
373
|
+
table: {
|
|
374
|
+
widths: ['auto', 8, '*'],
|
|
375
|
+
body: lines.map((line: any) => ([
|
|
376
|
+
{ text: line.label || '', bold: true, fontSize: 8, color: '#111827', alignment: 'right' },
|
|
377
|
+
{ text: ':', bold: true, fontSize: 8, color: '#111827', alignment: 'center' },
|
|
378
|
+
{ text: line.value || '-', fontSize: 8, color: '#111827', alignment: 'left' }
|
|
379
|
+
]))
|
|
380
|
+
},
|
|
381
|
+
layout: 'noBorders'
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
return stack;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
function buildBarcodeStack(code: string) {
|
|
389
|
+
const svg = textToSvgBarcode(code);
|
|
390
|
+
if (!svg) {
|
|
391
|
+
return [{ text: '' }];
|
|
392
|
+
}
|
|
393
|
+
return [
|
|
394
|
+
{
|
|
395
|
+
svg,
|
|
396
|
+
width: 80,
|
|
397
|
+
alignment: 'center',
|
|
398
|
+
margin: [0, 0, 0, 0]
|
|
399
|
+
}
|
|
400
|
+
];
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
function hasAddress(address: any) {
|
|
404
|
+
const lines = normalizeAddressLines(address);
|
|
405
|
+
if (lines.length > 0) {
|
|
406
|
+
return true;
|
|
407
|
+
}
|
|
408
|
+
const normalizedAddress = normalizeAddress(address);
|
|
409
|
+
if (!normalizedAddress) {
|
|
410
|
+
return false;
|
|
411
|
+
}
|
|
412
|
+
return !!firstValue(
|
|
413
|
+
getAddressFieldValue(normalizedAddress, ['A1', 'Addr1', 'Address1', 'Adrs1', 'Line1', 'Street1']),
|
|
414
|
+
getAddressFieldValue(normalizedAddress, ['A2', 'Addr2', 'Address2', 'Adrs2', 'Line2', 'Street2']),
|
|
415
|
+
getAddressFieldValue(normalizedAddress, ['Ct', 'City', 'Town', 'District']),
|
|
416
|
+
getAddressFieldValue(normalizedAddress, ['St', 'State', 'StateName', 'Province']),
|
|
417
|
+
getAddressFieldValue(normalizedAddress, ['Pin', 'PIN', 'Zip', 'ZipCode', 'PostalCode', 'Pincode'])
|
|
418
|
+
);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
function buildAddressLines(address: any) {
|
|
422
|
+
const lines = normalizeAddressLines(address);
|
|
423
|
+
if (lines.length > 0) {
|
|
424
|
+
return lines;
|
|
425
|
+
}
|
|
426
|
+
const normalizedAddress = normalizeAddress(address);
|
|
427
|
+
if (!normalizedAddress) {
|
|
428
|
+
return [];
|
|
429
|
+
}
|
|
430
|
+
const line1 = getAddressFieldValue(normalizedAddress, ['A1', 'Addr1', 'Address1', 'Adrs1', 'Line1', 'Street1']);
|
|
431
|
+
const line2 = getAddressFieldValue(normalizedAddress, ['A2', 'Addr2', 'Address2', 'Adrs2', 'Line2', 'Street2']);
|
|
432
|
+
const cityStatePin = [
|
|
433
|
+
getAddressFieldValue(normalizedAddress, ['Ct', 'City', 'Town', 'District']),
|
|
434
|
+
getAddressFieldValue(normalizedAddress, ['St', 'State', 'StateName', 'Province']),
|
|
435
|
+
getAddressFieldValue(normalizedAddress, ['Pin', 'PIN', 'Zip', 'ZipCode', 'PostalCode', 'Pincode'])
|
|
436
|
+
]
|
|
437
|
+
.filter((value: string) => !!value)
|
|
438
|
+
.join(', ');
|
|
439
|
+
|
|
440
|
+
return [line1, line2, cityStatePin].filter((value: string) => !!value);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
function normalizeAddressLines(address: any) {
|
|
444
|
+
if (!Array.isArray(address)) {
|
|
445
|
+
return [];
|
|
446
|
+
}
|
|
447
|
+
return address
|
|
448
|
+
.filter((line: any) => typeof line === 'string')
|
|
449
|
+
.map((line: string) => line.trim())
|
|
450
|
+
.filter((line: string) => !!line);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
function normalizeAddress(address: any) {
|
|
454
|
+
if (!address) {
|
|
455
|
+
return null;
|
|
456
|
+
}
|
|
457
|
+
if (typeof address === 'string') {
|
|
458
|
+
const line = address.trim();
|
|
459
|
+
return line ? { A1: line } : null;
|
|
460
|
+
}
|
|
461
|
+
if (Array.isArray(address)) {
|
|
462
|
+
if (address.length === 0) {
|
|
463
|
+
return null;
|
|
464
|
+
}
|
|
465
|
+
const preferred = address.find((entry: any) => entry?.DefBill || entry?.DefShip || entry?.Def);
|
|
466
|
+
return preferred || address || null;
|
|
467
|
+
}
|
|
468
|
+
if (typeof address === 'object') {
|
|
469
|
+
if (address?.Adrs && typeof address.Adrs === 'object') {
|
|
470
|
+
return normalizeAddress(address.Adrs);
|
|
471
|
+
}
|
|
472
|
+
if (address?.Address && typeof address.Address === 'object') {
|
|
473
|
+
return normalizeAddress(address.Address);
|
|
474
|
+
}
|
|
475
|
+
return address;
|
|
476
|
+
}
|
|
477
|
+
return null;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
function getAddressFieldValue(address: any, keys: string[]) {
|
|
481
|
+
for (const key of keys) {
|
|
482
|
+
const value = address?.[key];
|
|
483
|
+
if (value === undefined || value === null) {
|
|
484
|
+
continue;
|
|
485
|
+
}
|
|
486
|
+
const normalized = String(value).trim();
|
|
487
|
+
if (normalized) {
|
|
488
|
+
return normalized;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
return '';
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
// function formatDisplayDate(value: string) {
|
|
495
|
+
// if (!value) {
|
|
496
|
+
// return '-';
|
|
497
|
+
// }
|
|
498
|
+
// const dt = new Date(value);
|
|
499
|
+
// if (!Number.isNaN(dt.getTime())) {
|
|
500
|
+
// const day = leftPadWithZero(dt.getDate());
|
|
501
|
+
// const month = leftPadWithZero(dt.getMonth() + 1);
|
|
502
|
+
// const year = dt.getFullYear();
|
|
503
|
+
// return `${day}/${month}/${year}`;
|
|
504
|
+
// }
|
|
505
|
+
// return value;
|
|
506
|
+
// }
|
|
507
|
+
|
|
508
|
+
// function leftPadWithZero(value: number) {
|
|
509
|
+
// const text = String(value);
|
|
510
|
+
// return text.length >= 2 ? text : `0${text}`;
|
|
511
|
+
// }
|
|
512
|
+
|
|
513
|
+
function resolveShowBarCode(transactionData: any, printConfig: any = {}) {
|
|
514
|
+
if (Object.prototype.hasOwnProperty.call(printConfig || {}, 'Customer')) {
|
|
515
|
+
return isTruthy(printConfig?.Customer?.ShowBarCode);
|
|
516
|
+
}
|
|
517
|
+
return isTruthy(transactionData?.ShowBarCode)
|
|
518
|
+
|| isTruthy(transactionData?.Entity?.PrCustBar)
|
|
519
|
+
|| isTruthy(transactionData?.PrCustBar);
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
function resolvePartyVisibility(printConfig: any, key: string) {
|
|
523
|
+
if (Object.prototype.hasOwnProperty.call(printConfig || {}, key)) {
|
|
524
|
+
return isTruthy(printConfig?.[key]);
|
|
525
|
+
}
|
|
526
|
+
return true;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
function resolveBillToCode(transactionData: any) {
|
|
530
|
+
return firstValue(
|
|
531
|
+
transactionData?.BillTo?.Code,
|
|
532
|
+
transactionData?.Customer?.Code,
|
|
533
|
+
transactionData?.Cust?.Code
|
|
534
|
+
);
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
function resolvePurchaseBillToCode(transactionData: any) {
|
|
538
|
+
return firstValue(
|
|
539
|
+
transactionData?.BFrom?.Code,
|
|
540
|
+
transactionData?.BillTo?.Code,
|
|
541
|
+
transactionData?.Vendor?.Code,
|
|
542
|
+
transactionData?.Vnd?.Code,
|
|
543
|
+
transactionData?.Supplier?.Code
|
|
544
|
+
);
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
function resolveDocumentNumberLabel(printConfig: any, fallbackType: string) {
|
|
548
|
+
const typeValue = firstValue(printConfig?.Type, fallbackType);
|
|
549
|
+
const normalizedType = String(typeValue ?? '').trim();
|
|
550
|
+
if (!normalizedType) {
|
|
551
|
+
return `${fallbackType}#`;
|
|
552
|
+
}
|
|
553
|
+
const withoutHash = normalizedType.replace(/#+$/g, '').trim();
|
|
554
|
+
return `${withoutHash || fallbackType}#`;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
function isTruthy(value: any) {
|
|
558
|
+
if (typeof value === 'boolean') {
|
|
559
|
+
return value;
|
|
560
|
+
}
|
|
561
|
+
if (typeof value === 'number') {
|
|
562
|
+
return value !== 0;
|
|
563
|
+
}
|
|
564
|
+
if (typeof value === 'string') {
|
|
565
|
+
const normalized = value.trim().toLowerCase();
|
|
566
|
+
return normalized === 'true' || normalized === '1' || normalized === 'yes';
|
|
567
|
+
}
|
|
568
|
+
return false;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
function textToSvgBarcode(text: string) {
|
|
572
|
+
if (!text || typeof document === 'undefined') {
|
|
573
|
+
return '';
|
|
574
|
+
}
|
|
575
|
+
const svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
576
|
+
JsBarcode(svgElement, text, {
|
|
577
|
+
format: "CODE128",
|
|
578
|
+
width: 1.2,
|
|
579
|
+
height: 18,
|
|
580
|
+
margin: 0,
|
|
581
|
+
marginTop: 0,
|
|
582
|
+
displayValue: true,
|
|
583
|
+
fontSize: 6,
|
|
584
|
+
textMargin: 0,
|
|
585
|
+
fontOptions: 'bold'
|
|
586
|
+
});
|
|
587
|
+
return svgElement.outerHTML;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
function resolvePhoneFromContacts(contacts: any) {
|
|
591
|
+
if (!Array.isArray(contacts)) {
|
|
592
|
+
return { type: '', number: '' };
|
|
593
|
+
}
|
|
594
|
+
const preferred = contacts.find((contact: any) => firstValue(contact?.No));
|
|
595
|
+
if (!preferred) {
|
|
596
|
+
return { type: '', number: '' };
|
|
597
|
+
}
|
|
598
|
+
return {
|
|
599
|
+
type: firstValue(preferred?.Type),
|
|
600
|
+
number: firstValue(preferred?.No)
|
|
601
|
+
};
|
|
602
|
+
}
|