import React from 'react' import { useDispatch, useSelector } from "react-redux"; import moment from "moment"; import { getSession } from '../../../../Services/Others'; import { getBranchDetail } from '../../../../Features/BrachLogin/BranchLogin'; import { GlobalprintSlNo, GlobalprintItem, GlobalprintMRP, GlobalprintDiscount, GlobalprintQuantity, GlobalprintRate, GlobalprintAmount, GlobalprintHsnCode, GlobalprintQrcodet, GlobalPritdummyData } from '../../../../Features/ThemeChange/ThemeChange'; import '../../../../Styles/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle13.scss'; const PrintStyle13 = ({ orderId, CreatedDate, singleData2, table2Data, ExtraChargeDetails }) => { let OfferAmount = table2Data?.OrderOfferDetails?.reduce((acc, item) => { return acc + item.OfferAmount; }, 0); const GlobalSlNo = useSelector(GlobalprintSlNo) const GlobalItem = useSelector(GlobalprintItem) const GlobalMRP = useSelector(GlobalprintMRP) const GlobalDiscount = useSelector(GlobalprintDiscount) const GlobalQuantity = useSelector(GlobalprintQuantity) const GlobalRate = useSelector(GlobalprintRate) const GlobalAmount = useSelector(GlobalprintAmount) const GlobalHsnCode = useSelector(GlobalprintHsnCode) const GlobalQrcodet = useSelector(GlobalprintQrcodet) const GlobaldummyData = useSelector(GlobalPritdummyData) const dispatch = useDispatch(); const BranchId = getSession("BranchId"); const CashierName = getSession("userName") const Date1 = moment(CreatedDate).format('dddd, MMMM D, YYYY | hh:mmA'); const [BranchLogo, setBranchLogo] = useState(null) const [BranchAddress, setBranchAddress] = useState() const [BranchCity, setBranchCity] = useState() const [BranchZip, setBranchZip] = useState() const PackageDetails = table2Data?.PackageDtl; let totalQuantityFilter = table2Data?.productDetails?.map((item) => (item?.SalesQty)) const totalQuantity = totalQuantityFilter?.reduce( (accumulator, currentValue) => accumulator + currentValue, 0, ); const ExtraChargeTotal = table2Data?.ExtraChargeDetails?.reduce((accumulator, currentObject) => { return accumulator + currentObject.TotalAmt }, 0) const [base64Image, setBase64Image] = useState(null); const [conversionError, setConversionError] = useState(null); const OrderDetailGST = table2Data?.TaxDetails?.filter(item => item.TaxIdName === "CGST,SGST") const OrderDetailIGST = table2Data?.TaxDetails?.filter(item => item.TaxIdName === "IGST") const OrderDetailVAT = table2Data?.TaxDetails?.filter(item => item.TaxIdName === "VAT") useEffect(() => { fetchBranchData() }, []) useEffect(() => { async function fetchImage() { try { const base64 = await imageUrlToBase64(BranchLogo); setBase64Image(base64); } catch (error) { setConversionError(error.message || 'Error converting image'); } } if (BranchLogo) { fetchImage(); } }, [BranchLogo]); const fetchBranchData = async () => { const response = await dispatch(getBranchDetail({ BrId: BranchId })).unwrap(); if (response?.data?.statusCode === 1) { setBranchAddress(response?.data?.data?.[0]?.Address1) setBranchCity(response?.data?.data?.[0]?.City) setBranchZip(response?.data?.data?.[0]?.Zip) setBranchLogo(response?.data?.data?.[0]?.CompLogo) } else { setBranchAddress() setBranchCity() setBranchZip() setBranchLogo() } } const imageUrlToBase64 = async (url) => { try { const response = await fetch(url); const blob = await response.blob(); return new Promise((resolve, reject) => { const reader = new FileReader(); reader.onloadend = () => resolve(reader.result); reader.onerror = reject; reader.readAsDataURL(blob); }); } catch (error) { console.error('Error fetching or converting image:', error); throw error; } }; const products = [ { ProdName: 'BUTTER NAAN', Rate: 88.00, SalesQty: 2, MRP: 100, TotalAmt: 176, discount: 0, HSN: 0 }, { ProdName: 'GRILL CHICKEN (f)', Rate: 300.00, SalesQty: 1, MRP: 350, TotalAmt: 300, discount: 0, HSN: 0 }, { ProdName: 'TANDOORI CHICKEN (H) ', Rate: 200.00, SalesQty: 1, MRP: 250, TotalAmt: 200, discount: 0, HSN: 0 }, { ProdName: 'KULFI', Rate: 30.00, SalesQty: 1, MRP: 50, TotalAmt: 30, discount: 0, HSN: 0 }, { ProdName: 'Laddu', Rate: 30.00, SalesQty: 1, MRP: 50, TotalAmt: 30, discount: 0, HSN: 0 }, { ProdName: 'Chicken Biryani', Rate: 130.00, SalesQty: 1, MRP: 150, TotalAmt: 130, discount: 0, HSN: 0 }, { ProdName: 'Mutton Biryani', Rate: 230.00, SalesQty: 1, MRP: 250, TotalAmt: 230, discount: 0, HSN: 0 }, ]; return (
INVOICE
POZO RESTAURANT
HOSUR, TAMILNADU
Invoice No :553
Date : 02/12/12 - 07:20:00 Pm

HOTEL POZO
51 STEP COLONY, DHARGA, HOSUR KRISHNAGIRI - 635126 TAMILNADU
GST NO : 8907906906
PH : 8907906906
CIN NO : 8907906906
FSSL : 8907906906

INVOICE TO
Tamil Selvan
51 STEP COLONY, DHARGA, HOSUR
PH:8907906906

Bank Details :
Account Name :
Tamil Selvan
CIN NO : 8907906906

{GlobalSlNo &&
SL.No
}
{GlobalItem && 'ITEM /DESCRIPTION /'} {GlobalQuantity && 'QTY'}
{GlobalHsnCode &&
HSN
} {GlobalMRP && MRP} {GlobalRate &&
Price
} {GlobalDiscount && (%)} {GlobalAmount &&
Total
}

{(GlobaldummyData ? products : singleData2)?.map((item, index) => (
{GlobalSlNo &&
{index + 1}
}
{GlobalItem && ( <> {item?.ProdName} {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})
) ) ) : ( ({item?.Size ? item?.Size : "1"} {item?.SinglePc === "Y" ? "PCS" : item?.Type !== "C" ? item?.UomName : "COMBO"} ) )} {" - "} {GlobalQuantity && item?.SalesQty} )}
{GlobalHsnCode &&
{item?.HSN}
} {GlobalMRP &&
{item?.MRP}
} {GlobalRate &&
{item?.Rate}
} {GlobalDiscount &&
{item?.discount}
} {GlobalAmount &&
{item?.TotalAmt}
}
))}
CGST% CGST Amt SGST% IGST% IGST Amt
6.00% 7.99 6.00% 7.99 0.00
Total Item :
100
Qty:
100
Extra Charges :
100
Discount :
100
Total :
100
Net Amount :
100.00
Net Total In Word : One Hundred twenty six only
Terms & Condition
Menu available everyday 11.30am onwards (Lunch and Dinner)
Authorised Signatory
Thank You Visit Again.!
{/*
print
*/}
) } export default PrintStyle13