diff --git a/src/Pages/PurchaseReturn/PrintReturn/A4purchaseReturn/A4Standard.jsx b/src/Pages/PurchaseReturn/PrintReturn/A4purchaseReturn/A4Standard.jsx index bd5dd5e..3699853 100644 --- a/src/Pages/PurchaseReturn/PrintReturn/A4purchaseReturn/A4Standard.jsx +++ b/src/Pages/PurchaseReturn/PrintReturn/A4purchaseReturn/A4Standard.jsx @@ -1,3 +1,16 @@ +import { useSelector } from 'react-redux'; +import { + GlobalRowType, + GlobalSelectedFooterColor, + GlobalSelectedFooterFontColor, + GlobalSelectedPrintHeaderColor, + GlobalSelectedPrintHeaderFontColor, + GlobalSelectedTableBodyColor, + GlobalSelectedTableBodyFontColor, + GlobalSelectedTableHeaderColor, + GlobalSelectedTableHeaderFontColor, +} from '../../../../Features/ThemeChange/ThemeChange'; + const A4Standard = ({ invoiceData, preference, printDatas, FieldDetails }) => { const { InvoiceNo, @@ -50,7 +63,8 @@ const A4Standard = ({ invoiceData, preference, printDatas, FieldDetails }) => { 0 ); const totalAmountBeforeTax = ProductDetails?.reduce( - (sum, item) => sum + Math.floor((Number(item?.NetAmount-item?.TaxAmount))|| 0), + (sum, item) => + sum + Math.floor(Number(item?.NetAmount - item?.TaxAmount) || 0), 0 ); const totalAmountAfterTax = ProductDetails?.reduce( @@ -117,6 +131,59 @@ const A4Standard = ({ invoiceData, preference, printDatas, FieldDetails }) => { ); return num; } + + // + const SelectedHeaderColor = useSelector(GlobalSelectedPrintHeaderColor); + const SelectedHeaderFontColor = useSelector( + GlobalSelectedPrintHeaderFontColor + ); + const SelectedTableHeaderColor = useSelector(GlobalSelectedTableHeaderColor); + const SelectedTableHeaderFontColor = useSelector( + GlobalSelectedTableHeaderFontColor + ); + const SelectedTableBodyColor = useSelector(GlobalSelectedTableBodyColor); + const SelectedTableBodyFontColor = useSelector( + GlobalSelectedTableBodyFontColor + ); + const SelectedRowType = useSelector(GlobalRowType); + const SelectedTableFooterColor = useSelector(GlobalSelectedFooterColor); + const SelectedTableFooterFontColor = useSelector( + GlobalSelectedFooterFontColor + ); + + // + let printColors = FieldDetails?.PrintColors; + const headerColor = printColors?.find((obj) => obj.headerColor)?.headerColor; + const tableHeaderColor = printColors?.find( + (obj) => obj.tableHeaderColor + )?.tableHeaderColor; + const tableBodyColor = printColors?.find( + (obj) => obj.tableBodyColor + )?.tableBodyColor; + const footerColor = printColors?.find((obj) => obj.footerColor)?.footerColor; + + // + const headerStyle = { + backgroundColor: headerColor?.background, + color: headerColor?.font, + }; + const tableHeaderStyle = { + backgroundColor: tableHeaderColor?.background, + color: tableHeaderColor?.font, + }; + + const tableBodyStyle = { + backgroundColor: tableBodyColor?.background, + color: tableBodyColor?.font, + }; + + const rowtypeStyle = tableBodyColor?.rowType; + + const footerColorStyle = { + backgroundColor: footerColor?.background, + color: footerColor?.font, + }; + return ( <>
-
+
{branch.CompName}
{' '} @@ -313,27 +380,32 @@ const A4Standard = ({ invoiceData, preference, printDatas, FieldDetails }) => {
- {/* - { label: 'S.No', key: 'sno', width: '5%' }, - { label: 'Product', key: 'ProdName', width: '20%' }, - { label: 'Purchased Qty', key: 'Qty', width: '10%' }, - { label: 'Returned Qty', key: 'ReturnedQty', width: '10%' }, - { label: 'Rate', key: 'ProductRate', width: '10%' }, - { label: 'Tax', key: 'TaxAmount', width: '10%' }, - { label: 'Total', key: 'TotalAmount', width: '15%' }, */} - - - - - - - - + + + + + + + + {ProductDetails?.map((e, index) => ( - + @@ -343,11 +415,6 @@ const A4Standard = ({ invoiceData, preference, printDatas, FieldDetails }) => { ))} - {/* - - - - */}
S.NoProductPurchased QtyReturned QtyRateTaxTotal
S.NoProductPurchased QtyReturned QtyRateTaxTotal
{index + 1} {e?.ProdName} {e?.PurQty}{e?.NetAmount}
1ITEM 1012100880
2ITEM 20213503000300
3ITEM 30312502000200
4ITEM 40415030030
5ITEM 50515030030
@@ -412,7 +479,7 @@ const A4Standard = ({ invoiceData, preference, printDatas, FieldDetails }) => { -
+
{bank?.AccountNo && ( <> diff --git a/src/Pages/PurchaseReturn/PrintReturn/A4purchaseReturn/PrintA4Style11.jsx b/src/Pages/PurchaseReturn/PrintReturn/A4purchaseReturn/PrintA4Style11.jsx index 1891eb0..41ffd54 100644 --- a/src/Pages/PurchaseReturn/PrintReturn/A4purchaseReturn/PrintA4Style11.jsx +++ b/src/Pages/PurchaseReturn/PrintReturn/A4purchaseReturn/PrintA4Style11.jsx @@ -1,5 +1,16 @@ import { useSelector } from 'react-redux'; -import { GloabalFieldDetails } from '../../../../Features/ThemeChange/ThemeChange'; +import { + GloabalFieldDetails, + GlobalRowType, + GlobalSelectedFooterColor, + GlobalSelectedFooterFontColor, + GlobalSelectedPrintHeaderColor, + GlobalSelectedPrintHeaderFontColor, + GlobalSelectedTableBodyColor, + GlobalSelectedTableBodyFontColor, + GlobalSelectedTableHeaderColor, + GlobalSelectedTableHeaderFontColor, +} from '../../../../Features/ThemeChange/ThemeChange'; const PrintStyleDCToInvoice1 = ({ invoiceData, @@ -49,6 +60,58 @@ const PrintStyleDCToInvoice1 = ({ const lastChunkRows = paginatedChunks.at(-1)?.length || 0; const shouldFooterBeOnNewPage = lastChunkRows > (pageSize === 'A5' ? 5 : 10); + // + const SelectedHeaderColor = useSelector(GlobalSelectedPrintHeaderColor); + const SelectedHeaderFontColor = useSelector( + GlobalSelectedPrintHeaderFontColor + ); + const SelectedTableHeaderColor = useSelector(GlobalSelectedTableHeaderColor); + const SelectedTableHeaderFontColor = useSelector( + GlobalSelectedTableHeaderFontColor + ); + const SelectedTableBodyColor = useSelector(GlobalSelectedTableBodyColor); + const SelectedTableBodyFontColor = useSelector( + GlobalSelectedTableBodyFontColor + ); + const SelectedRowType = useSelector(GlobalRowType); + const SelectedTableFooterColor = useSelector(GlobalSelectedFooterColor); + const SelectedTableFooterFontColor = useSelector( + GlobalSelectedFooterFontColor + ); + + // + let printColors = FieldDetails?.PrintColors; + const headerColor = printColors?.find((obj) => obj.headerColor)?.headerColor; + const tableHeaderColor = printColors?.find( + (obj) => obj.tableHeaderColor + )?.tableHeaderColor; + const tableBodyColor = printColors?.find( + (obj) => obj.tableBodyColor + )?.tableBodyColor; + const footerColor = printColors?.find((obj) => obj.footerColor)?.footerColor; + + // + const headerStyle = { + backgroundColor: headerColor?.background, + color: headerColor?.font, + }; + const tableHeaderStyle = { + backgroundColor: tableHeaderColor?.background, + color: tableHeaderColor?.font, + }; + + const tableBodyStyle = { + backgroundColor: tableBodyColor?.background, + color: tableBodyColor?.font, + }; + + const rowtypeStyle = tableBodyColor?.rowType; + + const footerColorStyle = { + backgroundColor: footerColor?.background, + color: footerColor?.font, + }; + const renderFooter = () => ( <> {/*
*/} @@ -60,7 +123,10 @@ const PrintStyleDCToInvoice1 = ({ <>
{/* {notesText &&

{notesText}

} */} -
+
{termsAndConditions && termsAndConditionsData?.length > 0 && (

Terms & Conditions

@@ -261,6 +327,7 @@ const PrintStyleDCToInvoice1 = ({ branch={branch} CustName={CustName} SupplierNo={SupplierNo} + headerStyle={headerStyle} /> {/*
*/} ) : null} - + {isLastPage && ( <> {/*
*/} @@ -329,6 +401,7 @@ const PrintStyleDCToInvoice1 = ({ branch={branch} CustName={CustName} SupplierNo={SupplierNo} + headerStyle={headerStyle} /> {/*
*/} @@ -342,7 +415,12 @@ const PrintStyleDCToInvoice1 = ({ SupplierNo={SupplierNo} />
- + ( -
+const Header = ({ logo, branch, CustName, SupplierNo, headerStyle }) => ( +
); -const ProductTable = ({ data }) => { +const ProductTable = ({ + data, + tableHeaderStyle, + rowtypeStyle, + tableBodyStyle, +}) => { const columns = [ { label: 'S.No', key: 'sno', width: '5%' }, { label: 'Product', key: 'ProdName', width: '30%', align: 'left' }, @@ -440,7 +523,11 @@ const ProductTable = ({ data }) => { {columns.map((col) => ( @@ -486,7 +584,7 @@ const Summary = ({ TotalAmount, TaxAmount, GrandTotal }) => ( width: '100%', flexDirection: 'row-reverse', backgroundColor: '#999999', - marginTop:"10px" + marginTop: '10px', }} >
@@ -527,7 +625,7 @@ const Summary = ({ TotalAmount, TaxAmount, GrandTotal }) => ( padding: '10px', backgroundColor: 'rgb(253, 199, 22)', textAlign: 'center', - borderBottom: "1px dashed black" + borderBottom: '1px dashed black', }} > {' '} diff --git a/src/Pages/PurchaseReturn/PrintReturn/A4purchaseReturn/PrintStyleA5.jsx b/src/Pages/PurchaseReturn/PrintReturn/A4purchaseReturn/PrintStyleA5.jsx index 9105cbe..b3430bf 100644 --- a/src/Pages/PurchaseReturn/PrintReturn/A4purchaseReturn/PrintStyleA5.jsx +++ b/src/Pages/PurchaseReturn/PrintReturn/A4purchaseReturn/PrintStyleA5.jsx @@ -1,5 +1,16 @@ import { useSelector } from 'react-redux'; -import { GloabalFieldDetails } from '../../../../Features/ThemeChange/ThemeChange'; +import { + GloabalFieldDetails, + GlobalRowType, + GlobalSelectedFooterColor, + GlobalSelectedFooterFontColor, + GlobalSelectedPrintHeaderColor, + GlobalSelectedPrintHeaderFontColor, + GlobalSelectedTableBodyColor, + GlobalSelectedTableBodyFontColor, + GlobalSelectedTableHeaderColor, + GlobalSelectedTableHeaderFontColor, +} from '../../../../Features/ThemeChange/ThemeChange'; const PrintStyleDCToInvoice1 = ({ invoiceData, @@ -49,6 +60,58 @@ const PrintStyleDCToInvoice1 = ({ const lastChunkRows = paginatedChunks.at(-1)?.length || 0; const shouldFooterBeOnNewPage = lastChunkRows > (pageSize === 'A5' ? 5 : 10); + // + const SelectedHeaderColor = useSelector(GlobalSelectedPrintHeaderColor); + const SelectedHeaderFontColor = useSelector( + GlobalSelectedPrintHeaderFontColor + ); + const SelectedTableHeaderColor = useSelector(GlobalSelectedTableHeaderColor); + const SelectedTableHeaderFontColor = useSelector( + GlobalSelectedTableHeaderFontColor + ); + const SelectedTableBodyColor = useSelector(GlobalSelectedTableBodyColor); + const SelectedTableBodyFontColor = useSelector( + GlobalSelectedTableBodyFontColor + ); + const SelectedRowType = useSelector(GlobalRowType); + const SelectedTableFooterColor = useSelector(GlobalSelectedFooterColor); + const SelectedTableFooterFontColor = useSelector( + GlobalSelectedFooterFontColor + ); + + // + let printColors = FieldDetails?.PrintColors; + const headerColor = printColors?.find((obj) => obj.headerColor)?.headerColor; + const tableHeaderColor = printColors?.find( + (obj) => obj.tableHeaderColor + )?.tableHeaderColor; + const tableBodyColor = printColors?.find( + (obj) => obj.tableBodyColor + )?.tableBodyColor; + const footerColor = printColors?.find((obj) => obj.footerColor)?.footerColor; + + // + const headerStyle = { + backgroundColor: headerColor?.background, + color: headerColor?.font, + }; + const tableHeaderStyle = { + backgroundColor: tableHeaderColor?.background, + color: tableHeaderColor?.font, + }; + + const tableBodyStyle = { + backgroundColor: tableBodyColor?.background, + color: tableBodyColor?.font, + }; + + const rowtypeStyle = tableBodyColor?.rowType; + + const footerColorStyle = { + backgroundColor: footerColor?.background, + color: footerColor?.font, + }; + const renderFooter = () => ( <> {/*
*/} @@ -60,7 +123,10 @@ const PrintStyleDCToInvoice1 = ({ <>
{/* {notesText &&

{notesText}

} */} -
+
{termsAndConditions && termsAndConditionsData?.length > 0 && (

Terms & Conditions

@@ -261,6 +327,7 @@ const PrintStyleDCToInvoice1 = ({ branch={branch} CustName={CustName} SupplierNo={SupplierNo} + headerStyle={headerStyle} /> {/*
*/} ) : null} - + {isLastPage && ( <> {/*
*/} @@ -329,6 +401,7 @@ const PrintStyleDCToInvoice1 = ({ branch={branch} CustName={CustName} SupplierNo={SupplierNo} + headerStyle={headerStyle} /> {/*
*/} @@ -342,7 +415,12 @@ const PrintStyleDCToInvoice1 = ({ SupplierNo={SupplierNo} />
- + ( -
+const Header = ({ logo, branch, CustName, SupplierNo, headerStyle }) => ( +
); -const ProductTable = ({ data }) => { +const ProductTable = ({ + data, + tableHeaderStyle, + tableBodyStyle, + rowtypeStyle, +}) => { const columns = [ { label: 'S.No', key: 'sno', width: '5%' }, { label: 'Product', key: 'ProdName', width: '30%', align: 'left' }, @@ -440,7 +523,11 @@ const ProductTable = ({ data }) => {
{ {data.map((prod, index) => (
{index + 1} {prod.ProdName}
{columns.map((col) => ( @@ -486,7 +584,7 @@ const Summary = ({ TotalAmount, TaxAmount, GrandTotal }) => ( width: '100%', flexDirection: 'row-reverse', backgroundColor: '#999999', - marginTop:"10px" + marginTop: '10px', }} >
@@ -527,7 +625,7 @@ const Summary = ({ TotalAmount, TaxAmount, GrandTotal }) => ( padding: '10px', backgroundColor: 'rgb(253, 199, 22)', textAlign: 'center', - borderBottom: "1px dashed black" + borderBottom: '1px dashed black', }} > {' '} diff --git a/src/Pages/PurchaseReturn/PrintReturn/A4purchaseReturn/PurchaseTaxInvoice.jsx b/src/Pages/PurchaseReturn/PrintReturn/A4purchaseReturn/PurchaseTaxInvoice.jsx index f34af78..c0a99ae 100644 --- a/src/Pages/PurchaseReturn/PrintReturn/A4purchaseReturn/PurchaseTaxInvoice.jsx +++ b/src/Pages/PurchaseReturn/PrintReturn/A4purchaseReturn/PurchaseTaxInvoice.jsx @@ -2,859 +2,2018 @@ import { useSelector } from 'react-redux'; import { isMobile } from 'react-device-detect'; import moment from 'moment'; -import { GlobalPritdummyData } from '../../../../Features/ThemeChange/ThemeChange'; +import { + GlobalPritdummyData, + GlobalRowType, + GlobalSelectedFooterColor, + GlobalSelectedFooterFontColor, + GlobalSelectedPrintHeaderColor, + GlobalSelectedPrintHeaderFontColor, + GlobalSelectedTableBodyColor, + GlobalSelectedTableBodyFontColor, + GlobalSelectedTableHeaderColor, + GlobalSelectedTableHeaderFontColor, +} from '../../../../Features/ThemeChange/ThemeChange'; import { extractLastNumberOrderId } from '../../../../Services/Others'; const PurchaseTaxInvoice = ({ - index, - table2Data, - Date1, - totalQuantity, - OrderDetailGST, - OrderDetailIGST, - PaymentStatus, - BranchData, - printDatas, - PurchaseInvoiceData, - BankDetails, + index, + table2Data, + Date1, + totalQuantity, + OrderDetailGST, + OrderDetailIGST, + PaymentStatus, + BranchData, + printDatas, + PurchaseInvoiceData, + BankDetails, }) => { + const GlobaldummyData = useSelector(GlobalPritdummyData); + let BillName = printDatas?.PrintHdrName; - const GlobaldummyData = useSelector(GlobalPritdummyData); - let BillName = printDatas?.PrintHdrName; + // Function to convert number to words + const numberToWords = (num) => { + const a = [ + '', + 'One', + 'Two', + 'Three', + 'Four', + 'Five', + 'Six', + 'Seven', + 'Eight', + 'Nine', + 'Ten', + 'Eleven', + 'Twelve', + 'Thirteen', + 'Fourteen', + 'Fifteen', + 'Sixteen', + 'Seventeen', + 'Eighteen', + 'Nineteen', + ]; + const b = [ + '', + '', + 'Twenty', + 'Thirty', + 'Forty', + 'Fifty', + 'Sixty', + 'Seventy', + 'Eighty', + 'Ninety', + ]; - // Function to convert number to words - const numberToWords = (num) => { - const a = [ - "", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", - "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", - "Eighteen", "Nineteen" - ]; - const b = ["", "", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"]; + if (num === 0) return 'Zero'; + if (num < 20) return a[num]; + if (num < 100) + return b[Math.floor(num / 10)] + (num % 10 ? ' ' + a[num % 10] : ''); + if (num < 1000) + return ( + a[Math.floor(num / 100)] + + ' Hundred' + + (num % 100 ? ' and ' + numberToWords(num % 100) : '') + ); + if (num < 100000) + return ( + numberToWords(Math.floor(num / 1000)) + + ' Thousand' + + (num % 1000 ? ' ' + numberToWords(num % 1000) : '') + ); + if (num < 10000000) + return ( + numberToWords(Math.floor(num / 100000)) + + ' Lakh' + + (num % 100000 ? ' ' + numberToWords(num % 100000) : '') + ); + if (num < 1000000000) + return ( + numberToWords(Math.floor(num / 10000000)) + + ' Crore' + + (num % 10000000 ? ' ' + numberToWords(num % 10000000) : '') + ); - if (num === 0) return "Zero"; - if (num < 20) return a[num]; - if (num < 100) return b[Math.floor(num / 10)] + (num % 10 ? " " + a[num % 10] : ""); - if (num < 1000) - return a[Math.floor(num / 100)] + " Hundred" + (num % 100 ? " and " + numberToWords(num % 100) : ""); - if (num < 100000) - return numberToWords(Math.floor(num / 1000)) + " Thousand" + (num % 1000 ? " " + numberToWords(num % 1000) : ""); - if (num < 10000000) - return numberToWords(Math.floor(num / 100000)) + " Lakh" + (num % 100000 ? " " + numberToWords(num % 100000) : ""); - if (num < 1000000000) - return numberToWords(Math.floor(num / 10000000)) + " Crore" + (num % 10000000 ? " " + numberToWords(num % 10000000) : ""); + return 'Number too large'; + }; - return "Number too large"; - }; + // Fixed data mapping with proper fallbacks + const invoiceData = { + // Company Details - with proper fallbacks + companyName: + printDatas?.companyName || + PurchaseInvoiceData?.AddressDetails?.[0]?.CompName || + BranchData?.BrName || + table2Data?.BrName || + 'Company Name', + companyspecname: + printDatas?.companyspecname || table2Data?.AppSpecificName || '', + companyAddress: { + address1: + printDatas?.companyAddress?.address1 || + PurchaseInvoiceData?.AddressDetails?.[0]?.Address1 || + BranchData?.Address1 || + '', + address2: + printDatas?.companyAddress?.address2 || + PurchaseInvoiceData?.AddressDetails?.[0]?.Address2 || + BranchData?.Address2 || + '', + city: + printDatas?.companyAddress?.city || + PurchaseInvoiceData?.AddressDetails?.[0]?.City || + BranchData?.City || + '', + state: + printDatas?.companyAddress?.state || + PurchaseInvoiceData?.AddressDetails?.[0]?.State || + BranchData?.State || + '', + zip: + printDatas?.companyAddress?.zip || + PurchaseInvoiceData?.AddressDetails?.[0]?.Zip || + BranchData?.Zip || + '', + }, + companyGSTIN: + PurchaseInvoiceData?.AddressDetails?.[0]?.BrGSTIN || + BranchData?.BrGSTIN || + BranchData?.GSTIN || + '', + companyEmail: + PurchaseInvoiceData?.AddressDetails?.[0]?.BrEmail || + BranchData?.BrEmail || + BranchData?.Email || + '', + companyMobile: + PurchaseInvoiceData?.AddressDetails?.[0]?.BrMobile || + BranchData?.BrMobile || + BranchData?.Mobile || + '', + companyMobile2: + PurchaseInvoiceData?.AddressDetails?.[0]?.BrMobile2 || + BranchData?.BrMobile2 || + '', - // Fixed data mapping with proper fallbacks - const invoiceData = { - // Company Details - with proper fallbacks - companyName: printDatas?.companyName || - PurchaseInvoiceData?.AddressDetails?.[0]?.CompName || - BranchData?.BrName || - table2Data?.BrName || - "Company Name", - companyspecname: printDatas?.companyspecname || - table2Data?.AppSpecificName || "", - companyAddress: { - address1: printDatas?.companyAddress?.address1 || - PurchaseInvoiceData?.AddressDetails?.[0]?.Address1 || - BranchData?.Address1 || "", - address2: printDatas?.companyAddress?.address2 || - PurchaseInvoiceData?.AddressDetails?.[0]?.Address2 || - BranchData?.Address2 || "", - city: printDatas?.companyAddress?.city || - PurchaseInvoiceData?.AddressDetails?.[0]?.City || - BranchData?.City || "", - state: printDatas?.companyAddress?.state || - PurchaseInvoiceData?.AddressDetails?.[0]?.State || - BranchData?.State || "", - zip: printDatas?.companyAddress?.zip || - PurchaseInvoiceData?.AddressDetails?.[0]?.Zip || - BranchData?.Zip || "" - }, - companyGSTIN: PurchaseInvoiceData?.AddressDetails?.[0]?.BrGSTIN || - BranchData?.BrGSTIN || - BranchData?.GSTIN || "", - companyEmail: PurchaseInvoiceData?.AddressDetails?.[0]?.BrEmail || - BranchData?.BrEmail || - BranchData?.Email || "", - companyMobile: PurchaseInvoiceData?.AddressDetails?.[0]?.BrMobile || - BranchData?.BrMobile || - BranchData?.Mobile || "", - companyMobile2: PurchaseInvoiceData?.AddressDetails?.[0]?.BrMobile2 || - BranchData?.BrMobile2 || "", + // Invoice Details - with proper fallbacks + invoiceNo: PurchaseInvoiceData?.InvoiceNo + ? extractLastNumberOrderId(PurchaseInvoiceData.InvoiceNo) + : PurchaseInvoiceData?.PurReturnId + ? extractLastNumberOrderId(PurchaseInvoiceData.PurReturnId) + : '', + invoiceDate: PurchaseInvoiceData?.InvoiceDate + ? moment(PurchaseInvoiceData.InvoiceDate).format('DD-MM-YYYY') + : moment().format('DD-MM-YYYY'), - // Invoice Details - with proper fallbacks - invoiceNo: PurchaseInvoiceData?.InvoiceNo ? - extractLastNumberOrderId(PurchaseInvoiceData.InvoiceNo) : - (PurchaseInvoiceData?.PurReturnId ? - extractLastNumberOrderId(PurchaseInvoiceData.PurReturnId) : ""), - invoiceDate: PurchaseInvoiceData?.InvoiceDate ? - moment(PurchaseInvoiceData.InvoiceDate).format('DD-MM-YYYY') : - moment().format('DD-MM-YYYY'), + // Customer Details - with proper fallbacks + customerName: + PurchaseInvoiceData?.CustomerDetails?.[0]?.CustSuppName || + PurchaseInvoiceData?.CustName || + PurchaseInvoiceData?.SupplierName || + 'Customer Name', + customerMobile: + PurchaseInvoiceData?.CustomerDetails?.[0]?.MobileNo || + PurchaseInvoiceData?.CustMobile || + PurchaseInvoiceData?.SupplierMobile || + '', + customerGSTIN: + PurchaseInvoiceData?.CustomerDetails?.[0]?.CustGSTNo || + PurchaseInvoiceData?.CustGSTIN || + PurchaseInvoiceData?.SupplierGSTIN || + '', + customerAddress: { + address1: + PurchaseInvoiceData?.AddressDetail?.[0]?.Address1 || + PurchaseInvoiceData?.CustomerDetails?.[0]?.Address1 || + '', + address2: + PurchaseInvoiceData?.AddressDetail?.[0]?.City || + PurchaseInvoiceData?.CustomerDetails?.[0]?.City || + '', + state: + PurchaseInvoiceData?.AddressDetail?.[0]?.State || + PurchaseInvoiceData?.CustomerDetails?.[0]?.State || + '', + }, - // Customer Details - with proper fallbacks - customerName: PurchaseInvoiceData?.CustomerDetails?.[0]?.CustSuppName || - PurchaseInvoiceData?.CustName || - PurchaseInvoiceData?.SupplierName || - "Customer Name", - customerMobile: PurchaseInvoiceData?.CustomerDetails?.[0]?.MobileNo || - PurchaseInvoiceData?.CustMobile || - PurchaseInvoiceData?.SupplierMobile || "", - customerGSTIN: PurchaseInvoiceData?.CustomerDetails?.[0]?.CustGSTNo || - PurchaseInvoiceData?.CustGSTIN || - PurchaseInvoiceData?.SupplierGSTIN || "", - customerAddress: { - address1: PurchaseInvoiceData?.AddressDetail?.[0]?.Address1 || - PurchaseInvoiceData?.CustomerDetails?.[0]?.Address1 || "", - address2: PurchaseInvoiceData?.AddressDetail?.[0]?.City || - PurchaseInvoiceData?.CustomerDetails?.[0]?.City || "", - state: PurchaseInvoiceData?.AddressDetail?.[0]?.State || - PurchaseInvoiceData?.CustomerDetails?.[0]?.State || "" - }, + // Product Details - using the correct data source + productDetails: + PurchaseInvoiceData?.ProductDetails || table2Data?.ProductDetails || [], - // Product Details - using the correct data source - productDetails: PurchaseInvoiceData?.ProductDetails || table2Data?.ProductDetails || [], + // Totals - with proper calculations and fallbacks + totalAmount: Number( + PurchaseInvoiceData?.BillAmount || + PurchaseInvoiceData?.TotalAmount || + PurchaseInvoiceData?.NetAmount || + 0 + ), + taxAmount: Number( + PurchaseInvoiceData?.TaxAmount || + OrderDetailGST?.reduce( + (sum, item) => sum + (item.CGST || 0) + (item.SGST || 0), + 0 + ) || + OrderDetailIGST?.reduce((sum, item) => sum + (item.IGST || 0), 0) || + 0 + ), + grandTotal: Number( + PurchaseInvoiceData?.NetAmount || + PurchaseInvoiceData?.GrandTotal || + PurchaseInvoiceData?.TotalAmount || + 0 + ), + totalBillAmount: Number( + PurchaseInvoiceData?.BillAmount || + PurchaseInvoiceData?.GrandTotal || + PurchaseInvoiceData?.SubTotal || + 0 + ), - // Totals - with proper calculations and fallbacks - totalAmount: Number(PurchaseInvoiceData?.BillAmount || - PurchaseInvoiceData?.TotalAmount || - PurchaseInvoiceData?.NetAmount || 0), - taxAmount: Number(PurchaseInvoiceData?.TaxAmount || - (OrderDetailGST?.reduce((sum, item) => sum + (item.CGST || 0) + (item.SGST || 0), 0)) || - (OrderDetailIGST?.reduce((sum, item) => sum + (item.IGST || 0), 0)) || 0), - grandTotal: Number(PurchaseInvoiceData?.NetAmount || - PurchaseInvoiceData?.GrandTotal || - PurchaseInvoiceData?.TotalAmount || 0), - totalBillAmount: Number(PurchaseInvoiceData?.BillAmount || - PurchaseInvoiceData?.GrandTotal || - PurchaseInvoiceData?.SubTotal || 0), + // Bank Details - with proper fallback + bankDetails: + (Array.isArray(BankDetails) ? BankDetails[0] : BankDetails) || {}, + }; - // Bank Details - with proper fallback - bankDetails: (Array.isArray(BankDetails) ? BankDetails[0] : BankDetails) || {} - }; + let PageSize = printDatas?.PageSize || 'A4'; + // Calculate GST totals with proper fallbacks + const cgstTotal = + OrderDetailGST && OrderDetailGST.length > 0 + ? Number( + OrderDetailGST.reduce( + (sum, item) => sum + (Number(item.CGST) || 0), + 0 + ) + )?.toFixed(2) + : '0.00'; - let PageSize = printDatas?.PageSize || "A4"; + const sgstTotal = + OrderDetailGST && OrderDetailGST.length > 0 + ? Number( + OrderDetailGST.reduce( + (sum, item) => sum + (Number(item.SGST) || 0), + 0 + ) + )?.toFixed(2) + : '0.00'; - // Calculate GST totals with proper fallbacks - const cgstTotal = OrderDetailGST && OrderDetailGST.length > 0 - ? Number(OrderDetailGST.reduce((sum, item) => sum + (Number(item.CGST) || 0), 0))?.toFixed(2) - : "0.00"; + const igstTotal = + OrderDetailIGST && OrderDetailIGST.length > 0 + ? Number( + OrderDetailIGST.reduce( + (sum, item) => sum + (Number(item.IGST) || 0), + 0 + ) + )?.toFixed(2) + : '0.00'; - const sgstTotal = OrderDetailGST && OrderDetailGST.length > 0 - ? Number(OrderDetailGST.reduce((sum, item) => sum + (Number(item.SGST) || 0), 0))?.toFixed(2) - : "0.00"; + // Calculate round off value with proper validation + const roundOffValue = + Number(invoiceData.grandTotal) - + (Number(invoiceData.totalBillAmount) + + Number(cgstTotal) + + Number(sgstTotal) + + Number(igstTotal)); - const igstTotal = OrderDetailIGST && OrderDetailIGST.length > 0 - ? Number(OrderDetailIGST.reduce((sum, item) => sum + (Number(item.IGST) || 0), 0))?.toFixed(2) - : "0.00"; + console.log('Tax Calculations:', { + totalBillAmount: Number(invoiceData.totalBillAmount), + cgstTotal, + sgstTotal, + igstTotal, + roundOffValue, + }); - // Calculate round off value with proper validation - const roundOffValue = Number(invoiceData.grandTotal) - ( - Number(invoiceData.totalBillAmount) + - Number(cgstTotal) + - Number(sgstTotal) + - Number(igstTotal) + function RoundOffFun(amount) { + if (isNaN(amount)) return '0.00'; + const roundedAmount = Math.round(amount); + const roundOffValue = parseFloat((roundedAmount - amount).toFixed(2)); + console.log( + 'Rounded Amount:', + roundedAmount, + 'Round Off Value:', + roundOffValue ); + return `${roundOffValue.toFixed(2)}`; + } - console.log("Tax Calculations:", { - totalBillAmount: Number(invoiceData.totalBillAmount), - cgstTotal, - sgstTotal, - igstTotal, - roundOffValue - }); + // Allow up to 10 items per page + const chunkSize = isMobile ? 7 : PageSize === 'A5' ? 9 : 8; + let dataSource = []; - function RoundOffFun(amount) { - if (isNaN(amount)) return "0.00"; - const roundedAmount = Math.round(amount); - const roundOffValue = parseFloat((roundedAmount - amount).toFixed(2)); - console.log("Rounded Amount:", roundedAmount, "Round Off Value:", roundOffValue); - return `${roundOffValue.toFixed(2)}`; + // Fixed data source logic - use ProductDetails from PurchaseInvoiceData + dataSource = PurchaseInvoiceData?.ProductDetails || []; + + // Ensure dataSource is always an array + if (!Array.isArray(dataSource)) { + dataSource = []; + } + + const paginatedChunks = []; + + // Always create at least one chunk, even if empty + if (dataSource.length === 0) { + paginatedChunks.push([]); + } else { + // Split data into chunks + for (let i = 0; i < dataSource.length; i += chunkSize) { + const chunk = dataSource.slice(i, i + chunkSize); + paginatedChunks.push(chunk); } + } - // Allow up to 10 items per page - const chunkSize = isMobile ? 7 : PageSize === "A5" ? 9 : 8; - let dataSource = []; + const lastChunkRows = + paginatedChunks.length > 0 + ? paginatedChunks[paginatedChunks.length - 1].length + : 0; + // If last page has more than 6 items, move footer to new page + const shouldFooterBeOnNewPage = lastChunkRows === chunkSize; - // Fixed data source logic - use ProductDetails from PurchaseInvoiceData - dataSource = PurchaseInvoiceData?.ProductDetails || []; + // If footer should be on new page, add an empty chunk for footer-only page + if (shouldFooterBeOnNewPage && paginatedChunks.length > 0) { + paginatedChunks.push([]); // Empty chunk for footer-only page + } - // Ensure dataSource is always an array - if (!Array.isArray(dataSource)) { - dataSource = []; - } + // + const SelectedHeaderColor = useSelector(GlobalSelectedPrintHeaderColor); + const SelectedHeaderFontColor = useSelector( + GlobalSelectedPrintHeaderFontColor + ); + const SelectedTableHeaderColor = useSelector(GlobalSelectedTableHeaderColor); + const SelectedTableHeaderFontColor = useSelector( + GlobalSelectedTableHeaderFontColor + ); + const SelectedTableBodyColor = useSelector(GlobalSelectedTableBodyColor); + const SelectedTableBodyFontColor = useSelector( + GlobalSelectedTableBodyFontColor + ); + const SelectedRowType = useSelector(GlobalRowType); + const SelectedTableFooterColor = useSelector(GlobalSelectedFooterColor); + const SelectedTableFooterFontColor = useSelector( + GlobalSelectedFooterFontColor + ); - const paginatedChunks = []; + // + let printColors = printDatas?.PrintColors; + const headerColor = printColors?.find((obj) => obj.headerColor)?.headerColor; + const tableHeaderColor = printColors?.find( + (obj) => obj.tableHeaderColor + )?.tableHeaderColor; + const tableBodyColor = printColors?.find( + (obj) => obj.tableBodyColor + )?.tableBodyColor; + const footerColor = printColors?.find((obj) => obj.footerColor)?.footerColor; - // Always create at least one chunk, even if empty - if (dataSource.length === 0) { - paginatedChunks.push([]); - } else { - // Split data into chunks - for (let i = 0; i < dataSource.length; i += chunkSize) { - const chunk = dataSource.slice(i, i + chunkSize); - paginatedChunks.push(chunk); - } - } + // + const headerStyle = { + backgroundColor: headerColor?.background, + color: headerColor?.font, + }; + const tableHeaderStyle = { + backgroundColor: tableHeaderColor?.background, + color: tableHeaderColor?.font, + }; - const lastChunkRows = paginatedChunks.length > 0 ? paginatedChunks[paginatedChunks.length - 1].length : 0; - // If last page has more than 6 items, move footer to new page - const shouldFooterBeOnNewPage = lastChunkRows === chunkSize; + const tableBodyStyle = { + backgroundColor: tableBodyColor?.background, + color: tableBodyColor?.font, + }; - // If footer should be on new page, add an empty chunk for footer-only page - if (shouldFooterBeOnNewPage && paginatedChunks.length > 0) { - paginatedChunks.push([]); // Empty chunk for footer-only page - } + const rowtypeStyle = tableBodyColor?.rowType; + + const footerColorStyle = { + backgroundColor: footerColor?.background, + color: footerColor?.font, + }; + + return ( +
+ {paginatedChunks.map((dataChunk, chunkIndex) => ( +
0 ? ' print-page-break' : ''}` + } + style={{ + display: 'flex', + flexDirection: 'column', + height: isMobile ? '275mm' : PageSize === 'A5' ? '130mm' : '245mm', + marginBottom: '0', + pageBreakAfter: + chunkIndex < paginatedChunks.length - 1 ? 'always' : 'auto', + }} + > + {renderInvoiceContent(dataChunk, chunkIndex)} +
+ ))} +
+ ); + + function renderInvoiceContent(dataChunk, chunkIndex) { + const isFirstPage = chunkIndex === 0; + const isLastPage = chunkIndex === paginatedChunks.length - 1; + const isFooterOnlyPage = + isLastPage && dataChunk.length === 0 && shouldFooterBeOnNewPage; return ( -
- {paginatedChunks.map((dataChunk, chunkIndex) => ( + <> + {/* Header - Only on first page */} + {isFirstPage && ( +
+
+

+ {BillName || 'Purchase Return Invoice'} +

+
+
+ (ORIGINAL FOR RECIPIENT) +
+
+
+ )} + + {/* Main Container - Always show */} +
+ {/* Top Section - Company and Invoice Details - Only on first page */} + {isFirstPage && ( +
+ {/* Left - Company Details */} +
0 ? ' print-page-break' : ''}`} - style={{ - display: "flex", - flexDirection: "column", - height: isMobile ? "275mm" : PageSize === "A5" ? '130mm' : "245mm", - marginBottom: "0", - pageBreakAfter: chunkIndex < paginatedChunks.length - 1 ? 'always' : 'auto' - }} + style={{ + padding: '10px', + fontSize: '11px', + textAlign: 'left', + // ...headerStyle, + }} > - {renderInvoiceContent(dataChunk, chunkIndex)} -
- ))} -
- ); - - function renderInvoiceContent(dataChunk, chunkIndex) { - const isFirstPage = chunkIndex === 0; - const isLastPage = chunkIndex === paginatedChunks.length - 1; - const isFooterOnlyPage = isLastPage && dataChunk.length === 0 && shouldFooterBeOnNewPage; - - return ( - <> - {/* Header - Only on first page */} - {isFirstPage && ( -
-
-

- {BillName || "Purchase Return Invoice"} -

-
-
(ORIGINAL FOR RECIPIENT)
-
+ +
+ {invoiceData.companyName} +
+ {invoiceData.companyspecname && ( +
+ {invoiceData.companyspecname}
- )} + )} +
{invoiceData.companyAddress.address1}
+ {invoiceData.companyAddress.address2 && ( +
{invoiceData.companyAddress.address2}
+ )} +
+ {invoiceData.companyAddress.city} + {invoiceData.companyAddress.zip + ? ` - ${invoiceData.companyAddress.zip}` + : ''} +
+ {invoiceData.companyAddress.state && ( +
{invoiceData.companyAddress.state}
+ )} + {invoiceData.companyGSTIN && ( +
GSTIN/UIN: {invoiceData.companyGSTIN}
+ )} + {invoiceData.companyEmail && ( +
E-Mail: {invoiceData.companyEmail}
+ )} + {invoiceData.companyMobile && ( +
+ Mobile: +91 {invoiceData.companyMobile} + {invoiceData.companyMobile2 + ? `, ${invoiceData.companyMobile2}` + : ''} +
+ )} +
- {/* Main Container - Always show */} -
+ {/* Customer Details */} +
+
+ Customer Details: +
+
+ {invoiceData.customerName} +
+ {invoiceData.customerAddress.address1 && ( +
{invoiceData.customerAddress.address1}
+ )} + {invoiceData.customerAddress.address2 && ( +
{invoiceData.customerAddress.address2}
+ )} + {invoiceData.customerMobile && ( +
Mobile: {invoiceData.customerMobile}
+ )} + {invoiceData.customerGSTIN && ( +
GSTIN/UIN: {invoiceData.customerGSTIN}
+ )} + {invoiceData.customerAddress.state && ( +
State Name: {invoiceData.customerAddress.state}
+ )} +
+
- {/* Top Section - Company and Invoice Details - Only on first page */} - {isFirstPage && ( -
+ {/* Right - Invoice Details */} +
+ {/* Invoice No and Date */} +
+
+
+ Invoice No. +
+
+ {invoiceData.invoiceNo} +
+
+
+
Dated
+
+ {invoiceData.invoiceDate} +
+
+
- {/* Left - Company Details */} -
-
-
- {invoiceData.companyName} -
- {invoiceData.companyspecname && ( -
{invoiceData.companyspecname}
- )} -
{invoiceData.companyAddress.address1}
- {invoiceData.companyAddress.address2 &&
{invoiceData.companyAddress.address2}
} -
{invoiceData.companyAddress.city}{invoiceData.companyAddress.zip ? ` - ${invoiceData.companyAddress.zip}` : ""}
- {invoiceData.companyAddress.state &&
{invoiceData.companyAddress.state}
} - {invoiceData.companyGSTIN &&
GSTIN/UIN: {invoiceData.companyGSTIN}
} - {invoiceData.companyEmail &&
E-Mail: {invoiceData.companyEmail}
} - {invoiceData.companyMobile && ( -
Mobile: +91 {invoiceData.companyMobile}{invoiceData.companyMobile2 ? `, ${invoiceData.companyMobile2}` : ""}
- )} -
+ {/* Delivery Note and Payment Terms */} +
+
+
+ Delivery Note +
+
+
+
+
+ Mode/Terms of Payment +
+
+
+
- {/* Customer Details */} -
-
Customer Details:
-
{invoiceData.customerName}
- {invoiceData.customerAddress.address1 &&
{invoiceData.customerAddress.address1}
} - {invoiceData.customerAddress.address2 &&
{invoiceData.customerAddress.address2}
} - {invoiceData.customerMobile &&
Mobile: {invoiceData.customerMobile}
} - {invoiceData.customerGSTIN &&
GSTIN/UIN: {invoiceData.customerGSTIN}
} - {invoiceData.customerAddress.state &&
State Name: {invoiceData.customerAddress.state}
} -
-
+ {/* Reference and Other References */} +
+
+
+ Reference No. & Date +
+
+
+
+
+ Other References +
+
+
+
- {/* Right - Invoice Details */} -
- {/* Invoice No and Date */} -
-
-
Invoice No.
-
{invoiceData.invoiceNo}
-
-
-
Dated
-
{invoiceData.invoiceDate}
-
-
+ {/* Buyer's Order */} +
+
+
+ Buyer's Order No. +
+
+
+
+
+ Dated +
+
+
+
- {/* Delivery Note and Payment Terms */} -
-
-
Delivery Note
-
-
-
-
Mode/Terms of Payment
-
-
-
+ {/* Dispatch Details */} +
+
+
+ Dispatch Doc No. +
+
+
+
+
+ Delivery Note Date +
+
+
+
- {/* Reference and Other References */} -
-
-
Reference No. & Date
-
-
-
-
Other References
-
-
-
+ {/* Dispatched through and Destination */} +
+
+
+ Dispatched through +
+
+
+
+
+ Destination +
+
+
+
- {/* Buyer's Order */} -
-
-
Buyer's Order No.
-
-
-
-
Dated
-
-
-
+ {/* Terms of Delivery */} +
+
+ Terms of Delivery +
+
+
+
+
+ )} - {/* Dispatch Details */} -
-
-
Dispatch Doc No.
-
-
-
-
Delivery Note Date
-
-
-
+ {/* Continuation header for non-first pages */} + {!isFirstPage && ( +
+

+ {BillName || 'Purchase Return Invoice'} +

+
+ Invoice No: {invoiceData.invoiceNo} +
+
+ )} - {/* Dispatched through and Destination */} -
-
-
Dispatched through
-
-
-
-
Destination
-
-
-
+ {/* Items Table */} + {(dataChunk.length > 0 || !isFooterOnlyPage) && ( +
+ {/* Table Header */} +
+
+ Sl.No +
+
+ Description of Goods +
+
+ HSN/SAC +
+
+ Quantity +
+
+ Return Qty +
+
+ Rate +
+
+ Amount +
+
- {/* Terms of Delivery */} -
-
Terms of Delivery
-
-
-
+ {/* Table Rows - Dynamic data from dataChunk */} + {dataChunk && dataChunk.length > 0 ? ( + <> + {dataChunk?.map((item, index) => ( +
+
+ {chunkIndex * chunkSize + index + 1} +
+
+
+ {item.ProdName || 'Product Name'}
- )} + {item.BrandName && ( +
+ {item.BrandName} +
+ )} +
+
+ {item.HSN || ''} +
+
+ {item.PurQty || 0} {'NOS'} +
+
+ {item.ReturnQty || 0} {'NOS'} +
+
+ {Number(item.RatePerUnit || 0)?.toLocaleString( + 'en-IN', + { minimumFractionDigits: 2, maximumFractionDigits: 2 } + )} +
+
+ {Number(item.NetAmount || 0)?.toLocaleString('en-IN', { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + })} +
+
+ ))} - {/* Continuation header for non-first pages */} - {!isFirstPage && ( -
-

- {BillName || "Purchase Return Invoice"} -

-
Invoice No: {invoiceData.invoiceNo}
+ {/* Tax summary on last page */} + {isLastPage && ( + <> + {/* Total without tax amount */} +
+
+
+ Subtotal
- )} - - {/* Items Table */} - {(dataChunk.length > 0 || !isFooterOnlyPage) && ( -
- {/* Table Header */} -
-
Sl.No
-
Description of Goods
-
HSN/SAC
-
Quantity
-
Return Qty
-
Rate
-
Amount
-
- - {/* Table Rows - Dynamic data from dataChunk */} - {(dataChunk && dataChunk.length > 0) ? ( - <> - {dataChunk?.map((item, index) => ( -
-
- {chunkIndex * chunkSize + index + 1} -
-
-
- {item.ProdName || 'Product Name'} -
- {item.BrandName &&
{item.BrandName}
} -
-
- {item.HSN || ''} -
-
- {item.PurQty || 0} {'NOS'} -
-
- {item.ReturnQty || 0} {'NOS'} -
-
- {Number(item.RatePerUnit || 0)?.toLocaleString('en-IN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })} -
-
- {Number(item.NetAmount || 0)?.toLocaleString('en-IN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })} -
-
- ))} - - {/* Tax summary on last page */} - {isLastPage && ( - <> - {/* Total without tax amount */} -
-
-
Subtotal
-
-
-
-
-
- ₹ {Number(invoiceData?.totalBillAmount).toLocaleString('en-IN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })} -
-
- - {/* CGST */} - {OrderDetailGST && OrderDetailGST.length > 0 && ( -
-
-
CGST
-
-
-
-
-
₹ {cgstTotal}
-
- )} - - {/* SGST */} - {OrderDetailGST && OrderDetailGST.length > 0 && ( -
-
-
SGST
-
-
-
-
-
₹ {sgstTotal}
-
- )} - - - {/* IGST */} - {OrderDetailGST && OrderDetailGST.length > 0 && ( -
-
-
IGST
-
-
-
-
- -
- {OrderDetailIGST && OrderDetailIGST.length > 0 - ? Number(OrderDetailIGST.reduce((sum, item) => sum + (item.IGST || 0), 0)).toLocaleString('en-IN', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) - : "0.00"} -
-
- )} - {/* Rounding Off */} -
-
-
ROUNDING OFF
-
-
-
-
- -
- {RoundOffFun(roundOffValue)} -
-
- {Array.from({ length: chunkSize - dataChunk.length })?.map((_, idx) => ( -
-
 
-
 
-
 
-
 
-
 
-
 
-
 
-
- ))} - {/* Total */} -
-
-
Total
-
-
- {totalQuantity || - (invoiceData.productDetails?.reduce((sum, item) => sum + (item.PurQty || 0), 0)) || - 0} NOS -
-
-
-
- ₹ {Number(invoiceData.grandTotal).toLocaleString('en-IN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })} -
-
- - )} - - ) : ( - - // Show empty row when no data -
-
-
-
No items to display
-
-
-
-
-
-
-
-
-
-
-
- )} +
+
+
+
+
+ ₹{' '} + {Number(invoiceData?.totalBillAmount).toLocaleString( + 'en-IN', + { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + } + )}
+
+ + {/* CGST */} + {OrderDetailGST && OrderDetailGST.length > 0 && ( +
+
+
+ CGST +
+
+
+
+
+
+ ₹ {cgstTotal} +
+
+ )} + + {/* SGST */} + {OrderDetailGST && OrderDetailGST.length > 0 && ( +
+
+
+ SGST +
+
+
+
+
+
+ ₹ {sgstTotal} +
+
+ )} + + {/* IGST */} + {OrderDetailGST && OrderDetailGST.length > 0 && ( +
+
+
+ IGST +
+
+
+
+
+ +
+ {OrderDetailIGST && OrderDetailIGST.length > 0 + ? Number( + OrderDetailIGST.reduce( + (sum, item) => sum + (item.IGST || 0), + 0 + ) + ).toLocaleString('en-IN', { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + }) + : '0.00'} +
+
+ )} + {/* Rounding Off */} +
+
+
+ ROUNDING OFF +
+
+
+
+
+ +
+ {RoundOffFun(roundOffValue)} +
+
+ {Array.from({ + length: chunkSize - dataChunk.length, + })?.map((_, idx) => ( +
+
+   +
+
+   +
+
+   +
+
+   +
+
+   +
+
+   +
+
+   +
+
+ ))} + {/* Total */} +
+
+
+ Total +
+
+
+ {totalQuantity || + invoiceData.productDetails?.reduce( + (sum, item) => sum + (item.PurQty || 0), + 0 + ) || + 0}{' '} + NOS +
+
+
+
+ ₹{' '} + {Number(invoiceData.grandTotal).toLocaleString( + 'en-IN', + { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + } + )} +
+
+ + )} + + ) : ( + // Show empty row when no data +
+
+ - +
+
+ No items to display +
+
+ - +
+
+ - +
+
+ - +
+
+ - +
+
+ - +
+
+ )} +
+ )} + {/* Tax summary - Only on last page */} + + {/* Footer content - Only on last page */} + {isLastPage && ( + <> + {/* Amount in Words */} +
+
+
+ Amount Chargeable (in words) +
+
+ INR {numberToWords(Math.floor(invoiceData.grandTotal))} Only +
+
+

E. & O.E

+
+ + {/* Tax Breakdown Table */} + {OrderDetailGST && OrderDetailGST.length > 0 && ( +
+ {/* Tax Table Header - Main Headers */} +
+
+ HSN/SAC +
+
+ Taxable Value +
+
+ CGST +
+
+ SGST/UTGST +
+
+ Tax Amount +
+
+ + {/* Tax Table Sub-Headers */} +
+
+
+
+ Rate +
+
+ Amount +
+
+ Rate +
+
+ Amount +
+
+
+ + {/* Tax Table Rows - Dynamic from OrderDetailGST */} + {OrderDetailGST && OrderDetailGST.length > 0 ? ( + OrderDetailGST?.map((taxItem, index) => ( +
+
+ {taxItem.HSN || ''} +
+
+ {Number(taxItem.WithOutTaxAmount || 0).toLocaleString( + 'en-IN', + { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + } + )} +
+
+ {taxItem.TaxPercentage + ? taxItem.TaxPercentage / 2 + '%' + : '0%'} +
+
+ {Number(taxItem.CGST || 0).toLocaleString('en-IN', { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + })} +
+
+ {taxItem.TaxPercentage + ? taxItem.TaxPercentage / 2 + '%' + : '0%'} +
+
+ {Number(taxItem.SGST || 0).toLocaleString('en-IN', { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + })} +
+
+ {Number( + (taxItem.CGST || 0) + (taxItem.SGST || 0) + ).toLocaleString('en-IN', { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + })} +
+
+ )) + ) : ( + // Show 0 values when no GST data +
+
+ - +
+
+ 0.00 +
+
+ 0% +
+
+ 0.00 +
+
+ 0% +
+
+ 0.00 +
+
+ 0.00 +
+
+ )} + + {/* Tax Table Total */} +
+
+ Total +
+
+ {OrderDetailGST && OrderDetailGST.length > 0 + ? Number( + OrderDetailGST.reduce( + (sum, item) => sum + (item.WithoutTaxRate || 0), + 0 + ) + ).toLocaleString('en-IN', { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + }) + : '0.00'} +
+
+
+ {OrderDetailGST && OrderDetailGST.length > 0 + ? Number( + OrderDetailGST.reduce( + (sum, item) => sum + (item.CGST || 0), + 0 + ) + ).toLocaleString('en-IN', { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + }) + : '0.00'} +
+
+
+ {OrderDetailGST && OrderDetailGST.length > 0 + ? Number( + OrderDetailGST.reduce( + (sum, item) => sum + (item.SGST || 0), + 0 + ) + ).toLocaleString('en-IN', { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + }) + : '0.00'} +
+
+ {OrderDetailGST && OrderDetailGST.length > 0 + ? Number( + OrderDetailGST.reduce( + (sum, item) => + sum + + (item.CGST || 0) + + (item.SGST || 0) + + (item.WithoutTaxRate || 0), + 0 + ) + ).toLocaleString('en-IN', { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + }) + : '0.00'} +
+
+
+ )} + + {/* Tax Amount in Words */} + {OrderDetailGST && OrderDetailGST.length > 0 && ( +
+
+ Tax Amount (in words): INR{' '} + {numberToWords( + Math.floor( + invoiceData.taxAmount || + OrderDetailGST?.reduce( + (sum, item) => + sum + (item.CGST || 0) + (item.SGST || 0), + 0 + ) || + 0 + ) + )}{' '} + Only +
+
+ )} + + {/* Bank Details and Signature */} +
+ {/* Declaration */} +
+
+
+ Declaration +
+
+ We declare that this invoice shows the actual price of the + goods described and that all particulars are true and + correct. +
+
+
+ + {/* Signature Section */} +
+ {/* Bank Details */} +
+
+ Company's Bank Details +
+
+ + A/c Holder's Name: + {' '} + {invoiceData.companyName} +
+
+ Bank Name:{' '} + {invoiceData.bankDetails?.BankName || ''} +
+
+ A/c No.:{' '} + {invoiceData.bankDetails?.AccountNo || ''} +
+
+ + Branch & IFS Code: + {' '} + {invoiceData.bankDetails?.BankBranch || ''} &{' '} + {invoiceData.bankDetails?.IFSCCode || ''} +
+ {invoiceData.bankDetails?.SWIFTCode && ( +
+ SWIFT Code:{' '} + {invoiceData.bankDetails?.SWIFTCode || ''} +
)} - {/* Tax summary - Only on last page */} - - {/* Footer content - Only on last page */} - {isLastPage && ( - <> - {/* Amount in Words */} -
-
-
Amount Chargeable (in words)
-
INR {numberToWords(Math.floor(invoiceData.grandTotal))} Only
-
-

E. & O.E

-
- - - {/* Tax Breakdown Table */} - {OrderDetailGST && OrderDetailGST.length > 0 &&
- - {/* Tax Table Header - Main Headers */} -
-
HSN/SAC
-
Taxable Value
-
CGST
-
SGST/UTGST
-
Tax Amount
-
- - {/* Tax Table Sub-Headers */} -
-
-
-
Rate
-
Amount
-
Rate
-
Amount
-
-
- - {/* Tax Table Rows - Dynamic from OrderDetailGST */} - {OrderDetailGST && OrderDetailGST.length > 0 ? ( - OrderDetailGST?.map((taxItem, index) => ( -
-
{taxItem.HSN || ''}
-
{Number(taxItem.WithOutTaxAmount || 0).toLocaleString('en-IN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}
-
{taxItem.TaxPercentage ? (taxItem.TaxPercentage / 2) + '%' : '0%'}
-
{Number(taxItem.CGST || 0).toLocaleString('en-IN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}
-
{taxItem.TaxPercentage ? (taxItem.TaxPercentage / 2) + '%' : '0%'}
-
{Number(taxItem.SGST || 0).toLocaleString('en-IN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}
-
{Number((taxItem.CGST || 0) + (taxItem.SGST || 0)).toLocaleString('en-IN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}
-
- )) - ) : ( - // Show 0 values when no GST data -
-
-
-
0.00
-
0%
-
0.00
-
0%
-
0.00
-
0.00
-
- )} - - {/* Tax Table Total */} -
-
Total
-
- {OrderDetailGST && OrderDetailGST.length > 0 - ? Number(OrderDetailGST.reduce((sum, item) => sum + (item.WithoutTaxRate || 0), 0)).toLocaleString('en-IN', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) - : "0.00" - } -
-
-
- {OrderDetailGST && OrderDetailGST.length > 0 - ? Number(OrderDetailGST.reduce((sum, item) => sum + (item.CGST || 0), 0)).toLocaleString('en-IN', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) - : "0.00" - } -
-
-
- {OrderDetailGST && OrderDetailGST.length > 0 - ? Number(OrderDetailGST.reduce((sum, item) => sum + (item.SGST || 0), 0)).toLocaleString('en-IN', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) - : "0.00" - } -
-
- {OrderDetailGST && OrderDetailGST.length > 0 - ? Number(OrderDetailGST.reduce((sum, item) => sum + (item.CGST || 0) + (item.SGST || 0) + (item.WithoutTaxRate || 0), 0)).toLocaleString('en-IN', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) - : "0.00" - } -
-
-
} - - {/* Tax Amount in Words */} - {OrderDetailGST && OrderDetailGST.length > 0 &&
-
- Tax Amount (in words): INR {numberToWords(Math.floor(invoiceData.taxAmount || (OrderDetailGST?.reduce((sum, item) => sum + (item.CGST || 0) + (item.SGST || 0), 0) || 0)))} Only -
-
} - - {/* Bank Details and Signature */} -
- {/* Declaration */} -
-
-
Declaration
-
We declare that this invoice shows the actual price of the goods described and that all particulars are true and correct.
-
-
- - - {/* Signature Section */} -
- {/* Bank Details */} -
-
Company's Bank Details
-
A/c Holder's Name: {invoiceData.companyName}
-
Bank Name: {invoiceData.bankDetails?.BankName || ""}
-
A/c No.: {invoiceData.bankDetails?.AccountNo || ""}
-
Branch & IFS Code: {invoiceData.bankDetails?.BankBranch || ""} & {invoiceData.bankDetails?.IFSCCode || ""}
- {invoiceData.bankDetails?.SWIFTCode &&
SWIFT Code: {invoiceData.bankDetails?.SWIFTCode || ""}
} -
-
-
for {invoiceData.companyName}
-
-
-
- {/*
DD
+
+
+
+ for {invoiceData.companyName} +
+
+
+
+ {/*
DD
TECHNOLOGIES
ELECTRONICS
*/} -
-
-
Authorised Signatory
-
-
-
-
- - )} - -
- - {/* Footer - Only on last page */} - {isLastPage && ( -
-
This is a Computer Generated Invoice
+
+
+
+ Authorised Signatory +
- )} +
+
+
- ); - } + )} +
+ + {/* Footer - Only on last page */} + {isLastPage && ( +
+
This is a Computer Generated Invoice
+
+ )} + + ); + } }; export default PurchaseTaxInvoice; diff --git a/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle1.jsx b/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle1.jsx index 84c6217..b0f604e 100644 --- a/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle1.jsx +++ b/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle1.jsx @@ -1,8 +1,24 @@ import { useSelector } from 'react-redux'; -import { GloabalFieldDetails } from '../../../../Features/ThemeChange/ThemeChange'; +import { + GloabalFieldDetails, + GlobalRowType, + GlobalSelectedFooterColor, + GlobalSelectedFooterFontColor, + GlobalSelectedPrintHeaderColor, + GlobalSelectedPrintHeaderFontColor, + GlobalSelectedTableBodyColor, + GlobalSelectedTableBodyFontColor, + GlobalSelectedTableHeaderColor, + GlobalSelectedTableHeaderFontColor, +} from '../../../../Features/ThemeChange/ThemeChange'; import { dateFormatChange1 } from '../../../../Services/Others'; -const PrintStylePurchaseReturn = ({ invoiceData, preference, printDatas,FieldDetails}) => { +const PrintStylePurchaseReturn = ({ + invoiceData, + preference, + printDatas, + FieldDetails, +}) => { const { InvoiceNo, SupplierNo, @@ -19,8 +35,10 @@ const PrintStylePurchaseReturn = ({ invoiceData, preference, printDatas,FieldDet } = invoiceData; // const fieldDetails = useSelector(GloabalFieldDetails); - const signature = FieldDetails?.FieldDetails?.some((e) => e?.ConfigName == "signature"); - + const signature = FieldDetails?.FieldDetails?.some( + (e) => e?.ConfigName == 'signature' + ); + // const termsAndConditions = fieldDetails?.['terms&conditions']; const signatureImg = FieldDetails?.Signature; @@ -29,8 +47,10 @@ const PrintStylePurchaseReturn = ({ invoiceData, preference, printDatas,FieldDet const pageSize = FieldDetails?.PageSize; const branch = AddressDetails?.[0]; const logo = branch?.CompLogo; - let termsAndConditions = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="terms&conditions") - let termsAndConditionsData=FieldDetails?.TermsandConditions + let termsAndConditions = FieldDetails?.FieldDetails?.some( + (e) => e?.ConfigName == 'terms&conditions' + ); + let termsAndConditionsData = FieldDetails?.TermsandConditions; const printGreeting = preference?.[0]?.SettingDtlDetails?.find( (i) => i.SettingIdName === 'PrintGreetings' @@ -45,6 +65,60 @@ const PrintStylePurchaseReturn = ({ invoiceData, preference, printDatas,FieldDet const lastChunkRows = paginatedChunks.at(-1)?.length || 0; const shouldFooterBeOnNewPage = lastChunkRows > (pageSize === 'A5' ? 5 : 10); + // + const SelectedHeaderColor = useSelector(GlobalSelectedPrintHeaderColor); + const SelectedHeaderFontColor = useSelector( + GlobalSelectedPrintHeaderFontColor + ); + const SelectedTableHeaderColor = useSelector(GlobalSelectedTableHeaderColor); + const SelectedTableHeaderFontColor = useSelector( + GlobalSelectedTableHeaderFontColor + ); + const SelectedTableBodyColor = useSelector(GlobalSelectedTableBodyColor); + const SelectedTableBodyFontColor = useSelector( + GlobalSelectedTableBodyFontColor + ); + const SelectedRowType = useSelector(GlobalRowType); + const SelectedTableFooterColor = useSelector(GlobalSelectedFooterColor); + const SelectedTableFooterFontColor = useSelector( + GlobalSelectedFooterFontColor + ); + + // + let printColors = FieldDetails?.PrintColors; + const headerColor = printColors?.find((obj) => obj.headerColor)?.headerColor; + const tableHeaderColor = printColors?.find( + (obj) => obj.tableHeaderColor + )?.tableHeaderColor; + const tableBodyColor = printColors?.find( + (obj) => obj.tableBodyColor + )?.tableBodyColor; + const footerColor = printColors?.find((obj) => obj.footerColor)?.footerColor; + + // + const headerStyle = { + backgroundColor: headerColor?.background, + + color: headerColor?.font, + }; + const tableHeaderStyle = { + backgroundColor: tableHeaderColor?.background, + + color: tableHeaderColor?.font, + }; + + const tableBodyStyle = { + backgroundColor: tableBodyColor?.background, + color: tableBodyColor?.font, + }; + + const rowtypeStyle = tableBodyColor?.rowType; + + const footerColorStyle = { + backgroundColor: footerColor?.background, + color: footerColor?.font, + }; + const renderFooter = () => ( <>
@@ -60,7 +134,7 @@ const PrintStylePurchaseReturn = ({ invoiceData, preference, printDatas,FieldDet <>
{/* {notesText &&

{notesText}

} */} -
+
{termsAndConditions && termsAndConditionsData?.length > 0 && (

Terms & Conditions

@@ -88,8 +162,10 @@ const PrintStylePurchaseReturn = ({ invoiceData, preference, printDatas,FieldDet return ( <> -
+
{formatTheme ? ( paginatedChunks.map((dataChunk, chunkIndex) => { const isLastPage = chunkIndex === paginatedChunks.length - 1; @@ -116,7 +192,11 @@ const PrintStylePurchaseReturn = ({ invoiceData, preference, printDatas,FieldDet
{formatTheme || chunkIndex === 0 ? ( <> -
+

) : null} - + {!formatTheme && isFinalFooterPage && renderFooter()}
{formatTheme && isFinalFooterPage && ( @@ -142,7 +227,7 @@ const PrintStylePurchaseReturn = ({ invoiceData, preference, printDatas,FieldDet }) ) : (
-
+


- + {renderFooter()}
)} @@ -167,8 +257,8 @@ export default PrintStylePurchaseReturn; // --- Subcomponents --- -const Header = ({ logo, branch }) => ( -
+const Header = ({ logo, branch, headerStyle }) => ( +
{logo && logo}
{branch.CompName}
@@ -178,7 +268,7 @@ const Header = ({ logo, branch }) => (
Mobile: +91 {branch.BrMobile}
-
+
Purchase Return
@@ -202,8 +292,7 @@ const InvoiceMeta = ({
- Date:{' '} - {dateFormatChange1(InvoiceDate)} + Date: {dateFormatChange1(InvoiceDate)}
{VehicleNo && (
@@ -218,16 +307,21 @@ const InvoiceMeta = ({ Supplier Name: {CustName}
)} - {SupplierNo && -
- Supplier Mobile No: {SupplierNo || '-'} -
- } + {SupplierNo && ( +
+ Supplier Mobile No: {SupplierNo || '-'} +
+ )}
); -const ProductTable = ({ data }) => { +const ProductTable = ({ + data, + tableHeaderStyle, + rowtypeStyle, + tableBodyStyle, +}) => { const columns = [ { label: 'S.No', key: 'sno', width: '5%' }, { label: 'Product', key: 'ProdName', width: '20%' }, @@ -241,7 +335,7 @@ const ProductTable = ({ data }) => { return (
{ {data.map((prod, index) => (
{index + 1} {prod.ProdName}
- + {columns?.map((col) => ( {data?.map((prod, index) => ( - + {/* */} @@ -270,13 +377,13 @@ const ProductTable = ({ data }) => { const Summary = ({ TotalAmount, TaxAmount, GrandTotal }) => (
- Subtotal: ₹ {TotalAmount?.toFixed(2)} + Subtotal: ₹ {TotalAmount?.toFixed(2)}
- Tax Amount: ₹ {TaxAmount?.toFixed(2)} + Tax Amount: ₹ {TaxAmount?.toFixed(2)}
- Grand Total: ₹ {GrandTotal?.toFixed(2)} + Grand Total: ₹ {GrandTotal?.toFixed(2)}
); diff --git a/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle10.jsx b/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle10.jsx index 6b7a431..993093c 100644 --- a/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle10.jsx +++ b/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle10.jsx @@ -1,8 +1,19 @@ import { useSelector } from 'react-redux'; -import { GloabalFieldDetails } from '../../../../Features/ThemeChange/ThemeChange'; +import { + GloabalFieldDetails, + GlobalRowType, + GlobalSelectedFooterColor, + GlobalSelectedFooterFontColor, + GlobalSelectedPrintHeaderColor, + GlobalSelectedPrintHeaderFontColor, + GlobalSelectedTableBodyColor, + GlobalSelectedTableBodyFontColor, + GlobalSelectedTableHeaderColor, + GlobalSelectedTableHeaderFontColor, +} from '../../../../Features/ThemeChange/ThemeChange'; import { dateFormatChange1 } from '../../../../Services/Others'; -const PrintStyle10PurchaseReturn = ({ +const PrintStyle10PurchaseReturn = ({ invoiceData, preference, printDatas, @@ -50,6 +61,58 @@ const PrintStyle10PurchaseReturn = ({ const lastChunkRows = paginatedChunks.at(-1)?.length || 0; const shouldFooterBeOnNewPage = lastChunkRows > (pageSize === 'A5' ? 5 : 10); + // + const SelectedHeaderColor = useSelector(GlobalSelectedPrintHeaderColor); + const SelectedHeaderFontColor = useSelector( + GlobalSelectedPrintHeaderFontColor + ); + const SelectedTableHeaderColor = useSelector(GlobalSelectedTableHeaderColor); + const SelectedTableHeaderFontColor = useSelector( + GlobalSelectedTableHeaderFontColor + ); + const SelectedTableBodyColor = useSelector(GlobalSelectedTableBodyColor); + const SelectedTableBodyFontColor = useSelector( + GlobalSelectedTableBodyFontColor + ); + const SelectedRowType = useSelector(GlobalRowType); + const SelectedTableFooterColor = useSelector(GlobalSelectedFooterColor); + const SelectedTableFooterFontColor = useSelector( + GlobalSelectedFooterFontColor + ); + + // + let printColors = FieldDetails?.PrintColors; + const headerColor = printColors?.find((obj) => obj.headerColor)?.headerColor; + const tableHeaderColor = printColors?.find( + (obj) => obj.tableHeaderColor + )?.tableHeaderColor; + const tableBodyColor = printColors?.find( + (obj) => obj.tableBodyColor + )?.tableBodyColor; + const footerColor = printColors?.find((obj) => obj.footerColor)?.footerColor; + + // + const headerStyle = { + backgroundColor: headerColor?.background, + color: headerColor?.font, + }; + const tableHeaderStyle = { + backgroundColor: tableHeaderColor?.background, + color: tableHeaderColor?.font, + }; + + const tableBodyStyle = { + backgroundColor: tableBodyColor?.background, + color: tableBodyColor?.font, + }; + + const rowtypeStyle = tableBodyColor?.rowType; + + const footerColorStyle = { + backgroundColor: footerColor?.background, + color: footerColor?.font, + }; + const renderFooter = () => ( <> {/*
*/} @@ -66,7 +129,7 @@ const PrintStyle10PurchaseReturn = ({ }} /> {/* {notesText &&

{notesText}

} */} -
+
{termsAndConditions && termsAndConditionsData?.length > 0 && (

Terms & Conditions

@@ -257,7 +320,11 @@ padding-top: 10px;
{formatTheme || chunkIndex === 0 ? ( <> -
+

) : null} - +
-
+

{/*
*/} - +
( -
+const Header = ({ logo, branch, headerStyle }) => ( +
{logo && logo}
{branch.CompName}
{branch.Address1}-{branch.City}-{branch?.Zip}
- {branch.BrMobile &&
- Mobile: +91 {branch.BrMobile} -
} + {branch.BrMobile &&
Mobile: +91 {branch.BrMobile}
}
Purchase Return @@ -413,8 +488,7 @@ const InvoiceMeta = ({
- Date:{' '} - {dateFormatChange1(InvoiceDate)} + Date: {dateFormatChange1(InvoiceDate)}
{VehicleNo && (
@@ -426,10 +500,15 @@ const InvoiceMeta = ({
); -const ProductTable = ({ data }) => { +const ProductTable = ({ + data, + tableHeaderStyle, + rowtypeStyle, + tableBodyStyle, +}) => { const columns = [ { label: 'S.No', key: 'sno', width: '5%' }, - { label: 'Product', key: 'ProdName', width: '30%' ,}, + { label: 'Product', key: 'ProdName', width: '30%' }, { label: 'Purchased Qty', key: 'Qty', width: '10%' }, { label: 'Returned Qty', key: 'ReturnedQty', width: '10%' }, { label: 'Rate', key: 'ProductRate', width: '10%' }, @@ -440,9 +519,9 @@ const ProductTable = ({ data }) => { return (
{col.label} @@ -251,7 +345,20 @@ const ProductTable = ({ data }) => {
{index + 1} {prod.ProdName}{prod.ProdVariantName}
- + {columns.map((col) => ( - ))} @@ -450,7 +529,20 @@ const ProductTable = ({ data }) => { {data.map((prod, index) => ( - + {/* */} diff --git a/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle11.jsx b/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle11.jsx index 45952e5..c68ec2e 100644 --- a/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle11.jsx +++ b/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle11.jsx @@ -1,8 +1,19 @@ import { useSelector } from 'react-redux'; -import { GloabalFieldDetails } from '../../../../Features/ThemeChange/ThemeChange'; +import { + GloabalFieldDetails, + GlobalRowType, + GlobalSelectedFooterColor, + GlobalSelectedFooterFontColor, + GlobalSelectedPrintHeaderColor, + GlobalSelectedPrintHeaderFontColor, + GlobalSelectedTableBodyColor, + GlobalSelectedTableBodyFontColor, + GlobalSelectedTableHeaderColor, + GlobalSelectedTableHeaderFontColor, +} from '../../../../Features/ThemeChange/ThemeChange'; import { dateFormatChange1 } from '../../../../Services/Others'; -const PrintStyle11PurchaseReturn = ({ +const PrintStyle11PurchaseReturn = ({ invoiceData, preference, printDatas, @@ -65,6 +76,58 @@ const PrintStyle11PurchaseReturn = ({ const lastChunkRows = paginatedChunks.at(-1)?.length || 0; const shouldFooterBeOnNewPage = lastChunkRows > (pageSize === 'A5' ? 5 : 9); + // + const SelectedHeaderColor = useSelector(GlobalSelectedPrintHeaderColor); + const SelectedHeaderFontColor = useSelector( + GlobalSelectedPrintHeaderFontColor + ); + const SelectedTableHeaderColor = useSelector(GlobalSelectedTableHeaderColor); + const SelectedTableHeaderFontColor = useSelector( + GlobalSelectedTableHeaderFontColor + ); + const SelectedTableBodyColor = useSelector(GlobalSelectedTableBodyColor); + const SelectedTableBodyFontColor = useSelector( + GlobalSelectedTableBodyFontColor + ); + const SelectedRowType = useSelector(GlobalRowType); + const SelectedTableFooterColor = useSelector(GlobalSelectedFooterColor); + const SelectedTableFooterFontColor = useSelector( + GlobalSelectedFooterFontColor + ); + + // + let printColors = FieldDetails?.PrintColors; + const headerColor = printColors?.find((obj) => obj.headerColor)?.headerColor; + const tableHeaderColor = printColors?.find( + (obj) => obj.tableHeaderColor + )?.tableHeaderColor; + const tableBodyColor = printColors?.find( + (obj) => obj.tableBodyColor + )?.tableBodyColor; + const footerColor = printColors?.find((obj) => obj.footerColor)?.footerColor; + + // + const headerStyle = { + backgroundColor: headerColor?.background, + color: headerColor?.font, + }; + const tableHeaderStyle = { + backgroundColor: tableHeaderColor?.background, + color: tableHeaderColor?.font, + }; + + const tableBodyStyle = { + backgroundColor: tableBodyColor?.background, + color: tableBodyColor?.font, + }; + + const rowtypeStyle = tableBodyColor?.rowType; + + const footerColorStyle = { + backgroundColor: footerColor?.background, + color: footerColor?.font, + }; + const renderFooter = () => ( <> {/*
*/} @@ -76,7 +139,10 @@ const PrintStyle11PurchaseReturn = ({ <>
{/* {notesText &&

{notesText}

} */} -
+
{termsAndConditions && termsAndConditionsData?.length > 0 && (

Terms & Conditions

@@ -215,8 +281,10 @@ const PrintStyle11PurchaseReturn = ({ `} -
+
{formatTheme ? ( paginatedChunks.map((dataChunk, chunkIndex) => { const isLastPage = chunkIndex === paginatedChunks.length - 1; @@ -243,7 +311,11 @@ const PrintStyle11PurchaseReturn = ({
{formatTheme || chunkIndex === 0 ? ( <> -
+
{/*
*/} ) : null} - + {isLastPage && ( <> {/*
*/} @@ -294,7 +371,7 @@ const PrintStyle11PurchaseReturn = ({ }) ) : (
-
+
{/*
*/} {/*
*/} - + ( -
+const Header = ({ logo, branch, headerStyle }) => ( +
{/* {logo && logo} */}
- -
{branch.CompName}
-
-
+ }} + /> +
{branch.Address1}-{branch.City}-{branch?.Zip}
-
+
Mobile: +91 {branch.BrMobile}
-
+ }} + />
- Date:{' '} - {dateFormatChange1(InvoiceDate)} + Date: {dateFormatChange1(InvoiceDate)}
{VehicleNo && (
@@ -405,7 +486,12 @@ const InvoiceMeta = ({
); -const ProductTable = ({ data }) => { +const ProductTable = ({ + data, + tableHeaderStyle, + rowtypeStyle, + tableBodyStyle, +}) => { const columns = [ { label: 'S.No', key: 'sno', width: '5%' }, { label: 'Product', key: 'ProdName', width: '20%' }, @@ -419,7 +505,7 @@ const ProductTable = ({ data }) => { return (
+ {col.label}
{index + 1} {prod.ProdName}{prod.ProdVariantName}
- + {columns.map((col) => ( {data.map((prod, index) => ( - + {/* */} diff --git a/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle12.jsx b/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle12.jsx index 3bc6b6d..c576455 100644 --- a/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle12.jsx +++ b/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle12.jsx @@ -1,8 +1,19 @@ import { useSelector } from 'react-redux'; -import { GloabalFieldDetails } from '../../../../Features/ThemeChange/ThemeChange'; +import { + GloabalFieldDetails, + GlobalRowType, + GlobalSelectedFooterColor, + GlobalSelectedFooterFontColor, + GlobalSelectedPrintHeaderColor, + GlobalSelectedPrintHeaderFontColor, + GlobalSelectedTableBodyColor, + GlobalSelectedTableBodyFontColor, + GlobalSelectedTableHeaderColor, + GlobalSelectedTableHeaderFontColor, +} from '../../../../Features/ThemeChange/ThemeChange'; import { dateFormatChange1 } from '../../../../Services/Others'; -const PrintStyle12PurchaseReturn = ({ +const PrintStyle12PurchaseReturn = ({ invoiceData, preference, printDatas, @@ -50,6 +61,58 @@ const PrintStyle12PurchaseReturn = ({ const lastChunkRows = paginatedChunks.at(-1)?.length || 0; const shouldFooterBeOnNewPage = lastChunkRows > (pageSize === 'A5' ? 5 : 10); + // + const SelectedHeaderColor = useSelector(GlobalSelectedPrintHeaderColor); + const SelectedHeaderFontColor = useSelector( + GlobalSelectedPrintHeaderFontColor + ); + const SelectedTableHeaderColor = useSelector(GlobalSelectedTableHeaderColor); + const SelectedTableHeaderFontColor = useSelector( + GlobalSelectedTableHeaderFontColor + ); + const SelectedTableBodyColor = useSelector(GlobalSelectedTableBodyColor); + const SelectedTableBodyFontColor = useSelector( + GlobalSelectedTableBodyFontColor + ); + const SelectedRowType = useSelector(GlobalRowType); + const SelectedTableFooterColor = useSelector(GlobalSelectedFooterColor); + const SelectedTableFooterFontColor = useSelector( + GlobalSelectedFooterFontColor + ); + + // + let printColors = FieldDetails?.PrintColors; + const headerColor = printColors?.find((obj) => obj.headerColor)?.headerColor; + const tableHeaderColor = printColors?.find( + (obj) => obj.tableHeaderColor + )?.tableHeaderColor; + const tableBodyColor = printColors?.find( + (obj) => obj.tableBodyColor + )?.tableBodyColor; + const footerColor = printColors?.find((obj) => obj.footerColor)?.footerColor; + + // + const headerStyle = { + backgroundColor: headerColor?.background, + color: headerColor?.font, + }; + const tableHeaderStyle = { + backgroundColor: tableHeaderColor?.background, + color: tableHeaderColor?.font, + }; + + const tableBodyStyle = { + backgroundColor: tableBodyColor?.background, + color: tableBodyColor?.font, + }; + + const rowtypeStyle = tableBodyColor?.rowType; + + const footerColorStyle = { + backgroundColor: footerColor?.background, + color: footerColor?.font, + }; + const renderFooter = () => ( <> {/*
*/} @@ -61,7 +124,7 @@ const PrintStyle12PurchaseReturn = ({ <>
{/* {notesText &&

{notesText}

} */} -
+
{termsAndConditions && termsAndConditionsData?.length > 0 && (

Terms & Conditions

@@ -261,6 +324,7 @@ const PrintStyle12PurchaseReturn = ({ branch={branch} CustName={CustName} SupplierNo={SupplierNo} + headerStyle={headerStyle} /> {/*
*/} ) : null} - + {isLastPage && ( <> {/*
*/} @@ -312,12 +381,12 @@ const PrintStyle12PurchaseReturn = ({ }) ) : (
- {/*
*/}
{/*
*/} @@ -331,7 +400,12 @@ const PrintStyle12PurchaseReturn = ({ SupplierNo={SupplierNo} />
- + - {renderFooter()}
)} @@ -348,22 +421,22 @@ const PrintStyle12PurchaseReturn = ({ ); }; -export default PrintStyle12PurchaseReturn ; +export default PrintStyle12PurchaseReturn; // --- Subcomponents --- -const Header = ({ logo, branch, CustName, SupplierNo }) => ( -
+const Header = ({ logo, branch, CustName, SupplierNo, headerStyle }) => ( +
{branch.CompName}
{branch.Address1}-{branch.City}-{branch?.Zip}
{branch?.BrMobile &&
Mobile: +91 {branch?.BrMobile}
} -
+
{CustName && (
- Supplier Name: {CustName} + Supplier Name: {CustName}
)} {SupplierNo && ( @@ -375,7 +448,6 @@ const Header = ({ logo, branch, CustName, SupplierNo }) => (
Purchase Return
-
{logo && logo}
@@ -398,8 +470,7 @@ const InvoiceMeta = ({
- Date:{' '} - {dateFormatChange1(InvoiceDate)} + Date: {dateFormatChange1(InvoiceDate)}
{VehicleNo && (
@@ -411,7 +482,12 @@ const InvoiceMeta = ({
); -const ProductTable = ({ data }) => { +const ProductTable = ({ + data, + tableHeaderStyle, + rowtypeStyle, + tableBodyStyle, +}) => { const columns = [ { label: 'S.No', key: 'sno', width: '5%' }, { label: 'Product', key: 'ProdName', width: '30%', align: 'left' }, @@ -425,7 +501,7 @@ const ProductTable = ({ data }) => { return (
{col.label} @@ -429,7 +515,20 @@ const ProductTable = ({ data }) => {
{index + 1} {prod.ProdName}{prod.ProdVariantName}
- + {columns.map((col) => ( {data.map((prod, index) => ( - + {/* */} @@ -458,9 +547,7 @@ const Summary = ({ TotalAmount, TaxAmount, GrandTotal }) => (
-
- Subtotal -
+
Subtotal
:
@@ -468,15 +555,13 @@ const Summary = ({ TotalAmount, TaxAmount, GrandTotal }) => (
-
- Tax Amount -
+
Tax Amount
:
₹ {TaxAmount.toFixed(2)}
-
-
+
+
Grand Total @@ -484,11 +569,11 @@ const Summary = ({ TotalAmount, TaxAmount, GrandTotal }) => (
:
{' '} - ₹ {GrandTotal.toFixed(2)} + ₹ {GrandTotal.toFixed(2)}
- -
+ +
); diff --git a/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle2.jsx b/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle2.jsx index 0ea43d2..6b1acdc 100644 --- a/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle2.jsx +++ b/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle2.jsx @@ -1,5 +1,16 @@ import { useSelector } from 'react-redux'; -import { GloabalFieldDetails } from '../../../../Features/ThemeChange/ThemeChange'; +import { + GloabalFieldDetails, + GlobalRowType, + GlobalSelectedFooterColor, + GlobalSelectedFooterFontColor, + GlobalSelectedPrintHeaderColor, + GlobalSelectedPrintHeaderFontColor, + GlobalSelectedTableBodyColor, + GlobalSelectedTableBodyFontColor, + GlobalSelectedTableHeaderColor, + GlobalSelectedTableHeaderFontColor, +} from '../../../../Features/ThemeChange/ThemeChange'; import { dateFormatChange1 } from '../../../../Services/Others'; const PrintStyle2PurchaseReturn = ({ @@ -27,30 +38,30 @@ const PrintStyle2PurchaseReturn = ({ // const signature = fieldDetails?.['signature']; // const termsAndConditions = fieldDetails?.['terms&conditions']; // const termsAndConditionsData = FieldDetails?.TermsandConditions; -// let termsAndConditions = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="terms&conditions") -// let termsAndConditionsData=FieldDetails?.TermsandConditions + // let termsAndConditions = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="terms&conditions") + // let termsAndConditionsData=FieldDetails?.TermsandConditions -// const signatureImg = printDatas?.Signature; -// const notesText = printDatas?.Notes; -// const formatTheme = printDatas?.PrintType !== 'S'; -// const pageSize = printDatas?.PageSize; -// const branch = AddressDetails?.[0]; -// const logo = branch?.CompLogo; + // const signatureImg = printDatas?.Signature; + // const notesText = printDatas?.Notes; + // const formatTheme = printDatas?.PrintType !== 'S'; + // const pageSize = printDatas?.PageSize; + // const branch = AddressDetails?.[0]; + // const logo = branch?.CompLogo; - // const fieldDetails = useSelector(GloabalFieldDetails); - const signature = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="signature"); + // const fieldDetails = useSelector(GloabalFieldDetails); + const signature = FieldDetails?.FieldDetails?.some( + (e) => e?.ConfigName == 'signature' + ); const signatureImg = FieldDetails?.Signature; const notesText = FieldDetails?.Notes; const formatTheme = FieldDetails?.PrintType == 'S'; const pageSize = FieldDetails?.PageSize; const branch = AddressDetails?.[0]; const logo = branch?.CompLogo; - let termsAndConditions = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="terms&conditions") - let termsAndConditionsData=FieldDetails?.TermsandConditions - - - - + let termsAndConditions = FieldDetails?.FieldDetails?.some( + (e) => e?.ConfigName == 'terms&conditions' + ); + let termsAndConditionsData = FieldDetails?.TermsandConditions; const printGreeting = preference?.[0]?.SettingDtlDetails?.find( (i) => i.SettingIdName === 'PrintGreetings' @@ -65,6 +76,60 @@ const PrintStyle2PurchaseReturn = ({ const lastChunkRows = paginatedChunks.at(-1)?.length || 0; const shouldFooterBeOnNewPage = lastChunkRows > (pageSize === 'A5' ? 5 : 10); + // + const SelectedHeaderColor = useSelector(GlobalSelectedPrintHeaderColor); + const SelectedHeaderFontColor = useSelector( + GlobalSelectedPrintHeaderFontColor + ); + const SelectedTableHeaderColor = useSelector(GlobalSelectedTableHeaderColor); + const SelectedTableHeaderFontColor = useSelector( + GlobalSelectedTableHeaderFontColor + ); + const SelectedTableBodyColor = useSelector(GlobalSelectedTableBodyColor); + const SelectedTableBodyFontColor = useSelector( + GlobalSelectedTableBodyFontColor + ); + const SelectedRowType = useSelector(GlobalRowType); + const SelectedTableFooterColor = useSelector(GlobalSelectedFooterColor); + const SelectedTableFooterFontColor = useSelector( + GlobalSelectedFooterFontColor + ); + + // + let printColors = FieldDetails?.PrintColors; + const headerColor = printColors?.find((obj) => obj.headerColor)?.headerColor; + const tableHeaderColor = printColors?.find( + (obj) => obj.tableHeaderColor + )?.tableHeaderColor; + const tableBodyColor = printColors?.find( + (obj) => obj.tableBodyColor + )?.tableBodyColor; + const footerColor = printColors?.find((obj) => obj.footerColor)?.footerColor; + + // + const headerStyle = { + backgroundColor: headerColor?.background, + + color: headerColor?.font, + }; + const tableHeaderStyle = { + backgroundColor: tableHeaderColor?.background, + + color: tableHeaderColor?.font, + }; + + const tableBodyStyle = { + backgroundColor: tableBodyColor?.background, + color: tableBodyColor?.font, + }; + + const rowtypeStyle = tableBodyColor?.rowType; + + const footerColorStyle = { + backgroundColor: footerColor?.background, + color: footerColor?.font, + }; + const renderFooter = () => ( <> {/*
*/} @@ -76,7 +141,10 @@ const PrintStyle2PurchaseReturn = ({ <>
{/* {notesText &&

{notesText}

} */} -
+
{termsAndConditions && termsAndConditionsData?.length > 0 && (

Terms & Conditions

@@ -207,8 +275,10 @@ const PrintStyle2PurchaseReturn = ({ `} -
+
{formatTheme ? ( paginatedChunks.map((dataChunk, chunkIndex) => { const isLastPage = chunkIndex === paginatedChunks.length - 1; @@ -235,7 +305,11 @@ const PrintStyle2PurchaseReturn = ({
{formatTheme || chunkIndex === 0 ? ( <> -
+
{/*
*/} ) : null} - + {isLastPage && ( <> {/*
*/} @@ -286,7 +365,7 @@ const PrintStyle2PurchaseReturn = ({ }) ) : (
-
+
{/*
*/}
- + ( -
+const Header = ({ logo, branch, headerStyle }) => ( +
{logo && logo}
{branch.CompName}
@@ -342,11 +426,13 @@ const Header = ({ logo, branch }) => (
Mobile: +91 {branch.BrMobile}
-
+
Purchase Return
@@ -370,8 +456,7 @@ const InvoiceMeta = ({
- Date:{' '} - {dateFormatChange1(InvoiceDate)} + Date: {dateFormatChange1(InvoiceDate)}
{VehicleNo && (
@@ -383,7 +468,12 @@ const InvoiceMeta = ({
); -const ProductTable = ({ data }) => { +const ProductTable = ({ + data, + tableHeaderStyle, + rowtypeStyle, + tableBodyStyle, +}) => { const columns = [ { label: 'S.No', key: 'sno', width: '5%' }, { label: 'Product', key: 'ProdName', width: '20%' }, @@ -397,7 +487,7 @@ const ProductTable = ({ data }) => { return (
{
{index + 1} {prod.ProdName}{prod.ProdVariantName}
- + {columns.map((col) => ( {data.map((prod, index) => ( - + {/* */} @@ -432,7 +535,7 @@ const Summary = ({ TotalAmount, TaxAmount, GrandTotal }) => (
:
- ₹ {TotalAmount.toFixed(2)} + ₹ {TotalAmount.toFixed(2)}
@@ -441,7 +544,7 @@ const Summary = ({ TotalAmount, TaxAmount, GrandTotal }) => (
:
- ₹ {TaxAmount.toFixed(2)} + ₹ {TaxAmount.toFixed(2)}
@@ -451,7 +554,7 @@ const Summary = ({ TotalAmount, TaxAmount, GrandTotal }) => (
:
{' '} - ₹ {GrandTotal.toFixed(2)} + ₹ {GrandTotal.toFixed(2)}
diff --git a/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle3.jsx b/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle3.jsx index 7ccbfac..1d18921 100644 --- a/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle3.jsx +++ b/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle3.jsx @@ -1,8 +1,19 @@ import { useSelector } from 'react-redux'; -import { GloabalFieldDetails } from '../../../../Features/ThemeChange/ThemeChange'; +import { + GloabalFieldDetails, + GlobalRowType, + GlobalSelectedFooterColor, + GlobalSelectedFooterFontColor, + GlobalSelectedPrintHeaderColor, + GlobalSelectedPrintHeaderFontColor, + GlobalSelectedTableBodyColor, + GlobalSelectedTableBodyFontColor, + GlobalSelectedTableHeaderColor, + GlobalSelectedTableHeaderFontColor, +} from '../../../../Features/ThemeChange/ThemeChange'; import { dateFormatChange1 } from '../../../../Services/Others'; -const PrintStyle3PurchaseReturn = ({ +const PrintStyle3PurchaseReturn = ({ invoiceData, preference, printDatas, @@ -28,17 +39,19 @@ const PrintStyle3PurchaseReturn = ({ // const termsAndConditions = fieldDetails?.['terms&conditions']; // const termsAndConditionsData = FieldDetails?.TermsandConditions; - -const signature = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="signature"); + const signature = FieldDetails?.FieldDetails?.some( + (e) => e?.ConfigName == 'signature' + ); const signatureImg = FieldDetails?.Signature; const notesText = FieldDetails?.Notes; const formatTheme = FieldDetails?.PrintType == 'S'; const pageSize = FieldDetails?.PageSize; const branch = AddressDetails?.[0]; const logo = branch?.CompLogo; - let termsAndConditions = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="terms&conditions") - let termsAndConditionsData=FieldDetails?.TermsandConditions - + let termsAndConditions = FieldDetails?.FieldDetails?.some( + (e) => e?.ConfigName == 'terms&conditions' + ); + let termsAndConditionsData = FieldDetails?.TermsandConditions; const printGreeting = preference?.[0]?.SettingDtlDetails?.find( (i) => i.SettingIdName === 'PrintGreetings' @@ -53,6 +66,60 @@ const signature = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="signatur const lastChunkRows = paginatedChunks.at(-1)?.length || 0; const shouldFooterBeOnNewPage = lastChunkRows > (pageSize === 'A5' ? 5 : 10); + // + const SelectedHeaderColor = useSelector(GlobalSelectedPrintHeaderColor); + const SelectedHeaderFontColor = useSelector( + GlobalSelectedPrintHeaderFontColor + ); + const SelectedTableHeaderColor = useSelector(GlobalSelectedTableHeaderColor); + const SelectedTableHeaderFontColor = useSelector( + GlobalSelectedTableHeaderFontColor + ); + const SelectedTableBodyColor = useSelector(GlobalSelectedTableBodyColor); + const SelectedTableBodyFontColor = useSelector( + GlobalSelectedTableBodyFontColor + ); + const SelectedRowType = useSelector(GlobalRowType); + const SelectedTableFooterColor = useSelector(GlobalSelectedFooterColor); + const SelectedTableFooterFontColor = useSelector( + GlobalSelectedFooterFontColor + ); + + // + let printColors = FieldDetails?.PrintColors; + const headerColor = printColors?.find((obj) => obj.headerColor)?.headerColor; + const tableHeaderColor = printColors?.find( + (obj) => obj.tableHeaderColor + )?.tableHeaderColor; + const tableBodyColor = printColors?.find( + (obj) => obj.tableBodyColor + )?.tableBodyColor; + const footerColor = printColors?.find((obj) => obj.footerColor)?.footerColor; + + // + const headerStyle = { + backgroundColor: headerColor?.background, + + color: headerColor?.font, + }; + const tableHeaderStyle = { + backgroundColor: tableHeaderColor?.background, + + color: tableHeaderColor?.font, + }; + + const tableBodyStyle = { + backgroundColor: tableBodyColor?.background, + color: tableBodyColor?.font, + }; + + const rowtypeStyle = tableBodyColor?.rowType; + + const footerColorStyle = { + backgroundColor: footerColor?.background, + color: footerColor?.font, + }; + const renderFooter = () => ( <> {/*
*/} @@ -64,7 +131,10 @@ const signature = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="signatur <>
{/* {notesText &&

{notesText}

} */} -
+
{termsAndConditions && termsAndConditionsData?.length > 0 && (

Terms & Conditions

@@ -189,8 +259,10 @@ const signature = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="signatur } `} -
+
{formatTheme ? ( paginatedChunks.map((dataChunk, chunkIndex) => { const isLastPage = chunkIndex === paginatedChunks.length - 1; @@ -217,7 +289,11 @@ const signature = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="signatur
{formatTheme || chunkIndex === 0 ? ( <> -
+
{/*
*/} e?.ConfigName=="signatur ) : null} - + {isLastPage && ( <> {/*
*/} @@ -266,7 +347,7 @@ const signature = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="signatur }) ) : (
-
+
{/*
*/} e?.ConfigName=="signatur SupplierNo={SupplierNo} />
- + e?.ConfigName=="signatur ); }; -export default PrintStyle3PurchaseReturn ; +export default PrintStyle3PurchaseReturn; // --- Subcomponents --- -const Header = ({ logo, branch }) => ( -
+const Header = ({ logo, branch, headerStyle }) => ( +
{logo && logo}
{branch.CompName}
@@ -324,7 +410,7 @@ const Header = ({ logo, branch }) => (
Mobile: +91 {branch.BrMobile}
-
+
Purchase Return
@@ -348,8 +434,7 @@ const InvoiceMeta = ({
- Date:{' '} - {dateFormatChange1(InvoiceDate)} + Date: {dateFormatChange1(InvoiceDate)}
{VehicleNo && (
@@ -361,7 +446,12 @@ const InvoiceMeta = ({
); -const ProductTable = ({ data }) => { +const ProductTable = ({ + data, + tableHeaderStyle, + rowtypeStyle, + tableBodyStyle, +}) => { const columns = [ { label: 'S.No', key: 'sno', width: '5%' }, { label: 'Product', key: 'ProdName', width: '20%' }, @@ -375,7 +465,7 @@ const ProductTable = ({ data }) => { return (
{col.label} @@ -407,7 +497,20 @@ const ProductTable = ({ data }) => {
{index + 1} {prod.ProdName}{prod.ProdVariantName}
- + {columns.map((col) => ( {data.map((prod, index) => ( - + {/* */} diff --git a/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle4.jsx b/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle4.jsx index afc26fb..53b4253 100644 --- a/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle4.jsx +++ b/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle4.jsx @@ -1,8 +1,19 @@ import { useSelector } from 'react-redux'; -import { GloabalFieldDetails } from '../../../../Features/ThemeChange/ThemeChange'; +import { + GloabalFieldDetails, + GlobalRowType, + GlobalSelectedFooterColor, + GlobalSelectedFooterFontColor, + GlobalSelectedPrintHeaderColor, + GlobalSelectedPrintHeaderFontColor, + GlobalSelectedTableBodyColor, + GlobalSelectedTableBodyFontColor, + GlobalSelectedTableHeaderColor, + GlobalSelectedTableHeaderFontColor, +} from '../../../../Features/ThemeChange/ThemeChange'; import { dateFormatChange1 } from '../../../../Services/Others'; -const PrintStyle4PurchaseReturn = ({ +const PrintStyle4PurchaseReturn = ({ invoiceData, preference, printDatas, @@ -24,15 +35,19 @@ const PrintStyle4PurchaseReturn = ({ } = invoiceData; console.log(printDatas, 'printDatas'); const fieldDetails = useSelector(GloabalFieldDetails); -const signature = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="signature"); + const signature = FieldDetails?.FieldDetails?.some( + (e) => e?.ConfigName == 'signature' + ); const signatureImg = FieldDetails?.Signature; const notesText = FieldDetails?.Notes; const formatTheme = FieldDetails?.PrintType == 'S'; const pageSize = FieldDetails?.PageSize; const branch = AddressDetails?.[0]; const logo = branch?.CompLogo; - let termsAndConditions = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="terms&conditions") - let termsAndConditionsData=FieldDetails?.TermsandConditions + let termsAndConditions = FieldDetails?.FieldDetails?.some( + (e) => e?.ConfigName == 'terms&conditions' + ); + let termsAndConditionsData = FieldDetails?.TermsandConditions; const printGreeting = preference?.[0]?.SettingDtlDetails?.find( (i) => i.SettingIdName === 'PrintGreetings' ); @@ -46,6 +61,58 @@ const signature = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="signatur const lastChunkRows = paginatedChunks.at(-1)?.length || 0; const shouldFooterBeOnNewPage = lastChunkRows > (pageSize === 'A5' ? 5 : 10); + // + const SelectedHeaderColor = useSelector(GlobalSelectedPrintHeaderColor); + const SelectedHeaderFontColor = useSelector( + GlobalSelectedPrintHeaderFontColor + ); + const SelectedTableHeaderColor = useSelector(GlobalSelectedTableHeaderColor); + const SelectedTableHeaderFontColor = useSelector( + GlobalSelectedTableHeaderFontColor + ); + const SelectedTableBodyColor = useSelector(GlobalSelectedTableBodyColor); + const SelectedTableBodyFontColor = useSelector( + GlobalSelectedTableBodyFontColor + ); + const SelectedRowType = useSelector(GlobalRowType); + const SelectedTableFooterColor = useSelector(GlobalSelectedFooterColor); + const SelectedTableFooterFontColor = useSelector( + GlobalSelectedFooterFontColor + ); + + // + let printColors = FieldDetails?.PrintColors; + const headerColor = printColors?.find((obj) => obj.headerColor)?.headerColor; + const tableHeaderColor = printColors?.find( + (obj) => obj.tableHeaderColor + )?.tableHeaderColor; + const tableBodyColor = printColors?.find( + (obj) => obj.tableBodyColor + )?.tableBodyColor; + const footerColor = printColors?.find((obj) => obj.footerColor)?.footerColor; + + // + const headerStyle = { + backgroundColor: headerColor?.background, + color: headerColor?.font, + }; + const tableHeaderStyle = { + backgroundColor: tableHeaderColor?.background, + color: tableHeaderColor?.font, + }; + + const tableBodyStyle = { + backgroundColor: tableBodyColor?.background, + color: tableBodyColor?.font, + }; + + const rowtypeStyle = tableBodyColor?.rowType; + + const footerColorStyle = { + backgroundColor: footerColor?.background, + color: footerColor?.font, + }; + const renderFooter = () => ( <> {/*
*/} @@ -57,7 +124,10 @@ const signature = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="signatur <>
{/* {notesText &&

{notesText}

} */} -
+
{termsAndConditions && termsAndConditionsData?.length > 0 && (

Terms & Conditions

@@ -189,6 +259,7 @@ padding-top: 10px; } `} +
{formatTheme || chunkIndex === 0 ? ( <> -
+
{/*
*/} ) : null} - + {isLastPage && ( <> {/*
*/} @@ -268,7 +348,7 @@ padding-top: 10px; }) ) : (
-
+
{/*
*/}
- + ( -
+const Header = ({ logo, branch, headerStyle }) => ( +
{logo && logo}
{branch.CompName}
@@ -326,7 +411,7 @@ const Header = ({ logo, branch }) => (
Mobile: +91 {branch.BrMobile}
-
+
Purchase Return
@@ -350,8 +435,7 @@ const InvoiceMeta = ({
- Date:{' '} - {dateFormatChange1(InvoiceDate)} + Date: {dateFormatChange1(InvoiceDate)}
{VehicleNo && (
@@ -363,7 +447,12 @@ const InvoiceMeta = ({
); -const ProductTable = ({ data }) => { +const ProductTable = ({ + data, + tableHeaderStyle, + rowtypeStyle, + tableBodyStyle, +}) => { const columns = [ { label: 'S.No', key: 'sno', width: '5%' }, { label: 'Product', key: 'ProdName', width: '20%' }, @@ -377,7 +466,7 @@ const ProductTable = ({ data }) => { return (
{col.label} @@ -385,7 +475,20 @@ const ProductTable = ({ data }) => {
{index + 1} {prod.ProdName}{prod.ProdVariantName}
- + {columns.map((col) => ( {data.map((prod, index) => ( - + {/* */} diff --git a/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle5.jsx b/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle5.jsx index 52e92ab..98e0c5e 100644 --- a/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle5.jsx +++ b/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle5.jsx @@ -1,8 +1,19 @@ import { useSelector } from 'react-redux'; -import { GloabalFieldDetails } from '../../../../Features/ThemeChange/ThemeChange'; +import { + GloabalFieldDetails, + GlobalRowType, + GlobalSelectedFooterColor, + GlobalSelectedFooterFontColor, + GlobalSelectedPrintHeaderColor, + GlobalSelectedPrintHeaderFontColor, + GlobalSelectedTableBodyColor, + GlobalSelectedTableBodyFontColor, + GlobalSelectedTableHeaderColor, + GlobalSelectedTableHeaderFontColor, +} from '../../../../Features/ThemeChange/ThemeChange'; import { dateFormatChange1 } from '../../../../Services/Others'; -const PrintStyle5PurchaseReturn = ({ +const PrintStyle5PurchaseReturn = ({ invoiceData, preference, printDatas, @@ -25,15 +36,19 @@ const PrintStyle5PurchaseReturn = ({ console.log(printDatas, 'printDatas'); const fieldDetails = useSelector(GloabalFieldDetails); -const signature = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="signature"); + const signature = FieldDetails?.FieldDetails?.some( + (e) => e?.ConfigName == 'signature' + ); const signatureImg = FieldDetails?.Signature; const notesText = FieldDetails?.Notes; const formatTheme = FieldDetails?.PrintType == 'S'; const pageSize = FieldDetails?.PageSize; const branch = AddressDetails?.[0]; const logo = branch?.CompLogo; - let termsAndConditions = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="terms&conditions") - let termsAndConditionsData=FieldDetails?.TermsandConditions + let termsAndConditions = FieldDetails?.FieldDetails?.some( + (e) => e?.ConfigName == 'terms&conditions' + ); + let termsAndConditionsData = FieldDetails?.TermsandConditions; const printGreeting = preference?.[0]?.SettingDtlDetails?.find( (i) => i.SettingIdName === 'PrintGreetings' ); @@ -47,6 +62,58 @@ const signature = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="signatur const lastChunkRows = paginatedChunks.at(-1)?.length || 0; const shouldFooterBeOnNewPage = lastChunkRows > (pageSize === 'A5' ? 5 : 10); + // + const SelectedHeaderColor = useSelector(GlobalSelectedPrintHeaderColor); + const SelectedHeaderFontColor = useSelector( + GlobalSelectedPrintHeaderFontColor + ); + const SelectedTableHeaderColor = useSelector(GlobalSelectedTableHeaderColor); + const SelectedTableHeaderFontColor = useSelector( + GlobalSelectedTableHeaderFontColor + ); + const SelectedTableBodyColor = useSelector(GlobalSelectedTableBodyColor); + const SelectedTableBodyFontColor = useSelector( + GlobalSelectedTableBodyFontColor + ); + const SelectedRowType = useSelector(GlobalRowType); + const SelectedTableFooterColor = useSelector(GlobalSelectedFooterColor); + const SelectedTableFooterFontColor = useSelector( + GlobalSelectedFooterFontColor + ); + + // + let printColors = FieldDetails?.PrintColors; + const headerColor = printColors?.find((obj) => obj.headerColor)?.headerColor; + const tableHeaderColor = printColors?.find( + (obj) => obj.tableHeaderColor + )?.tableHeaderColor; + const tableBodyColor = printColors?.find( + (obj) => obj.tableBodyColor + )?.tableBodyColor; + const footerColor = printColors?.find((obj) => obj.footerColor)?.footerColor; + + // + const headerStyle = { + backgroundColor: headerColor?.background, + color: headerColor?.font, + }; + const tableHeaderStyle = { + backgroundColor: tableHeaderColor?.background, + color: tableHeaderColor?.font, + }; + + const tableBodyStyle = { + backgroundColor: tableBodyColor?.background, + color: tableBodyColor?.font, + }; + + const rowtypeStyle = tableBodyColor?.rowType; + + const footerColorStyle = { + backgroundColor: footerColor?.background, + color: footerColor?.font, + }; + const renderFooter = () => ( <> {/*
*/} @@ -58,7 +125,10 @@ const signature = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="signatur <>
{/* {notesText &&

{notesText}

} */} -
+
{termsAndConditions && termsAndConditionsData?.length > 0 && (

Terms & Conditions

@@ -215,13 +285,15 @@ const signature = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="signatur } `} -
+
{formatTheme ? ( paginatedChunks.map((dataChunk, chunkIndex) => { const isLastPage = chunkIndex === paginatedChunks.length - 1; const isFinalFooterPage = isLastPage && !shouldFooterBeOnNewPage; - return (
e?.ConfigName=="signatur
{formatTheme || chunkIndex === 0 ? ( <> -
+

e?.ConfigName=="signatur ) : null} - + {isLastPage && ( <> {/*
*/} @@ -292,7 +373,7 @@ const signature = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="signatur }) ) : (
-
+

e?.ConfigName=="signatur SupplierNo={SupplierNo} />
- + - + {/*
*/} @@ -320,11 +406,11 @@ const signature = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="signatur Supplier Name: {CustName}
)} - {SupplierNo && -
- Supplier Mobile No: {SupplierNo || '-'} -
- } + {SupplierNo && ( +
+ Supplier Mobile No: {SupplierNo || '-'} +
+ )}
{renderFooter()} @@ -335,12 +421,12 @@ const signature = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="signatur ); }; -export default PrintStyle5PurchaseReturn ; +export default PrintStyle5PurchaseReturn; // --- Subcomponents --- -const Header = ({ logo, branch }) => ( -
+const Header = ({ logo, branch, headerStyle }) => ( +
{logo && logo}
{branch.CompName}
@@ -374,8 +460,7 @@ const InvoiceMeta = ({
- Date:{' '} - {dateFormatChange1(InvoiceDate)} + Date: {dateFormatChange1(InvoiceDate)}
{VehicleNo && (
@@ -387,7 +472,12 @@ const InvoiceMeta = ({
); -const ProductTable = ({ data }) => { +const ProductTable = ({ + data, + tableHeaderStyle, + tableBodyStyle, + rowtypeStyle, +}) => { const columns = [ { label: 'S.No', key: 'sno', width: '5%' }, { label: 'Product', key: 'ProdName', width: '20%' }, @@ -400,8 +490,8 @@ const ProductTable = ({ data }) => { return (
{col.label} @@ -387,7 +476,20 @@ const ProductTable = ({ data }) => {
{index + 1} {prod.ProdName}{prod.ProdVariantName}
- - + + {columns.map((col) => ( {data.map((prod, index) => ( - + {/* */} @@ -460,4 +563,4 @@ const Summary = ({ TotalAmount, TaxAmount, GrandTotal }) => ( -); \ No newline at end of file +); diff --git a/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle6.jsx b/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle6.jsx index aaffe8a..edfc118 100644 --- a/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle6.jsx +++ b/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle6.jsx @@ -1,8 +1,19 @@ import { useSelector } from 'react-redux'; -import { GloabalFieldDetails } from '../../../../Features/ThemeChange/ThemeChange'; +import { + GloabalFieldDetails, + GlobalRowType, + GlobalSelectedFooterColor, + GlobalSelectedFooterFontColor, + GlobalSelectedPrintHeaderColor, + GlobalSelectedPrintHeaderFontColor, + GlobalSelectedTableBodyColor, + GlobalSelectedTableBodyFontColor, + GlobalSelectedTableHeaderColor, + GlobalSelectedTableHeaderFontColor, +} from '../../../../Features/ThemeChange/ThemeChange'; import { dateFormatChange1 } from '../../../../Services/Others'; -const PrintStyle6PurchaseReturn = ({ +const PrintStyle6PurchaseReturn = ({ invoiceData, preference, printDatas, @@ -23,15 +34,19 @@ const PrintStyle6PurchaseReturn = ({ VehicleNo, } = invoiceData; console.log(printDatas, 'printDatas'); -const signature = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="signature"); + const signature = FieldDetails?.FieldDetails?.some( + (e) => e?.ConfigName == 'signature' + ); const signatureImg = FieldDetails?.Signature; const notesText = FieldDetails?.Notes; const formatTheme = FieldDetails?.PrintType == 'S'; const pageSize = FieldDetails?.PageSize; const branch = AddressDetails?.[0]; const logo = branch?.CompLogo; - let termsAndConditions = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="terms&conditions") - let termsAndConditionsData=FieldDetails?.TermsandConditions + let termsAndConditions = FieldDetails?.FieldDetails?.some( + (e) => e?.ConfigName == 'terms&conditions' + ); + let termsAndConditionsData = FieldDetails?.TermsandConditions; const printGreeting = preference?.[0]?.SettingDtlDetails?.find( (i) => i.SettingIdName === 'PrintGreetings' @@ -46,6 +61,58 @@ const signature = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="signatur const lastChunkRows = paginatedChunks.at(-1)?.length || 0; const shouldFooterBeOnNewPage = lastChunkRows > (pageSize === 'A5' ? 5 : 10); + // + const SelectedHeaderColor = useSelector(GlobalSelectedPrintHeaderColor); + const SelectedHeaderFontColor = useSelector( + GlobalSelectedPrintHeaderFontColor + ); + const SelectedTableHeaderColor = useSelector(GlobalSelectedTableHeaderColor); + const SelectedTableHeaderFontColor = useSelector( + GlobalSelectedTableHeaderFontColor + ); + const SelectedTableBodyColor = useSelector(GlobalSelectedTableBodyColor); + const SelectedTableBodyFontColor = useSelector( + GlobalSelectedTableBodyFontColor + ); + const SelectedRowType = useSelector(GlobalRowType); + const SelectedTableFooterColor = useSelector(GlobalSelectedFooterColor); + const SelectedTableFooterFontColor = useSelector( + GlobalSelectedFooterFontColor + ); + + // + let printColors = FieldDetails?.PrintColors; + const headerColor = printColors?.find((obj) => obj.headerColor)?.headerColor; + const tableHeaderColor = printColors?.find( + (obj) => obj.tableHeaderColor + )?.tableHeaderColor; + const tableBodyColor = printColors?.find( + (obj) => obj.tableBodyColor + )?.tableBodyColor; + const footerColor = printColors?.find((obj) => obj.footerColor)?.footerColor; + + // + const headerStyle = { + backgroundColor: headerColor?.background, + color: headerColor?.font, + }; + const tableHeaderStyle = { + backgroundColor: tableHeaderColor?.background, + color: tableHeaderColor?.font, + }; + + const tableBodyStyle = { + backgroundColor: tableBodyColor?.background, + color: tableBodyColor?.font, + }; + + const rowtypeStyle = tableBodyColor?.rowType; + + const footerColorStyle = { + backgroundColor: footerColor?.background, + color: footerColor?.font, + }; + const renderFooter = () => ( <> {/*
*/} @@ -57,7 +124,10 @@ const signature = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="signatur <>
{/* {notesText &&

{notesText}

} */} -
+
{termsAndConditions && termsAndConditionsData?.length > 0 && (

Terms & Conditions

@@ -205,14 +275,15 @@ const signature = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="signatur } `} -
+
{formatTheme ? ( paginatedChunks.map((dataChunk, chunkIndex) => { const isLastPage = chunkIndex === paginatedChunks.length - 1; const isFinalFooterPage = isLastPage && !shouldFooterBeOnNewPage; - return (
e?.ConfigName=="signatur
{formatTheme || chunkIndex === 0 ? ( <> -
+
{/*
*/} e?.ConfigName=="signatur ) : null} - + {isLastPage && ( <> {/*
*/} @@ -283,7 +363,7 @@ const signature = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="signatur }) ) : (
-
+
{/*
*/} e?.ConfigName=="signatur SupplierNo={SupplierNo} />
- + e?.ConfigName=="signatur ); }; -export default PrintStyle6PurchaseReturn ; +export default PrintStyle6PurchaseReturn; // --- Subcomponents --- -const Header = ({ logo, branch }) => ( -
+const Header = ({ logo, branch, headerStyle }) => ( +
{logo && logo}
{branch.CompName}
{branch.Address1}-{branch.City}-{branch?.Zip}
-
- Mobile: +91 {branch.BrMobile} -
+
Mobile: +91 {branch.BrMobile}
Purchase Return
@@ -365,8 +448,7 @@ const InvoiceMeta = ({
- Date:{' '} - {dateFormatChange1(InvoiceDate)} + Date: {dateFormatChange1(InvoiceDate)}
{VehicleNo && (
@@ -378,7 +460,12 @@ const InvoiceMeta = ({
); -const ProductTable = ({ data }) => { +const ProductTable = ({ + data, + tableHeaderStyle, + rowtypeStyle, + tableBodyStyle, +}) => { const columns = [ { label: 'S.No', key: 'sno', width: '5%' }, { label: 'Product', key: 'ProdName', width: '20%' }, @@ -392,7 +479,7 @@ const ProductTable = ({ data }) => { return (
{col.label} @@ -411,7 +501,20 @@ const ProductTable = ({ data }) => {
{index + 1} {prod.ProdName}{prod.ProdVariantName}
- + {columns.map((col) => ( {data.map((prod, index) => ( - + {/* */} diff --git a/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle7.jsx b/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle7.jsx index a3fdc30..b59f822 100644 --- a/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle7.jsx +++ b/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle7.jsx @@ -1,8 +1,19 @@ import { useSelector } from 'react-redux'; -import { GloabalFieldDetails } from '../../../../Features/ThemeChange/ThemeChange'; +import { + GloabalFieldDetails, + GlobalRowType, + GlobalSelectedFooterColor, + GlobalSelectedFooterFontColor, + GlobalSelectedPrintHeaderColor, + GlobalSelectedPrintHeaderFontColor, + GlobalSelectedTableBodyColor, + GlobalSelectedTableBodyFontColor, + GlobalSelectedTableHeaderColor, + GlobalSelectedTableHeaderFontColor, +} from '../../../../Features/ThemeChange/ThemeChange'; import { dateFormatChange1 } from '../../../../Services/Others'; -const PrintStyle7PurchaseReturn = ({ +const PrintStyle7PurchaseReturn = ({ invoiceData, preference, printDatas, @@ -23,15 +34,19 @@ const PrintStyle7PurchaseReturn = ({ VehicleNo, } = invoiceData; console.log(printDatas, 'printDatas'); -const signature = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="signature"); + const signature = FieldDetails?.FieldDetails?.some( + (e) => e?.ConfigName == 'signature' + ); const signatureImg = FieldDetails?.Signature; const notesText = FieldDetails?.Notes; const formatTheme = FieldDetails?.PrintType == 'S'; const pageSize = FieldDetails?.PageSize; const branch = AddressDetails?.[0]; const logo = branch?.CompLogo; - let termsAndConditions = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="terms&conditions") - let termsAndConditionsData=FieldDetails?.TermsandConditions + let termsAndConditions = FieldDetails?.FieldDetails?.some( + (e) => e?.ConfigName == 'terms&conditions' + ); + let termsAndConditionsData = FieldDetails?.TermsandConditions; const printGreeting = preference?.[0]?.SettingDtlDetails?.find( (i) => i.SettingIdName === 'PrintGreetings' @@ -46,6 +61,58 @@ const signature = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="signatur const lastChunkRows = paginatedChunks.at(-1)?.length || 0; const shouldFooterBeOnNewPage = lastChunkRows > (pageSize === 'A5' ? 5 : 10); + // + const SelectedHeaderColor = useSelector(GlobalSelectedPrintHeaderColor); + const SelectedHeaderFontColor = useSelector( + GlobalSelectedPrintHeaderFontColor + ); + const SelectedTableHeaderColor = useSelector(GlobalSelectedTableHeaderColor); + const SelectedTableHeaderFontColor = useSelector( + GlobalSelectedTableHeaderFontColor + ); + const SelectedTableBodyColor = useSelector(GlobalSelectedTableBodyColor); + const SelectedTableBodyFontColor = useSelector( + GlobalSelectedTableBodyFontColor + ); + const SelectedRowType = useSelector(GlobalRowType); + const SelectedTableFooterColor = useSelector(GlobalSelectedFooterColor); + const SelectedTableFooterFontColor = useSelector( + GlobalSelectedFooterFontColor + ); + + // + let printColors = FieldDetails?.PrintColors; + const headerColor = printColors?.find((obj) => obj.headerColor)?.headerColor; + const tableHeaderColor = printColors?.find( + (obj) => obj.tableHeaderColor + )?.tableHeaderColor; + const tableBodyColor = printColors?.find( + (obj) => obj.tableBodyColor + )?.tableBodyColor; + const footerColor = printColors?.find((obj) => obj.footerColor)?.footerColor; + + // + const headerStyle = { + backgroundColor: headerColor?.background, + color: headerColor?.font, + }; + const tableHeaderStyle = { + backgroundColor: tableHeaderColor?.background, + color: tableHeaderColor?.font, + }; + + const tableBodyStyle = { + backgroundColor: tableBodyColor?.background, + color: tableBodyColor?.font, + }; + + const rowtypeStyle = tableBodyColor?.rowType; + + const footerColorStyle = { + backgroundColor: footerColor?.background, + color: footerColor?.font, + }; + const renderFooter = () => ( <> {/*
*/} @@ -57,7 +124,10 @@ const signature = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="signatur <>
{/* {notesText &&

{notesText}

} */} -
+
{termsAndConditions && termsAndConditionsData?.length > 0 && (

Terms & Conditions

@@ -205,14 +275,15 @@ const signature = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="signatur `} -
+
{formatTheme ? ( paginatedChunks.map((dataChunk, chunkIndex) => { const isLastPage = chunkIndex === paginatedChunks.length - 1; const isFinalFooterPage = isLastPage && !shouldFooterBeOnNewPage; - return (
e?.ConfigName=="signatur
{formatTheme || chunkIndex === 0 ? ( <> -
+

e?.ConfigName=="signatur ) : null} - + {isLastPage && ( <> {/*
*/} @@ -283,7 +363,7 @@ const signature = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="signatur }) ) : (
-
+

e?.ConfigName=="signatur SupplierNo={SupplierNo} />
- + e?.ConfigName=="signatur ); }; -export default PrintStyle7PurchaseReturn ; +export default PrintStyle7PurchaseReturn; // --- Subcomponents --- -const Header = ({ logo, branch }) => ( -
+const Header = ({ logo, branch, headerStyle }) => ( +
{logo && logo}
{branch.CompName}
{branch.Address1}-{branch.City}-{branch?.Zip}
-
- Mobile: +91 {branch.BrMobile} -
+
Mobile: +91 {branch.BrMobile}
Purchase Return
@@ -365,8 +448,7 @@ const InvoiceMeta = ({
- Date:{' '} - {dateFormatChange1(InvoiceDate)} + Date: {dateFormatChange1(InvoiceDate)}
{VehicleNo && (
@@ -378,7 +460,12 @@ const InvoiceMeta = ({
); -const ProductTable = ({ data }) => { +const ProductTable = ({ + data, + tableHeaderStyle, + rowtypeStyle, + tableBodyStyle, +}) => { const columns = [ { label: 'S.No', key: 'sno', width: '5%' }, { label: 'Product', key: 'ProdName', width: '20%' }, @@ -392,7 +479,7 @@ const ProductTable = ({ data }) => { return (
{col.label} @@ -402,7 +489,20 @@ const ProductTable = ({ data }) => {
{index + 1} {prod.ProdName}{prod.ProdVariantName}
- + {columns.map((col) => ( {data.map((prod, index) => ( - + {/* */} @@ -437,17 +537,20 @@ const Summary = ({ TotalAmount, TaxAmount, GrandTotal }) => ( -
+
Grand Total
:
-
+
{' '} ₹ {GrandTotal.toFixed(2)}
diff --git a/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle8.jsx b/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle8.jsx index 94584f6..2a1e93a 100644 --- a/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle8.jsx +++ b/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle8.jsx @@ -1,8 +1,19 @@ import { useSelector } from 'react-redux'; -import { GloabalFieldDetails } from '../../../../Features/ThemeChange/ThemeChange'; +import { + GloabalFieldDetails, + GlobalRowType, + GlobalSelectedFooterColor, + GlobalSelectedFooterFontColor, + GlobalSelectedPrintHeaderColor, + GlobalSelectedPrintHeaderFontColor, + GlobalSelectedTableBodyColor, + GlobalSelectedTableBodyFontColor, + GlobalSelectedTableHeaderColor, + GlobalSelectedTableHeaderFontColor, +} from '../../../../Features/ThemeChange/ThemeChange'; import { dateFormatChange1 } from '../../../../Services/Others'; -const PrintStyle8PurchaseReturn = ({ +const PrintStyle8PurchaseReturn = ({ invoiceData, preference, printDatas, @@ -50,6 +61,58 @@ const PrintStyle8PurchaseReturn = ({ const lastChunkRows = paginatedChunks.at(-1)?.length || 0; const shouldFooterBeOnNewPage = lastChunkRows > (pageSize === 'A5' ? 5 : 10); + // + const SelectedHeaderColor = useSelector(GlobalSelectedPrintHeaderColor); + const SelectedHeaderFontColor = useSelector( + GlobalSelectedPrintHeaderFontColor + ); + const SelectedTableHeaderColor = useSelector(GlobalSelectedTableHeaderColor); + const SelectedTableHeaderFontColor = useSelector( + GlobalSelectedTableHeaderFontColor + ); + const SelectedTableBodyColor = useSelector(GlobalSelectedTableBodyColor); + const SelectedTableBodyFontColor = useSelector( + GlobalSelectedTableBodyFontColor + ); + const SelectedRowType = useSelector(GlobalRowType); + const SelectedTableFooterColor = useSelector(GlobalSelectedFooterColor); + const SelectedTableFooterFontColor = useSelector( + GlobalSelectedFooterFontColor + ); + + // + let printColors = FieldDetails?.PrintColors; + const headerColor = printColors?.find((obj) => obj.headerColor)?.headerColor; + const tableHeaderColor = printColors?.find( + (obj) => obj.tableHeaderColor + )?.tableHeaderColor; + const tableBodyColor = printColors?.find( + (obj) => obj.tableBodyColor + )?.tableBodyColor; + const footerColor = printColors?.find((obj) => obj.footerColor)?.footerColor; + + // + const headerStyle = { + backgroundColor: headerColor?.background, + color: headerColor?.font, + }; + const tableHeaderStyle = { + backgroundColor: tableHeaderColor?.background, + color: tableHeaderColor?.font, + }; + + const tableBodyStyle = { + backgroundColor: tableBodyColor?.background, + color: tableBodyColor?.font, + }; + + const rowtypeStyle = tableBodyColor?.rowType; + + const footerColorStyle = { + backgroundColor: footerColor?.background, + color: footerColor?.font, + }; + const renderFooter = () => ( <> {/*
*/} @@ -61,7 +124,10 @@ const PrintStyle8PurchaseReturn = ({ <>
{/* {notesText &&

{notesText}

} */} -
+
{termsAndConditions && termsAndConditionsData?.length > 0 && (

Terms & Conditions

@@ -251,7 +317,11 @@ padding-top: 10px;
{formatTheme || chunkIndex === 0 ? ( <> -
+
{/*
*/} ) : null} - + {isLastPage && ( <> {/*
*/} @@ -302,7 +377,7 @@ padding-top: 10px; }) ) : (
-
+
{/*
*/}
- + ( -
+const Header = ({ logo, branch, headerStyle }) => ( +
{logo && logo}
{branch.CompName}
@@ -382,8 +462,7 @@ const InvoiceMeta = ({
- Date:{' '} - {dateFormatChange1(InvoiceDate)} + Date: {dateFormatChange1(InvoiceDate)}
{VehicleNo && (
@@ -395,7 +474,12 @@ const InvoiceMeta = ({
); -const ProductTable = ({ data }) => { +const ProductTable = ({ + data, + tableHeaderStyle, + rowtypeStyle, + tableBodyStyle, +}) => { const columns = [ { label: 'S.No', key: 'sno', width: '5%' }, { label: 'Product', key: 'ProdName', width: '30%', align: 'left' }, @@ -409,7 +493,7 @@ const ProductTable = ({ data }) => { return (
{col.label} @@ -402,7 +489,20 @@ const ProductTable = ({ data }) => {
{index + 1} {prod.ProdName}{prod.ProdVariantName}
- + {columns.map((col) => ( {data.map((prod, index) => ( - + {/* */} diff --git a/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle9.jsx b/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle9.jsx index e0ef8f9..23b8126 100644 --- a/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle9.jsx +++ b/src/Pages/PurchaseReturn/PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle9.jsx @@ -1,8 +1,19 @@ import { useSelector } from 'react-redux'; -import { GloabalFieldDetails } from '../../../../Features/ThemeChange/ThemeChange'; +import { + GloabalFieldDetails, + GlobalRowType, + GlobalSelectedFooterColor, + GlobalSelectedFooterFontColor, + GlobalSelectedPrintHeaderColor, + GlobalSelectedPrintHeaderFontColor, + GlobalSelectedTableBodyColor, + GlobalSelectedTableBodyFontColor, + GlobalSelectedTableHeaderColor, + GlobalSelectedTableHeaderFontColor, +} from '../../../../Features/ThemeChange/ThemeChange'; import { dateFormatChange1 } from '../../../../Services/Others'; -const PrintStyle9PurchaseReturn = ({ +const PrintStyle9PurchaseReturn = ({ invoiceData, preference, printDatas, @@ -24,15 +35,19 @@ const PrintStyle9PurchaseReturn = ({ } = invoiceData; console.log(printDatas, 'printDatas'); const fieldDetails = useSelector(GloabalFieldDetails); -const signature = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="signature"); + const signature = FieldDetails?.FieldDetails?.some( + (e) => e?.ConfigName == 'signature' + ); const signatureImg = FieldDetails?.Signature; const notesText = FieldDetails?.Notes; const formatTheme = FieldDetails?.PrintType == 'S'; const pageSize = FieldDetails?.PageSize; const branch = AddressDetails?.[0]; const logo = branch?.CompLogo; - let termsAndConditions = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="terms&conditions") - let termsAndConditionsData=FieldDetails?.TermsandConditions + let termsAndConditions = FieldDetails?.FieldDetails?.some( + (e) => e?.ConfigName == 'terms&conditions' + ); + let termsAndConditionsData = FieldDetails?.TermsandConditions; const printGreeting = preference?.[0]?.SettingDtlDetails?.find( (i) => i.SettingIdName === 'PrintGreetings' ); @@ -46,6 +61,58 @@ const signature = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="signatur const lastChunkRows = paginatedChunks.at(-1)?.length || 0; const shouldFooterBeOnNewPage = lastChunkRows > (pageSize === 'A5' ? 5 : 10); + // + const SelectedHeaderColor = useSelector(GlobalSelectedPrintHeaderColor); + const SelectedHeaderFontColor = useSelector( + GlobalSelectedPrintHeaderFontColor + ); + const SelectedTableHeaderColor = useSelector(GlobalSelectedTableHeaderColor); + const SelectedTableHeaderFontColor = useSelector( + GlobalSelectedTableHeaderFontColor + ); + const SelectedTableBodyColor = useSelector(GlobalSelectedTableBodyColor); + const SelectedTableBodyFontColor = useSelector( + GlobalSelectedTableBodyFontColor + ); + const SelectedRowType = useSelector(GlobalRowType); + const SelectedTableFooterColor = useSelector(GlobalSelectedFooterColor); + const SelectedTableFooterFontColor = useSelector( + GlobalSelectedFooterFontColor + ); + + // + let printColors = FieldDetails?.PrintColors; + const headerColor = printColors?.find((obj) => obj.headerColor)?.headerColor; + const tableHeaderColor = printColors?.find( + (obj) => obj.tableHeaderColor + )?.tableHeaderColor; + const tableBodyColor = printColors?.find( + (obj) => obj.tableBodyColor + )?.tableBodyColor; + const footerColor = printColors?.find((obj) => obj.footerColor)?.footerColor; + + // + const headerStyle = { + backgroundColor: headerColor?.background, + color: headerColor?.font, + }; + const tableHeaderStyle = { + backgroundColor: tableHeaderColor?.background, + color: tableHeaderColor?.font, + }; + + const tableBodyStyle = { + backgroundColor: tableBodyColor?.background, + color: tableBodyColor?.font, + }; + + const rowtypeStyle = tableBodyColor?.rowType; + + const footerColorStyle = { + backgroundColor: footerColor?.background, + color: footerColor?.font, + }; + const renderFooter = () => ( <> {/*
*/} @@ -57,7 +124,10 @@ const signature = FieldDetails?.FieldDetails?.some((e)=>e?.ConfigName=="signatur <>
{/* {notesText &&

{notesText}

} */} -
+
{termsAndConditions && termsAndConditionsData?.length > 0 && (

Terms & Conditions

@@ -249,7 +319,11 @@ padding-top: 10px;
{formatTheme || chunkIndex === 0 ? ( <> -
+
{/*
*/} ) : null} - + {isLastPage && ( <> {/*
*/} @@ -281,10 +360,12 @@ padding-top: 10px; Supplier Name: {CustName}
)} - {SupplierNo&&
- Supplier Mobile No:{' '} - {SupplierNo || '-'} -
} + {SupplierNo && ( +
+ Supplier Mobile No:{' '} + {SupplierNo || '-'} +
+ )}
)} @@ -298,7 +379,7 @@ padding-top: 10px; }) ) : (
-
+
{/*
*/}
- + ( -
+const Header = ({ logo, branch, headerStyle }) => ( +
{/* {logo && logo} */}
{branch.CompName}
@@ -356,11 +442,10 @@ const Header = ({ logo, branch }) => (
Mobile: +91 {branch.BrMobile}
-
-
- Purchase Return -
+
+ Purchase Return +
); @@ -381,8 +466,7 @@ const InvoiceMeta = ({
- Date:{' '} - {dateFormatChange1(InvoiceDate)} + Date: {dateFormatChange1(InvoiceDate)}
{VehicleNo && (
@@ -394,7 +478,12 @@ const InvoiceMeta = ({
); -const ProductTable = ({ data }) => { +const ProductTable = ({ + data, + tableHeaderStyle, + tableBodyStyle, + rowtypeStyle, +}) => { const columns = [ { label: 'S.No', key: 'sno', width: '5%' }, { label: 'Product', key: 'ProdName', width: '20%' }, @@ -407,8 +496,8 @@ const ProductTable = ({ data }) => { return (
{
{index + 1} {prod.ProdName}{prod.ProdVariantName}
- - + + {columns.map((col) => ( {data.map((prod, index) => ( - + {/* */} diff --git a/src/Pages/PurchaseReturn/purchasereturnPrint.jsx b/src/Pages/PurchaseReturn/purchasereturnPrint.jsx index 24c6d2c..c2edfa0 100644 --- a/src/Pages/PurchaseReturn/purchasereturnPrint.jsx +++ b/src/Pages/PurchaseReturn/purchasereturnPrint.jsx @@ -19,7 +19,6 @@ import PrintStyle9 from './PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle9' import PrintStyle10 from './PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle10'; import PrintStyle11 from './PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle11'; import PrintStyle12 from './PrintReturn/ThermalPrinterPurchaseReturn/PrintStyle12'; -import { SelectedPrintTemplate } from '../../Features/ThemeChange/ThemeChange'; import PrintA4Style11 from './PrintReturn/A4purchaseReturn/PrintA4Style11'; import PrintA5Style11 from './PrintReturn/A4purchaseReturn/PrintStyleA5'; import A4Standard from './PrintReturn/A4purchaseReturn/A4Standard'; @@ -63,8 +62,6 @@ const PaymentPdfReturn = ({ const [BranchZip, setBranchZip] = useState(); const CashierName = getSession('userName'); const [BrDtl, setBrDtl] = useState(); - // const selectedStyle = useSelector(SelectedPrintTemplate); - // const TotalCal= singleData2?.map((item) =>(item.Price)) const productsData = table2Data?.productDetails || []; const offers = table2Data?.OrderOfferDetails || []; @@ -362,62 +359,6 @@ const PaymentPdfReturn = ({ )} )} - - {/* Token print */} - {/* {Object.entries( - singleData2?.reduce((acc, item, idx) => { - if (item.TokenAvailable === 'Y') { - if (!item.CounterName) { - // For null or empty CounterName, print each item individually - acc[`individual-${idx}`] = [item]; - } else { - if (!acc[item.CounterName]) { - acc[item.CounterName] = []; - } - acc[item.CounterName].push(item); // Group by CounterName - } - } - return acc; - }, {}) - ).map(([counterName, items], index) => ( -
-
-
-

{items[0]?.BrName}

-

Token

-
-
-

BillNo: {orderId}

-

{Date1}

-
-
{col.label} @@ -418,7 +507,20 @@ const ProductTable = ({ data }) => {
{index + 1} {prod.ProdName}{prod.ProdVariantName}
- - - - - - - - - - - {items.map((item, idx) => ( - - - - - - - - ))} - -
S.NoItemQtyRatePrice
{idx + 1}{item.ProdName}{item.SalesQty}{item.Rate}{item.TotalAmt}
-
-
- ))} */} ); };