import { useDispatch, useSelector } from "react-redux"; import { dateFormatChange1 } from "../../../../Services/Others"; import { GlobalPritdummyData, changeReprintDataFound, } from "../../../../Features/ThemeChange/ThemeChange"; import "../../../../Styles/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle1.scss"; import QRCode from "react-qr-code"; import { ApplicationPreferences } from "../../../../Features/BrachLogin/BranchLogin"; const OtherServicePrintStyle1 = ({ table2Data, PaymentStatus, printDatas, }) => { const dispatch = useDispatch(); const GlobaldummyData = useSelector(GlobalPritdummyData); const appPreferences = useSelector(ApplicationPreferences); const bookingTypePreference = appPreferences?.find((preference) => preference?.PreferredCatName === 'Booking Type')?.PreferenceCatDetails const takeAwayPreference = bookingTypePreference?.find((type) => type?.PreferredSubCatName?.toLowerCase() === "take away" && type?.PreferredStatus === 'Y') const keysLength = Object.keys(table2Data ?? {}).length; let FormatTheme = printDatas?.PrintType == "S" ? true : false let PageSize = printDatas?.PageSize console.log("table2Datatable2Datatable2Datatable2Data", table2Data,table2Data?.[0]?.BranchName ); if (keysLength > 0) { dispatch(changeReprintDataFound(true)); } const formattedDate =dateFormatChange1(table2Data?.[0]?.CreatedDate); // `${day}-${monthNames[monthIndex]}-${year}`; const TakeawayData = table2Data?.productDetails?.filter( (item) => item.BookingTypeName?.toLowerCase() === "takeaway" ); const DineInData = table2Data?.productDetails?.filter( (item) => item.BookingTypeName?.toLowerCase() === "dine in" ); const offers = table2Data?.OrderOfferDetails || []; // Calculate SalesWiseOffers total amount offers.forEach(offer => { if (offer.TableName === 'SalesWiseOffers') { TotalOfferAmount += offer.OfferAmount; } }); const products = [ { ProdName: "ITEM 1", Rate: 88.0, SalesQty: 2, MRP: 100, TotalAmt: 176, discount: 0, HSN: "01", }, { ProdName: "ITEM 2", Rate: 300.0, SalesQty: 1, MRP: 350, TotalAmt: 300, discount: 0, HSN: "02", }, { ProdName: "ITEM 3", Rate: 200.0, SalesQty: 1, MRP: 250, TotalAmt: 200, discount: 0, HSN: "03", }, { ProdName: "ITEM 4", Rate: 30.0, SalesQty: 1, MRP: 50, TotalAmt: 30, discount: 0, HSN: "04", }, { ProdName: "ITEM 5", Rate: 30.0, SalesQty: 1, MRP: 50, TotalAmt: 30, discount: 0, HSN: "05", }, { ProdName: "ITEM 6", Rate: 130.0, SalesQty: 1, MRP: 150, TotalAmt: 130, discount: 0, HSN: "06", }, { ProdName: "ITEM 7", Rate: 230.0, SalesQty: 1, MRP: 250, TotalAmt: 230, discount: 0, HSN: "08", }, ]; const chunkSize = PageSize == "A5" ? 8 : 11; let dataSource = []; if (GlobaldummyData || TakeawayData?.length > 0) { dataSource = GlobaldummyData ? products : TakeawayData; } else if (DineInData?.length > 0) { dataSource = DineInData; } // Paginate the data const paginatedChunks = []; for (let i = 0; i < dataSource.length; i += chunkSize) { paginatedChunks.push(dataSource.slice(i, i + chunkSize)); } const lastChunkRows = paginatedChunks.length > 0 ? paginatedChunks[paginatedChunks.length - 1].length : 0; const shouldFooterBeOnNewPage = lastChunkRows > (PageSize == "A5" ? 5 : 10); console.log(paginatedChunks,"paginatedChunkspaginatedChunkspaginatedChunks"); return ( <>
{" "} {table2Data?.[0]?.BranchName ? table2Data?.[0].BranchName : "" }
{ (table2Data?.[0]?.Address1 || "") + (table2Data?.[0]?.City ? (table2Data?.[0]?.Address1 && table2Data?.[0]?.City ? "-" : "") + table2Data?.[0]?.City : "") + (table2Data?.[0]?.Zip ? (table2Data?.[0]?.City && table2Data?.[0]?.Zip ? "-" : "") + table2Data?.[0]?.Zip : "")}
{" "} Mobile : +91 {GlobaldummyData ? "986XXXXXXX" : table2Data?.[0]?.BrMobileNo}

{/* orderdetails */}
{" "} BillNo: {table2Data?.[0]?.TicketNo ? table2Data?.[0]?.TicketNo :" "}
{" "} Date : {table2Data?.[0]?.CreatedDate ? formattedDate : table2Data?.[0]?.CreatedDate }{" "}
{/* orderdetails */}
{/* itemdata (loop) */}
{/* {(TakeawayData?.length > 0 || GlobaldummyData) && ( */} <> {takeAwayPreference &&
Other Services
}
{table2Data?.[0]?.OtherServicesTicketDetails?.map( (item, index) => ( ) )}
S.No Name Qty Rate Tax Amt
{index + 1} {item?.ServiceName} {item?.Qty} {item?.Rate} {item?.TaxAmount} {item?.TotalAmount}
<>
{" "} BillAmount:₹{table2Data?.[0]?.BillAmount}
{table2Data?.[0]?.TaxAmount > 0 &&
TaxAmount :₹ {(table2Data?.[0]?.TaxAmount?table2Data?.[0]?.TaxAmount:"")}
}
Amount :₹ {(table2Data?.[0]?.NetAmount?table2Data?.[0]?.NetAmount:"")}
Payment Type : {(table2Data?.[0]?.PaymentTypeName?table2Data?.[0]?.PaymentTypeName:"")}
Thank You Visit Again
{/* QR CODE */}
{/* QRcode */}
); }; export default OtherServicePrintStyle1;