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 ( <>
| S.No | Name | Qty | Rate | Tax | Amt |
|---|---|---|---|---|---|
| {index + 1} | {item?.ServiceName} | {item?.Qty} | {item?.Rate} | {item?.TaxAmount} | {item?.TotalAmount} |