From fb09fc53823c1c2ba9e774bb282977edd6238a62 Mon Sep 17 00:00:00 2001 From: karthikalakshmi Date: Tue, 3 Mar 2026 09:56:17 +0530 Subject: [PATCH] Update src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle4.jsx --- .../ThermalPrinter/PrintStyle4.jsx | 674 ++++++++---------- 1 file changed, 315 insertions(+), 359 deletions(-) diff --git a/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle4.jsx b/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle4.jsx index 07f43c2..8f98179 100644 --- a/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle4.jsx +++ b/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle4.jsx @@ -90,6 +90,7 @@ const Printstyle4 = ({ const GlobalHsnCode = useSelector(GlobalprintHsnCode); const GlobalQrcodet = useSelector(GlobalprintQrcodet); const GlobaldummyData = useSelector(GlobalPritdummyData); + console.log(GlobaldummyData, "GlobaldummyData") const GlobalSignature = useSelector(GlobalprintSignature); const GlobaltermsAndConditions = useSelector(GlobalprinttermsAndConditions); const GlobalSignatureImages = useSelector(GlobalSignatureImage); @@ -199,6 +200,7 @@ const Printstyle4 = ({ const TakeawayData = table2Data?.productDetails?.filter( (item) => item.BookingTypeName?.toLowerCase() === 'takeaway' ); + console.log(TakeawayData, "TakeawayData") const DineInData = table2Data?.productDetails?.filter( (item) => item.BookingTypeName?.toLowerCase() === 'dine in' ); @@ -345,6 +347,8 @@ const Printstyle4 = ({ ? paginatedChunks[paginatedChunks.length - 1].length : 0; const shouldFooterBeOnNewPage = lastChunkRows > (PageSize == 'A5' ? 5 : 10); + + console.log(paginatedChunks, 'paginatedChunks') return ( <> {FormatTheme ? ( @@ -489,7 +493,14 @@ const Printstyle4 = ({ >
Dt: {GlobaldummyData ? formattedDate : Date1} + + {SalesModePref?.SettingValue == 'Y' && +
+ {' '} + Name : {table2Data?.SalesMode == "R" ? "RT" : "WS"}{' '} +
}
+
Bill No : {GlobaldummyData @@ -509,8 +520,8 @@ const Printstyle4 = ({ style={{ textTransform: 'uppercase', fontSize: '12px' }} > Estimate{' '} - {SalesModePref?.SettingValue == 'Y' && - `(${table2Data?.SalesMode ? table2Data?.SalesMode : 'R'})`} + {/* {SalesModePref?.SettingValue == 'Y' && + `(${table2Data?.SalesMode ? table2Data?.SalesMode : 'R'})`} */}
)} @@ -528,8 +539,8 @@ const Printstyle4 = ({ : PaymentStatusSuccess?.length === 1 ? PaymentStatusSuccess?.[0]?.PaymentTypeName : ''}{' '} - {SalesModePref?.SettingValue == 'Y' && - `(${table2Data?.SalesMode ? table2Data?.SalesMode : 'R'})`} + {/* {SalesModePref?.SettingValue == 'Y' && + `(${table2Data?.SalesMode ? table2Data?.SalesMode : 'R'})`} */} )}
@@ -698,194 +709,137 @@ const Printstyle4 = ({ {dataChunk?.map((item, index) => { + + const identifiers = item?.ProductIdentifierDtls ?? []; + + const serials = identifiers + .filter(d => d.SerialNumber) + .map(d => d.SerialNumber); + + const imeis = identifiers + .filter(d => d.IMEI1 || d.IMEI2) + .map(d => [d.IMEI1, d.IMEI2].filter(Boolean).join(", ")); + + const descriptions = identifiers + .filter(d => d.Description) + .map(d => d.Description); + + const packageList = PackageDetails?.filter( + pkg => pkg.ProdId === item.ProdId + ) ?? []; + return ( + + {/* SL NO */} {GlobaldummyData ? GlobalSlNo && {index + 1} - : SLNO && ( - - {chunkIndex * chunkSize + index + 1} - - )} + : SLNO && {chunkIndex * chunkSize + index + 1} + } + + {/* ITEM COLUMN */} {GlobaldummyData ? GlobalItem && {item?.ProdName} : Item && ( + {/* Product Name */}
{item?.ProdName}
- {PackageDetails?.filter( - (pkg) => pkg.ProdId === item.ProdId - ).length > 0 ? ( -
- {PackageDetails?.filter( - (pkg) => - pkg.ProdId === item.ProdId - )?.map((item, index) => ( - - {item.ParcelCount} PCS{' '} - {item.ParcelQty} PACK ( - {item.ParcelType}) - - ))} - {( - (item?.ProductIdentifierDtls - ?.length > 0 - ? item?.ProductIdentifierDtls.filter( - (items) => - items.SerialNumber - ) - .map( - (a, index) => - ` ${a.SerialNumber}` - ) - .join('') - : '') + - (item?.ProductIdentifierDtls - ?.length > 0 - ? item?.ProductIdentifierDtls.filter( - (item1) => - item1.IMEI1 || item1.IMEI2 - ) - .map((item2, index) => { - const imei1 = - item2.IMEI1 || ''; - const imei2 = - item2.IMEI2 || ''; - return ` ${[imei1, imei2].filter(Boolean).join(',')}`; - }) - .join('') - : '') - ).trim()} + {/* Package OR Size */} + {packageList.length > 0 ? ( +
+ {packageList.map((pkg, i) => ( +
+ {pkg.ParcelCount} PCS {pkg.ParcelQty} PACK ({pkg.ParcelType}) +
+ ))}
) : (
- {( - (UomPrint?.SettingValue === 'Y' + {(UomPrint?.SettingValue === 'Y' ? (item?.Size || '1') + (item?.SinglePc === 'Y' ? ' PCS' : item?.Type !== 'C' ? ` ${item?.UomName}` : ' COMBO') - : '') + - (item?.BrandName - ? ` ${item?.BrandName}` - : '') + - (item?.ProductIdentifierDtls - ?.length > 0 - ? item?.ProductIdentifierDtls.filter( - (items) => - items.SerialNumber - ) - .map( - (a, index) => - ` ${a.SerialNumber}` - ) - .join('') - : '') + - (item?.ProductIdentifierDtls - ?.length > 0 - ? item?.ProductIdentifierDtls.filter( - (item1) => - item1.IMEI1 || item1.IMEI2 - ) - .map((item2, index) => { - const imei1 = - item2.IMEI1 || ''; - const imei2 = - item2.IMEI2 || ''; - return ` ${[imei1, imei2].filter(Boolean).join(',')}`; - }) - .join('') - : '') - ).trim()} + : '')} + {item?.BrandName || ""}
)} - - )} - {GlobaldummyData - ? GlobalQuantity && ( - - {item?.SalesQty} - - ) - : Quantity && ( - - {item?.SalesQty} - - )} - {GlobaldummyData - ? GlobalHsnCode && ( - - {item?.HSN} - - ) - : HsnCode && ( - - {item?.HSN} - - )} - {GlobaldummyData - ? GlobalMRP && ( - - {item?.MRP} - - ) - : MRP && ( - - {item?.SinglePc === 'Y' - ? item?.Rate - : item?.MRP} - - )} - {GlobaldummyData - ? GlobalDiscount && ( - - {item.discount} - - ) - : Discount && ( - - {item?.Type != 'C' - ? item?.OfferAmt || 0 - : item?.OfferValue || 0} - - )} - {GlobaldummyData - ? GlobalRate && ( - - {item?.Rate} + {/* Serials */} + {serials.map((s, i) => ( +
{s}
+ ))} + + {/* IMEIs */} + {imeis.map((iVal, i) => ( +
{iVal}
+ ))} + + {/* Description - Always New Line */} + + + {descriptions.map((d, i) => ( +
{d}
+ ))} ) - : Rate && ( - - {item?.Rate} - - )} - {GlobaldummyData - ? GlobalAmount && ( - - {item?.TotalAmt} - - ) - : Amount && ( - - {' '} - {item?.Type != 'C' - ? item?.TotalAmt - item?.OfferAmt || 0 - : item?.TotalAmt - item?.OfferValue || - 0} - - )} + } + + {/* Quantity */} + {(GlobaldummyData ? GlobalQuantity : Quantity) && ( + + {item?.SalesQty} + + )} + + {/* HSN */} + {(GlobaldummyData ? GlobalHsnCode : HsnCode) && ( + + {item?.HSN} + + )} + + {/* MRP */} + {(GlobaldummyData ? GlobalMRP : MRP) && ( + + {item?.SinglePc === "Y" ? item?.Rate : item?.MRP} + + )} + + {/* Discount */} + {(GlobaldummyData ? GlobalDiscount : Discount) && ( + + {item?.Type !== "C" + ? item?.OfferAmt || 0 + : item?.OfferValue || 0} + + )} + + {/* Rate */} + {(GlobaldummyData ? GlobalRate : Rate) && ( + + {item?.Rate} + + )} + + {/* Amount */} + {(GlobaldummyData ? GlobalAmount : Amount) && ( + + {item?.Type !== "C" + ? (item?.TotalAmt || 0) - (item?.OfferAmt || 0) + : (item?.TotalAmt || 0) - (item?.OfferValue || 0)} + + )} + ); })} @@ -3195,7 +3149,16 @@ const Printstyle4 = ({ justifyContent: 'space-between', }} > -
Dt: {GlobaldummyData ? formattedDate : Date1}
+
+ Dt: {GlobaldummyData ? formattedDate : Date1} + + {SalesModePref?.SettingValue == 'Y' && +
+ {' '} + Name : {table2Data?.SalesMode == "R" ? "RT" : "WS"}{' '} +
} +
+
Bill No : {GlobaldummyData @@ -3214,8 +3177,8 @@ const Printstyle4 = ({ style={{ textTransform: 'uppercase', fontSize: '12px' }} > Estimate{' '} - {SalesModePref?.SettingValue == 'Y' && - `(${table2Data?.SalesMode ? table2Data?.SalesMode : 'R'})`} + {/* {SalesModePref?.SettingValue == 'Y' && + `(${table2Data?.SalesMode ? table2Data?.SalesMode : 'R'})`} */}
)} @@ -3235,8 +3198,8 @@ const Printstyle4 = ({ : PaymentStatusSuccess?.length === 1 ? PaymentStatusSuccess?.[0]?.PaymentTypeName + ' Bill' : ''}{' '} - {SalesModePref?.SettingValue == 'Y' && - `(${table2Data?.SalesMode ? table2Data?.SalesMode : 'R'})`} + {/* {SalesModePref?.SettingValue == 'Y' && + `(${table2Data?.SalesMode ? table2Data?.SalesMode : 'R'})`} */}
)}
@@ -3370,203 +3333,101 @@ const Printstyle4 = ({ : Item && (
{item?.ProdName}
-
- {PackageDetails?.filter( - (pkg) => pkg.ProdId === item.ProdId - ).length > 0 ? ( -
- {PackageDetails?.filter( - (pkg) => pkg.ProdId === item.ProdId - )?.map((item, index) => ( - - {item.ParcelCount} PCS{' '} - {item.ParcelQty} PACK ( - {item.ParcelType}) - - ))} - {( - (item?.ProductIdentifierDtls - ?.length > 0 - ? item?.ProductIdentifierDtls.filter( - (items) => items.SerialNumber - ) - .map( - (a, index) => - ` ${a.SerialNumber}` - ) - .join('') - : '') + - (item?.ProductIdentifierDtls - ?.length > 0 - ? item?.ProductIdentifierDtls.filter( - (item1) => - item1.IMEI1 || item1.IMEI2 - ) - .map((item2, index) => { - const imei1 = - item2.IMEI1 || ''; - const imei2 = - item2.IMEI2 || ''; - return ` ${[imei1, imei2].filter(Boolean).join(',')}`; - }) - .join('') - : '') - ).trim()} + {/* Serial Numbers */} + {item?.ProductIdentifierDtls + ?.filter(d => d.SerialNumber) + ?.map((d, i) => ( +
+ {d.SerialNumber}
- ) : ( -
- {( - (UomPrint?.SettingValue === 'Y' - ? (item?.Size || '1') + - (item?.SinglePc === 'Y' - ? ' PCS' - : item?.Type !== 'C' - ? ` ${item?.UomName}` - : ' COMBO') - : '') + - (item?.BrandName - ? ` ${item?.BrandName}` - : '') + - (item?.ProductIdentifierDtls - ?.length > 0 - ? item?.ProductIdentifierDtls.filter( - (items) => items.SerialNumber - ) - .map( - (a, index) => - ` ${a.SerialNumber}` - ) - .join('') - : '') + - (item?.ProductIdentifierDtls - ?.length > 0 - ? item?.ProductIdentifierDtls.filter( - (item1) => - item1.IMEI1 || item1.IMEI2 - ) - .map((item2, index) => { - const imei1 = - item2.IMEI1 || ''; - const imei2 = - item2.IMEI2 || ''; - return ` ${[imei1, imei2].filter(Boolean).join(',')}`; - }) - .join('') - : '') - ).trim()} + ))} + + {/* IMEI Numbers */} + {item?.ProductIdentifierDtls + ?.filter(d => d.IMEI1 || d.IMEI2) + ?.map((d, i) => ( +
+ {[d.IMEI1, d.IMEI2].filter(Boolean).join(", ")}
- )} -
+ ))} + + {/* ✅ Description ALWAYS NEW LINE */} + {item?.ProductIdentifierDtls + ?.filter(d => d.Description) + ?.map((d, i) => ( +
+ {d.Description} +
+ ))} )} {GlobaldummyData ? GlobalQuantity && ( {item?.SalesQty} - + +
+ + {/* Package Details */} + {PackageDetails?.filter(pkg => pkg.ProdId === item.ProdId).length > 0 ? ( +
+ {PackageDetails + ?.filter(pkg => pkg.ProdId === item.ProdId) + ?.map((pkg, index) => ( +
+ {pkg.ParcelCount} PCS {pkg.ParcelQty} PACK ({pkg.ParcelType}) +
+ ))} + + {/* Serial */} + {item?.ProductIdentifierDtls + ?.filter(d => d.SerialNumber) + ?.map((d, i) => ( +
+ {d.SerialNumber} +
+ ))} + + {/* IMEI */} + {item?.ProductIdentifierDtls + ?.filter(d => d.IMEI1 || d.IMEI2) + ?.map((d, i) => ( +
+ {[d.IMEI1, d.IMEI2].filter(Boolean).join(', ')} +
+ ))} + + {/* ✅ Description NEW LINE */} + {item?.ProductIdentifierDtls + ?.filter(d => d.Description) + ?.map((d, i) => ( +
+ {d.Description} +
+ ))} + +
+ ) : ( +
+ {UomPrint?.SettingValue === 'Y' && ( + <>({item?.Size || '1'}) {item?.SinglePc === 'Y' ? 'PCS' : item?.Type !== 'C' ? item?.UomName : 'COMBO'} + )} + {item?.BrandName || ""} +
+ )} + +
) : Quantity && ( {item?.SalesQty} - {/*
- {PackageDetails?.filter( - (pkg) => pkg.ProdId === item.ProdId - ).length > 0 ? ( -
- {PackageDetails?.filter( - (pkg) => pkg.ProdId === item.ProdId - )?.map((item, index) => ( - - {item.ParcelCount} PCS{' '} - {item.ParcelQty} PACK ( - {item.ParcelType}) - - ))} - - {( - (item?.ProductIdentifierDtls - ?.length > 0 - ? item?.ProductIdentifierDtls.filter( - (items) => items.SerialNumber - ) - .map( - (a, index) => - ` ${a.SerialNumber}` - ) - .join('') - : '') + - (item?.ProductIdentifierDtls - ?.length > 0 - ? item?.ProductIdentifierDtls.filter( - (item1) => - item1.IMEI1 || item1.IMEI2 - ) - .map((item2, index) => { - const imei1 = - item2.IMEI1 || ''; - const imei2 = - item2.IMEI2 || ''; - return ` ${[imei1, imei2].filter(Boolean).join(',')}`; - }) - .join('') - : '') - ).trim()} -
- ) : ( -
- {( - (item?.Size || '1') + - (item?.SinglePc === 'Y' - ? ' PCS' - : item?.Type !== 'C' - ? ` ${item?.UomName}` - : ' COMBO') + - (item?.BrandName - ? ` ${item?.BrandName}` - : '') + - (item?.ProductIdentifierDtls - ?.length > 0 - ? item?.ProductIdentifierDtls.filter( - (items) => items.SerialNumber - ) - .map( - (a, index) => - ` ${a.SerialNumber}` - ) - .join('') - : '') + - (item?.ProductIdentifierDtls - ?.length > 0 - ? item?.ProductIdentifierDtls.filter( - (item1) => - item1.IMEI1 || item1.IMEI2 - ) - .map((item2, index) => { - const imei1 = - item2.IMEI1 || ''; - const imei2 = - item2.IMEI2 || ''; - return ` ${[imei1, imei2].filter(Boolean).join(',')}`; - }) - .join('') - : '') - ).trim()} -
- )} -
*/} )} {GlobaldummyData @@ -3689,6 +3550,7 @@ const Printstyle4 = ({
)} + {DineInData?.length > 0 && ( <>
{item?.ProdName}
+ {( + (item?.ProductIdentifierDtls + ?.length > 0 + ? item?.ProductIdentifierDtls.filter( + (items) => items.SerialNumber + ) + .map( + (a, index) => + ` ${a.SerialNumber}` + ) + .join('') + : '') + + (item?.ProductIdentifierDtls + ?.length > 0 + ? item?.ProductIdentifierDtls.filter( + (item1) => + item1.IMEI1 || item1.IMEI2 + ) + .map((item2) => { + const imei1 = + item2.IMEI1 || ''; + const imei2 = + item2.IMEI2 || ''; + return ` ${[imei1, imei2].filter(Boolean).join(',')}`; + }) + .join('') + : '') + + + (item?.ProductIdentifierDtls + ?.length > 0 + ? item?.ProductIdentifierDtls.filter( + (item1) => + item1.IMEI1 || item1.IMEI2 || item1.SerialNumber + ) + .map((item2) => { + return ` ${item2?.Description}`; + }) + .join('') + : '') + ).trim()} )} {GlobaldummyData @@ -3840,15 +3742,15 @@ const Printstyle4 = ({ {item?.SalesQty} {UomPrint?.SettingValue === 'Y' && -
- ({item?.Size ? item?.Size : '1'}{' '} - {item?.SinglePc == 'Y' - ? 'PCS' - : item?.Type != 'C' - ? item?.UomName - : 'COMBO'} - ) -
+
+ ({item?.Size ? item?.Size : '1'}{' '} + {item?.SinglePc == 'Y' + ? 'PCS' + : item?.Type != 'C' + ? item?.UomName + : 'COMBO'} + ) +
} )} @@ -3946,6 +3848,7 @@ const Printstyle4 = ({ )}
+
+ {/*
+
OVER ALL QTY
+
+ {GlobaldummyData + ? '1,066' + : Number(productsData?.reduce((a, b) => a + b.SalesQty, 0))} +
+
*/} +
+
+
ITEM :
+
+ {GlobaldummyData + ? '1,066' + : productsData?.length} +
+
+
+
QTY :
+
+ {GlobaldummyData + ? '1,066' + : Number(productsData?.reduce((a, b) => a + b.SalesQty, 0))} +
+
+ +
{/*