From df6f4af53ed1da857e712a1891915d863e90e4fe Mon Sep 17 00:00:00 2001 From: Tamilselvan Date: Mon, 30 Mar 2026 18:36:31 +0530 Subject: [PATCH] added phoneumber name address in the preference --- .../ThermalPrinter/PrintStyle4.jsx | 3625 +++++++++-------- src/Pages/Preference/PreferenceList.jsx | 182 +- 2 files changed, 1946 insertions(+), 1861 deletions(-) diff --git a/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle4.jsx b/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle4.jsx index 73d2bef..29e537b 100644 --- a/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle4.jsx +++ b/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle4.jsx @@ -175,6 +175,21 @@ const Printstyle4 = ({ (setting) => setting?.SettingIdName?.toLowerCase() === 'estimateprintheader' )?.SettingValue === 'Y'; + const estimatebrname = + SettingData?.[0]?.SettingDtlDetails?.find( + (setting) => + setting?.SettingIdName?.toLowerCase() === 'estimatebrname' + )?.SettingValue === 'Y'; + const estimatebraddress = + SettingData?.[0]?.SettingDtlDetails?.find( + (setting) => + setting?.SettingIdName?.toLowerCase() === 'estimatebraddress' + )?.SettingValue === 'Y'; + const estimatebrphone = + SettingData?.[0]?.SettingDtlDetails?.find( + (setting) => + setting?.SettingIdName?.toLowerCase() === 'estimatebrphone' + )?.SettingValue === 'Y'; const estimateTitle = SettingData?.[0]?.SettingDtlDetails?.find( (setting) => setting?.SettingIdName?.toLowerCase() === 'estimatetitle' @@ -473,8 +488,8 @@ const Printstyle4 = ({ flexDirection: 'column', justifyContent: chunkIndex === paginatedChunks.length - 1 && - !shouldFooterBeOnNewPage && - FormatTheme + !shouldFooterBeOnNewPage && + FormatTheme ? 'space-between' : '', height: isMobile @@ -524,7 +539,7 @@ const Printstyle4 = ({ /> ) : null} {base64Image && - (PrintLogo?.SettingValue === 'Y' || LogoField) ? ( + (PrintLogo?.SettingValue === 'Y' || LogoField) ? (
{' '} @@ -606,10 +621,10 @@ const Printstyle4 = ({ {GlobaldummyData ? '51' : table2Data?.OrderId && - extractLastNumberOrderId( - table2Data?.OrderId, - table2Data?.FYStatus - )} + extractLastNumberOrderId( + table2Data?.OrderId, + table2Data?.FYStatus + )}
{/*
{GlobaldummyData ? formattedDate : Date1}
*/} @@ -635,9 +650,9 @@ const Printstyle4 = ({ {GlobaldummyData ? 'Cash Bill' : BillName || - (PaymentStatusSuccess?.length === 1 - ? PaymentStatusSuccess?.[0]?.PaymentTypeName + ' Bill' - : ' Bill')}{' '} + (PaymentStatusSuccess?.length === 1 + ? PaymentStatusSuccess?.[0]?.PaymentTypeName + ' Bill' + : ' Bill')}{' '} {/* {SalesModePref?.SettingValue == 'Y' && `(${table2Data?.SalesMode ? table2Data?.SalesMode : 'R'})`} */} @@ -672,172 +687,172 @@ const Printstyle4 = ({ {GlobaldummyData ? GlobalSlNo && ( - - # - - ) + + # + + ) : SLNO && ( - - # - - )} + + # + + )} {GlobaldummyData ? GlobalItem && ( - Item - ) + Item + ) : Item && ( - Item - )} + Item + )} {GlobaldummyData ? GlobalQuantity && ( - - Qty - - ) + + Qty + + ) : Quantity && ( - - {WeightasKg ? 'Qty/Kg' : 'Qty'} - - )} + + {WeightasKg ? 'Qty/Kg' : 'Qty'} + + )} {GlobaldummyData ? GlobalHsnCode && ( - - HSN - - ) + + HSN + + ) : HsnCode && ( - - HSN - - )} + + HSN + + )} {GlobaldummyData ? GlobalMRP && ( - - MRP - - ) + + MRP + + ) : MRP && ( - - MRP - - )} + + MRP + + )} {GlobaldummyData ? GlobalDiscount && ( - - Dis{' '} - - ) + + Dis{' '} + + ) : Discount && ( - - Dis{' '} - - )} + + Dis{' '} + + )} {GlobaldummyData ? GlobalRate && ( - - Rate - - ) + + Rate + + ) : Rate && ( - - Rate - - )} + + Rate + + )} {GlobaldummyData ? GlobalAmount && ( - - Amt - - ) + + Amt + + ) : Amount && ( - - Amt - - )} + + Amt + + )} @@ -874,12 +889,12 @@ const Printstyle4 = ({ style={ index % 2 !== 1 && rowtypeStyle === 'even' ? { - ...tableBodyStyle, - } + ...tableBodyStyle, + } : index % 2 === 1 && rowtypeStyle === 'odd' ? { - ...tableBodyStyle, - } + ...tableBodyStyle, + } : {} } > @@ -887,84 +902,84 @@ const Printstyle4 = ({ {GlobaldummyData ? GlobalSlNo && {index + 1} : SLNO && ( - - {chunkIndex * chunkSize + index + 1} - - )} + + {chunkIndex * chunkSize + index + 1} + + )} {/* ITEM COLUMN */} {GlobaldummyData ? GlobalItem && {item?.ProdName} : Item && ( - - {/* Product Name */} -
{item?.ProdName}
+ + {/* Product Name */} +
{item?.ProdName}
- {/* Package OR Size */} - {packageList.length > 0 ? ( -
- {packageList.map((pkg, i) => ( -
- {pkg.ParcelCount} PCS{' '} - {pkg.ParcelQty} PACK ( - {pkg.ParcelType}) -
- ))} -
- ) : ( -
- {UomPrint?.SettingValue === 'Y' - ? (item?.Size || '1') + - (item?.SinglePc === 'Y' - ? ' PCS' - : item?.Type !== 'C' - ? ` ${item?.UomName}` - : ' COMBO') - : ''} - {item?.BrandName || ''} -
- )} + {/* Package OR Size */} + {packageList.length > 0 ? ( +
+ {packageList.map((pkg, i) => ( +
+ {pkg.ParcelCount} PCS{' '} + {pkg.ParcelQty} PACK ( + {pkg.ParcelType}) +
+ ))} +
+ ) : ( +
+ {UomPrint?.SettingValue === 'Y' + ? (item?.Size || '1') + + (item?.SinglePc === 'Y' + ? ' PCS' + : item?.Type !== 'C' + ? ` ${item?.UomName}` + : ' COMBO') + : ''} + {item?.BrandName || ''} +
+ )} - {/* Serials */} - {serials.map((s, i) => ( -
{s}
- ))} + {/* Serials */} + {serials.map((s, i) => ( +
{s}
+ ))} - {/* IMEIs */} - {imeis.map((iVal, i) => ( -
{iVal}
- ))} + {/* IMEIs */} + {imeis.map((iVal, i) => ( +
{iVal}
+ ))} - {/* Description from first identifier */} - {descriptions[0] && ( -
{descriptions[0]}
- )} - - )} + {/* Description from first identifier */} + {descriptions[0] && ( +
{descriptions[0]}
+ )} + + )} {/* Quantity */} {(GlobaldummyData ? GlobalQuantity : Quantity) && ( - - {item?.SalesQty} - - )} + + {item?.SalesQty} + + )} {/* HSN */} {(GlobaldummyData ? GlobalHsnCode : HsnCode) && ( - - {item?.HSN} - - )} + + {item?.HSN} + + )} {/* MRP */} {(GlobaldummyData ? GlobalMRP : MRP) && ( @@ -979,16 +994,16 @@ const Printstyle4 = ({ {(GlobaldummyData ? GlobalDiscount : Discount) && ( - - {item?.Type !== 'C' - ? item?.OfferAmt || + + {item?.Type !== 'C' + ? item?.OfferAmt || item?.DiscountAmt / item?.SalesQty || 0 - : item?.OfferValue || + : item?.OfferValue || item?.DiscountAmt / item?.SalesQty || 0} - - )} + + )} {/* Rate */} {(GlobaldummyData ? GlobalRate : Rate) && ( @@ -1002,9 +1017,9 @@ const Printstyle4 = ({ {item?.Type !== 'C' ? (item?.TotalAmt || 0) - - (item?.OfferAmt || 0) + (item?.OfferAmt || 0) : (item?.TotalAmt || 0) - - (item?.OfferValue || 0)} + (item?.OfferValue || 0)} )} @@ -1033,170 +1048,170 @@ const Printstyle4 = ({ {GlobaldummyData ? GlobalSlNo && ( - - # - - ) + + # + + ) : SLNO && ( - - # - - )} + + # + + )} {GlobaldummyData ? GlobalItem && ( - Item - ) + Item + ) : Item && ( - Item - )} + Item + )} {GlobaldummyData ? GlobalQuantity && ( - - Qty - - ) + + Qty + + ) : Quantity && ( - - Qty - - )} + + Qty + + )} {GlobaldummyData ? GlobalHsnCode && ( - - HSN - - ) + + HSN + + ) : HsnCode && ( - - HSN - - )} + + HSN + + )} {GlobaldummyData ? GlobalMRP && ( - - MRP - - ) + + MRP + + ) : MRP && ( - - MRP - - )} + + MRP + + )} {GlobaldummyData ? GlobalDiscount && ( - - Dis{' '} - - ) + + Dis{' '} + + ) : Discount && ( - - Dis{' '} - - )} + + Dis{' '} + + )} {GlobaldummyData ? GlobalRate && ( - - Rate - - ) + + Rate + + ) : Rate && ( - - Rate - - )} + + Rate + + )} {GlobaldummyData ? GlobalAmount && ( - - Amt - - ) + + Amt + + ) : Amount && ( - - Amt - - )} + + Amt + + )} @@ -1207,138 +1222,138 @@ const Printstyle4 = ({ style={ index % 2 !== 1 && rowtypeStyle === 'even' ? { - ...tableBodyStyle, - } + ...tableBodyStyle, + } : index % 2 === 1 && rowtypeStyle === 'odd' ? { - ...tableBodyStyle, - } + ...tableBodyStyle, + } : {} } > {GlobaldummyData ? GlobalSlNo && {index + 1} : SLNO && ( - - {chunkIndex * chunkSize + index + 1} - - )} + + {chunkIndex * chunkSize + index + 1} + + )} {GlobaldummyData ? GlobalItem && {item?.ProdName} : Item && ( - -
{item?.ProdName}
- {UomPrint?.SettingValue === 'Y' && ( -
- ({item?.Size ? item?.Size : '1'}{' '} - {item?.SinglePc == 'Y' - ? 'PCS' - : item?.Type != 'C' - ? item?.UomName - : 'COMBO'} - ) -
- )} - - )} + +
{item?.ProdName}
+ {UomPrint?.SettingValue === 'Y' && ( +
+ ({item?.Size ? item?.Size : '1'}{' '} + {item?.SinglePc == 'Y' + ? 'PCS' + : item?.Type != 'C' + ? item?.UomName + : 'COMBO'} + ) +
+ )} + + )} {GlobaldummyData ? GlobalQuantity && ( - - {item?.SalesQty} - - ) + + {item?.SalesQty} + + ) : Quantity && ( - - {item?.SalesQty} - - )} + + {item?.SalesQty} + + )} {GlobaldummyData ? GlobalHsnCode && ( - - {item?.HSN} - - ) + + {item?.HSN} + + ) : HsnCode && ( - - {item?.HSN} - - )} + + {item?.HSN} + + )} {GlobaldummyData ? GlobalMRP && ( - - {item?.MRP} - - ) + + {item?.MRP} + + ) : MRP && ( - - {item?.SinglePc === 'Y' - ? item?.Rate - : item?.MRP} - - )} + + {item?.SinglePc === 'Y' + ? item?.Rate + : item?.MRP} + + )} {GlobaldummyData ? GlobalDiscount && ( - - {item.discount} - - ) + + {item.discount} + + ) : Discount && ( - - {item?.Type !== 'C' - ? item?.OfferAmt || - item?.DiscountAmt / - item?.SalesQty || - 0 - : item?.OfferValue || - item?.DiscountAmt / - item?.SalesQty || - 0} - - )} + + {item?.Type !== 'C' + ? item?.OfferAmt || + item?.DiscountAmt / + item?.SalesQty || + 0 + : item?.OfferValue || + item?.DiscountAmt / + item?.SalesQty || + 0} + + )} {GlobaldummyData ? GlobalTax && ( - - {item?.ProdTaxPercentage || 0} - - ) + + {item?.ProdTaxPercentage || 0} + + ) : Tax && - table2Data?.OrderType !== 'E' && ( - - {item?.ProdTaxPercentage || 0} - - )} + table2Data?.OrderType !== 'E' && ( + + {item?.ProdTaxPercentage || 0} + + )} {GlobaldummyData ? GlobalRate && ( - - {item?.Rate} - - ) + + {item?.Rate} + + ) : Rate && ( - - {item?.Rate} - - )} + + {item?.Rate} + + )} {GlobaldummyData ? GlobalAmount && ( - - {item?.TotalAmt} - - ) + + {item?.TotalAmt} + + ) : Amount && ( - - {' '} - {item?.Type !== 'C' - ? item?.TotalAmt - - (item?.OfferAmt || 0) - : item?.TotalAmt - - (item?.OfferValue || 0)} - - )} + + {' '} + {item?.Type !== 'C' + ? item?.TotalAmt - + (item?.OfferAmt || 0) + : item?.TotalAmt - + (item?.OfferValue || 0)} + + )} ); })} @@ -1392,11 +1407,11 @@ const Printstyle4 = ({ {GlobaldummyData ? '1,066' : Number( - productsData?.reduce( - (a, b) => a + b.SalesQty, - 0 - ) - )} + productsData?.reduce( + (a, b) => a + b.SalesQty, + 0 + ) + )} @@ -1583,17 +1598,17 @@ const Printstyle4 = ({ ' hundred' + (num % 100 ? ' ' + - (num % 100 < 20 - ? ones[num % 100] - : tens[ - Math.floor( - (num % 100) / 10 - ) - ] + - (num % 10 - ? ' ' + - ones[num % 10] - : '')) + (num % 100 < 20 + ? ones[num % 100] + : tens[ + Math.floor( + (num % 100) / 10 + ) + ] + + (num % 10 + ? ' ' + + ones[num % 10] + : '')) : '') ); return num.toString(); @@ -1866,7 +1881,7 @@ const Printstyle4 = ({ : '+'} {Math.abs( (lastTransaction?.BeforeAdjustment ?? 0) - - (lastTransaction?.AfterAdjustment ?? 0) + (lastTransaction?.AfterAdjustment ?? 0) ).toFixed(2)} @@ -1892,83 +1907,83 @@ const Printstyle4 = ({ {GlobaldummyData ? GlobalCredit && ( -
-
Advance Amount:
-
Opening Balance:
-
- ) +
+
Advance Amount:
+
Opening Balance:
+
+ ) : CreditDetails && - table2Data?.CustomerDetails?.length > 0 && ( -
- {(() => { - const c = table2Data.CustomerDetails[0]; - const items = []; + table2Data?.CustomerDetails?.length > 0 && ( +
+ {(() => { + const c = table2Data.CustomerDetails[0]; + const items = []; - if ( - PaymentStatusSuccess?.[0]?.PaymentTypeName === - 'Credit' - ) { - if (c.OldCreditBal !== 0) { - items.push({ - label: - c.OldCreditBal > 0 - ? 'Advance Amount' - : 'Opening Balance', - value: Math.abs(c.OldCreditBal).toFixed(2), - }); - } - } - - if (c.CurrentCreditBal !== 0) { + if ( + PaymentStatusSuccess?.[0]?.PaymentTypeName === + 'Credit' + ) { + if (c.OldCreditBal !== 0) { items.push({ label: - c.CurrentCreditBal > 0 - ? 'Current Advance Amount' - : 'Current Balance Amount', - value: Math.abs(c.CurrentCreditBal).toFixed( - 2 - ), + c.OldCreditBal > 0 + ? 'Advance Amount' + : 'Opening Balance', + value: Math.abs(c.OldCreditBal).toFixed(2), }); } + } - return items.map((i, idx) => ( -

- - {i.label} - - : - - {i.value} - -

- )); - })()} -
- )} + if (c.CurrentCreditBal !== 0) { + items.push({ + label: + c.CurrentCreditBal > 0 + ? 'Current Advance Amount' + : 'Current Balance Amount', + value: Math.abs(c.CurrentCreditBal).toFixed( + 2 + ), + }); + } + + return items.map((i, idx) => ( +

+ + {i.label} + + : + + {i.value} + +

+ )); + })()} +
+ )}
{!estimatePrintHeader && table2Data?.OrderType === 'E' ? ( '' @@ -1976,59 +1991,59 @@ const Printstyle4 = ({
{GlobaldummyData ? GlobalQrcodet && ( -
- image -
- Scan to Pay{' '} -
-
- ₹ - {GlobaldummyData - ? '1,066' - : Number(table2Data?.NetAmount).toFixed( - 2 - )} -
+
+ image +
+ Scan to Pay{' '}
- ) +
+ ₹ + {GlobaldummyData + ? '1,066' + : Number(table2Data?.NetAmount).toFixed( + 2 + )} +
+
+ ) : Qrcodet && - paymentTypeUPI && ( -
- -
- Scan to Pay{' '} -
-
- ₹ - {GlobaldummyData - ? '1,066' - : Number(table2Data?.NetAmount).toFixed( - 2 - )} -
+ paymentTypeUPI && ( +
+ +
+ Scan to Pay{' '}
- )} +
+ ₹ + {GlobaldummyData + ? '1,066' + : Number(table2Data?.NetAmount).toFixed( + 2 + )} +
+
+ )}
)} @@ -2140,28 +2155,28 @@ const Printstyle4 = ({
{GlobaldummyData ? GlobalIsnotes && ( -
-

- Notes : 10 days Return policy -

+
+

+ Notes : 10 days Return policy +

-
-
- ) +
+
+ ) : Notestext && ( -
-

- {Notestext} -

+
+

+ {Notestext} +

-
-
- )} +
+
+ )}
)} @@ -2181,137 +2196,137 @@ const Printstyle4 = ({ > {GlobaldummyData ? GlobaltermsAndConditions && ( -
+

-

- Terms & Conditions -

-
    -
  1. - Once goods are sold, they are not - exchangeable or refundable. -
  2. -
  3. - Please check the product before leaving - the counter. -
  4. -
-
- ) + Terms & Conditions +

+
    +
  1. + Once goods are sold, they are not + exchangeable or refundable. +
  2. +
  3. + Please check the product before leaving + the counter. +
  4. +
+
+ ) : TermsnAdCondition == true && - TermsAndConditions?.length > 0 && ( -
0 && ( +
+

-

- Terms & Conditions -

-
    - {TermsAndConditions?.map((item) => ( -
  1. - {item?.TermsandConditions} -
  2. - ))} - {/*
  3. Please check the product before leaving the counter.
  4. */} -
-
- )} + Terms & Conditions +

+
    + {TermsAndConditions?.map((item) => ( +
  1. + {item?.TermsandConditions} +
  2. + ))} + {/*
  3. Please check the product before leaving the counter.
  4. */} +
+
+ )} {GlobaldummyData ? GlobalSignature && ( -
+

-

- Signature -

- -
- ) + Signature +

+ +
+ ) : Signature == true && ( -
+

-

- Signature -

- -
- )} + Signature +

+ +
+ )} )} @@ -2386,11 +2401,11 @@ const Printstyle4 = ({ {GlobaldummyData ? '1,066' : Number( - productsData?.reduce( - (a, b) => a + b.SalesQty, - 0 - ) - )} + productsData?.reduce( + (a, b) => a + b.SalesQty, + 0 + ) + )} @@ -2577,16 +2592,16 @@ const Printstyle4 = ({ ' hundred' + (num % 100 ? ' ' + - (num % 100 < 20 - ? ones[num % 100] - : tens[ - Math.floor( - (num % 100) / 10 - ) - ] + - (num % 10 - ? ' ' + ones[num % 10] - : '')) + (num % 100 < 20 + ? ones[num % 100] + : tens[ + Math.floor( + (num % 100) / 10 + ) + ] + + (num % 10 + ? ' ' + ones[num % 10] + : '')) : '') ); return num.toString(); @@ -2859,7 +2874,7 @@ const Printstyle4 = ({ : '+'} {Math.abs( (lastTransaction?.BeforeAdjustment ?? 0) - - (lastTransaction?.AfterAdjustment ?? 0) + (lastTransaction?.AfterAdjustment ?? 0) ).toFixed(2)} @@ -2883,81 +2898,81 @@ const Printstyle4 = ({ {GlobaldummyData ? GlobalCredit && ( -
-
Advance Amount:
-
Opening Balance:
-
- ) +
+
Advance Amount:
+
Opening Balance:
+
+ ) : CreditDetails && - table2Data?.CustomerDetails?.length > 0 && ( -
- {(() => { - const c = table2Data.CustomerDetails[0]; - const items = []; + table2Data?.CustomerDetails?.length > 0 && ( +
+ {(() => { + const c = table2Data.CustomerDetails[0]; + const items = []; - if ( - PaymentStatusSuccess?.[0]?.PaymentTypeName === - 'Credit' - ) { - if (c.OldCreditBal !== 0) { - items.push({ - label: - c.OldCreditBal > 0 - ? 'Advance Amount' - : 'Opening Balance', - value: Math.abs(c.OldCreditBal).toFixed(2), - }); - } - } - - if (c.CurrentCreditBal !== 0) { + if ( + PaymentStatusSuccess?.[0]?.PaymentTypeName === + 'Credit' + ) { + if (c.OldCreditBal !== 0) { items.push({ label: - c.CurrentCreditBal > 0 - ? 'Current Advance Amount' - : 'Current Balance Amount', - value: Math.abs(c.CurrentCreditBal).toFixed(2), + c.OldCreditBal > 0 + ? 'Advance Amount' + : 'Opening Balance', + value: Math.abs(c.OldCreditBal).toFixed(2), }); } + } - return items.map((i, idx) => ( -

- - {i.label} - - : - - {i.value} - -

- )); - })()} -
- )} + if (c.CurrentCreditBal !== 0) { + items.push({ + label: + c.CurrentCreditBal > 0 + ? 'Current Advance Amount' + : 'Current Balance Amount', + value: Math.abs(c.CurrentCreditBal).toFixed(2), + }); + } + + return items.map((i, idx) => ( +

+ + {i.label} + + : + + {i.value} + +

+ )); + })()} +
+ )} {/*
*/}
{!estimatePrintHeader && table2Data?.OrderType === 'E' ? ( @@ -2966,55 +2981,55 @@ const Printstyle4 = ({
{GlobaldummyData ? GlobalQrcodet && ( -
- image -
- Scan to Pay{' '} -
-
- ₹ - {GlobaldummyData - ? '1,066' - : Number(table2Data?.NetAmount).toFixed(2)} -
+
+ image +
+ Scan to Pay{' '}
- ) +
+ ₹ + {GlobaldummyData + ? '1,066' + : Number(table2Data?.NetAmount).toFixed(2)} +
+
+ ) : Qrcodet && - paymentTypeUPI && ( -
- -
- Scan to Pay{' '} -
-
- ₹ - {GlobaldummyData - ? '1,066' - : Number(table2Data?.NetAmount).toFixed(2)} -
+ paymentTypeUPI && ( +
+ +
+ Scan to Pay{' '}
- )} +
+ ₹ + {GlobaldummyData + ? '1,066' + : Number(table2Data?.NetAmount).toFixed(2)} +
+
+ )}
)}
@@ -3121,28 +3136,28 @@ const Printstyle4 = ({
{GlobaldummyData ? GlobalIsnotes && ( -
-

- Notes : 10 days Return policy -

+
+

+ Notes : 10 days Return policy +

-
-
- ) +
+
+ ) : Notestext && ( -
-

- {Notestext} -

+
+

+ {Notestext} +

-
-
- )} +
+
+ )}
)} @@ -3162,137 +3177,137 @@ const Printstyle4 = ({ > {GlobaldummyData ? GlobaltermsAndConditions && ( -
+

-

- Terms & Conditions -

-
    -
  1. - Once goods are sold, they are not - exchangeable or refundable. -
  2. -
  3. - Please check the product before leaving the - counter. -
  4. -
-
- ) + Terms & Conditions +

+
    +
  1. + Once goods are sold, they are not + exchangeable or refundable. +
  2. +
  3. + Please check the product before leaving the + counter. +
  4. +
+
+ ) : TermsnAdCondition == true && - TermsAndConditions?.length > 0 && ( -
0 && ( +
+

-

- Terms & Conditions -

-
    - {TermsAndConditions?.map((item) => ( -
  1. - {item?.TermsandConditions} -
  2. - ))} - {/*
  3. Please check the product before leaving the counter.
  4. */} -
-
- )} + Terms & Conditions +

+
    + {TermsAndConditions?.map((item) => ( +
  1. + {item?.TermsandConditions} +
  2. + ))} + {/*
  3. Please check the product before leaving the counter.
  4. */} +
+
+ )} {GlobaldummyData ? GlobalSignature && ( -
+

-

- Signature -

- -
- ) + Signature +

+ +
+ ) : Signature == true && ( -
+

-

- Signature -

- -
- )} + Signature +

+ +
+ )}
)} @@ -3339,7 +3354,7 @@ const Printstyle4 = ({ /> ) : null} {base64Image && - (PrintLogo?.SettingValue === 'Y' || LogoField) ? ( + (PrintLogo?.SettingValue === 'Y' || LogoField) ? ( ) : null} -
{GlobaldummyData ? 'XYZ Shop' : table2Data?.BrName} -
+ } -
-
- {' '} - Mobile : +91{' '} - {GlobaldummyData ? '986XXXXXXX' : table2Data?.BrMobile} -
+ (table2Data?.AddressDetails?.[0]?.City + ? (table2Data?.AddressDetails?.[0]?.Address1 && + table2Data?.AddressDetails?.[0]?.City + ? '-' + : '') + table2Data?.AddressDetails?.[0]?.City + : '') + + (table2Data?.AddressDetails?.[0]?.Zip + ? (table2Data?.AddressDetails?.[0]?.City && + table2Data?.AddressDetails?.[0]?.Zip + ? '-' + : '') + table2Data?.AddressDetails?.[0]?.Zip + : '')} +
} + {estimatebrphone && ( +
+ {' '} + Mobile : +91{' '} + {GlobaldummyData ? '986XXXXXXX' : table2Data?.BrMobile} +
+ )} )} {/*
@@ -3429,10 +3446,10 @@ const Printstyle4 = ({ {GlobaldummyData ? '51' : table2Data?.OrderId && - extractLastNumberOrderId( - table2Data?.OrderId, - table2Data?.FYStatus - )} + extractLastNumberOrderId( + table2Data?.OrderId, + table2Data?.FYStatus + )}
@@ -3459,9 +3476,9 @@ const Printstyle4 = ({ ? GlobalBilltext : 'Cash' + ' Bill' : BillName || - (PaymentStatusSuccess?.length === 1 - ? PaymentStatusSuccess?.[0]?.PaymentTypeName + ' Bill' - : ' Bill')}{' '} + (PaymentStatusSuccess?.length === 1 + ? PaymentStatusSuccess?.[0]?.PaymentTypeName + ' Bill' + : ' Bill')}{' '} {/* {SalesModePref?.SettingValue == 'Y' && `(${table2Data?.SalesMode ? table2Data?.SalesMode : 'R'})`} */} @@ -3490,112 +3507,112 @@ const Printstyle4 = ({ {GlobaldummyData ? GlobalSlNo && ( - - # - - ) + + # + + ) : SLNO && ( - - # - - )} + + # + + )} {GlobaldummyData ? GlobalItem && ( - Item - ) + Item + ) : Item && Item} {GlobaldummyData ? GlobalQuantity && ( - - Qty - - ) + + Qty + + ) : Quantity && ( - - Qty - - )} + + Qty + + )} {GlobaldummyData ? GlobalHsnCode && ( - - HSN - - ) + + HSN + + ) : HsnCode && ( - - HSN - - )} + + HSN + + )} {GlobaldummyData ? GlobalMRP && ( - - MRP - - ) + + MRP + + ) : MRP && ( - - MRP - - )} + + MRP + + )} {GlobaldummyData ? GlobalDiscount && ( - - Dis{' '} - - ) + + Dis{' '} + + ) : Discount && ( - - Dis{' '} - - )} + + Dis{' '} + + )} {/* {GlobaldummyData ? GlobalTax && ( - Rate - - ) + + Rate + + ) : Rate && ( - - Rate - - )} + + Rate + + )} {GlobaldummyData ? GlobalAmount && ( - - Amt - - ) + + Amt + + ) : Amount && ( - - Amt - - )} + + Amt + + )} @@ -3677,12 +3694,12 @@ const Printstyle4 = ({ style={ index % 2 !== 1 && rowtypeStyle === 'even' ? { - ...tableBodyStyle, - } + ...tableBodyStyle, + } : index % 2 === 1 && rowtypeStyle === 'odd' ? { - ...tableBodyStyle, - } + ...tableBodyStyle, + } : {} } > @@ -3692,240 +3709,240 @@ const Printstyle4 = ({ {GlobaldummyData ? GlobalItem && {item?.ProdName} : Item && ( - -
{item?.ProdName}
+ +
{item?.ProdName}
- {/* Serial Numbers */} - {item?.ProductIdentifierDtls?.filter( - (d) => d.SerialNumber - )?.map((d, i) => ( -
- {d.SerialNumber} + {/* Serial Numbers */} + {item?.ProductIdentifierDtls?.filter( + (d) => d.SerialNumber + )?.map((d, i) => ( +
+ {d.SerialNumber} +
+ ))} + + {/* IMEI Numbers */} + {item?.ProductIdentifierDtls?.filter( + (d) => d.IMEI1 || d.IMEI2 + )?.map((d, i) => ( +
+ {[d.IMEI1, d.IMEI2] + .filter(Boolean) + .join(', ')} +
+ ))} + + {/* Description from first identifier */} + {item?.ProductIdentifierDtls?.length > 0 && + item.ProductIdentifierDtls?.[0] + ?.Description && ( +
+ { + item.ProductIdentifierDtls?.[0] + ?.Description + }
- ))} - - {/* IMEI Numbers */} - {item?.ProductIdentifierDtls?.filter( - (d) => d.IMEI1 || d.IMEI2 - )?.map((d, i) => ( -
- {[d.IMEI1, d.IMEI2] - .filter(Boolean) - .join(', ')} -
- ))} - - {/* Description from first identifier */} - {item?.ProductIdentifierDtls?.length > 0 && - item.ProductIdentifierDtls?.[0] - ?.Description && ( -
- { - item.ProductIdentifierDtls?.[0] - ?.Description - } -
- )} - - )} + )} + + )} {GlobaldummyData ? GlobalQuantity && ( - - {item?.SalesQty} + + {item?.SalesQty} -
- {/* Package Details */} - {PackageDetails?.filter( - (pkg) => pkg.ProdId === item.ProdId - ).length > 0 ? ( -
- {PackageDetails?.filter( - (pkg) => pkg.ProdId === item.ProdId - )?.map((pkg, index) => ( -
- {pkg.ParcelCount} PCS{' '} - {pkg.ParcelQty} PACK ( - {pkg.ParcelType}) +
+ {/* Package Details */} + {PackageDetails?.filter( + (pkg) => pkg.ProdId === item.ProdId + ).length > 0 ? ( +
+ {PackageDetails?.filter( + (pkg) => pkg.ProdId === item.ProdId + )?.map((pkg, index) => ( +
+ {pkg.ParcelCount} PCS{' '} + {pkg.ParcelQty} PACK ( + {pkg.ParcelType}) +
+ ))} + + {/* Serial */} + {item?.ProductIdentifierDtls?.filter( + (d) => d.SerialNumber + )?.map((d, i) => ( +
+ {d.SerialNumber} +
+ ))} + + {/* IMEI */} + {item?.ProductIdentifierDtls?.filter( + (d) => d.IMEI1 || d.IMEI2 + )?.map((d, i) => ( +
+ {[d.IMEI1, d.IMEI2] + .filter(Boolean) + .join(', ')} +
+ ))} + + {/* Description from first identifier */} + {item?.ProductIdentifierDtls?.length > + 0 && + item.ProductIdentifierDtls?.[0] + ?.Description && ( +
+ { + item + .ProductIdentifierDtls?.[0] + ?.Description + }
- ))} - - {/* Serial */} - {item?.ProductIdentifierDtls?.filter( - (d) => d.SerialNumber - )?.map((d, i) => ( -
- {d.SerialNumber} -
- ))} - - {/* IMEI */} - {item?.ProductIdentifierDtls?.filter( - (d) => d.IMEI1 || d.IMEI2 - )?.map((d, i) => ( -
- {[d.IMEI1, d.IMEI2] - .filter(Boolean) - .join(', ')} -
- ))} - - {/* Description from first identifier */} - {item?.ProductIdentifierDtls?.length > - 0 && - item.ProductIdentifierDtls?.[0] - ?.Description && ( -
- { - item - .ProductIdentifierDtls?.[0] - ?.Description - } -
- )} -
- ) : ( -
- {UomPrint?.SettingValue === 'Y' && ( - <> - ({item?.Size || '1'}){' '} - {item?.SinglePc === 'Y' - ? 'PCS' - : item?.Type !== 'C' - ? item?.UomName - : 'COMBO'}{' '} - )} - {item?.BrandName || ''} -
- )} -
- - ) +
+ ) : ( +
+ {UomPrint?.SettingValue === 'Y' && ( + <> + ({item?.Size || '1'}){' '} + {item?.SinglePc === 'Y' + ? 'PCS' + : item?.Type !== 'C' + ? item?.UomName + : 'COMBO'}{' '} + + )} + {item?.BrandName || ''} +
+ )} +
+ + ) : Quantity && ( - - {item?.SalesQty} - - )} + + {item?.SalesQty} + + )} {GlobaldummyData ? GlobalHsnCode && ( - - {item?.HSN} - - ) + + {item?.HSN} + + ) : HsnCode && ( - - {item?.HSN} - - )} + + {item?.HSN} + + )} {GlobaldummyData ? GlobalMRP && ( - - {item?.MRP} - - ) + + {item?.MRP} + + ) : MRP && ( - - {item?.SinglePc === 'Y' - ? item?.Rate - : item?.MRP} - {GlobaldummyData - ? GlobalTax && ( - - - GST:{' '} - {' '} - {item?.ProdTaxPercentage || 0} - - ) - : Tax == true && - table2Data?.OrderType !== 'E' && ( - - {/* */} - - GST:{' '} - {' '} - {item?.ProdTaxPercentage || 0} - - )} - - )} + + {item?.SinglePc === 'Y' + ? item?.Rate + : item?.MRP} + {GlobaldummyData + ? GlobalTax && ( + + + GST:{' '} + {' '} + {item?.ProdTaxPercentage || 0} + + ) + : Tax == true && + table2Data?.OrderType !== 'E' && ( + + {/* */} + + GST:{' '} + {' '} + {item?.ProdTaxPercentage || 0} + + )} + + )} {GlobaldummyData ? GlobalDiscount && ( - - {item.discount} - - ) + + {item.discount} + + ) : Discount && ( - - {item?.Type !== 'C' - ? item?.OfferAmt || - item?.DiscountAmt / item?.SalesQty || - 0 - : item?.OfferValue || - item?.DiscountAmt / item?.SalesQty || - 0} - - )} + + {item?.Type !== 'C' + ? item?.OfferAmt || + item?.DiscountAmt / item?.SalesQty || + 0 + : item?.OfferValue || + item?.DiscountAmt / item?.SalesQty || + 0} + + )} {GlobaldummyData ? GlobalRate && ( - - {item?.Rate} - - ) + + {item?.Rate} + + ) : Rate && ( - - {item?.Rate} - - )} + + {item?.Rate} + + )} {GlobaldummyData ? GlobalAmount && ( - - {item?.TotalAmt} - - ) + + {item?.TotalAmt} + + ) : Amount && ( - - {' '} - {item?.Type !== 'C' - ? item?.TotalAmt - (item?.OfferAmt || 0) - : item?.TotalAmt - - (item?.OfferValue || 0)} - - )} + + {' '} + {item?.Type !== 'C' + ? item?.TotalAmt - (item?.OfferAmt || 0) + : item?.TotalAmt - + (item?.OfferValue || 0)} + + )} ); } @@ -3959,48 +3976,48 @@ const Printstyle4 = ({ : Item && Item} {GlobaldummyData ? GlobalQuantity && ( - - Qty - - ) + + Qty + + ) : Quantity && ( - - Qty - - )} + + Qty + + )} {GlobaldummyData ? GlobalHsnCode && ( - - HSN - - ) + + HSN + + ) : HsnCode && ( - - HSN - - )} + + HSN + + )} {GlobaldummyData ? GlobalMRP && ( - - MRP - - ) + + MRP + + ) : MRP && ( - - MRP - - )} + + MRP + + )} {GlobaldummyData ? GlobalDiscount && ( - - Dis{' '} - - ) + + Dis{' '} + + ) : Discount && ( - - Dis{' '} - - )} + + Dis{' '} + + )} {/* {GlobaldummyData ? GlobalTax && ( - Rate - - ) + + Rate + + ) : Rate && ( - - Rate - - )} + + Rate + + )} {GlobaldummyData ? GlobalAmount && ( - - Amt - - ) + + Amt + + ) : Amount && ( - - Amt - - )} + + Amt + + )} @@ -4056,12 +4073,12 @@ const Printstyle4 = ({ style={ index % 2 !== 1 && rowtypeStyle === 'even' ? { - ...tableBodyStyle, - } + ...tableBodyStyle, + } : index % 2 === 1 && rowtypeStyle === 'odd' ? { - ...tableBodyStyle, - } + ...tableBodyStyle, + } : {} } > @@ -4071,53 +4088,68 @@ const Printstyle4 = ({ {GlobaldummyData ? GlobalItem && {item?.ProdName} : Item && ( - -
{item?.ProdName}
- {( - (item?.ProductIdentifierDtls?.length > 0 - ? item?.ProductIdentifierDtls.filter( - (items) => items.SerialNumber - ) - .map( - (a, index) => ` ${a.SerialNumber}` - ) - .join('') - : '') + - (item?.ProductIdentifierDtls?.length > 0 - ? item?.ProductIdentifierDtls.filter( - (item1) => - item1.IMEI1 || item1.IMEI2 - ) - .map((item2) => { - const imei1 = item2.IMEI1 || ''; - const imei2 = item2.IMEI2 || ''; - return ` ${[imei1, imei2].filter(Boolean).join(',')}`; - }) - .join('') - : '') + - (item?.ProductIdentifierDtls?.length > - 0 && - item.ProductIdentifierDtls?.[0] - ?.Description) && ( -
- { - item.ProductIdentifierDtls?.[0] - ?.Description - } -
+ +
{item?.ProdName}
+ {( + (item?.ProductIdentifierDtls?.length > 0 + ? item?.ProductIdentifierDtls.filter( + (items) => items.SerialNumber ) - )?.trim()} - - )} + .map( + (a, index) => ` ${a.SerialNumber}` + ) + .join('') + : '') + + (item?.ProductIdentifierDtls?.length > 0 + ? item?.ProductIdentifierDtls.filter( + (item1) => + item1.IMEI1 || item1.IMEI2 + ) + .map((item2) => { + const imei1 = item2.IMEI1 || ''; + const imei2 = item2.IMEI2 || ''; + return ` ${[imei1, imei2].filter(Boolean).join(',')}`; + }) + .join('') + : '') + + (item?.ProductIdentifierDtls?.length > + 0 && + item.ProductIdentifierDtls?.[0] + ?.Description) && ( +
+ { + item.ProductIdentifierDtls?.[0] + ?.Description + } +
+ ) + )?.trim()} + + )} {GlobaldummyData ? GlobalQuantity && ( - - {item?.SalesQty} + + {item?.SalesQty} +
+ ({item?.Size ? item?.Size : '1'}{' '} + {item?.SinglePc == 'Y' + ? 'PCS' + : item?.Type != 'C' + ? item?.UomName + : 'COMBO'} + ) +
+ + ) + : Quantity && ( + + {item?.SalesQty} + {UomPrint?.SettingValue === 'Y' && (
({item?.Size ? item?.Size : '1'}{' '} {item?.SinglePc == 'Y' @@ -4127,103 +4159,88 @@ const Printstyle4 = ({ : 'COMBO'} )
- - ) - : Quantity && ( - - {item?.SalesQty} - {UomPrint?.SettingValue === 'Y' && ( -
- ({item?.Size ? item?.Size : '1'}{' '} - {item?.SinglePc == 'Y' - ? 'PCS' - : item?.Type != 'C' - ? item?.UomName - : 'COMBO'} - ) -
- )} - - )} + )} + + )} {GlobaldummyData ? GlobalHsnCode && ( - - {item?.HSN} - - ) + + {item?.HSN} + + ) : HsnCode && ( - - {item?.HSN} - - )} + + {item?.HSN} + + )} {GlobaldummyData ? GlobalMRP && ( - - {item?.MRP} - - ) + + {item?.MRP} + + ) : MRP && ( - - {item?.SinglePc === 'Y' - ? item?.Rate - : item?.MRP} - - )} + + {item?.SinglePc === 'Y' + ? item?.Rate + : item?.MRP} + + )} {GlobaldummyData ? GlobalDiscount && ( - - {item.discount} - - ) + + {item.discount} + + ) : Discount && ( - - {item?.Type !== 'C' - ? item?.OfferAmt || - item?.DiscountAmt / item?.SalesQty || - 0 - : item?.OfferValue || - item?.DiscountAmt / item?.SalesQty || - 0} - - )} + + {item?.Type !== 'C' + ? item?.OfferAmt || + item?.DiscountAmt / item?.SalesQty || + 0 + : item?.OfferValue || + item?.DiscountAmt / item?.SalesQty || + 0} + + )} {GlobaldummyData ? GlobalTax && ( - - {item?.ProdTaxPercentage || 0} - - ) + + {item?.ProdTaxPercentage || 0} + + ) : Tax == true && - table2Data?.OrderType !== 'E' && ( - - {item?.ProdTaxPercentage || 0} - - )} + table2Data?.OrderType !== 'E' && ( + + {item?.ProdTaxPercentage || 0} + + )} {GlobaldummyData ? GlobalRate && ( - - {item?.Rate} - - ) + + {item?.Rate} + + ) : Rate && ( - - {item?.Rate} - - )} + + {item?.Rate} + + )} {GlobaldummyData ? GlobalAmount && ( - - {item?.TotalAmt} - - ) + + {item?.TotalAmt} + + ) : Amount && ( - - {' '} - {item?.Type !== 'C' - ? item?.TotalAmt - (item?.OfferAmt || 0) - : item?.TotalAmt - - (item?.OfferValue || 0)} - - )} + + {' '} + {item?.Type !== 'C' + ? item?.TotalAmt - (item?.OfferAmt || 0) + : item?.TotalAmt - + (item?.OfferValue || 0)} + + )} ); } @@ -4443,14 +4460,14 @@ const Printstyle4 = ({ ' hundred' + (num % 100 ? ' ' + - (num % 100 < 20 - ? ones[num % 100] - : tens[ - Math.floor((num % 100) / 10) - ] + - (num % 10 - ? ' ' + ones[num % 10] - : '')) + (num % 100 < 20 + ? ones[num % 100] + : tens[ + Math.floor((num % 100) / 10) + ] + + (num % 10 + ? ' ' + ones[num % 10] + : '')) : '') ); return num.toString(); @@ -4712,7 +4729,7 @@ const Printstyle4 = ({ {lastTransaction?.AdjustmentType === 'REFUND' ? '-' : '+'} {Math.abs( (lastTransaction?.BeforeAdjustment ?? 0) - - (lastTransaction?.AfterAdjustment ?? 0) + (lastTransaction?.AfterAdjustment ?? 0) ).toFixed(2)}
@@ -4735,79 +4752,79 @@ const Printstyle4 = ({ )} {GlobaldummyData ? GlobalCredit && ( -
-
Advance Amount:
-
Opening Balance:
-
- ) +
+
Advance Amount:
+
Opening Balance:
+
+ ) : CreditDetails && - table2Data?.CustomerDetails?.length > 0 && ( -
- {(() => { - const c = table2Data.CustomerDetails[0]; - const items = []; + table2Data?.CustomerDetails?.length > 0 && ( +
+ {(() => { + const c = table2Data.CustomerDetails[0]; + const items = []; - if ( - PaymentStatusSuccess?.[0]?.PaymentTypeName === 'Credit' - ) { - if (c.OldCreditBal !== 0) { - items.push({ - label: - c.OldCreditBal > 0 - ? 'Advance Amount' - : 'Opening Balance', - value: Math.abs(c.OldCreditBal).toFixed(2), - }); - } - } - - if (c.CurrentCreditBal !== 0) { + if ( + PaymentStatusSuccess?.[0]?.PaymentTypeName === 'Credit' + ) { + if (c.OldCreditBal !== 0) { items.push({ label: - c.CurrentCreditBal > 0 - ? 'Current Advance Amount' - : 'Current Balance Amount', - value: Math.abs(c.CurrentCreditBal).toFixed(2), + c.OldCreditBal > 0 + ? 'Advance Amount' + : 'Opening Balance', + value: Math.abs(c.OldCreditBal).toFixed(2), }); } + } - return items.map((i, idx) => ( -

- {i.label} - : - {i.value} -

- )); - })()} -
- )} + if (c.CurrentCreditBal !== 0) { + items.push({ + label: + c.CurrentCreditBal > 0 + ? 'Current Advance Amount' + : 'Current Balance Amount', + value: Math.abs(c.CurrentCreditBal).toFixed(2), + }); + } + + return items.map((i, idx) => ( +

+ {i.label} + : + {i.value} +

+ )); + })()} +
+ )}
{!estimatePrintHeader && table2Data?.OrderType === 'E' ? ( '' @@ -4815,51 +4832,51 @@ const Printstyle4 = ({
{GlobaldummyData ? GlobalQrcodet && ( -
- image -
Scan to Pay
-
- ₹ - {GlobaldummyData - ? '1,066' - : Number(table2Data?.NetAmount).toFixed(2)} -
+
+ image +
Scan to Pay
+
+ ₹ + {GlobaldummyData + ? '1,066' + : Number(table2Data?.NetAmount).toFixed(2)}
- ) +
+ ) : Qrcodet && - paymentTypeUPI && ( -
- -
Scan to Pay
-
- ₹ - {GlobaldummyData - ? '1,066' - : Number(table2Data?.NetAmount).toFixed(2)} -
+ paymentTypeUPI && ( +
+ +
Scan to Pay
+
+ ₹ + {GlobaldummyData + ? '1,066' + : Number(table2Data?.NetAmount).toFixed(2)}
- )} +
+ )}
)}
@@ -4957,21 +4974,21 @@ const Printstyle4 = ({
{GlobaldummyData ? GlobalIsnotes && ( -
-

- Notes : 10 days Return policy -

+
+

+ Notes : 10 days Return policy +

-
-
- ) +
+
+ ) : Notestext && ( -
-

{Notestext}

+
+

{Notestext}

-
-
- )} +
+
+ )}
)} @@ -4991,136 +5008,136 @@ const Printstyle4 = ({ > {GlobaldummyData ? GlobaltermsAndConditions && ( -
+

-

- Terms & Conditions -

-
    -
  1. - Once goods are sold, they are not exchangeable or - refundable. -
  2. -
  3. - Please check the product before leaving the counter. -
  4. -
-
- ) + Terms & Conditions +

+
    +
  1. + Once goods are sold, they are not exchangeable or + refundable. +
  2. +
  3. + Please check the product before leaving the counter. +
  4. +
+
+ ) : TermsnAdCondition == true && - TermsAndConditions?.length > 0 && ( -
0 && ( +
+

-

- Terms & Conditions -

-
    - {TermsAndConditions?.map((item) => ( -
  1. - {item?.TermsandConditions} -
  2. - ))} - {/*
  3. Please check the product before leaving the counter.
  4. */} -
-
- )} + Terms & Conditions +

+
    + {TermsAndConditions?.map((item) => ( +
  1. + {item?.TermsandConditions} +
  2. + ))} + {/*
  3. Please check the product before leaving the counter.
  4. */} +
+
+ )} {GlobaldummyData ? GlobalSignature && ( -
+

-

- Signature -

- -
- ) + Signature +

+ +
+ ) : Signature == true && ( -
+

-

- Signature -

- -
- )} + Signature +

+ +
+ )}
)}
diff --git a/src/Pages/Preference/PreferenceList.jsx b/src/Pages/Preference/PreferenceList.jsx index c5e08cd..4db346b 100644 --- a/src/Pages/Preference/PreferenceList.jsx +++ b/src/Pages/Preference/PreferenceList.jsx @@ -1,4 +1,4 @@ -import { useCallback, useEffect, useRef, useState } from 'react'; +import React, { useCallback, useEffect, useRef, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { Form, Checkbox, Radio, Divider, InputNumber } from 'antd'; import { ArrowRightOutlined } from '@ant-design/icons'; @@ -30,6 +30,7 @@ const PreferenceList = ({ setting = false }) => { const { SadminuserAccess, featureaddDetails } = useAuth(); const dispatch = useDispatch(); const formRef = useRef(); + const prevEstimateRef = useRef([]); const CompId = getSession('CompId'); const BranchId = getSession('BranchId'); const AppId = getSession('AppId'); @@ -157,6 +158,10 @@ const PreferenceList = ({ setting = false }) => { ...(allSettingsMap['estimatetitle']?.value === 'Y' ? ['estimatetitle'] : []), + ...(allSettingsMap['estimatebrname']?.value === 'Y' ? ['estimatebrname'] : []), + ...(allSettingsMap['estimatebraddress']?.value === 'Y' ? ['estimatebraddress'] : []), + ...(allSettingsMap['estimatebrphone']?.value === 'Y' ? ['estimatebrphone'] : []), + ], scanlayout: allSettingsMap['scanlayout']?.value === 'Y', verifyproduct: allSettingsMap['verifyproduct']?.value === 'Y', @@ -207,9 +212,9 @@ const PreferenceList = ({ setting = false }) => { } }; }, []); - useEffect(()=>{ + useEffect(() => { fetchTableData(); - },[selectedUserId]) + }, [selectedUserId]) useEffect(() => { if (settingsList) { @@ -217,6 +222,8 @@ const PreferenceList = ({ setting = false }) => { setInitialValues(built); console.log(built, 'built'); formRef.current?.setFieldsValue(built); + prevEstimateRef.current = built.estimateSettings ?? []; + } }, [settingsList]); @@ -311,7 +318,7 @@ const PreferenceList = ({ setting = false }) => { }; const fetchTableData = async () => { - const res = await dispatch(gettableData({ CompId, BranchId, AppId,UserId:selectedUserId })).unwrap(); + const res = await dispatch(gettableData({ CompId, BranchId, AppId, UserId: selectedUserId })).unwrap(); const data = { CompId, BranchId, AppId, UserId: selectedUserId }; // const res = await dispatch(getPreferenceData(data)).unwrap(); if (res?.data?.statusCode === 1 && res?.data?.data?.length > 0) { @@ -405,8 +412,15 @@ const PreferenceList = ({ setting = false }) => { dinein: values.enabledModules, estimation: values.enabledModules, parking: values.enabledFeatures, + // estimateprintheader: values.estimateSettings, + // estimatebrname: values.estimatebrname, + // estimatebraddress: values.estimatebraddress, + // estimatebrphone: values.estimatebrphone, estimateprintheader: values.estimateSettings, estimatetitle: values.estimateSettings, + estimatebrname: values.estimateSettings, + estimatebraddress: values.estimateSettings, + estimatebrphone: values.estimateSettings, offer: values.enabledFeatures, whatsapp: values.pdfSendOptions, sms: values.pdfSendOptions, @@ -481,51 +495,51 @@ const PreferenceList = ({ setting = false }) => { }; useEffect(() => { - if (userDropDown?.length > 0 && !formRef.current?.getFieldValue("userId")) { - const adminUser = userDropDown.find( - (user) => user.UserTypeName === "Admin" - ); + if (userDropDown?.length > 0 && !formRef.current?.getFieldValue("userId")) { + const adminUser = userDropDown.find( + (user) => user.UserTypeName === "Admin" + ); - if (adminUser) { - formRef.current?.setFieldsValue({ - userId: adminUser.UserId - }); + if (adminUser) { + formRef.current?.setFieldsValue({ + userId: adminUser.UserId + }); + } } - } -}, [userDropDown]); + }, [userDropDown]); const UserDropDownChange = (value) => { let user = userDropDown?.find((item) => item?.UserId === value); - setSelectedUserId(user?.UserId) + setSelectedUserId(user?.UserId) formRef.current?.setFieldsValue({ userId: value, }); }; -const userDropData = async () => { - const data ={ - branchId:BranchId, - compId:CompId, - appId:AppId - } - const gettinguserDropDown = await dispatch(getBranchUsers(data)).unwrap(); - // const gettinguserDropDown = await dispatch(UserDataBasedOnBranchId(BranchId)).unwrap(); + const userDropData = async () => { + const data = { + branchId: BranchId, + compId: CompId, + appId: AppId + } + const gettinguserDropDown = await dispatch(getBranchUsers(data)).unwrap(); + // const gettinguserDropDown = await dispatch(UserDataBasedOnBranchId(BranchId)).unwrap(); - if (gettinguserDropDown?.data?.statusCode === 1) { - const finaluserDropDown = gettinguserDropDown?.data?.data?.filter((value) => value.ActiveStatus === "A"); - setUserDropDown(finaluserDropDown); + if (gettinguserDropDown?.data?.statusCode === 1) { + const finaluserDropDown = gettinguserDropDown?.data?.data?.filter((value) => value.ActiveStatus === "A"); + setUserDropDown(finaluserDropDown); - if (UserType === 'Employee') { - setSelectedUserId(UserId); - } else { - const adminUser = finaluserDropDown.find( - (user) => user.UserTypeName === "Admin" - ); - if (adminUser) { - setSelectedUserId(adminUser.UserId); + if (UserType === 'Employee') { + setSelectedUserId(UserId); + } else { + const adminUser = finaluserDropDown.find( + (user) => user.UserTypeName === "Admin" + ); + if (adminUser) { + setSelectedUserId(adminUser.UserId); + } } } - } -}; + }; const renderCheckbox = (name, label) => allSettingsMap[name] !== undefined && ( @@ -533,6 +547,53 @@ const userDropData = async () => { Yes ); + const ESTIMATE_PRINT_SETTINGS = [ + { + key: 'estimateprintheader', + label: 'Show shop header', + children: [ + { key: 'estimatebrname', label: 'name' }, + { key: 'estimatebraddress', label: 'address' }, + { key: 'estimatebrphone', label: 'phone number' }, + ], + }, + { + key: 'estimatetitle', + label: 'Show "Estimate" title', + children: [], + }, + ]; + const handleEstimateChange = (checkedValues) => { + const prev = prevEstimateRef.current; + let updated = [...checkedValues]; + + ESTIMATE_PRINT_SETTINGS.forEach(({ key, children }) => { + if (!children.length) return; + + const childKeys = children + .filter((c) => allSettingsMap[c.key] !== undefined) + .map((c) => c.key); + + const parentJustChecked = checkedValues.includes(key) && !prev.includes(key); + + // Parent just checked → add all children + if (parentJustChecked) { + updated = [...new Set([...updated, ...childKeys])]; + } + + // Calculate AFTER updated may have changed above ✅ + const anyChildChecked = childKeys.some((c) => updated.includes(c)); + + // All children removed → remove parent + if (updated.includes(key) && !anyChildChecked) { // ✅ uses variable, no duplicate + updated = updated.filter((v) => v !== key); + } + }); + + prevEstimateRef.current = updated; + formRef.current?.setFieldValue('estimateSettings', updated); + }; + return ( <> @@ -621,7 +682,7 @@ const userDropData = async () => { initialValues={initialValues} className="preferences-list" > - {(UserType === 'Admin' || UserType === 'Super Admin' || UserType === 'Super Admin User')&& ( + {(UserType === 'Admin' || UserType === 'Super Admin' || UserType === 'Super Admin User') && ( { 'mobilea4', 'Prefer printing in A4/A5 on mobile?' )} - {(allSettingsMap['estimateprintheader'] !== undefined || - allSettingsMap['estimatetitle'] !== undefined) && ( - - - {allSettingsMap['estimateprintheader'] !== undefined && ( - - Show shop header (Name, Address, GST) - - )} - {allSettingsMap['estimatetitle'] !== undefined && ( - - Show “Estimate (R/W)” title - - )} - - - )} + {ESTIMATE_PRINT_SETTINGS.some(({ key }) => allSettingsMap[key] !== undefined) && ( + + {({ getFieldValue }) => ( + + handleEstimateChange(vals, formRef)}> + {ESTIMATE_PRINT_SETTINGS + .filter(({ key }) => allSettingsMap[key] !== undefined) + .map(({ key, label, children }) => ( + + {label} + + {children.length > 0 && + getFieldValue('estimateSettings')?.includes(key) && + children + .filter((child) => allSettingsMap[child.key] !== undefined) + .map((child) => ( + + {child.label} + + ))} + + ))} + + + )} + + )}