diff --git a/src/Features/BookingScreen/BookingData/BookingData.js b/src/Features/BookingScreen/BookingData/BookingData.js index a8530a3..d167ffd 100644 --- a/src/Features/BookingScreen/BookingData/BookingData.js +++ b/src/Features/BookingScreen/BookingData/BookingData.js @@ -391,9 +391,27 @@ export const getAllCustomer = createAsyncThunk( } } ); +export const getSearchedCustomer = createAsyncThunk( + 'product/getSearchedCustomer', + async ({ CompId, AppId, branchId, searchValue }) => { + if ( + CompId !== null && + CompId !== undefined && + branchId !== null && + branchId !== undefined && + AppId !== null && + AppId !== undefined + && searchValue !== '' && searchValue !== null && searchValue !== undefined + ) { + return await axiosRetailInstanceData.get( + `/Customer?compId=${CompId}&branchId=${branchId}&appId=${AppId}&custName=${encodeURIComponent(searchValue)}` + ); + } + } +); export const getCustomerForHold = createAsyncThunk( - 'product/getAllCustomer', + 'product/getCustomerForHold', async ({ CompId, AppId, branchId, OrderId }) => { if ( CompId != null && diff --git a/src/Images/xls-export.png b/src/Images/xls-export.png new file mode 100644 index 0000000..acf48d3 Binary files /dev/null and b/src/Images/xls-export.png differ diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/BSBillingEditQuantity.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/BSBillingEditQuantity.jsx index 51b1605..60b6b7d 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/BSBillingEditQuantity.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/BSBillingEditQuantity.jsx @@ -469,6 +469,14 @@ const BSBillingEditQuantity = (props) => { setMessageType('warning'); return; } + } else if (itemWiseLimitPreferenece) { + const exceptEditedItemCart = calculateOverAllQtyLimit(CartOrderDetails?.filter((_, index) => index !== editedProductIndex && _.ProdId === editedProduct?.ProdId && _.InwardDtlId === editedProduct?.InwardDtlId)); + const totalQtyForItem = ((exceptEditedItemCart || 0) + (editedQty || 0)); + if (totalQtyForItem > maxQtyLimit) { + setMessageData(`Item Quantity Limit Exceeds than ${maxQtyLimit}`); + setMessageType('warning'); + return; + } } } diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BSBillingTable1.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BSBillingTable1.jsx index e83c74b..17e71ba 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BSBillingTable1.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable1/BSBillingTable1.jsx @@ -1146,6 +1146,8 @@ const BSBillingTable1 = () => { e?.BookingTypeName != item?.BookingTypeName ); if (tableData?.length <= 1) { + await dispatch(changeSelectedOption(null)); + await dispatch(ChangeSelectedCustDisable(false)); await dispatch(changeReorderHoldDetails({})); await dispatch(changeReorderProductDetails([])); await dispatch(changeUnpaidData(false)); diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable2/BsBill2.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable2/BsBill2.jsx index b6b3808..8b15246 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable2/BsBill2.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable2/BsBill2.jsx @@ -1062,6 +1062,8 @@ const BsBill2 = () => { await dispatch(changeSelProdWiseEst([])); await dispatch(ChangeTotalAmount([])); dispatch(changeBillEditingMode(false)); + await dispatch(changeSelectedOption(null)); + await dispatch(ChangeSelectedCustDisable(false)); await dispatch(changePreviousOrderPayment([])); await dispatch(changePreviousOrderOfferDetail([])); } @@ -1101,6 +1103,8 @@ const BsBill2 = () => { await dispatch(changeSelProdWiseEst([])); await dispatch(ChangeTotalAmount([])); dispatch(changeBillEditingMode(false)); + await dispatch(changeSelectedOption(null)); + await dispatch(ChangeSelectedCustDisable(false)); await dispatch(changePreviousOrderPayment([])); await dispatch(changePreviousOrderOfferDetail([])); } diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable3/BSBillingTable3.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable3/BSBillingTable3.jsx index 400438c..5f95604 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable3/BSBillingTable3.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable3/BSBillingTable3.jsx @@ -1107,6 +1107,8 @@ const BSBillingTable3 = () => { ); if (tableData?.length <= 1) { + await dispatch(changeSelectedOption(null)); + await dispatch(ChangeSelectedCustDisable(false)); await dispatch(changeReorderHoldDetails({})); await dispatch(changeReorderProductDetails([])); await dispatch(changeUnpaidData(false)); @@ -2360,7 +2362,7 @@ const BSBillingTable3 = () => { fontSize: '16px', }} > - {(tableData?.length > 0)? ( + {(tableData?.length > 0) ? ( { {item?.Type != 'C' ? item.Offer && item.Offer > 0 ? item.Offer - :item.DiscountAmt ? item.DiscountAmt : '-' + : item.DiscountAmt ? item.DiscountAmt : '-' : item?.OfferPrice && item?.OfferPrice > 0 ? item?.OfferType === 'F' ? `₹${safeRound(item.OfferPrice)}` diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable4/BSBillingTable4.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable4/BSBillingTable4.jsx index 403861e..63216bb 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable4/BSBillingTable4.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable4/BSBillingTable4.jsx @@ -1050,6 +1050,8 @@ const BSBillingTable4 = () => { ); if (tableData?.length <= 1) { + await dispatch(changeSelectedOption(null)); + await dispatch(ChangeSelectedCustDisable(false)); await dispatch(changeReorderHoldDetails({})); await dispatch(changeReorderProductDetails([])); await dispatch(changeUnpaidData(false)); diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable5/BsBill.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable5/BsBill.jsx index e531f8b..a0cfbe7 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable5/BsBill.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable5/BsBill.jsx @@ -870,6 +870,8 @@ const BsBill = () => { ); if (TableData?.length <= 1) { + await dispatch(changeSelectedOption(null)); + await dispatch(ChangeSelectedCustDisable(false)); await dispatch(changeReorderHoldDetails({})); await dispatch(changeReorderProductDetails([])); await dispatch(changeUnpaidData(false)); @@ -2944,6 +2946,8 @@ const BsBill = () => { // if the quantity of the item is 1, remove the item from the cart if (TableData?.length <= 1) { + await dispatch(changeSelectedOption(null)); + await dispatch(ChangeSelectedCustDisable(false)); await dispatch(changeReorderHoldDetails({})); await dispatch(changeReorderProductDetails([])); await dispatch(changeUnpaidData(false)); @@ -2975,6 +2979,8 @@ const BsBill = () => { // if the quantity of the item is 1, remove the item from the cart if (TableData?.length <= 1) { + await dispatch(changeSelectedOption(null)); + await dispatch(ChangeSelectedCustDisable(false)); await dispatch(changeReorderHoldDetails({})); await dispatch(changeReorderProductDetails([])); await dispatch(changeUnpaidData(false)); @@ -3013,6 +3019,7 @@ const BsBill = () => { await dispatch(ChangeOverAllDiscEstimate(null)); await dispatch(changeSelProdWiseEst([])); await dispatch(ChangeTotalAmount([])); + } } } diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable6/BSBillingTable6.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable6/BSBillingTable6.jsx index ba0b56a..c46c7f1 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable6/BSBillingTable6.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable6/BSBillingTable6.jsx @@ -1106,6 +1106,8 @@ const BSBillingTable6 = () => { dispatch(changeBillEditingMode(false)); await dispatch(changePreviousOrderPayment([])); await dispatch(changePreviousOrderOfferDetail([])); + await dispatch(changeSelectedOption(null)); + await dispatch(ChangeSelectedCustDisable(false)); } if (item?.Offer > 0) { diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable7/BSBillingTable7.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable7/BSBillingTable7.jsx index a019ea4..5557c0b 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable7/BSBillingTable7.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable7/BSBillingTable7.jsx @@ -40,6 +40,7 @@ import { changeBillEditingMode, changePreviousOrderPayment, changePreviousOrderOfferDetail, + ChangeSelectedCustDisable, } from '../../../../../Features/BookingScreen/BookingData/BookingData'; import { ChangeFullFreeProductList, @@ -139,16 +140,16 @@ const BSBillingTable7 = () => { OrderType === 'Hold' ? tableData?.filter((a, b) => a.BookingTypeName === 'TakeAway') : tableData?.filter( - (a, b) => a.BookingTypeName === 'TakeAway' && !a?.SalesId - ); + (a, b) => a.BookingTypeName === 'TakeAway' && !a?.SalesId + ); const OldtableDataDinein = tableData?.filter( (a, b) => a.BookingTypeName === 'Dine In' && a?.SalesId ); const OldtableDataTakeAway = OrderType != 'Hold' ? tableData?.filter( - (a, b) => a.BookingTypeName === 'TakeAway' && a?.SalesId - ) + (a, b) => a.BookingTypeName === 'TakeAway' && a?.SalesId + ) : []; const productBasedExtraCharges = GlobalExtraCharge.filter( (obj) => 'ProdName' in obj @@ -946,9 +947,9 @@ const BSBillingTable7 = () => { )?.map((item, idx) => idx === 0 ? { - ...item, - FreeQty, - } + ...item, + FreeQty, + } : item ), }; @@ -985,6 +986,8 @@ const BSBillingTable7 = () => { dispatch(changeBillEditingMode(false)); await dispatch(changePreviousOrderPayment([])); await dispatch(changePreviousOrderOfferDetail([])); + await dispatch(changeSelectedOption(null)); + await dispatch(ChangeSelectedCustDisable(false)); } if (item?.Offer > 0) { //check is Buyxgetx Or something @@ -2144,16 +2147,16 @@ const BSBillingTable7 = () => { ? item?.SalesId && OrderType !== 'Hold' ? 'rgb(243, 248, 213)' : triggerAnimation && - index === 0 && - !item?.SalesId && - tableDataTakeAway?.length >= PreviousdataLength + index === 0 && + !item?.SalesId && + tableDataTakeAway?.length >= PreviousdataLength ? 'wheat' : triggerAnimation && - index === 0 && - tableDataTakeAway?.length >= - PreviousdataLength && - !HoldOrderDtl && - !UnpaidData + index === 0 && + tableDataTakeAway?.length >= + PreviousdataLength && + !HoldOrderDtl && + !UnpaidData ? 'wheat' : 'inherit' : 'none', @@ -2161,9 +2164,9 @@ const BSBillingTable7 = () => { item?.SalesId && OrderType !== 'Hold' ? 'rgb(243, 248, 213)' : GlobEstBooking === 'ParEst' && - GlobProdwisedata?.includes( - item?.InwardDtlId + ' ' + item?.BookingTypeName - ) + GlobProdwisedata?.includes( + item?.InwardDtlId + ' ' + item?.BookingTypeName + ) ? '#b2d1f7' : index % 2 === 0 ? 'white' @@ -2188,15 +2191,14 @@ const BSBillingTable7 = () => { ? () => handleEditQuantity(item) : editdelete === 'Delete' ? () => removeFromCart(item) - : () => {} + : () => { } } // onClick={editdelete === "Edit" ? () => handleEditQuantity(item) : editdelete === "Delete" ? () => removeFromCart(item) : ""} - className={`${ - item?.SalesId && OrderType !== 'Hold' + className={`${item?.SalesId && OrderType !== 'Hold' ? 'BSBill-Table7-content-disabled' : 'BSBill-Table7-content' - } + } `} > @@ -2280,21 +2282,21 @@ const BSBillingTable7 = () => { {productBasedExtraCharges?.find( (find) => find.ProdId === item.ProdId ) !== undefined && ( -
- Extra Charges :{' '} - { - productBasedExtraCharges?.find( - (find) => find.ProdId === item.ProdId - )?.TotalAmt - } -
- )} +
+ Extra Charges :{' '} + { + productBasedExtraCharges?.find( + (find) => find.ProdId === item.ProdId + )?.TotalAmt + } +
+ )} )} {tableitem.OptionName == 'MRP' && ( @@ -2373,27 +2375,27 @@ const BSBillingTable7 = () => { ? item?.SalesId ? 'rgb(243, 248, 213)' : BookingType === 'Dine In' && - triggerAnimation && - OldtableDataTakeAway?.length + index === 0 && - !item?.SalesId && - tableDataDinein?.length >= PreviousdataLength + triggerAnimation && + OldtableDataTakeAway?.length + index === 0 && + !item?.SalesId && + tableDataDinein?.length >= PreviousdataLength ? 'wheat' : BookingType !== 'Dine In' && - triggerAnimation && - OldtableDataTakeAway?.length + index === 0 && - tableDataDinein?.length >= - PreviousdataLength && - !HoldOrderDtl && - !UnpaidData + triggerAnimation && + OldtableDataTakeAway?.length + index === 0 && + tableDataDinein?.length >= + PreviousdataLength && + !HoldOrderDtl && + !UnpaidData ? 'wheat' : 'inherit' : 'none', background: item?.SalesId ? 'rgb(243, 248, 213)' : GlobEstBooking === 'ParEst' && - GlobProdwisedata?.includes( - item?.InwardDtlId + ' ' + item?.BookingTypeName - ) + GlobProdwisedata?.includes( + item?.InwardDtlId + ' ' + item?.BookingTypeName + ) ? '#b2d1f7' : (OldtableDataTakeAway?.length + index) % 2 === 0 ? 'white' @@ -2418,15 +2420,14 @@ const BSBillingTable7 = () => { ? () => handleEditQuantity(item) : editdelete === 'Delete' ? () => removeFromCart(item) - : () => {} + : () => { } } // onClick={editdelete === "Edit" ? () => handleEditQuantity(item) : editdelete === "Delete" ? () => removeFromCart(item) : ""} - className={`${ - item?.SalesId + className={`${item?.SalesId ? 'BSBill-Table7-content-disabled' : 'BSBill-Table7-content' - } + } `} > @@ -2506,21 +2507,21 @@ const BSBillingTable7 = () => { {productBasedExtraCharges?.find( (find) => find.ProdId === item.ProdId ) !== undefined && ( -
- Extra Charges :{' '} - { - productBasedExtraCharges?.find( - (find) => find.ProdId === item.ProdId - )?.TotalAmt - } -
- )} +
+ Extra Charges :{' '} + { + productBasedExtraCharges?.find( + (find) => find.ProdId === item.ProdId + )?.TotalAmt + } +
+ )} )} {tableitem.OptionName == 'MRP' && ( @@ -2599,43 +2600,43 @@ const BSBillingTable7 = () => { ? BookingType === 'Dine In' && item?.SalesId ? 'rgb(243, 248, 213)' : BookingType === 'Dine In' && - triggerAnimation && - OldtableDataDinein?.length + - OldtableDataTakeAway?.length + - index === - 0 && - !item?.SalesId && - tableDataTakeAway?.length >= PreviousdataLength + triggerAnimation && + OldtableDataDinein?.length + + OldtableDataTakeAway?.length + + index === + 0 && + !item?.SalesId && + tableDataTakeAway?.length >= PreviousdataLength ? 'wheat' : BookingType !== 'Dine In' && - triggerAnimation && - OldtableDataDinein?.length + - OldtableDataTakeAway?.length + - index === - 0 && - tableDataTakeAway?.length >= - PreviousdataLength && - !HoldOrderDtl && - !UnpaidData + triggerAnimation && + OldtableDataDinein?.length + + OldtableDataTakeAway?.length + + index === + 0 && + tableDataTakeAway?.length >= + PreviousdataLength && + !HoldOrderDtl && + !UnpaidData ? 'wheat' : (OldtableDataDinein?.length + - OldtableDataTakeAway?.length + - index) % - 2 === - 0 + OldtableDataTakeAway?.length + + index) % + 2 === + 0 ? 'white' : SelectedBillColor?.[ - 'OverallBackgroundColor' - ] + 'OverallBackgroundColor' + ] ? SelectedBillColor?.[ - 'OverallBackgroundColor' - ] + 'OverallBackgroundColor' + ] : '#d6d6d6' : (OldtableDataDinein?.length + - OldtableDataTakeAway?.length + - index) % - 2 === - 0 + OldtableDataTakeAway?.length + + index) % + 2 === + 0 ? 'white' : SelectedBillColor?.['OverallBackgroundColor'] ? SelectedBillColor?.['OverallBackgroundColor'] @@ -2644,15 +2645,15 @@ const BSBillingTable7 = () => { BookingType === 'Dine In' && item?.SalesId ? 'rgb(243, 248, 213)' : GlobEstBooking === 'ParEst' && - GlobProdwisedata?.includes( - item?.InwardDtlId + ' ' + item?.BookingTypeName - ) + GlobProdwisedata?.includes( + item?.InwardDtlId + ' ' + item?.BookingTypeName + ) ? '#b2d1f7' : (OldtableDataDinein?.length + - OldtableDataTakeAway?.length + - index) % - 2 === - 0 + OldtableDataTakeAway?.length + + index) % + 2 === + 0 ? 'white' : SelectedBillColor?.['OverallBackgroundColor'] ? SelectedBillColor?.['OverallBackgroundColor'] @@ -2661,9 +2662,9 @@ const BSBillingTable7 = () => { BillOrderPre === 'Y' && !BookingTypeBoth ? triggerAnimation && OldtableDataDinein?.length + - OldtableDataTakeAway?.length + - index === - 0 && + OldtableDataTakeAway?.length + + index === + 0 && !item?.SalesId && tableDataTakeAway?.length >= PreviousdataLength && !HoldOrderDtl && @@ -2680,22 +2681,21 @@ const BSBillingTable7 = () => { onClick={ editdelete === 'Edit' ? () => - item.Type == 'P' || item.Type == 'C' + item.Type == 'P' || item.Type == 'C' + ? handleEditQuantity(item) + : item.ServiceType == 'G' ? handleEditQuantity(item) - : item.ServiceType == 'G' - ? handleEditQuantity(item) - : '' + : '' : editdelete === 'Delete' ? () => removeFromCart(item) - : () => {} + : () => { } } // onClick={editdelete === "Edit" ? () => handleEditQuantity(item) : editdelete === "Delete" ? () => removeFromCart(item) : ""} - className={`${ - BookingType === 'Dine In' && item?.SalesId + className={`${BookingType === 'Dine In' && item?.SalesId ? 'BSBill-Table7-content-disabled' : 'BSBill-Table7-content' - } + } `} > @@ -2734,8 +2734,8 @@ const BSBillingTable7 = () => { padding: '8px', }} onClick={() => - (item.FullProductIdentifierDtls?.length > 0 || - item.ProductIdentifierDtls?.length > 0 || imeiModal) && + (item.FullProductIdentifierDtls?.length > 0 || + item.ProductIdentifierDtls?.length > 0 || imeiModal) && handleImeiDetails(item) } > @@ -2755,8 +2755,8 @@ const BSBillingTable7 = () => { {!item?.ProdVariantName?.toLowerCase()?.includes( 'variant' ) && ( - {item?.ProdVariantName} - )} + {item?.ProdVariantName} + )} {item?.Size} {item?.SinglePc == 'Y' ? 'PCS' @@ -2790,21 +2790,21 @@ const BSBillingTable7 = () => { {productBasedExtraCharges?.find( (find) => find.ProdId === item.ProdId ) !== undefined && ( -
- Extra Charges :{' '} - { - productBasedExtraCharges?.find( - (find) => find.ProdId === item.ProdId - )?.TotalAmt - } -
- )} +
+ Extra Charges :{' '} + { + productBasedExtraCharges?.find( + (find) => find.ProdId === item.ProdId + )?.TotalAmt + } +
+ )} )} {tableitem.OptionName == 'MRP' && ( @@ -2885,45 +2885,45 @@ const BSBillingTable7 = () => { !BookingTypeBoth ? 'rgb(243, 248, 213)' : BookingType === 'Dine In' && - triggerAnimation && - OldtableDataTakeAway?.length + - OldtableDataDinein?.length + - tableDataTakeAway?.length + - index === - 0 && - !item?.SalesId && - tableDataDinein?.length >= PreviousdataLength + triggerAnimation && + OldtableDataTakeAway?.length + + OldtableDataDinein?.length + + tableDataTakeAway?.length + + index === + 0 && + !item?.SalesId && + tableDataDinein?.length >= PreviousdataLength ? 'wheat' : BookingType !== 'Dine In' && - triggerAnimation && - OldtableDataTakeAway?.length + - OldtableDataDinein?.length + - tableDataTakeAway?.length + - index === - 0 && - tableDataDinein?.length >= - PreviousdataLength && - !HoldOrderDtl && - !UnpaidData + triggerAnimation && + OldtableDataTakeAway?.length + + OldtableDataDinein?.length + + tableDataTakeAway?.length + + index === + 0 && + tableDataDinein?.length >= + PreviousdataLength && + !HoldOrderDtl && + !UnpaidData ? 'wheat' : 'inherit' : 'none', background: BookingType === 'Dine In' && - item?.SalesId && - !BookingTypeBoth + item?.SalesId && + !BookingTypeBoth ? 'rgb(243, 248, 213)' : GlobEstBooking === 'ParEst' && - GlobProdwisedata?.includes( - item?.InwardDtlId + ' ' + item?.BookingTypeName - ) + GlobProdwisedata?.includes( + item?.InwardDtlId + ' ' + item?.BookingTypeName + ) ? '#b2d1f7' : (OldtableDataTakeAway?.length + - OldtableDataDinein?.length + - tableDataTakeAway?.length + - index) % - 2 === - 0 + OldtableDataDinein?.length + + tableDataTakeAway?.length + + index) % + 2 === + 0 ? 'white' : SelectedBillColor?.['OverallBackgroundColor'] ? SelectedBillColor?.['OverallBackgroundColor'] @@ -2932,10 +2932,10 @@ const BSBillingTable7 = () => { BillOrderPre === 'Y' && !BookingTypeBoth ? triggerAnimation && OldtableDataTakeAway?.length + - OldtableDataDinein?.length + - tableDataTakeAway?.length + - index === - 0 && + OldtableDataDinein?.length + + tableDataTakeAway?.length + + index === + 0 && !item?.SalesId && tableDataDinein?.length >= PreviousdataLength && !HoldOrderDtl && @@ -2955,15 +2955,14 @@ const BSBillingTable7 = () => { ? () => handleEditQuantity(item) : editdelete === 'Delete' ? () => removeFromCart(item) - : () => {} + : () => { } } // onClick={editdelete === "Edit" ? () => handleEditQuantity(item) : editdelete === "Delete" ? () => removeFromCart(item) : ""} - className={`${ - BookingType === 'Dine In' && item?.SalesId + className={`${BookingType === 'Dine In' && item?.SalesId ? 'BSBill-Table7-content-disabled' : 'BSBill-Table7-content' - } + } `} > @@ -3047,21 +3046,21 @@ const BSBillingTable7 = () => { {productBasedExtraCharges?.find( (find) => find.ProdId === item.ProdId ) !== undefined && ( -
- Extra Charges :{' '} - { - productBasedExtraCharges?.find( - (find) => find.ProdId === item.ProdId - )?.TotalAmt - } -
- )} +
+ Extra Charges :{' '} + { + productBasedExtraCharges?.find( + (find) => find.ProdId === item.ProdId + )?.TotalAmt + } +
+ )} )} {tableitem.OptionName == 'MRP' && ( diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/ComboBillTableEdit/ComboEditQtyAndRate.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/ComboBillTableEdit/ComboEditQtyAndRate.jsx index 523c199..e21261e 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/ComboBillTableEdit/ComboEditQtyAndRate.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/ComboBillTableEdit/ComboEditQtyAndRate.jsx @@ -341,6 +341,16 @@ const ComboEditQtyAndRate = (props) => { setQuantity(removeProds1?.OrderQty || 1) return; } + } else if (itemWiseLimitPreferenece) { + let editedProduct = CartOrderDetails?.find((_, index) => index === editedProductIndex) + const exceptEditedItemCart = calculateOverAllQtyLimit(CartOrderDetails?.filter((_, index) => index !== editedProductIndex && _.ProdId === editedProduct?.ProdId && _.InwardDtlId === editedProduct?.InwardDtlId)); + const totalQtyForItem = ((exceptEditedItemCart || 0) + (editedQty || 0)); + if (totalQtyForItem > maxQtyLimit) { + setMessageData(`Item Quantity Limit Exceeds than ${maxQtyLimit}`); + setMessageType('warning'); + setQuantity(editedProduct?.OrderQty || 1) + return; + } } } const editedProduct = CartOrderDetails[editedProductIndex]; diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/ComboSalesBillTable/ComboSalesBillTable.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/ComboSalesBillTable/ComboSalesBillTable.jsx index b2a4850..eaa3925 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/ComboSalesBillTable/ComboSalesBillTable.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/ComboSalesBillTable/ComboSalesBillTable.jsx @@ -94,9 +94,9 @@ const ComboSalesBillTable = () => { const removeProducts = useRemoveProducts(); const applyOffer = useApplyOfferto_CardDetail(); const preferenceDatas = useSelector(PreferenceData); - const UomPrint = preferenceDatas?.[0]?.SettingDtlDetails?.filter( - (i) => i.SettingIdName === 'PrintUom' - )?.[0]; + const UomPrint = preferenceDatas?.[0]?.SettingDtlDetails?.filter( + (i) => i.SettingIdName === 'PrintUom' + )?.[0]; const preferenceDetails = preferenceDatas?.[0]?.SettingDtlDetails; const preferenceOffer = preferenceDetails?.find((item) => item.SettingIdName === 'Offer') @@ -1292,6 +1292,8 @@ const ComboSalesBillTable = () => { await dispatch(ChangeOverAllDiscEstimate(null)); await dispatch(changeSelProdWiseEst([])); dispatch(changeBillEditingMode(false)); + await dispatch(changeSelectedOption(null)); + await dispatch(ChangeSelectedCustDisable(false)); await dispatch(changePreviousOrderPayment([])); await dispatch(changePreviousOrderOfferDetail([])); } @@ -2548,13 +2550,13 @@ const ComboSalesBillTable = () => { { - dispatch(changeCombofocus(true)); - row.FullProductIdentifierDtls?.length > 0 || - row.ProductIdentifierDtls?.length > 0 + onClick={() => { + dispatch(changeCombofocus(true)); + row.FullProductIdentifierDtls?.length > 0 || + row.ProductIdentifierDtls?.length > 0 ? handleImeiDetails(row) - : editField && handleEditQuantity(row); - }} + : editField && handleEditQuantity(row); + }} > {row?.Type !== 'OS' ? row.ProdName : row.ServiceName} {row?.BrandName ? ` ${row.BrandName}` : ''} @@ -2610,10 +2612,9 @@ const ComboSalesBillTable = () => { }} key={`qty-${index}`} tabIndex={0} - className={`${ - EditQtyCombo && row?.localId === Index - ? 'EditQTYcomboTD' - : 'qtyTd' + className={`${EditQtyCombo && row?.localId === Index + ? 'EditQTYcomboTD' + : 'qtyTd' } ${isActiveCell ? 'active-cell' : ''}`} onClick={() => { dispatch(changeCombofocus(true)); diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTable.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTable.jsx index 87ff635..f63f9e0 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTable.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/StandardTable/StandardTable.jsx @@ -1170,6 +1170,8 @@ const StandardTable = () => { await dispatch(changeUnpaidData(false)); await dispatch(changeBookingType('TakeAway')); await dispatch(changeTokenOnly(false)); + await dispatch(changeSelectedOption(null)); + await dispatch(ChangeSelectedCustDisable(false)); await dispatch(ChangeTotalAmount([])); await dispatch(changeAllProductTokenAvailable(false)); await dispatch(ChangeOverAllDiscSales(null)); diff --git a/src/Pages/BookingScreen/Components/BSItemCards/RemoveFromCartFunction.jsx b/src/Pages/BookingScreen/Components/BSItemCards/RemoveFromCartFunction.jsx index d0150e2..e6f9b87 100644 --- a/src/Pages/BookingScreen/Components/BSItemCards/RemoveFromCartFunction.jsx +++ b/src/Pages/BookingScreen/Components/BSItemCards/RemoveFromCartFunction.jsx @@ -223,9 +223,9 @@ export const useRemoveFromCart = () => { AppId: AppId, ...(AvailableDate && selectedDate ? { - fromDate: selectedDate?.[0], - toDate: selectedDate?.[1], - } + fromDate: selectedDate?.[0], + toDate: selectedDate?.[1], + } : {}), }; await dispatch(getSelectedFavItems(data)).unwrap(); @@ -237,9 +237,9 @@ export const useRemoveFromCart = () => { ProdSubCat: useSelector((state) => state.BookingData.ProductSubCategorie), ...(AvailableDate && selectedDate ? { - fromDate: selectedDate?.[0], - toDate: selectedDate?.[1], - } + fromDate: selectedDate?.[0], + toDate: selectedDate?.[1], + } : {}), }; @@ -250,9 +250,9 @@ export const useRemoveFromCart = () => { prodCat: useSelector((state) => state.BookingData.ProductCategorie), ...(AvailableDate && selectedDate ? { - fromDate: selectedDate?.[0], - toDate: selectedDate?.[1], - } + fromDate: selectedDate?.[0], + toDate: selectedDate?.[1], + } : {}), }; @@ -312,6 +312,8 @@ export const useRemoveFromCart = () => { dispatch(changeBillEditingMode(false)); await dispatch(changePreviousOrderPayment([])); await dispatch(changePreviousOrderOfferDetail([])); + await dispatch(changeSelectedOption(null)); + await dispatch(ChangeSelectedCustDisable(false)); } else { let putData = { OrderId: [ReportholdData?.OrderId] }; let response = await dispatch(puttinghold(putData)).unwrap(); @@ -345,26 +347,26 @@ export const useRemoveFromCart = () => { console.log('isItemInCart', isItemInCart); if (isItemInCart?.OrderQty > 1) { const UpdatedCartItem = - // if the item is already in the cart, increase the quantity of the item - { - ...isItemInCart, - OrderQty: isItemInCart?.OrderQty - 1, - TotalAmt: (isItemInCart?.OrderQty - 1) * isItemInCart?.OrderRate, - TaxAmt: ( + // if the item is already in the cart, increase the quantity of the item + { + ...isItemInCart, + OrderQty: isItemInCart?.OrderQty - 1, + TotalAmt: (isItemInCart?.OrderQty - 1) * isItemInCart?.OrderRate, + TaxAmt: ( + ((isItemInCart?.OrderQty - 1) * + isItemInCart?.OrderRate * + isItemInCart?.TaxPercentage) / + (100 + isItemInCart?.TaxPercentage) + ).toFixed(2), + WithoutTaxRate: + (isItemInCart?.OrderQty - 1) * isItemInCart?.OrderRate - + ( ((isItemInCart?.OrderQty - 1) * isItemInCart?.OrderRate * isItemInCart?.TaxPercentage) / (100 + isItemInCart?.TaxPercentage) ).toFixed(2), - WithoutTaxRate: - (isItemInCart?.OrderQty - 1) * isItemInCart?.OrderRate - - ( - ((isItemInCart?.OrderQty - 1) * - isItemInCart?.OrderRate * - isItemInCart?.TaxPercentage) / - (100 + isItemInCart?.TaxPercentage) - ).toFixed(2), - }; + }; const UpdatedcardData = [UpdatedCartItem, ...UpdatedData]; if (OfferCheckedInSetup && preferenceOffer) { diff --git a/src/Pages/BookingScreen/Components/BookingFunctionality/CustomerOtp.scss b/src/Pages/BookingScreen/Components/BookingFunctionality/CustomerOtp.scss index e68c81a..75dbd7e 100644 --- a/src/Pages/BookingScreen/Components/BookingFunctionality/CustomerOtp.scss +++ b/src/Pages/BookingScreen/Components/BookingFunctionality/CustomerOtp.scss @@ -59,6 +59,7 @@ padding: 10px 10px; border-radius: 8px; width: 60%; + @media (max-width: 768px) { width: 100%; } @@ -105,6 +106,7 @@ width: 100%; overflow-x: hidden; } + .BSOTPKioskPayment-dailpad-1, .BSOTPKioskPayment-dailpad-2, .BSOTPKioskPayment-dailpad-3 { @@ -330,7 +332,7 @@ } .paymentCardMain .ant-radio-group, -.ant-radio-wrapper span.ant-radio + * { +.ant-radio-wrapper span.ant-radio+* { padding: 10px 10px; } @@ -338,10 +340,7 @@ padding: 54px 35px !important; } -.paymentCardMain - .ant-collapse - .ant-collapse-item:last-child - > .ant-collapse-content { +.paymentCardMain .ant-collapse .ant-collapse-item:last-child>.ant-collapse-content { overflow: scroll; height: 26vh; } @@ -465,6 +464,7 @@ color: #fff; border-radius: 10px; cursor: pointer; + @media (max-width: 768px) { width: 100%; } @@ -573,6 +573,7 @@ } } } + .BSOTPItem3Warning { position: fixed; top: 0%; @@ -635,12 +636,14 @@ align-items: center; justify-content: center; flex-direction: column; + .input-err { font-family: 'Poppins', sans-serif; font-size: 12px; margin-top: 6px; color: rgb(224, 0, 0); } + input { width: 60%; outline: none; @@ -652,11 +655,13 @@ border-radius: 6px; border: 1px solid #333; font-size: 20px; + @media (max-width: 768px) { width: 100%; } } } + .BSOTPdailpad-main { display: flex; flex-direction: column; @@ -688,14 +693,17 @@ .BSOTPotp-box.active { border: 2px solid #28a745; } + .BSOTPpaymentModal-Master { scrollbar-width: thin; - height: 90vh; + height: max-content; + max-height: 90vh; overflow: auto; } + .optEnterResendOTP { display: flex; align-items: center; justify-content: center; gap: 1rem; -} +} \ No newline at end of file diff --git a/src/Pages/BookingScreen/Components/UtillComponents/BSSelectCustomer.jsx b/src/Pages/BookingScreen/Components/UtillComponents/BSSelectCustomer.jsx index b466313..808a397 100644 --- a/src/Pages/BookingScreen/Components/UtillComponents/BSSelectCustomer.jsx +++ b/src/Pages/BookingScreen/Components/UtillComponents/BSSelectCustomer.jsx @@ -26,6 +26,7 @@ import { changeOrderCardDetails, changeCustomerID, changeCombofocus, + getSearchedCustomer, } from '../../../../Features/BookingScreen/BookingData/BookingData'; import Select from 'react-select'; import { @@ -45,6 +46,7 @@ import { FaPlus, FaMinus, FaEye, + FaLessThanEqual, } from 'react-icons/fa'; import { DefaultModal } from '../../../../Components/Modal/DefaultModal'; import WsPreOrderForm from '../../../Wholesalespreorder/WholesalePreorderForm'; @@ -246,10 +248,16 @@ const BSCustomerSelect = ({ TopName = null }) => { // Customer data const [allCustomers, setAllCustomers] = useState([]); + // useEffect(() => { + // dispatch(getAllCustomer({ CompId, AppId, branchId: BranchId })) + // .unwrap() + // .then((res) => setAllCustomers(res?.data?.data || [])); + // setProductQuantities({}); + // }, [CompId, AppId, BranchId, dispatch, customerRefreshTrigger]); + useEffect(() => { - dispatch(getAllCustomer({ CompId, AppId, branchId: BranchId })) - .unwrap() - .then((res) => setAllCustomers(res?.data?.data || [])); + if (!CompId || !AppId || !BranchId) return; + setAllCustomers([]); setProductQuantities({}); }, [CompId, AppId, BranchId, dispatch, customerRefreshTrigger]); @@ -286,11 +294,11 @@ const BSCustomerSelect = ({ TopName = null }) => { () => GetCustId ? { - value: GetCustId?.CustMobile, - label: GetCustId?.CustName || GetCustId?.CustMobile, - CustId: GetCustId?.CustId, - CustName: GetCustId?.CustName, - } + value: GetCustId?.CustMobile, + label: GetCustId?.CustName || GetCustId?.CustMobile, + CustId: GetCustId?.CustId, + CustName: GetCustId?.CustName, + } : null, [GetCustId] ); @@ -307,7 +315,7 @@ const BSCustomerSelect = ({ TopName = null }) => { setCustLoyaltyPoint(selOption?.TotalLoyaltyPoints || 0); setCashLoyaltyPoint( selOption?.LoyaltyPointsDetail?.filter((l) => l?.RewardType === 'Cash') || - [] + [] ); setFreeProductLoyalty( selOption?.LoyaltyPointsDetail?.filter( @@ -540,6 +548,9 @@ const BSCustomerSelect = ({ TopName = null }) => { ) ); } + if (selectedOption === undefined || selectedOption === null) { + setAllCustomers([]); + } setCustomerpreorder(true); }; @@ -978,6 +989,33 @@ const BSCustomerSelect = ({ TopName = null }) => { setMessageType(null); }, []); + let debounceTimer; + + const debounceSearch = (value) => { + clearTimeout(debounceTimer); + + debounceTimer = setTimeout(() => { + handleSearchCustomer(value, false); + }, 500); + }; + + const handleSearchCustomer = async (value, open = true) => { + const data = { + AppId, + CompId, + branchId: BranchId, + searchValue: value, + } + const response = await dispatch(getSearchedCustomer(data))?.unwrap(); // your API + if (response?.data?.data?.length > 0 && response?.data?.statusCode === 1) { + setAllCustomers(response?.data?.data || []); + } else if (open) { + handleAddCustomer(value); + } else if (!open) { + setAllCustomers([]); + } + }; + // Render return ( <> @@ -1020,11 +1058,11 @@ const BSCustomerSelect = ({ TopName = null }) => { OrderCardDetail?.length > 0 ? handleLoyaltyPoints : () => { - setMessageData( - 'Add products to cart to redeem loyalty points.' - ); - setMessageType('error'); - } + setMessageData( + 'Add products to cart to redeem loyalty points.' + ); + setMessageType('error'); + } } > {custLoyaltyPoint || 0} @@ -1066,7 +1104,7 @@ const BSCustomerSelect = ({ TopName = null }) => { AppType ? null : selOption || - (selectedCustomerData?.label ? selectedCustomerData : null) + (selectedCustomerData?.label ? selectedCustomerData : null) } onChange={handleChange} onMenuOpen={() => dispatch(changeCombofocus(true))} @@ -1078,14 +1116,25 @@ const BSCustomerSelect = ({ TopName = null }) => { className="customer-select-option" onInputChange={(value) => { if (!value) return; + + const onlyNumbers = /^\d+$/.test(value); const isIndianMobile = /^\d{10}$/.test(value) && /^[6-9]/.test(value); - const existingCustomer = options?.filter( - (option) => option?.value === value || option?.label === value - ); - if (isIndianMobile && existingCustomer?.length === 0) { - handleAddCustomer(value); + // const existingCustomer = options?.filter( + // (option) => option?.value === value || option?.label === value + // ); + // if (isIndianMobile && existingCustomer?.length === 0) { + // handleAddCustomer(value); + // } + + if (onlyNumbers && isIndianMobile) { + handleSearchCustomer(value); + return; + } + + if (/[a-zA-Z]/.test(value)) { + debounceSearch(value); } }} /> @@ -1383,7 +1432,7 @@ const BSCustomerSelect = ({ TopName = null }) => { const quantity = productQuantities[compositeKey] || 0; const canIncrease = totalConsumedPoints + prod.PointsRequired <= - custLoyaltyPoint && + custLoyaltyPoint && (prod?.StockAvailable === 'Y' ? quantity < prod.BalanceQty : true); @@ -1477,63 +1526,63 @@ const BSCustomerSelect = ({ TopName = null }) => { {(filteredLoyaltyFreeProducts?.length > 0 || loyaltyFreeProductsInCart?.length > 0) && ( - -
- You have free products for loyalty points in cart. -
- Do you want to keep them? + +
+ You have free products for loyalty points in cart. +
+ Do you want to keep them? +
+
+ + +
+ } + trigger="click" + open={clearPopoverVisible && loyaltyModal} + onOpenChange={(visible) => setClearPopoverVisible(visible)} + > +
- - + Clear Offer
- } - trigger="click" - open={clearPopoverVisible && loyaltyModal} - onOpenChange={(visible) => setClearPopoverVisible(visible)} - > -
-
- Clear Offer -
-
-
- )} + + )} )} @@ -1545,7 +1594,7 @@ const BSCustomerSelect = ({ TopName = null }) => { width={600} handleCancel={() => setViewModal(false)} footer={false} - // title="Selected Products" + // title="Selected Products" >

Selected Free Products

diff --git a/src/Pages/BranchLogin/BranchLogin.jsx b/src/Pages/BranchLogin/BranchLogin.jsx index 391244f..27c6da5 100644 --- a/src/Pages/BranchLogin/BranchLogin.jsx +++ b/src/Pages/BranchLogin/BranchLogin.jsx @@ -433,11 +433,16 @@ const BranchLogin = () => { {CompBranchData?.map((branch) => (
{ + e.stopPropagation(); + onChangeBranch(branch?.BrId); + }} >
{branch?.LocationType === 'W' ? ( @@ -477,7 +482,7 @@ const BranchLogin = () => { ? 'openGodownBTN' : 'openBrachBTN' } - onClick={() => onChangeBranch(branch?.BrId)} + // onClick={() => onChangeBranch(branch?.BrId)} > {branch?.LocationType === 'W' ? 'Open Warehouse' @@ -562,14 +567,12 @@ const BranchLogin = () => { {SelectTypeName === 'OTP' ? !FirstTimeOtp ? `send ${SelectTypeName.toLocaleLowerCase()}` - : `resend ${SelectTypeName.toLocaleLowerCase()}${ - seconds > 0 ? ` in ${seconds}s` : '' - }` + : `resend ${SelectTypeName.toLocaleLowerCase()}${seconds > 0 ? ` in ${seconds}s` : '' + }` : !FirstTimePin ? `send ${SelectTypeName.toLocaleLowerCase()}` - : `resend ${SelectTypeName.toLocaleLowerCase()}${ - seconds > 0 ? ` in ${seconds}s` : '' - }`} + : `resend ${SelectTypeName.toLocaleLowerCase()}${seconds > 0 ? ` in ${seconds}s` : '' + }`}
diff --git a/src/Pages/Reports/LedgerReport/LedgerReport.jsx b/src/Pages/Reports/LedgerReport/LedgerReport.jsx index 24e4044..ca6e62e 100644 --- a/src/Pages/Reports/LedgerReport/LedgerReport.jsx +++ b/src/Pages/Reports/LedgerReport/LedgerReport.jsx @@ -28,6 +28,9 @@ import '../../../Styles/Reports/LedgerReport/LedgerReport.scss'; import { isMobile } from 'react-device-detect'; import { ReportMobilePDFPrint } from '../../paymentpdfPage/ReportMobilePDFPrint.js'; import { useSelector } from 'react-redux'; +import excelExport from '../../../Images/xls-export.png'; +import ExcelJS from 'exceljs'; +import { saveAs } from 'file-saver'; dayjs.extend(customParseFormat); @@ -403,6 +406,215 @@ const LedgerReport = () => { } }; + const exportToExcel = async () => { + if (!LedgerData || LedgerData.length === 0) return; + + const workbook = new ExcelJS.Workbook(); + const worksheet = workbook.addWorksheet("Ledger Report"); + + worksheet.views = [ + { + state: "frozen", + ySplit: 2 + } + ]; + + // HEADER ROW 1 + worksheet.addRow([ + "SI No", + "Type", + "Cus-Id", + "Cus-Name", + "RC.NO", + "Mob.No", + "Address", + "Payment Mode", + "Date", + "Debit", + "Credit", + "Balance in", + "" + ]); + + // HEADER ROW 2 + worksheet.addRow([ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Credit", + "Debit" + ]); + + // MERGE CELLS + worksheet.mergeCells("A1:A2"); + worksheet.mergeCells("B1:B2"); + worksheet.mergeCells("C1:C2"); + worksheet.mergeCells("D1:D2"); + worksheet.mergeCells("E1:E2"); + worksheet.mergeCells("F1:F2"); + worksheet.mergeCells("G1:G2"); + worksheet.mergeCells("H1:H2"); + worksheet.mergeCells("I1:I2"); + worksheet.mergeCells("J1:J2"); + worksheet.mergeCells("K1:K2"); + worksheet.mergeCells("L1:M1"); + + // worksheet.eachRow((row) => { + // row.eachCell((cell) => { + // cell.protection = { + // locked: true + // }; + // }); + // }); + + // Lock header rows + [1, 2].forEach((rowNumber) => { + const row = worksheet.getRow(rowNumber); + row.eachCell((cell) => { + cell.protection = { locked: true }; + }); + }); + + // HEADER STYLE + const headerRows = [1, 2]; + + headerRows.forEach((rowNumber) => { + const row = worksheet.getRow(rowNumber); + + row.eachCell((cell) => { + cell.font = { + bold: true, + color: { argb: "FFFFFFFF" } // white text + }; + + cell.alignment = { + vertical: "middle", + horizontal: "center" + }; + + cell.fill = { + type: "pattern", + pattern: "solid", + fgColor: { argb: "FF2E7D32" } // green header + }; + + cell.border = { + top: { style: "thin" }, + left: { style: "thin" }, + bottom: { style: "thin" }, + right: { style: "thin" } + }; + }); + }); + + // specifically ensure Balance in header center + worksheet.getCell("L1").alignment = { horizontal: "center", vertical: "middle" }; + + // COLUMN WIDTH + worksheet.columns = [ + { width: 8 }, + { width: 10 }, + { width: 12 }, + { width: 20 }, + { width: 12 }, + { width: 15 }, + { width: 25 }, + { width: 15 }, + { width: 15 }, + { width: 12 }, + { width: 12 }, + { width: 12 }, + { width: 12 } + ]; + + // DATA ROWS + LedgerData.forEach((row, index) => { + const r = worksheet.addRow([ + index + 1, + row.TypeName === "OB" ? "OB" : row.TypeName, + row.CustId ? extractLastNumber(row.CustId) : "GEN", + row.CustName || "", + row.ReceiptNo || "", + row.MobileNo || "", + row.Address1 || "", + row.PaymentTypeName || "", + ExtractDateFormate(row.Date) || "", + row.Debit > 0 ? row.Debit : "", + row.Credit > 0 ? row.Credit : "", + row.BalCredit > 0 ? row.BalCredit : "", + row.BalDebit > 0 ? row.BalDebit : "" + ]); + + // 🔓 Unlock every cell in this row + r.eachCell({ includeEmpty: true }, (cell) => { + cell.protection = { locked: false }; + }); + + // Credit red + if (row.BalCredit > 0) { + r.getCell(12).font = { color: { argb: "FFFF0000" } }; + } + + // Debit green + if (row.BalDebit > 0) { + r.getCell(13).font = { color: { argb: "FF008000" } }; + } + }); + + // Unlock all data rows + worksheet.eachRow((row, rowNumber) => { + if (rowNumber > 2) { + row.eachCell((cell) => { + cell.protection = { locked: false }; + }); + } + }); + + await worksheet.protect("ledger123", { + selectLockedCells: true, + selectUnlockedCells: true, + formatColumns: true, // allow column resize + formatRows: false, + insertColumns: false, + insertRows: false, + deleteColumns: false, + deleteRows: false + }); + + const buffer = await workbook.xlsx.writeBuffer(); + + const blob = new Blob([buffer], { + type: "application/vnd.openxmlformats-of ficedocument.spreadsheetml.sheet" + }); + + const now = new Date(); + + const day = String(now.getDate()).padStart(2, "0"); + const month = String(now.getMonth() + 1).padStart(2, "0"); + const year = now.getFullYear(); + + let hours = now.getHours(); + const minutes = String(now.getMinutes()).padStart(2, "0"); + + const ampm = hours >= 12 ? "PM" : "AM"; + hours = hours % 12; + hours = hours ? hours : 12; + + hours = String(hours).padStart(2, "0"); + + const fileName = `Ledger Report_${day}-${month}-${year}_${hours}-${minutes}-${ampm}.xlsx`; + + saveAs(blob, fileName); + }; + const FirstOrderLedgerDateRaw = dayjs(FirstOrderLedgerDate); const disabledDate = (current) => { @@ -621,13 +833,24 @@ const LedgerReport = () => {
0 ? () => Print() : (() => { })} className={ LedgerData?.length > 0 ? 'ItemWiseReport-printerIcon' : 'ItemWiseReport-printerIcon-disabled' } /> + 0 ? "Export as Excel" : "No data to Export"} placement="top"> +
0 ? 'pointer' : 'not-allowed', opacity: LedgerData?.length > 0 ? 1 : 0.5 }}> + Excel Export 0 ? () => exportToExcel() : (() => { })} + /> +
+
diff --git a/src/Styles/Reports/LedgerReport/LedgerReport.scss b/src/Styles/Reports/LedgerReport/LedgerReport.scss index 3720377..541c29b 100644 --- a/src/Styles/Reports/LedgerReport/LedgerReport.scss +++ b/src/Styles/Reports/LedgerReport/LedgerReport.scss @@ -31,9 +31,9 @@ } .RadioButton { - display: flex; + display: flex; flex-wrap: nowrap; - justify-items: center; + justify-items: center; } .RadioButton-DMYPicker .ant-radio-group { @@ -58,7 +58,7 @@ height: 60px; } -.Ledger-datePicker { +.Ledger-datePicker { .ant-space-item { height: 70px; } @@ -88,8 +88,30 @@ // overflow-x: scroll; } +.ItemWiseReport-printerIcon-disabled { + opacity: 0.5; + cursor: not-allowed; + font-size: 30px; +} + +.ItemWiseReport-printerIcon { + font-size: 25px; + cursor: pointer; +} + +.ItemWiseReport-printerIcon:hover { + color: #414141; +} + +.ItemWiseReport-printerIcon { + font-size: 30px; +} + .ledger-PrintIcon { - font-size: xx-large; + font-size: xx-large; + display: flex; + align-items: center; + gap: 0.5rem; } .RadioButton-DMYPicker { @@ -120,8 +142,8 @@ width: 72px; } -.LedgerTable .ant-table-wrapper .ant-table-thead > tr > th, -.ant-table-wrapper .ant-table-thead > tr > td { +.LedgerTable .ant-table-wrapper .ant-table-thead>tr>th, +.ant-table-wrapper .ant-table-thead>tr>td { color: #000000; font-size: 12px; font-weight: 600; @@ -148,11 +170,11 @@ flex-direction: column; justify-content: center; width: max-content; - height: 50px; + height: 50px; } .MasterLedger-Report .ant-table-wrapper .ant-table-cell, -.MasterLedger-Report .ant-table-wrapper .ant-table-thead > tr > th { +.MasterLedger-Report .ant-table-wrapper .ant-table-thead>tr>th { padding: 1px 13px; width: 100px; } @@ -164,7 +186,7 @@ .RadioButton-DMYPicker p { padding: 0 !important; } - + .MasterLedger-Report .formDivAnt { row-gap: 0.1rem; } @@ -184,8 +206,8 @@ .ant-picker-month-panel { width: 200px !important; } - - + + .LedgerTable { height: 50vh; } @@ -194,7 +216,7 @@ overflow-y: scroll; } - .Ledger-datePicker { + .Ledger-datePicker { .ant-picker { width: 100px !important; @@ -208,15 +230,15 @@ transform: scale(0.8); margin: 0rem -1rem; } - + .dropDown-ledger { width: 70px !important; height: 64px !important; padding-left: 0px !important; } - .AllRadioButton { - width: 37vh; + .AllRadioButton { + width: 37vh; overflow-x: scroll; } } @@ -243,7 +265,7 @@ border: 1px solid #909090; font-family: "Poppins", sans-serif; - > thead { + >thead { position: sticky; top: -1px; } @@ -268,7 +290,7 @@ display: flex; flex-direction: column; gap: 4px; - overflow: scroll; + overflow: scroll; padding-bottom: 2rem; } @@ -314,7 +336,7 @@ justify-content: flex-end; gap: 1rem; - > div { + >div { border-radius: 6px; padding: 5px 10px; color: #fff; @@ -322,20 +344,21 @@ cursor: pointer; } - > div:nth-child(1) { + >div:nth-child(1) { background-color: #28aa3a; } - > div:nth-child(2) { + >div:nth-child(2) { background-color: #ff0000; } } .custom-table { + Button:disabled, Button[disabled] { width: unset !important; height: unset !important; border-radius: 50px !important; } -} +} \ No newline at end of file