diff --git a/src/Features/BookingScreen/BookingData/BookingData.js b/src/Features/BookingScreen/BookingData/BookingData.js index 9598fbc..23a4dab 100644 --- a/src/Features/BookingScreen/BookingData/BookingData.js +++ b/src/Features/BookingScreen/BookingData/BookingData.js @@ -804,37 +804,34 @@ export const getPaymentOptionFeatureApi = createAsyncThunk( ); export const getProductsearch = createAsyncThunk( - "BookingData/getProductsearch", + 'BookingData/getProductsearch', async ( { CompId, BranchId, AppId, ProdName }, { signal, rejectWithValue } ) => { try { if (!CompId || !BranchId || !AppId || !ProdName) { - return rejectWithValue("Invalid params"); + return rejectWithValue('Invalid params'); } - const response = await axiosRetailInstanceData.get( - `/productCardList`, - { - params: { - CompId, - BranchId, - AppId, - ProdName, - }, - signal, // ✅ Abort works here - } - ); + const response = await axiosRetailInstanceData.get(`/productCardList`, { + params: { + CompId, + BranchId, + AppId, + ProdName, + }, + signal, // ✅ Abort works here + }); return response.data; // ✅ return only data } catch (error) { // ✅ Abort error – ignore - if (error.name === "CanceledError" || error.name === "AbortError") { + if (error.name === 'CanceledError' || error.name === 'AbortError') { throw error; } - return rejectWithValue(error.response?.data || "API Error"); + return rejectWithValue(error.response?.data || 'API Error'); } } ); @@ -1472,7 +1469,6 @@ export const CustomerOrderList = createAsyncThunk( `/LastBuyProductList?compId=${CompId}&branchId=${BranchId}&appId=${AppId}&mobileNo=${MobileNo}` ); } - } ); @@ -1493,8 +1489,6 @@ export const getmultipleSearch = createAsyncThunk( } ); - - const initialState = { PrintStyle: null, CustId: null, @@ -1995,9 +1989,8 @@ const BookingData = createSlice({ state.SelectedDatas = []; } }), - builder.addCase(getProductsearch.fulfilled, (state, action) => { - console.log(action?.payload, "mohanaacacacca") + console.log(action?.payload, 'mohanaacacacca'); if (action?.payload?.statusCode === 1) { state.SelectedDatas = action?.payload?.data; } else { diff --git a/src/Features/PurchaseOrder/PurchaseOrder.js b/src/Features/PurchaseOrder/PurchaseOrder.js index 127732b..b1b0994 100644 --- a/src/Features/PurchaseOrder/PurchaseOrder.js +++ b/src/Features/PurchaseOrder/PurchaseOrder.js @@ -101,7 +101,7 @@ export const getPurProdvaraiantdata = createAsyncThunk( data?.prodName !== undefined ) { return await axiosRetailInstanceData.get( - `/ProductCardList?CompId=${data?.CompId}&BranchId=${data?.BranchId}&AppId=${data?.AppId}&prodName=${encodeURIComponent(data?.prodName)}` + `/ProductCardList?CompId=${data?.CompId}&BranchId=${data?.BranchId}&AppId=${data?.AppId}&prodName=${encodeURIComponent(data?.prodName)}&type=S` ); } } diff --git a/src/Features/StockMaster/StockMaster.js b/src/Features/StockMaster/StockMaster.js index dcb8387..1724919 100644 --- a/src/Features/StockMaster/StockMaster.js +++ b/src/Features/StockMaster/StockMaster.js @@ -31,7 +31,7 @@ export const getInvoiceImageData = createAsyncThunk( formData.append("file", file); // 👈 actual file here const response = await axiosRetailOcrData.post( - "/invoiceupload", + "/invoice", formData, { headers: { diff --git a/src/Features/ThemeChange/ThemeChange.js b/src/Features/ThemeChange/ThemeChange.js index c097192..601bdeb 100644 --- a/src/Features/ThemeChange/ThemeChange.js +++ b/src/Features/ThemeChange/ThemeChange.js @@ -364,7 +364,14 @@ export const getPrintSelectionComponentData = createAsyncThunk( ); } ); - +export const getSalesTemplate = createAsyncThunk( + 'theme/getSalesTemplate', + async (Data) => { + return await axiosRetailInstanceData.get( + `${apiUrl}/ThemeMaster?compId=${Data.CompId}&branchId=${Data.BranchId}&appId=${Data.AppId}` + ); + } +); export const PricingAppPricingNameData = createAsyncThunk( 'theme/PricingAppPricingNameData', async (data) => { @@ -463,6 +470,7 @@ const initialState = { notes: false, SignatureImage: '', BillName: '', + SelectedHeaderColor: '#000000', allColors: [], allColorsCat: [], LayoutOverallColorsList: [], @@ -2139,6 +2147,9 @@ const ThemeSlice = createSlice({ changeBillName: (state, action) => { state.BillName = action?.payload; }, + changeSelectedHeaderColor: (state, action) => { + state.SelectedHeaderColor = action?.payload; + }, changeCurrentColor: (state, action) => { const { color } = action?.payload; state.CurrentColor = color; @@ -2332,16 +2343,7 @@ const ThemeSlice = createSlice({ getPrintSelectionComponentData.fulfilled, (state, action) => { if (action?.payload?.data?.statusCode === 1) { - const Advance = state?.PricingAppPricingName?.some( - (item) => item.PricingName === 'Premium' - ); - const hasCustomizedTemplate = - state.FeatureAddonData?.FeatureDtls?.some( - (item) => - item?.FeatureAddonName?.toLowerCase() === - 'customized template' - ); - if (Advance || hasCustomizedTemplate) { + state.PrintTemplate = action?.payload?.data?.data?.[0]?.ComponentDetails?.find( (item) => @@ -2367,7 +2369,7 @@ const ThemeSlice = createSlice({ acc[item.ConfigName] = true; return acc; }, {}); - } + } else if (action?.payload?.data?.statusCode == 0) { state.PrintTemplate = undefined; } @@ -2683,6 +2685,7 @@ export const { changeOthersTheme, changeActiveTheme, changeScanTemplate, + changeSelectedHeaderColor, } = ThemeSlice.actions; export const GlobalPricingAppPricingName = (state) => @@ -2713,6 +2716,8 @@ export const GlobalthemeFormat = (state) => state.theme?.themeFormat; export const Globalnotes = (state) => state.theme?.notes; export const GlobalSignatureImage = (state) => state.theme?.SignatureImage; export const GlobalBillName = (state) => state.theme?.BillName; +export const GlobalSelectedPrintHeaderColor = (state) => + state.theme?.SelectedHeaderColor; export const changeCurrentColorValue = (state) => state.theme?.CurrentColor; export const changeCurrentTextValue = (state) => state.theme?.CurrentText; diff --git a/src/Pages/AppPage/AppPage.jsx b/src/Pages/AppPage/AppPage.jsx index 3c7802a..bd7ca4f 100644 --- a/src/Pages/AppPage/AppPage.jsx +++ b/src/Pages/AppPage/AppPage.jsx @@ -580,28 +580,16 @@ console.log(iswarehouse,'iswarehouseiswarehouseiswarehouse'); 'GST Invoice Setup', `${subDirectory}setting/gst-invoice-setup` ), - ((Advance || - featureaddDetails?.find( - (item) => - item?.FeatureAddonName?.toLowerCase() === 'customized template' - )) && !iswarehouse) && + (!iswarehouse) && getsubItem('Customization', `${subDirectory}setting/Customize`, null, [ - (Advance || - featureaddDetails?.find( - (item) => - item?.FeatureAddonName?.toLowerCase() === 'customized template' - )) && + !iswarehouse ? getsubItem( 'Sales Screen', `${subDirectory}saleslayouts/sales-selection` ) : '', - (Advance || - featureaddDetails?.find( - (item) => - item?.FeatureAddonName?.toLowerCase() === 'customized template' - )) && + !iswarehouse ? getsubItem( 'Print Forms', @@ -616,11 +604,7 @@ console.log(iswarehouse,'iswarehouseiswarehouseiswarehouse'); `${subDirectory}saleslayouts/kiosk-selection` ) : '', - (Advance || - featureaddDetails?.find( - (item) => - item?.FeatureAddonName?.toLowerCase() === 'customized template' - )) && + !iswarehouse ? getsubItem( 'Barcode / QR', @@ -1318,29 +1302,17 @@ console.log(iswarehouse,'iswarehouseiswarehouseiswarehouse'); 'GST Invoice Setup', `${subDirectory}setting/gst-invoice-setup` ), - ((Advance || - featureaddDetails?.find( - (item) => - item?.FeatureAddonName?.toLowerCase() === 'customized template' - )) && + ( !iswarehouse) && getsubItem('Customization', `${subDirectory}setting/Customize`, null, [ - (Advance || - featureaddDetails?.find( - (item) => - item?.FeatureAddonName?.toLowerCase() === 'customized template' - )) && + !iswarehouse ? getsubItem( 'Sales Screen', `${subDirectory}saleslayouts/sales-selection` ) : '', - (Advance || - featureaddDetails?.find( - (item) => - item?.FeatureAddonName?.toLowerCase() === 'customized template' - )) && + !iswarehouse ? getsubItem( 'Print Forms', @@ -1355,11 +1327,7 @@ console.log(iswarehouse,'iswarehouseiswarehouseiswarehouse'); `${subDirectory}saleslayouts/kiosk-selection` ) : '', - (Advance || - featureaddDetails?.find( - (item) => - item?.FeatureAddonName?.toLowerCase() === 'customized template' - )) && + !iswarehouse ? getsubItem( 'Barcode / QR', @@ -2563,26 +2531,14 @@ const customizedmenuitem = [] 'GST Invoice Setup', `${subDirectory}setting/gst-invoice-setup` ), - (Advance || - featureaddDetails?.find( - (item) => - item?.FeatureAddonName?.toLowerCase() === 'customized template' - ) || - featureaddDetails?.find( - (item) => item?.FeatureAddonName?.toLowerCase() === 'kiosk sales' - )) && + !sportsAppPreference && getsubItem( 'Customization', `${subDirectory}setting/Customized`, null, [ - (Advance || - featureaddDetails?.find( - (item) => - item?.FeatureAddonName?.toLowerCase() === - 'customized template' - )) && + !sportsAppPreference && !iswarehouse ? getsubItem( @@ -2590,12 +2546,7 @@ const customizedmenuitem = [] `${subDirectory}saleslayouts/sales-selection` ) : '', - (Advance || - featureaddDetails?.find( - (item) => - item?.FeatureAddonName?.toLowerCase() === - 'customized template' - )) && + !iswarehouse ? getsubItem( 'Print Forms', @@ -2611,12 +2562,7 @@ const customizedmenuitem = [] `${subDirectory}saleslayouts/kiosk-selection` ) : '', - (Advance || - featureaddDetails?.find( - (item) => - item?.FeatureAddonName?.toLowerCase() === - 'customized template' - )) && + !iswarehouse && !sportsAppPreference ? getsubItem( diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/BSBillingEditQuantity.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/BSBillingEditQuantity.jsx index a30d951..74f5029 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/BSBillingEditQuantity.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/BSBillingEditQuantity.jsx @@ -87,11 +87,13 @@ const BSBillingEditQuantity = (props) => { ); const ReorderProductData = useSelector(GlobalReorderProductDetails); const templateData = useSelector(getTemplateData); - const OfferCheckedInSetup = templateData?.BookingNavbar?.[1].some( - (item) => item?.OptionName == 'Offer' - ) || (templateData?.BookingCombo1?.[1]?.some( - (item) => item?.OptionName == 'Offer' - )); + const OfferCheckedInSetup = + templateData?.BookingNavbar?.[1].some( + (item) => item?.OptionName == 'Offer' + ) || + templateData?.BookingCombo1?.[1]?.some( + (item) => item?.OptionName == 'Offer' + ); const [ClearQuantity, setClearQuantity] = useState(false); const CartOrderDetails = useSelector(GlobalOrderCardDetails); const SettingDataSelector = useSelector(PreferenceData); @@ -704,7 +706,7 @@ const BSBillingEditQuantity = (props) => { return ( cartItem?.InwardDtlId === editedProduct?.InwardDtlId && cartItem?.OfferMessage?.[0]?.OfferId === - editedProduct?.OfferMessage?.[0]?.OfferId && + editedProduct?.OfferMessage?.[0]?.OfferId && cartItem?.OfferMode === editedProduct?.OfferMode && cartItem?.BookingTypeName !== editedProduct?.BookingTypeName ); @@ -838,7 +840,7 @@ const BSBillingEditQuantity = (props) => { cartItem?.InwardDtlId === editedProduct?.InwardDtlId && cartItem?.OrderRate === editedProduct?.OrderRate && cartItem?.BookingTypeName !== - editedProduct?.BookingTypeName && + editedProduct?.BookingTypeName && !cartItem?.OfferMode && cartItem?.Offer === 0 ); @@ -852,7 +854,7 @@ const BSBillingEditQuantity = (props) => { cartItem?.InwardDtlId === editedProduct?.InwardDtlId && cartItem?.OrderRate === editedProduct?.OrderRate && cartItem?.BookingTypeName !== - editedProduct?.BookingTypeName && + editedProduct?.BookingTypeName && cartItem?.OfferMode === editedProduct?.OfferMode && cartItem?.Offer > 0 ); @@ -985,7 +987,7 @@ const BSBillingEditQuantity = (props) => { ) ) && product?.OfferId === - editedProduct?.OfferMessage?.[0]?.OfferId && + editedProduct?.OfferMessage?.[0]?.OfferId && product?.OfferMode === editedProduct?.OfferMode ) { const freeQty = @@ -1018,7 +1020,7 @@ const BSBillingEditQuantity = (props) => { // Also check main offer conditions const isMatchingOffer = offerProduct?.OfferId === - editedProduct?.OfferMessage?.[0]?.OfferId && + editedProduct?.OfferMessage?.[0]?.OfferId && offerProduct?.OfferMode === editedProduct?.OfferMode; if (hasMatchingFreeProduct && isMatchingOffer) { @@ -1101,7 +1103,7 @@ const BSBillingEditQuantity = (props) => { ) ) && product?.OfferId === - editedProduct?.OfferMessage?.[0]?.OfferId && + editedProduct?.OfferMessage?.[0]?.OfferId && product?.OfferMode === editedProduct?.OfferMode ) { return { @@ -1131,7 +1133,7 @@ const BSBillingEditQuantity = (props) => { // Also check main offer conditions const isMatchingOffer = offerProduct?.OfferId === - editedProduct?.OfferMessage?.[0]?.OfferId && + editedProduct?.OfferMessage?.[0]?.OfferId && offerProduct?.OfferMode === editedProduct?.OfferMode; if (hasMatchingFreeProduct && isMatchingOffer) { @@ -1318,7 +1320,7 @@ const BSBillingEditQuantity = (props) => { // Also check main offer conditions const isMatchingOffer = offerProduct?.OfferId === - editedProduct?.OfferMessage?.[0]?.OfferId && + editedProduct?.OfferMessage?.[0]?.OfferId && offerProduct?.OfferMode === editedProduct?.OfferMode; if (hasMatchingFreeProduct && isMatchingOffer) { @@ -1420,7 +1422,7 @@ const BSBillingEditQuantity = (props) => { // Also check main offer conditions const isMatchingOffer = offerProduct?.OfferId === - editedProduct?.OfferMessage?.[0]?.OfferId && + editedProduct?.OfferMessage?.[0]?.OfferId && offerProduct?.OfferMode === editedProduct?.OfferMode; if (hasMatchingFreeProduct && isMatchingOffer) { @@ -1574,7 +1576,7 @@ const BSBillingEditQuantity = (props) => { ) && cartItem?.Offer && isFreeProductApplicable?.OfferId === - cartItem?.OfferMessage?.[0]?.OfferId + cartItem?.OfferMessage?.[0]?.OfferId ); } ); @@ -1863,11 +1865,11 @@ const BSBillingEditQuantity = (props) => { product?.ProdId === editedProduct?.ProdId && product?.InwardDtlId === editedProduct?.InwardDtlId && product?.OfferId === - (sameBookingTypeProduct?.OfferMessage?.[0]?.OfferId || - otherBookingTypeProduct?.OfferMessage?.[0]?.OfferId) && + (sameBookingTypeProduct?.OfferMessage?.[0]?.OfferId || + otherBookingTypeProduct?.OfferMessage?.[0]?.OfferId) && product?.OfferMode === - (sameBookingTypeProduct?.OfferMode || - otherBookingTypeProduct?.OfferMode) + (sameBookingTypeProduct?.OfferMode || + otherBookingTypeProduct?.OfferMode) ) { return { ...product, @@ -1901,11 +1903,11 @@ const BSBillingEditQuantity = (props) => { // Also check main offer conditions const isMatchingOffer = offerProduct?.OfferId === - (sameBookingTypeProduct?.OfferMessage?.[0]?.OfferId || - otherBookingTypeProduct?.OfferMessage?.[0]?.OfferId) && + (sameBookingTypeProduct?.OfferMessage?.[0]?.OfferId || + otherBookingTypeProduct?.OfferMessage?.[0]?.OfferId) && offerProduct?.OfferMode === - (sameBookingTypeProduct?.OfferMode || - otherBookingTypeProduct?.OfferMode); + (sameBookingTypeProduct?.OfferMode || + otherBookingTypeProduct?.OfferMode); if (hasMatchingFreeProduct && isMatchingOffer) { // Get loyalty points from the matching free product @@ -2046,7 +2048,7 @@ const BSBillingEditQuantity = (props) => { cartItem?.Offer > 0 && isFreeProductApplicable?.OfferMode === cartItem?.OfferMode && isFreeProductApplicable?.OfferId === - cartItem?.OfferMessage?.[0]?.OfferId + cartItem?.OfferMessage?.[0]?.OfferId ); } ); @@ -2149,11 +2151,11 @@ const BSBillingEditQuantity = (props) => { if ( cartItem.ProdId === otherBookingTypeProduct.ProdId && cartItem.InwardDtlId === - otherBookingTypeProduct.InwardDtlId && + otherBookingTypeProduct.InwardDtlId && cartItem.BookingTypeName === - otherBookingTypeProduct.BookingTypeName && + otherBookingTypeProduct.BookingTypeName && cartItem.OrderRate === - otherBookingTypeProduct.OrderRate && + otherBookingTypeProduct.OrderRate && cartItem.OfferMode && cartItem.Offer > 0 ) { @@ -2224,12 +2226,12 @@ const BSBillingEditQuantity = (props) => { product?.ProdId === editedProduct?.ProdId && product?.InwardDtlId === editedProduct?.InwardDtlId && product?.OfferId === - (sameBookingTypeFreeProduct?.OfferMessage?.[0]?.OfferId || - otherBookingTypeFreeProduct?.OfferMessage?.[0] - ?.OfferId) && + (sameBookingTypeFreeProduct?.OfferMessage?.[0]?.OfferId || + otherBookingTypeFreeProduct?.OfferMessage?.[0] + ?.OfferId) && product?.OfferMode === - (sameBookingTypeFreeProduct?.OfferMode || - otherBookingTypeFreeProduct?.OfferMode) + (sameBookingTypeFreeProduct?.OfferMode || + otherBookingTypeFreeProduct?.OfferMode) ) { return { ...product, @@ -2263,13 +2265,13 @@ const BSBillingEditQuantity = (props) => { // Also check main offer conditions const isMatchingOffer = offerProduct?.OfferId === - (sameBookingTypeFreeProduct?.OfferMessage?.[0] - ?.OfferId || - otherBookingTypeFreeProduct?.OfferMessage?.[0] - ?.OfferId) && + (sameBookingTypeFreeProduct?.OfferMessage?.[0] + ?.OfferId || + otherBookingTypeFreeProduct?.OfferMessage?.[0] + ?.OfferId) && offerProduct?.OfferMode === - (sameBookingTypeFreeProduct?.OfferMode || - otherBookingTypeFreeProduct?.OfferMode); + (sameBookingTypeFreeProduct?.OfferMode || + otherBookingTypeFreeProduct?.OfferMode); if (hasMatchingFreeProduct && isMatchingOffer) { // Get loyalty points from the matching free product @@ -2351,11 +2353,11 @@ const BSBillingEditQuantity = (props) => { if ( cartItem.ProdId === sameBookingTypeProduct.ProdId && cartItem.InwardDtlId === - sameBookingTypeProduct.InwardDtlId && + sameBookingTypeProduct.InwardDtlId && cartItem.BookingTypeName === - sameBookingTypeProduct.BookingTypeName && + sameBookingTypeProduct.BookingTypeName && cartItem.OrderRate === - sameBookingTypeProduct.OrderRate && + sameBookingTypeProduct.OrderRate && cartItem.OfferMode && cartItem.Offer > 0 ) { @@ -2408,11 +2410,11 @@ const BSBillingEditQuantity = (props) => { if ( cartItem.ProdId === sameBookingTypeProduct.ProdId && cartItem.InwardDtlId === - sameBookingTypeProduct.InwardDtlId && + sameBookingTypeProduct.InwardDtlId && cartItem.BookingTypeName === - sameBookingTypeProduct.BookingTypeName && + sameBookingTypeProduct.BookingTypeName && cartItem.OrderRate === - sameBookingTypeProduct.OrderRate && + sameBookingTypeProduct.OrderRate && cartItem.OfferMode && cartItem.Offer > 0 ) { @@ -2501,11 +2503,11 @@ const BSBillingEditQuantity = (props) => { if ( cartItem.ProdId === otherBookingTypeProduct.ProdId && cartItem?.InwardDtlId === - otherBookingTypeProduct.InwardDtlId && + otherBookingTypeProduct.InwardDtlId && cartItem?.BookingTypeName === - otherBookingTypeProduct.BookingTypeName && + otherBookingTypeProduct.BookingTypeName && cartItem?.OrderRate === - otherBookingTypeProduct.OrderRate && + otherBookingTypeProduct.OrderRate && cartItem?.OfferMode && cartItem?.Offer > 0 ) { @@ -2534,11 +2536,11 @@ const BSBillingEditQuantity = (props) => { if ( cartItem.ProdId === otherBookingTypeProduct.ProdId && cartItem.InwardDtlId === - otherBookingTypeProduct.InwardDtlId && + otherBookingTypeProduct.InwardDtlId && cartItem.BookingTypeName === - otherBookingTypeProduct.BookingTypeName && + otherBookingTypeProduct.BookingTypeName && cartItem.OrderRate === - otherBookingTypeProduct.OrderRate && + otherBookingTypeProduct.OrderRate && cartItem.OfferMode && cartItem.Offer > 0 ) { @@ -2568,11 +2570,11 @@ const BSBillingEditQuantity = (props) => { if ( cartItem.ProdId === otherBookingTypeProduct.ProdId && cartItem.InwardDtlId === - otherBookingTypeProduct.InwardDtlId && + otherBookingTypeProduct.InwardDtlId && cartItem.BookingTypeName === - otherBookingTypeProduct.BookingTypeName && + otherBookingTypeProduct.BookingTypeName && cartItem.OrderRate === - otherBookingTypeProduct.OrderRate && + otherBookingTypeProduct.OrderRate && cartItem.OfferMode && cartItem.Offer > 0 ) { @@ -2671,12 +2673,12 @@ const BSBillingEditQuantity = (props) => { product?.ProdId === editedProduct?.ProdId && product?.InwardDtlId === editedProduct?.InwardDtlId && product?.OfferId === - (sameBookingTypeFreeProduct?.OfferMessage?.[0]?.OfferId || - otherBookingTypeFreeProduct?.OfferMessage?.[0] - ?.OfferId) && + (sameBookingTypeFreeProduct?.OfferMessage?.[0]?.OfferId || + otherBookingTypeFreeProduct?.OfferMessage?.[0] + ?.OfferId) && product?.OfferMode === - (sameBookingTypeFreeProduct?.OfferMode || - otherBookingTypeFreeProduct?.OfferMode) + (sameBookingTypeFreeProduct?.OfferMode || + otherBookingTypeFreeProduct?.OfferMode) ) { return { ...product, @@ -2710,12 +2712,12 @@ const BSBillingEditQuantity = (props) => { // Also check main offer conditions const isMatchingOffer = offerProduct?.OfferId === - (sameBookingTypeProduct?.OfferMessage?.[0]?.OfferId || - otherBookingTypeProduct?.OfferMessage?.[0] - ?.OfferId) && + (sameBookingTypeProduct?.OfferMessage?.[0]?.OfferId || + otherBookingTypeProduct?.OfferMessage?.[0] + ?.OfferId) && offerProduct?.OfferMode === - (sameBookingTypeProduct?.OfferMode || - otherBookingTypeProduct?.OfferMode); + (sameBookingTypeProduct?.OfferMode || + otherBookingTypeProduct?.OfferMode); if (hasMatchingFreeProduct && isMatchingOffer) { // Get loyalty points from the matching free product @@ -2794,11 +2796,11 @@ const BSBillingEditQuantity = (props) => { if ( cartItem.ProdId === sameBookingTypeProduct.ProdId && cartItem.InwardDtlId === - sameBookingTypeProduct.InwardDtlId && + sameBookingTypeProduct.InwardDtlId && cartItem.BookingTypeName === - sameBookingTypeProduct.BookingTypeName && + sameBookingTypeProduct.BookingTypeName && cartItem.OrderRate === - sameBookingTypeProduct.OrderRate && + sameBookingTypeProduct.OrderRate && cartItem.OfferMode && cartItem.Offer > 0 ) { @@ -2857,11 +2859,11 @@ const BSBillingEditQuantity = (props) => { if ( cartItem.ProdId === otherBookingTypeProduct.ProdId && cartItem.InwardDtlId === - otherBookingTypeProduct.InwardDtlId && + otherBookingTypeProduct.InwardDtlId && cartItem.BookingTypeName === - otherBookingTypeProduct.BookingTypeName && + otherBookingTypeProduct.BookingTypeName && cartItem.OrderRate === - otherBookingTypeProduct.OrderRate && + otherBookingTypeProduct.OrderRate && cartItem.OfferMode && cartItem.Offer > 0 ) { @@ -2933,12 +2935,12 @@ const BSBillingEditQuantity = (props) => { product?.ProdId === editedProduct?.ProdId && product?.InwardDtlId === editedProduct?.InwardDtlId && product?.OfferId === - (sameBookingTypeFreeProduct?.OfferMessage?.[0]?.OfferId || - otherBookingTypeFreeProduct?.OfferMessage?.[0] - ?.OfferId) && + (sameBookingTypeFreeProduct?.OfferMessage?.[0]?.OfferId || + otherBookingTypeFreeProduct?.OfferMessage?.[0] + ?.OfferId) && product?.OfferMode === - (sameBookingTypeFreeProduct?.OfferMode || - otherBookingTypeFreeProduct?.OfferMode) + (sameBookingTypeFreeProduct?.OfferMode || + otherBookingTypeFreeProduct?.OfferMode) ) { return { ...product, @@ -2972,12 +2974,12 @@ const BSBillingEditQuantity = (props) => { // Also check main offer conditions const isMatchingOffer = offerProduct?.OfferId === - (sameBookingTypeProduct?.OfferMessage?.[0]?.OfferId || - otherBookingTypeProduct?.OfferMessage?.[0] - ?.OfferId) && + (sameBookingTypeProduct?.OfferMessage?.[0]?.OfferId || + otherBookingTypeProduct?.OfferMessage?.[0] + ?.OfferId) && offerProduct?.OfferMode === - (sameBookingTypeProduct?.OfferMode || - otherBookingTypeProduct?.OfferMode); + (sameBookingTypeProduct?.OfferMode || + otherBookingTypeProduct?.OfferMode); if (hasMatchingFreeProduct && isMatchingOffer) { // Get loyalty points from the matching free product @@ -3131,17 +3133,17 @@ const BSBillingEditQuantity = (props) => { changeOrderCardDetails( CartOrderDetails?.map((i) => i?.InwardDtlId == updatedProduct?.InwardDtlId && - i?.BookingTypeName == updatedProduct?.BookingTypeName && - i?.localId === updatedProduct?.localId + i?.BookingTypeName == updatedProduct?.BookingTypeName && + i?.localId === updatedProduct?.localId ? { - ...updatedProduct, - Offer: 0, - OfferType: - updatedProduct?.Type === 'C' - ? updatedProduct?.OfferType - : null, - OfferMessage: null, - } + ...updatedProduct, + Offer: 0, + OfferType: + updatedProduct?.Type === 'C' + ? updatedProduct?.OfferType + : null, + OfferMessage: null, + } : i ) ) @@ -3158,9 +3160,10 @@ const BSBillingEditQuantity = (props) => { const UpdatedCartItemWithOffer = { ...updatedProduct, - Offer: (bestOffer?.OfferMode === 'I' || bestOffer?.OfferMode === 'Q') ? - bestOffer?.OfferAmount || updatedProduct.Offer : - updatedProduct.Offer || bestOffer?.OfferAmount, + Offer: + bestOffer?.OfferMode === 'I' || bestOffer?.OfferMode === 'Q' + ? bestOffer?.OfferAmount || updatedProduct.Offer + : updatedProduct.Offer || bestOffer?.OfferAmount, OfferType: updatedProduct?.OfferType || bestOffer?.OfferType, OfferMessage: updatedProduct?.OfferMessage || bestOffer?.OfferMessage, }; @@ -3175,10 +3178,11 @@ const BSBillingEditQuantity = (props) => { !c.SalesId && ((c?.OfferModeType && c?.OfferMode === 'B' ? true - : c?.OfferMode !== 'B') - && c?.OfferMode !== 'P' - && c?.OfferMode !== 'C' && c?.OfferMode !== 'O' - && c?.OfferMode !== 'L' + : c?.OfferMode !== 'B') && + c?.OfferMode !== 'P' && + c?.OfferMode !== 'C' && + c?.OfferMode !== 'O' && + c?.OfferMode !== 'L' ? true : c?.Offer === 0); @@ -3708,9 +3712,10 @@ const BSBillingEditQuantity = (props) => { /> - - + 'Change' + //
+ // + //
} open={EditOpen} width={600} @@ -3817,38 +3822,38 @@ const BSBillingEditQuantity = (props) => { ✖ -
-
AddQuantity(1)}> +
+
AddQuantity(1)}> 1
-
AddQuantity(2)}> +
AddQuantity(2)}> 2
-
AddQuantity(3)}> +
AddQuantity(3)}> 3
-
AddQuantity(4)}> +
AddQuantity(4)}> 4
-
AddQuantity(5)}> +
AddQuantity(5)}> 5
-
AddQuantity(6)}> +
AddQuantity(6)}> 6
-
AddQuantity(7)}> +
AddQuantity(7)}> 7
-
AddQuantity(8)}> +
AddQuantity(8)}> 8
-
AddQuantity(9)}> +
AddQuantity(9)}> 9
-
AddQuantity(0)}> +
AddQuantity(0)}> 0
@@ -3903,7 +3908,7 @@ const BSBillingEditQuantity = (props) => { ? `${parts[0]}.${parts.slice(1).join('')}` : cleanedValue; }} - // isOnChange={formType == "edit" || formRef.current?.getFieldsValue()?.CustName ? true : false} + // isOnChange={formType == "edit" || formRef.current?.getFieldsValue()?.CustName ? true : false} /> )} @@ -3966,7 +3971,7 @@ const BSBillingEditQuantity = (props) => { ? `${parts[0]}.${parts.slice(1).join('')}` : cleanedValue; }} - // isOnChange={formType == "edit" || formRef.current?.getFieldsValue()?.CustName ? true : false} + // isOnChange={formType == "edit" || formRef.current?.getFieldsValue()?.CustName ? true : false} /> {/* {
{((RadioBtnSelection == 'Price' && disableSubmitButton) || RadioBtnSelection == 'Quantity') && ( - } - > - )} + } + > + )}
diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable2/BSBillingTable2.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable2/BSBillingTable2.jsx index caa8639..2816c23 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable2/BSBillingTable2.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable2/BSBillingTable2.jsx @@ -222,6 +222,7 @@ import pozologoimg from '../../../../../Images/pozologoimg.png'; import PaymentGatewayEmbedded from '../../UtillComponents/PaymentGatewayEmbedded.jsx'; import MobileMultiPdfPrintTrigger from '../../UtillComponents/MobileMultiPdfPrintTrigger.jsx'; import { useDateStore } from '../../../../../Features/BookingScreen/BookingData/DateStore.js'; +import CustomerOrders from '../../BookingFunctionality/CustomerOrders.jsx'; const subDirectory = import.meta.env.ENV_BASE_URL; const MainHomeUrl = import.meta.env.ENV_MAIN_BASE_URL; diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable4/BSBilling4Payment.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable4/BSBilling4Payment.jsx index e74dd18..89d5b59 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable4/BSBilling4Payment.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable4/BSBilling4Payment.jsx @@ -836,7 +836,7 @@ const BSBilling4Payment = () => { const selectedStyle = stylesMap[ - printerTemplateStyle == undefined ? 'Style 13' : printerTemplateStyle + printerTemplateStyle == undefined ? 'Style 13' : printerTemplateStyle ]; console.log(selectedStyle, style, 'style'); if (selectedStyle) { @@ -2074,15 +2074,15 @@ const BSBilling4Payment = () => { OrderStatus: 'O', OrderType: BookingType === 'Dine In' || - BookingTypeBoth || - Estimation?.SettingValue == 'N' + BookingTypeBoth || + Estimation?.SettingValue == 'N' ? 'S' : GlobEstBooking === 'OvrAllEst' ? 'E' : GlobEstBooking === 'ParEst' ? GlobProdwisedata?.includes( - a.InwardDtlId + ' ' + a?.BookingTypeName - ) + a.InwardDtlId + ' ' + a?.BookingTypeName + ) ? 'E' : 'S' : 'S', @@ -2175,7 +2175,7 @@ const BSBilling4Payment = () => { : Paybtnnameselected?.toLowerCase() === 'credit' ? 'S' : Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'default' + SelectedUPIPayOption?.toLowerCase() === 'default' ? 'S' : 'P', OrderDtlDetails: @@ -2192,9 +2192,9 @@ const BSBilling4Payment = () => { ? globalTipAmount === 0 ? SelectedTableDetails : SelectedTableDetails?.map((item) => ({ - ...item, - TipsAmount: globalTipAmount, - })) + ...item, + TipsAmount: globalTipAmount, + })) : null, SalesPaymentType: 'normal', PaymentDetail: [ @@ -2207,8 +2207,8 @@ const BSBilling4Payment = () => { ? PaymentgatewayUPI?.[0]?.ModeId : SelectedUPIPayOption?.toLowerCase() === 'business' ? BusinessPayOption?.find( - (busupi) => busupi?.ModeId === UpiId - )?.ModeId + (busupi) => busupi?.ModeId === UpiId + )?.ModeId : paybtnselected : paybtnselected ? paybtnselected @@ -2216,9 +2216,9 @@ const BSBilling4Payment = () => { Amount: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? previousNetAmount - currentOrderNetAmount : Math.round(TotalAmount), MerchantId: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? null : Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'business' + SelectedUPIPayOption?.toLowerCase() === 'business' ? BusinessPayOption?.find((busupi) => busupi?.ModeId === UpiId) - ?.MerchantId + ?.MerchantId : null, PaymentOptionType: (salesBillEdit && currentOrderNetAmount < previousNetAmount) && (refundPaySelectedName?.toLowerCase() === 'cash' || refundPaySelectedName?.toLowerCase() === 'credit') ? 'PC' : Paybtnnameselected?.toLowerCase() === 'cash' @@ -2237,26 +2237,26 @@ const BSBilling4Payment = () => { ModeOfPayment: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? null : SelectedUPIPayOption?.toLowerCase() === 'default' ? PaymentUpiOptions?.find((upipay) => upipay?.UPIId === UpiId) - ?.UPIDetailId + ?.UPIDetailId : SelectedUPIPayOption?.toLowerCase() === 'business' ? BusinessPayOption?.find((busupi) => busupi?.ModeId === UpiId) - ?.MerchantUPIId + ?.MerchantUPIId : null, AccountDtl: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? [] : Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'default' + SelectedUPIPayOption?.toLowerCase() === 'default' ? useOptions?.[0]?.PaymentDetails?.Payatthecounter?.find( - (upipay) => upipay?.UPIId === UpiId - ) + (upipay) => upipay?.UPIId === UpiId + ) : (Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'pd') || - (Paybtnnameselected?.toLowerCase() === 'card' && - SelectedCardOption?.toLowerCase() === 'pd') + SelectedUPIPayOption?.toLowerCase() === 'pd') || + (Paybtnnameselected?.toLowerCase() === 'card' && + SelectedCardOption?.toLowerCase() === 'pd') ? useOptions?.[0]?.PaymentDetails?.PaymentDevice : (Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'pg') || - (Paybtnnameselected?.toLowerCase() === 'card' && - SelectedCardOption?.toLowerCase() === 'pg') + SelectedUPIPayOption?.toLowerCase() === 'pg') || + (Paybtnnameselected?.toLowerCase() === 'card' && + SelectedCardOption?.toLowerCase() === 'pg') ? useOptions?.[0]?.PaymentDetails?.PaymentGateway : [], PaymentStatus: (salesBillEdit && currentOrderNetAmount < previousNetAmount) ? 'S' : @@ -2265,7 +2265,7 @@ const BSBilling4Payment = () => { : Paybtnnameselected?.toLowerCase() === 'credit' ? 'S' : Paybtnnameselected?.toLowerCase() === 'upi' && - SelectedUPIPayOption?.toLowerCase() === 'default' + SelectedUPIPayOption?.toLowerCase() === 'default' ? 'S' : 'P', Debit: (salesBillEdit && currentOrderNetAmount < previousNetAmount && refundPaySelectedName?.toLowerCase() === 'credit') ? Math.round(previousNetAmount - currentOrderNetAmount) : 0, @@ -2340,14 +2340,14 @@ const BSBilling4Payment = () => { setMessageType('success'); setMessageData( response?.data?.response + - ' ' + - (response?.data?.OrderDetails?.length > 0 - ? response?.data?.OrderId && - extractLastNumberOrderId( - response?.data?.OrderId, - response?.data?.OrderDetails?.[0]?.FYStatus - ) - : '') + ' ' + + (response?.data?.OrderDetails?.length > 0 + ? response?.data?.OrderId && + extractLastNumberOrderId( + response?.data?.OrderId, + response?.data?.OrderDetails?.[0]?.FYStatus + ) + : '') ); response?.data?.OrderDetails?.length > 0 && setPrintOrderDetails([response?.data]); @@ -2508,14 +2508,14 @@ const BSBilling4Payment = () => { setMessageType('success'); setMessageData( response?.data?.response + - ' ' + - (response?.data?.OrderDetails?.length > 0 - ? response?.data?.OrderId && - extractLastNumberOrderId( - response?.data?.OrderId, - response?.data?.OrderDetails?.[0]?.FYStatus - ) - : '') + ' ' + + (response?.data?.OrderDetails?.length > 0 + ? response?.data?.OrderId && + extractLastNumberOrderId( + response?.data?.OrderId, + response?.data?.OrderDetails?.[0]?.FYStatus + ) + : '') ); response?.data?.OrderDetails?.length > 0 && setPrintOrderDetails([response?.data]); @@ -2622,14 +2622,14 @@ const BSBilling4Payment = () => { } setMessageData( response?.data?.response + - ' ' + - (response?.data?.OrderDetails?.length > 0 - ? response?.data?.OrderId && - extractLastNumberOrderId( - response?.data?.OrderId, - response?.data?.OrderDetails?.[0]?.FYStatus - ) - : '') + ' ' + + (response?.data?.OrderDetails?.length > 0 + ? response?.data?.OrderId && + extractLastNumberOrderId( + response?.data?.OrderId, + response?.data?.OrderDetails?.[0]?.FYStatus + ) + : '') ); if (response?.data?.OrderDetails?.length > 0) { setPrintOrderDetails([response?.data]); @@ -2805,14 +2805,14 @@ const BSBilling4Payment = () => { setMessageType('success'); setMessageData( bookingpaymentupdate?.data?.response + - ' ' + - (bookingpaymentupdate?.data?.OrderDetails?.length > 0 - ? bookingpaymentupdate?.data?.OrderId && - extractLastNumberOrderId( - bookingpaymentupdate?.data?.OrderId, - bookingpaymentupdate?.data?.OrderDetail?.[0]?.FYStatus - ) - : '') + ' ' + + (bookingpaymentupdate?.data?.OrderDetails?.length > 0 + ? bookingpaymentupdate?.data?.OrderId && + extractLastNumberOrderId( + bookingpaymentupdate?.data?.OrderId, + bookingpaymentupdate?.data?.OrderDetail?.[0]?.FYStatus + ) + : '') ); bookingpaymentupdate?.data?.OrderDetails?.length > 0 && setPrintOrderDetails([bookingpaymentupdate?.data]); @@ -2831,7 +2831,7 @@ const BSBilling4Payment = () => { if ( Date.now() - startTime > useOptions?.[0]?.PDConfigDetails?.[0]?.AutoCancelDurationInMinutes * - 60000 + 60000 ) { // 60,000 ms = 1 minute @@ -3068,9 +3068,9 @@ const BSBilling4Payment = () => { AppId: AppId, ...(AvailableDate && selectedDate ? { - fromDate: selectedDate?.[0], - toDate: selectedDate?.[1], - } + fromDate: selectedDate?.[0], + toDate: selectedDate?.[1], + } : {}), }; await dispatch(getSelectedFavItems(data)).unwrap(); @@ -3082,9 +3082,9 @@ const BSBilling4Payment = () => { ProdSubCat: ProdSubCat, ...(AvailableDate && selectedDate ? { - fromDate: selectedDate?.[0], - toDate: selectedDate?.[1], - } + fromDate: selectedDate?.[0], + toDate: selectedDate?.[1], + } : {}), }; @@ -3095,9 +3095,9 @@ const BSBilling4Payment = () => { prodCat: prodCat, ...(AvailableDate && selectedDate ? { - fromDate: selectedDate?.[0], - toDate: selectedDate?.[1], - } + fromDate: selectedDate?.[0], + toDate: selectedDate?.[1], + } : {}), }; @@ -3717,9 +3717,9 @@ const BSBilling4Payment = () => { OrderCardDetail?.length > 0 && 'not-allowed', color: OrderCardDetail?.length > 0 || - (selOption?.value === undefined && - GlobalAddCustomerDetails1?.length === 0 && - GetCustId?.CustMobile === undefined) + (selOption?.value === undefined && + GlobalAddCustomerDetails1?.length === 0 && + GetCustId?.CustMobile === undefined) ? 'gray' : 'rgb(18, 146, 238)', fontSize: '28px', @@ -3740,16 +3740,16 @@ const BSBilling4Payment = () => { (BookingType === 'Dine In' || BookingTypeBoth || CheckOrderType?.length > 0) && - !unpaidFlow && - OrderStatus + !unpaidFlow && + OrderStatus ? 'none' : 'auto', opacity: (BookingType === 'Dine In' || BookingTypeBoth || CheckOrderType?.length > 0) && - !unpaidFlow && - OrderStatus + !unpaidFlow && + OrderStatus ? 0.5 : 1, width: '2rem', @@ -3770,14 +3770,14 @@ const BSBilling4Payment = () => { width: '1.5rem', cursor: OrderCardDetail?.length === 0 || - CheckBookingStatus == 'Close' || - addnewAccess + CheckBookingStatus == 'Close' || + addnewAccess ? 'not-allowed' : 'pointer', color: OrderCardDetail?.length === 0 || - CheckBookingStatus == 'Close' || - addnewAccess + CheckBookingStatus == 'Close' || + addnewAccess ? 'gray' : 'rgb(18, 146, 238)', display: 'flex', @@ -3789,40 +3789,7 @@ const BSBilling4Payment = () => {
)} - {/* Customer Orders */} - {GetCustId && ( - - {' '} -
{ - if ( - CheckBookingStatus !== 'Close' && - !addnewAccess && - !(OrderCardDetail?.length > 0) - ) { - setCustomerPreviesOrders(true); - } - }} - style={{ - cursor: OrderCardDetail?.length > 0 && 'not-allowed', - color: - OrderCardDetail?.length > 0 || - (OrderCardDetail?.length > 0 && - GetCustId?.CustMobile === undefined) - ? 'gray' - : 'rgb(18, 146, 238)', - fontSize: '25px', - display: 'flex', - alignItems: 'center', - height: '2.46rem', - width: '1.5rem', - }} - > - -
-
- )} + {OtherServicesglobal && OrderCardDetail.length >= 1 && ( {' '} @@ -3837,14 +3804,14 @@ const BSBilling4Payment = () => { width: '1.5rem', cursor: OrderCardDetail?.length === 0 || - CheckBookingStatus == 'Close' || - addnewAccess + CheckBookingStatus == 'Close' || + addnewAccess ? 'not-allowed' : 'pointer', color: OrderCardDetail?.length === 0 || - CheckBookingStatus == 'Close' || - addnewAccess + CheckBookingStatus == 'Close' || + addnewAccess ? 'gray' : 'rgb(18, 146, 238)', display: 'flex', @@ -3859,6 +3826,41 @@ const BSBilling4Payment = () => { {/* */}
)} + + {/* Customer Orders */} + {GetCustId && ( + + {' '} +
{ + if ( + CheckBookingStatus !== 'Close' && + !addnewAccess && + !(OrderCardDetail?.length > 0) + ) { + setCustomerPreviesOrders(true); + } + }} + style={{ + cursor: OrderCardDetail?.length > 0 && 'not-allowed', + color: + OrderCardDetail?.length > 0 || + (OrderCardDetail?.length > 0 && + GetCustId?.CustMobile === undefined) + ? 'gray' + : 'rgb(18, 146, 238)', + fontSize: '25px', + display: 'flex', + alignItems: 'center', + height: '2.46rem', + width: '1.5rem', + }} + > + +
+
+ )} {tabledata?.length > 0 && (
{tableOptions @@ -3926,61 +3928,61 @@ const BSBilling4Payment = () => { <> {unpaidFlow == false ? item?.OptionName == 'Hold' && - BookingType !== 'Dine In' && - !BookingTypeBoth && - OrderCardDetail?.length != 0 && - CheckOrderType?.length === 0 && - OrderType != 'Failed' && - paybtns?.length > 0 && - CheckBookingStatus != 'Close' && - !addnewAccess && ( - - {' '} - AddBookingDetails('Hold')} - style={{ - fontSize: '30px', - cursor: 'pointer', - color: '' ? '#52c41a' : '#1292EE', - }} - /> - - ) + BookingType !== 'Dine In' && + !BookingTypeBoth && + OrderCardDetail?.length != 0 && + CheckOrderType?.length === 0 && + OrderType != 'Failed' && + paybtns?.length > 0 && + CheckBookingStatus != 'Close' && + !addnewAccess && ( + + {' '} + AddBookingDetails('Hold')} + style={{ + fontSize: '30px', + cursor: 'pointer', + color: '' ? '#52c41a' : '#1292EE', + }} + /> + + ) : ''} {unpaidFlow == false ? item?.OptionName == 'Hold' && - BookingType !== 'Dine In' && - !BookingTypeBoth && - Holddata?.length > 0 && - OrderCardDetail?.length == 0 && - paybtns?.length > 0 && - CheckBookingStatus != 'Close' && - !addnewAccess && ( - - {' '} - 0 && + OrderCardDetail?.length == 0 && + paybtns?.length > 0 && + CheckBookingStatus != 'Close' && + !addnewAccess && ( + - HandleholdModelOpen()} - style={{ - fontSize: '28px', - cursor: 'pointer', - color: Holddata ? '#52c41a' : 'default', - pointerEvents: - OrderType === 'Failed' ? 'none' : 'auto', - }} - /> - - - ) + {' '} + + HandleholdModelOpen()} + style={{ + fontSize: '28px', + cursor: 'pointer', + color: Holddata ? '#52c41a' : 'default', + pointerEvents: + OrderType === 'Failed' ? 'none' : 'auto', + }} + /> + + + ) : ''} ))} @@ -4006,16 +4008,16 @@ const BSBilling4Payment = () => { (BookingType === 'Dine In' || BookingTypeBoth || CheckOrderType?.length > 0) && - !unpaidFlow && - OrderStatus + !unpaidFlow && + OrderStatus ? 'none' : 'auto', opacity: (BookingType === 'Dine In' || BookingTypeBoth || CheckOrderType?.length > 0) && - !unpaidFlow && - OrderStatus + !unpaidFlow && + OrderStatus ? 0.5 : 1, }} @@ -4026,10 +4028,10 @@ const BSBilling4Payment = () => {
{SelectedBillTableCheckValues?.filter( (item) => diff --git a/src/Pages/BookingScreen/Components/PrintMainPage/PrinterSelection.jsx b/src/Pages/BookingScreen/Components/PrintMainPage/PrinterSelection.jsx index 32729ce..9146c44 100644 --- a/src/Pages/BookingScreen/Components/PrintMainPage/PrinterSelection.jsx +++ b/src/Pages/BookingScreen/Components/PrintMainPage/PrinterSelection.jsx @@ -12,6 +12,7 @@ import { DropDowns } from "../../../../Components/Forms/DropDown"; import { Switch } from "antd"; import { useSelector } from "react-redux"; import KioskPrinterSelection from "./KioskPrinterSelection"; +import { GlobalFeatAddOnData } from "../../../../Features/BookingScreen/BookingData/BookingData"; const PrinterSelection = (props) => { const CompId = getSession("CompId"); @@ -28,6 +29,7 @@ const PrinterSelection = (props) => { const [activePrinterId, setActivePrinterId] = useState(null); const [initialPrinters, setInitialPrinters] = useState([]); const PrinterDetails = useSelector(GlobalPrinterMappingDtls); + const FeatureAddonData = useSelector(GlobalFeatAddOnData); const [MyPrinter, setMyPrinter] = useState(true); const [MyKioskPrinter, setMyKioskPrinter] = useState(false); const { onClose } = props; @@ -314,6 +316,10 @@ const PrinterSelection = (props) => { {/* */} My Printer
+ {FeatureAddonData?.FeatureDtls?.find( + (item) => + item?.FeatureAddonName?.toLowerCase() === 'kiosk sales' + ) &&
{ {/* */} Kiosk Printer
+ }
diff --git a/src/Pages/BookingScreen/Components/PrintMainPage/SelectionComponent.jsx b/src/Pages/BookingScreen/Components/PrintMainPage/SelectionComponent.jsx index c1d674c..7bb7913 100644 --- a/src/Pages/BookingScreen/Components/PrintMainPage/SelectionComponent.jsx +++ b/src/Pages/BookingScreen/Components/PrintMainPage/SelectionComponent.jsx @@ -68,6 +68,7 @@ import { changeSelectedLogo, changeSelectedCredit, changeSelectedTax, + changeSelectedHeaderColor, } from '../../../../Features/ThemeChange/ThemeChange'; import '../../../../Styles/BookingScreen/Components/SelectionComponent/SelectionComponent.scss'; import { useAuth } from '../../../../AuthContext.jsx'; @@ -732,6 +733,13 @@ const SelectionComponent = forwardRef((props, ref) => { ) ? dispatch(changeNotes(true)) : dispatch(changeNotes(false)); + + checkedValues?.includes( + sizeCheckList.find((item) => item.ConfigName === 'Header Colour') + ?.ConfigId + ) + ? setisheadercolour(true) + : setisheadercolour(false); }; const handleOptions = async () => { @@ -1278,12 +1286,7 @@ const SelectionComponent = forwardRef((props, ref) => { > {sizeCheckList - ?.filter( - (item) => - item.ConfigName && - (SelectedStyleName == 'TaxInvoice' || - item.ConfigName != 'Header Colour') - ) + ?.filter((item) => item.ConfigName) ?.map((value, key) => ( {
)} - {isheadercolour && SelectedStyleName == 'TaxInvoice' && ( + {isheadercolour && ( + // {isheadercolour && SelectedStyleName == 'TaxInvoice' && (
Header Color { + setSelectedColour(color); + dispatch(changeSelectedHeaderColor(color)); + }} placeholder="Select color" />
diff --git a/src/Pages/BookingScreen/Components/UtillComponents/AllSalesPageSettings.jsx b/src/Pages/BookingScreen/Components/UtillComponents/AllSalesPageSettings.jsx index a561fbc..6772088 100644 --- a/src/Pages/BookingScreen/Components/UtillComponents/AllSalesPageSettings.jsx +++ b/src/Pages/BookingScreen/Components/UtillComponents/AllSalesPageSettings.jsx @@ -1,68 +1,78 @@ -import { useState } from "react"; -import { IoMdSettings } from "react-icons/io"; -import { DefaultModal } from "../../../../Components/Modal/DefaultModal"; -import TooltipWrapper from "../../../../Components/Tooltip/Tooltip"; +import { useState } from 'react'; +import { IoMdAdd, IoMdSettings } from 'react-icons/io'; +import { DefaultModal } from '../../../../Components/Modal/DefaultModal'; +import TooltipWrapper from '../../../../Components/Tooltip/Tooltip'; +import './AllSalesPageSettings.scss'; +import TableHeadersetting from './TableHeadersetting'; +import PaymentOptions from '../../../Payment/PaymentOptions/PaymentOptions'; const AllSalesPageSettings = () => { - const [settingModal,setsettingModal] = useState(false) - const [checkboxItems, setCheckboxItems] = useState([ - { id: 'item1', label: 'Show Details', checked: true }, - { id: 'item2', label: 'Auto Refresh', checked: false }, - { id: 'item3', label: 'Notifications', checked: true } - ]) - console.log(settingModal,"settingModal") - const onclose = () => { - setsettingModal(false) - } - return ( - <> - -
setsettingModal(true)} - style={{ - cursor: 'pointer', - display: 'flex', - alignItems: 'center', - gap: '5px', - padding: '5px 10px', - borderRadius: '4px', - - fontSize: '14px', - }} + const [settingModal, setsettingModal] = useState(false); + const [selectedComponent, setselectedComponent] = useState('Payment'); + + const onclose = () => { + setsettingModal(false); + }; + const ComponentSelect = (value) => { + setselectedComponent(value); + }; + return ( + <> + +
setsettingModal(true)} + style={{ + cursor: 'pointer', + display: 'flex', + alignItems: 'center', + gap: '5px', + padding: '5px 10px', + borderRadius: '4px', + fontSize: '14px', + backgroundColor: '#f0f0f0', + }} > - -
-
- - -
- {checkboxItems.map(item => ( -
- -
- ))} -
-
- - ) -} - -export default AllSalesPageSettings; \ No newline at end of file + +
+
+ + +
+
+
ComponentSelect('Payment')} + > + Payment Option +
+
ComponentSelect('Table')} + > + Table +
+
+
+ {selectedComponent == 'Payment' && ( +
+ +
+ )} + + {selectedComponent === 'Table' && ( + + )} +
+
+
+ + ); +}; + +export default AllSalesPageSettings; diff --git a/src/Pages/BookingScreen/Components/UtillComponents/AllSalesPageSettings.scss b/src/Pages/BookingScreen/Components/UtillComponents/AllSalesPageSettings.scss new file mode 100644 index 0000000..06f24ca --- /dev/null +++ b/src/Pages/BookingScreen/Components/UtillComponents/AllSalesPageSettings.scss @@ -0,0 +1,184 @@ +// /// Another swtich button style code + +// .SettingsListSwitchBTN { +// display: inline-flex; +// gap: 16px; +// font-family: "Poppins"; +// margin-bottom: 12px; +// border-bottom: 1px solid #d1d5db; +// } + +// .SettingsListSwitchBTN > div { +// font-size: 22px; +// font-weight: 600; +// cursor: pointer; +// color: #6b7280; +// display: flex; +// align-items: center; +// gap: 6px; +// position: relative; +// border: none; +// background: transparent; +// font-family: "Gilroy"; +// transition: color 0.2s ease; +// @media (max-width: 600px) { +// font-size: 18px; +// } +// } + +// .SettingsListSwitchBTN > div:hover { +// color: #0f172a; +// } + +// .SettingsSwitchBTN > div.selected { +// color: #0f172a; +// } + +// .SettingsListSwitchBTN > div.selected::after { +// content: ""; +// position: absolute; +// left: 0; +// bottom: -1px; +// width: 100%; +// height: 2px; +// background: #2c88ee; +// border-radius: 2px; +// } + +// .SettingsListSwitchBTN > div.selected svg { +// color: #4765db !important; +// } + +// // End +// .settingsales-DropDown-Selection { +// width: 150px !important; +// } +// .settingaddNewSalesFiledBTN { +// background-color: #2563eb; +// // background-color: #1292ee; +// color: #fff !important; +// width: max-content; +// height: max-content; +// padding: 4px 8px; +// font-size: 13px; +// font-weight: 400; +// display: flex; +// align-items: center; +// gap: 4px; +// cursor: pointer; +// border-radius: 6px; +// svg { +// color: #fff !important; +// font-weight: 500; +// display: flex; +// font-size: 16px; +// } +// } + +.AllSalesPageSettingsMainDiv { + width: 100%; + height: 100%; + display: flex; + align-items: flex-start; + gap: 1rem; + font-family: "Poppins", sans-serif; + justify-content: flex-start; +} + +.SettingsComponentDiv { + height: max-content; + max-height: 80vh; + width: 100%; + scrollbar-width: thin; + padding-right: 10px; + overflow: auto; + .option-maindiv { + display: flex; + align-items: flex-start; + flex-wrap: wrap; + } + .ant-checkbox-wrapper { + padding: 8px !important; + } +} + +.SettingsListSwitchBTN { + display: flex; + align-items: flex-start; + flex-direction: column; + gap: 6px; + width: 210px; + height: 100%; + overflow: auto; + background-color: #d8e5ff; + padding: 5px; + border-radius: 4px; + height: 80vh; + div { + width: 100%; + background-color: #fff; + outline: none; + border: none; + font-family: "Poppins", sans-serif; + padding: 8px 6px; + cursor: pointer; + border-radius: 4px; + transition: all 0.2s ease-in-out; + font-size: 14px; + font-weight: 400; + + &:hover { + background-color: #d1d8ec; + } + &.selected { + background-color: #ffffff; + color: #2563eb; + font-weight: 500; + border-right: 3px solid #2563eb; + } + } +} + +.settingaddNewSalesFiledBTN { + background-color: #2563eb; + // background-color: #1292ee; + color: #fff !important; + width: max-content; + height: max-content; + padding: 4px 8px; + font-size: 13px; + font-weight: 400; + display: flex; + align-items: center; + gap: 4px; + cursor: pointer; + border-radius: 6px; + svg { + color: #fff !important; + font-weight: 500; + display: flex; + font-size: 16px; + } +} + +// Table Header Setting CSS start here||| + +.SelectionComponentSubHeading { + color: #333; + font-size: 12px; + font-weight: 500; + font-family: "Poppins", sans-serif; +} + +.selctfontBackInputMain { + display: flex; + align-items: flex-start; + gap: 8px; + flex-wrap: wrap; + margin-top: 10px; +} +.selctfontBackInput { + display: flex; + flex-direction: column; + gap: 4px; +} diff --git a/src/Pages/BookingScreen/Components/UtillComponents/MultipleSearch.jsx b/src/Pages/BookingScreen/Components/UtillComponents/MultipleSearch.jsx index ace6660..a7cfc90 100644 --- a/src/Pages/BookingScreen/Components/UtillComponents/MultipleSearch.jsx +++ b/src/Pages/BookingScreen/Components/UtillComponents/MultipleSearch.jsx @@ -1,126 +1,125 @@ import React, { useEffect, useState } from "react"; import { getSession } from "../../../../Services/Others"; import { useDispatch } from "react-redux"; -import { getmultipleSearch, PostProductSearch } from "../../../../Features/BookingScreen/BookingData/BookingData"; +import { + getmultipleSearch, + PostProductSearch, +} from "../../../../Features/BookingScreen/BookingData/BookingData"; import Buttons from "../../../../Components/Forms/Buttons"; - const MultipleSearch = ({ close }) => { - const CompId = getSession("CompId"); - const BranchId = getSession("BranchId"); - const AppId = getSession("AppId"); - const dispatch = useDispatch(); + const CompId = getSession("CompId"); + const BranchId = getSession("BranchId"); + const AppId = getSession("AppId"); + const dispatch = useDispatch(); + const options = [ + { label: "Product Name", value: "ProdName" }, + { label: "Product Variant Name", value: "ProdVariantName" }, + // { label: "Product ID", value: "ProdId" }, + { label: "One Piece QR", value: "OnePcQR" }, + { label: "QR Code", value: "QrCode" }, + { label: "Product Name Code", value: "ProdNameCode" }, + { label: "Category Name", value: "CategoryName" }, + { label: "Sub Category Name", value: "SubCategoryName" }, + { label: "Brand Name", value: "BrandName" }, + ]; - const options = [ - { label: "Product Name", value: "ProdName" }, - { label: "Product Variant Name", value: "ProdVariantName" }, - // { label: "Product ID", value: "ProdId" }, - { label: "One Piece QR", value: "OnePcQR" }, - { label: "QR Code", value: "QrCode" }, - { label: "Product Name Code", value: "ProdNameCode" }, - { label: "Category Name", value: "CategoryName" }, - { label: "Sub Category Name", value: "SubCategoryName" }, - { label: "Brand Name", value: "BrandName" }, - ]; + const [selectedValues, setSelectedValues] = useState([]); + console.log(selectedValues, "selectedValuesselectedValues"); + useEffect(() => { + GetmultipleSearchData(); + }, []); - const [selectedValues, setSelectedValues] = useState([]); - console.log(selectedValues, 'selectedValuesselectedValues'); + const postMultipleSearch = async () => { + if (selectedValues.length === 0) { + alert("Please select at least one option!"); + return; + } + const data = { + CompId: CompId, + BranchId: BranchId, + AppId: AppId, + SearchTerms: selectedValues, + }; + try { + const response = await dispatch(PostProductSearch(data)).unwrap(); + console.log("Search Response:", response); + if (response?.data?.statusCode == 1) { + setSelectedValues(""); + close(false); + } + } catch (error) { + console.error("Search Error:", error); + } + }; - useEffect(() => { - GetmultipleSearchData(); - }, []); - - - const postMultipleSearch = async () => { - if (selectedValues.length === 0) { - alert("Please select at least one option!"); - return; - } - const data = { - CompId: CompId, - BranchId: BranchId, - AppId: AppId, - SearchTerms: selectedValues, - }; - try { - const response = await dispatch(PostProductSearch(data)).unwrap(); - console.log("Search Response:", response); - if (response?.data?.statusCode == 1) { - setSelectedValues('') - close(false); - } - } catch (error) { - console.error("Search Error:", error); - } + const GetmultipleSearchData = async () => { + const data = { + AppId, + CompId, + BranchId, }; + try { + const response = await dispatch(getmultipleSearch(data)).unwrap(); - const GetmultipleSearchData = async () => { - const data = { - AppId, - CompId, - BranchId, - }; + if (response?.data?.statusCode === 1) { + const selected = + response?.data?.data?.[0]?.SearchTermDtl?.map( + (item) => item?.SearchTerm, + ) || []; - try { - const response = await dispatch(getmultipleSearch(data)).unwrap(); + setSelectedValues(selected); + } + } catch (error) { + console.error("Get Search Terms Error:", error); + } + }; - if (response?.data?.statusCode === 1) { - const selected = response?.data?.data?.[0]?.SearchTermDtl?.map( - (item) => item?.SearchTerm - ) || []; - - setSelectedValues(selected); - } - } catch (error) { - console.error("Get Search Terms Error:", error); - } - }; - - return ( - <> -
- {options.map((item) => ( - - ))} - -
-
- } - /> -
- - - ); + return ( + <> +
+ {options.map((item) => ( + + ))} +
+
+ +
+ + ); }; export default MultipleSearch; diff --git a/src/Pages/BookingScreen/Components/UtillComponents/ProductPriceChange.jsx b/src/Pages/BookingScreen/Components/UtillComponents/ProductPriceChange.jsx index c9f35a6..2e20526 100644 --- a/src/Pages/BookingScreen/Components/UtillComponents/ProductPriceChange.jsx +++ b/src/Pages/BookingScreen/Components/UtillComponents/ProductPriceChange.jsx @@ -1,449 +1,518 @@ -import { shallowEqual, useSelector } from "react-redux"; -import { GlobalAccessForOthers, GlobalCardAccess, GlobalCombosearch, GlobalItemCard, GlobalProductCategorie, GlobalSelectedDatas, GlobalWithoutSubCatItemCard, triggerProductCard } from "../../../../Features/BookingScreen/BookingData/BookingData"; -import { DefaultModal } from "../../../../Components/Modal/DefaultModal"; -import { useCallback, useEffect, useRef, useState } from "react"; -import { Tables } from "../../../../Components/Tables/Table"; -import { InputField } from "../../../../Components/Forms/InputField"; -import { Form, Pagination, Tooltip } from "antd"; -import { getSession } from "../../../../Services/Others"; -import { Messages } from "../../../../Components/Notifications/Messages"; -import { useDispatch } from "react-redux"; -import { PutStockPrice } from "../../../../Features/StockPriceUpdate/StockPriceUpdateMaster"; -import PriceChange from "../../../../Images/PayOptImgs/PriceChange.svg" +import { shallowEqual, useSelector } from 'react-redux'; +import { + GlobalAccessForOthers, + GlobalCardAccess, + GlobalCombosearch, + GlobalItemCard, + GlobalProductCategorie, + GlobalSelectedDatas, + GlobalWithoutSubCatItemCard, + triggerProductCard, +} from '../../../../Features/BookingScreen/BookingData/BookingData'; +import { DefaultModal } from '../../../../Components/Modal/DefaultModal'; +import { useCallback, useEffect, useRef, useState } from 'react'; +import { Tables } from '../../../../Components/Tables/Table'; +import { InputField } from '../../../../Components/Forms/InputField'; +import { Form, Pagination, Tooltip } from 'antd'; +import { getSession } from '../../../../Services/Others'; +import { Messages } from '../../../../Components/Notifications/Messages'; +import { useDispatch } from 'react-redux'; +import { PutStockPrice } from '../../../../Features/StockPriceUpdate/StockPriceUpdateMaster'; +import PriceChange from '../../../../Images/PayOptImgs/PriceChange.svg'; -const ProductPriceChange = ({ showButton = true, priceChangeProduct = null, productPriceChange = false, setProductPriceChange = () => { }, setPriceChangeProduct = () => { } }) => { +const ProductPriceChange = ({ + showButton = true, + priceChangeProduct = [], + productPriceChange = false, + setProductPriceChange = () => {}, + setPriceChangeProduct = () => {}, +}) => { + const formRef = useRef(null); + const dispatch = useDispatch(); - const formRef = useRef(null); - const dispatch = useDispatch(); + const AppId = getSession('AppId'); + const CompId = getSession('CompId'); + const BranchId = getSession('BranchId'); + const UserId = getSession('UserId'); - const AppId = getSession('AppId'); - const CompId = getSession('CompId'); - const BranchId = getSession('BranchId'); - const UserId = getSession('UserId'); + const [messageData, setMessageData] = useState(null); + const [messageType, setMessageType] = useState(null); + const [currentPage, setCurrentPage] = useState(1); + const [pageSize] = useState(10); - const [messageData, setMessageData] = useState(null); - const [messageType, setMessageType] = useState(null); - const [currentPage, setCurrentPage] = useState(1); - const [pageSize] = useState(10); + const [noSubcatCardData, setNoSubcatCardData] = useState(); + const [priceChangeModal, setPriceChangeModal] = useState(false); - const [noSubcatCardData, setNoSubcatCardData] = useState(); - const [priceChangeModal, setPriceChangeModal] = useState(false); + const comboSearch = useSelector(GlobalCombosearch); + const ProdCat = useSelector(GlobalProductCategorie, shallowEqual); + const ItemCard = useSelector(GlobalItemCard, shallowEqual); + const withoutSubCatItemCard = useSelector( + GlobalWithoutSubCatItemCard, + shallowEqual + ); + const CardAccess = useSelector(GlobalCardAccess, shallowEqual); + const globalAccessForOthers = useSelector( + GlobalAccessForOthers, + shallowEqual + ); + const SelectedDatas = useSelector(GlobalSelectedDatas, shallowEqual); + const [tableData, setTableData] = useState([]); + const [editingKey, setEditingKey] = useState(null); + const [priceChangedProducts, setPriceChangedProducts] = useState([]); + console.log(comboSearch, 'comboSearch'); - const comboSearch = useSelector(GlobalCombosearch); - const ProdCat = useSelector(GlobalProductCategorie, shallowEqual); - const ItemCard = useSelector(GlobalItemCard, shallowEqual); - const withoutSubCatItemCard = useSelector(GlobalWithoutSubCatItemCard, shallowEqual); - const CardAccess = useSelector(GlobalCardAccess, shallowEqual); - const globalAccessForOthers = useSelector(GlobalAccessForOthers, shallowEqual); - const SelectedDatas = useSelector(GlobalSelectedDatas, shallowEqual); - const [tableData, setTableData] = useState([]); - const [editingKey, setEditingKey] = useState(null); - const [priceChangedProducts, setPriceChangedProducts] = useState([]); - console.log(comboSearch, "comboSearch") + // console.log(noSubcatCardData, "noSubcatCardData") - // console.log(noSubcatCardData, "noSubcatCardData") + useEffect(() => { + if ( + ProdCat && + (ItemCard || withoutSubCatItemCard) && + (!noSubcatCardData || noSubcatCardData?.length === 0) + ) { + setNoSubcatCardData( + ItemCard?.length === 0 ? withoutSubCatItemCard : ItemCard + ); + } + }, [ProdCat, ItemCard, withoutSubCatItemCard, noSubcatCardData]); - useEffect(() => { - if (ProdCat && (ItemCard || withoutSubCatItemCard) && (!noSubcatCardData || noSubcatCardData?.length === 0)) { - setNoSubcatCardData(ItemCard?.length === 0 ? withoutSubCatItemCard : ItemCard); - } - }, [ProdCat, ItemCard, withoutSubCatItemCard, noSubcatCardData]); + const priceChangeColumns = [ + { + title: 'S.No', + dataIndex: 'SlNo', + key: 'SlNo', + width: '60px', + align: 'center', + render: (text, record, index) => ( +
{(currentPage - 1) * pageSize + index + 1}
+ ), + }, + { + title: 'Product Name', + dataIndex: 'ProdName', + key: 'ProdName', + }, + { + title: 'Old MRP', + dataIndex: 'MRP', + key: 'MRP', + width: '100px', + align: 'right', + }, + { + title: 'New MRP (Optional)', + dataIndex: 'NewMRP', + key: 'NewMRP', + width: '100px', + align: 'right', + render: (text, record, index) => { + // if (index === editingKey) { - const priceChangeColumns = [ - { - title: 'S.No', - dataIndex: 'SlNo', - key: 'SlNo', - width: '60px', - align: 'center', - render: (text, record, index) =>
{(currentPage - 1) * pageSize + index + 1}
- }, - { - title: 'Product Name', - dataIndex: 'ProdName', - key: 'ProdName', - }, - { - title: 'Old MRP', - dataIndex: 'MRP', - key: 'MRP', - width: '100px', - align: 'right', - }, - { - title: 'New MRP (Optional)', - dataIndex: 'NewMRP', - key: 'NewMRP', - width: '100px', - align: 'right', - render: (text, record, index) => { - // if (index === editingKey) { + // } + // return
{text ? text : 'Enter New MRP'}
+ return ( + { + if (value === '') { + return Promise.resolve(); + } else if (parseFloat(value) < 1) { + return Promise.reject(`MRP should be greater than 0`); + } + return Promise.resolve(); + }, + }, + ]} + > + handleNewMRPChange(e?.target?.value, index)} + inputMode="decimal" + onInput={(e) => { + let cleanedValue = e.target.value.replace(/[^0-9.]/g, ''); // Remove invalid characters + const parts = cleanedValue.split('.'); - // } - // return
{text ? text : 'Enter New MRP'}
- return ( - { - if (value === '') { - return Promise.resolve(); - } else if (parseFloat(value) < 1) { - return Promise.reject(`MRP should be greater than 0`) - } - return Promise.resolve(); - }, - }, - ]}> - handleNewMRPChange(e?.target?.value, index)} - inputMode="decimal" - onInput={(e) => { - let cleanedValue = e.target.value.replace( - /[^0-9.]/g, - '' - ); // Remove invalid characters - const parts = cleanedValue.split('.'); + if (cleanedValue.startsWith('.')) { + cleanedValue = '0' + cleanedValue; + } - if (cleanedValue.startsWith('.')) { - cleanedValue = '0' + cleanedValue; - } + e.target.value = + parts.length > 2 + ? `${parts[0]}.${parts.slice(1).join('')}` + : cleanedValue; + }} + /> + + ); + }, + }, + { + title: 'Old Sell Price', + dataIndex: 'SellPrice', + key: 'SellPrice', + width: '120px', + align: 'right', + }, + { + title: 'New Sell Price', + dataIndex: 'NewSellPrice', + key: 'NewSellPrice', + width: '160px', + align: 'right', + render: (text, record, index) => { + // if (index === editingKey) { - e.target.value = - parts.length > 2 - ? `${parts[0]}.${parts.slice(1).join('')}` - : cleanedValue; - }} - /> -
- ); - }, - }, - { - title: 'Old Sell Price', - dataIndex: 'SellPrice', - key: 'SellPrice', - width: '120px', - align: 'right', - }, - { - title: 'New Sell Price', - dataIndex: 'NewSellPrice', - key: 'NewSellPrice', - width: '160px', - align: 'right', - render: (text, record, index) => { - // if (index === editingKey) { + // } + // return
{text ? text : 'Enter New Sell Price'}
+ return ( + { + if (value === '') { + return Promise.resolve(); + } else if (parseFloat(value) < 1) { + return Promise.reject( + `Sell Price should be greater than 0` + ); + } + return Promise.resolve(); + }, + }, + ]} + > + + handleNewSellPriceChange(e?.target?.value, index) + } + inputMode="decimal" + onInput={(e) => { + let cleanedValue = e.target.value.replace(/[^0-9.]/g, ''); // Remove invalid characters + const parts = cleanedValue.split('.'); - // } - // return
{text ? text : 'Enter New Sell Price'}
- return ( - { - if (value === '') { - return Promise.resolve(); - } else if (parseFloat(value) < 1) { - return Promise.reject(`Sell Price should be greater than 0`) - } - return Promise.resolve(); - }, - }, - ]} - > - handleNewSellPriceChange(e?.target?.value, index)} - inputMode="decimal" - onInput={(e) => { - let cleanedValue = e.target.value.replace( - /[^0-9.]/g, - '' - ); // Remove invalid characters - const parts = cleanedValue.split('.'); + if (cleanedValue.startsWith('.')) { + cleanedValue = '0' + cleanedValue; + } - if (cleanedValue.startsWith('.')) { - cleanedValue = '0' + cleanedValue; - } + e.target.value = + parts.length > 2 + ? `${parts[0]}.${parts.slice(1).join('')}` + : cleanedValue; + }} + /> + + ); + }, + }, + ]; - e.target.value = - parts.length > 2 - ? `${parts[0]}.${parts.slice(1).join('')}` - : cleanedValue; - }} - /> -
- ); - }, - }, - ]; + const cardData = !globalAccessForOthers + ? CardAccess + ? SelectedDatas?.length > 1 + ? SelectedDatas + : SelectedDatas?.[0]?.AppId === 0 && SelectedDatas?.[0]?.CompId === 0 + ? [] + : SelectedDatas + : ItemCard?.length === 0 || + (ItemCard?.[0]?.AppId === 0 && ItemCard?.[0]?.CompId === 0) + ? noSubcatCardData + : ItemCard + : []; - const cardData = !globalAccessForOthers - ? CardAccess - ? SelectedDatas?.length > 1 - ? SelectedDatas - : SelectedDatas?.[0]?.AppId === 0 && SelectedDatas?.[0]?.CompId === 0 - ? [] - : SelectedDatas - : ItemCard?.length === 0 || (ItemCard?.[0]?.AppId === 0 && ItemCard?.[0]?.CompId === 0) - ? noSubcatCardData - : ItemCard - : ''; + console.log(cardData, 'noSubcatCardDatanoSubcatCardData', ItemCard); - console.log(cardData, "noSubcatCardDatanoSubcatCardData", ItemCard) + useEffect(() => { + if (priceChangeModal || productPriceChange) { + const extractStockDtls = (data) => { + if (data?.length === 0 || !data) return []; - useEffect(() => { - const extractStockDtls = (data) => { - if (data?.length === 0) return []; + let stockDtls = []; - let stockDtls = []; + data?.forEach((item) => { + let products = item?.ProductDetail?.flatMap((product) => product); - data?.forEach(item => { - let products = item?.ProductDetail?.flatMap(product => product); + let variants = products?.flatMap( + (product) => product?.ProdVariantDetails + ); + const filteredVariants = variants?.filter( + (variant) => variant?.StockDetails?.length > 0 + ); + const stocks = filteredVariants?.flatMap((variant) => + variant?.StockDetails?.map((stock) => ({ + ...stock, + ProdName: + products?.[0]?.ProdName + + (variant?.ProdVariantName + ? ` (${variant?.ProdVariantName})` + : ''), + StockAvailable: products?.[0]?.StockAvailable, + ProdVariantName: variant?.ProdVariantName, + })) + ); - let variants = products?.flatMap(product => product?.ProdVariantDetails); - const filteredVariants = variants?.filter(variant => variant?.StockDetails?.length > 0); - const stocks = filteredVariants?.flatMap(variant => - variant?.StockDetails?.map(stock => ({ - ...stock, - ProdName: products?.[0]?.ProdName + (variant?.ProdVariantName ? ` (${variant?.ProdVariantName})` : ''), - StockAvailable: products?.[0]?.StockAvailable, - ProdVariantName: variant?.ProdVariantName - })) - ); + stockDtls.push( + ...stocks?.filter((stock) => + stock?.StockAvailable === 'Y' ? stock?.BatchRef : true + ) + ); + }); + console.log('extractStockDtls', stockDtls); + return stockDtls; + }; + setTableData(extractStockDtls(priceChangeProduct || cardData || [])); + setCurrentPage(1); + } + }, [cardData, priceChangeProduct, priceChangeModal, productPriceChange]); - stockDtls.push(...stocks?.filter(stock => - stock?.StockAvailable === 'Y' - ? stock?.BatchRef - : true - )); + const handleNewMRPChange = (value, index) => { + const updatedTableData = [...tableData]; + updatedTableData[index].NewMRP = value; + setTableData(updatedTableData); + updatedTableData[index].NewSellPrice = null; + formRef.current.setFieldsValue({ + [`NewMRP${index}`]: value, + [`NewSellPrice${index}`]: null, + }); - }); - console.log("extractStockDtls", stockDtls); - return stockDtls; - } - setTableData(extractStockDtls(priceChangeProduct || cardData)) - setCurrentPage(1) - }, [cardData, priceChangeProduct]) + const priceChangedProdList = [...priceChangedProducts]; + const prodIndex = priceChangedProdList?.findIndex( + (prod) => prod?.InwardDtlId === updatedTableData[index]?.InwardDtlId + ); + if (prodIndex !== -1) { + priceChangedProdList[prodIndex] = { + ...priceChangedProdList?.[prodIndex], + NewMRP: value, + NewSellPrice: null, + }; + } + setPriceChangedProducts(priceChangedProdList); + }; - const handleNewMRPChange = (value, index) => { - - const updatedTableData = [...tableData]; - updatedTableData[index].NewMRP = value; - setTableData(updatedTableData); + const handleNewSellPriceChange = (value, index) => { + const updatedTableData = [...tableData]; + if (updatedTableData[index]?.NewMRP) { + if (parseFloat(value) > parseFloat(updatedTableData[index]?.NewMRP)) { + setMessageType('error'); + setMessageData('New Sell Price cannot be greater than New MRP'); + formRef.current.setFieldsValue({ + [`NewSellPrice${index}`]: null, + }); updatedTableData[index].NewSellPrice = null; - formRef.current.setFieldsValue({ - [`NewMRP${index}`]: value, - [`NewSellPrice${index}`]: null, - }); - - const priceChangedProdList = [...priceChangedProducts]; - const prodIndex = priceChangedProdList?.findIndex(prod => prod?.InwardDtlId === updatedTableData[index]?.InwardDtlId); - if (prodIndex !== -1) { - priceChangedProdList[prodIndex] = { - ...priceChangedProdList?.[prodIndex], - NewMRP: value, - NewSellPrice: null, - }; - } - setPriceChangedProducts(priceChangedProdList); - } - - const handleNewSellPriceChange = (value, index) => { - const updatedTableData = [...tableData]; - if (updatedTableData[index]?.NewMRP) { - if (parseFloat(value) > parseFloat(updatedTableData[index]?.NewMRP)) { - setMessageType('error'); - setMessageData('New Sell Price cannot be greater than New MRP'); - formRef.current.setFieldsValue({ - [`NewSellPrice${index}`]: null, - }); - updatedTableData[index].NewSellPrice = null; - setTableData(updatedTableData); - const priceChangedProdList = [...priceChangedProducts]; - const prodIndex = priceChangedProdList?.findIndex(prod => prod?.InwardDtlId === updatedTableData[index]?.InwardDtlId); - - if (prodIndex !== -1) { - priceChangedProdList.splice(prodIndex, 1); - } - setPriceChangedProducts(priceChangedProdList); - return; - } - } - if (!updatedTableData[index]?.NewMRP && updatedTableData[index]?.MRP) { - if (parseFloat(value) > parseFloat(updatedTableData[index]?.MRP)) { - setMessageType('error'); - setMessageData('New Sell Price cannot be greater than MRP'); - formRef.current.setFieldsValue({ - [`NewSellPrice${index}`]: null, - }); - updatedTableData[index].NewSellPrice = null; - setTableData(updatedTableData); - const priceChangedProdList = [...priceChangedProducts]; - const prodIndex = priceChangedProdList?.findIndex(prod => prod?.InwardDtlId === updatedTableData[index]?.InwardDtlId); - - if (prodIndex !== -1) { - priceChangedProdList.splice(prodIndex, 1); - } - setPriceChangedProducts(priceChangedProdList); - return; - } - } - updatedTableData[index].NewSellPrice = value; setTableData(updatedTableData); - formRef.current.setFieldsValue({ - [`NewSellPrice${index}`]: value, - }); - const priceChangedProdList = [...priceChangedProducts]; - const prodIndex = priceChangedProdList?.findIndex(prod => prod?.InwardDtlId === updatedTableData[index]?.InwardDtlId); + const prodIndex = priceChangedProdList?.findIndex( + (prod) => prod?.InwardDtlId === updatedTableData[index]?.InwardDtlId + ); if (prodIndex !== -1) { - priceChangedProdList[prodIndex] = { - ...priceChangedProdList[prodIndex], - SellPrice: String(value) - }; - } else { - priceChangedProdList.push({ - ProdId: updatedTableData[index]?.ProdId, - ProdName: updatedTableData[index]?.ProdName, - MRP: String(updatedTableData[index]?.NewMRP || updatedTableData[index]?.MRP), - SellPrice: String(value), - AdjComment: "string", - InwardDtlId: updatedTableData[index]?.InwardDtlId - }); + priceChangedProdList.splice(prodIndex, 1); } - setPriceChangedProducts(priceChangedProdList); + return; + } } + if (!updatedTableData[index]?.NewMRP && updatedTableData[index]?.MRP) { + if (parseFloat(value) > parseFloat(updatedTableData[index]?.MRP)) { + setMessageType('error'); + setMessageData('New Sell Price cannot be greater than MRP'); + formRef.current.setFieldsValue({ + [`NewSellPrice${index}`]: null, + }); + updatedTableData[index].NewSellPrice = null; + setTableData(updatedTableData); + const priceChangedProdList = [...priceChangedProducts]; + const prodIndex = priceChangedProdList?.findIndex( + (prod) => prod?.InwardDtlId === updatedTableData[index]?.InwardDtlId + ); - const edit = (record, index) => { - console.log("edit", record, index); - setEditingKey(index); - } - - const handleSubmit = async () => { - console.log("submit"); - - if (priceChangedProducts?.length > 0) { - console.log("priceChangedProducts", priceChangedProducts); - const validation = priceChangedProducts?.every((prod) => { - if (parseFloat(prod?.MRP) < parseFloat(prod?.SellPrice)) { - setMessageType('error'); - setMessageData(`${prod?.ProdName}: MRP cannot be less than Sell Price`); - return false; - } - if (!parseFloat(prod?.SellPrice) || !parseFloat(prod?.MRP)) { - setMessageType('error'); - setMessageData(`${prod?.ProdName}: Please give Sell Price or MRP`); - return false; - } - return true; - }); - if (!validation) return; - - const data = { - AppId: AppId, - CompId: CompId, - BranchId: BranchId, - ProductDetails: priceChangedProducts, - UpdatedBy: UserId, - } - - const res = await dispatch(PutStockPrice(data))?.unwrap(); - if (res?.data?.statusCode === 1) { - setMessageData('Price Changed Successfully'); - setMessageType('success'); - setPriceChangeModal(false); - setProductPriceChange(false); - setEditingKey(null); - setPriceChangedProducts([]); - setTableData([]); - dispatch(triggerProductCard()) - setPriceChangeProduct(null); - formRef.current.resetFields(); - } else { - setMessageData('Error Updating Product Price') - setMessageType('error'); - } - } else { - setMessageType('error'); - setMessageData('No changes made / No sell price entered'); + if (prodIndex !== -1) { + priceChangedProdList.splice(prodIndex, 1); } + setPriceChangedProducts(priceChangedProdList); + return; + } + } + updatedTableData[index].NewSellPrice = value; + setTableData(updatedTableData); + formRef.current.setFieldsValue({ + [`NewSellPrice${index}`]: value, + }); + const priceChangedProdList = [...priceChangedProducts]; + const prodIndex = priceChangedProdList?.findIndex( + (prod) => prod?.InwardDtlId === updatedTableData[index]?.InwardDtlId + ); + + if (prodIndex !== -1) { + priceChangedProdList[prodIndex] = { + ...priceChangedProdList[prodIndex], + SellPrice: String(value), + }; + } else { + priceChangedProdList.push({ + ProdId: updatedTableData[index]?.ProdId, + ProdName: updatedTableData[index]?.ProdName, + MRP: String( + updatedTableData[index]?.NewMRP || updatedTableData[index]?.MRP + ), + SellPrice: String(value), + AdjComment: 'string', + InwardDtlId: updatedTableData[index]?.InwardDtlId, + }); } - const onComplete = useCallback(() => { - setMessageData(null); - setMessageType(null); - }, []) + setPriceChangedProducts(priceChangedProdList); + }; - return ( - <> + const edit = (record, index) => { + console.log('edit', record, index); + setEditingKey(index); + }; - - {showButton ? - - : <>} - { - setPriceChangeModal(false); - setProductPriceChange(false); - setEditingKey(null); - setPriceChangedProducts([]); - formRef?.current?.resetFields(); - setPriceChangeProduct(null); - }} - handleSubmit={handleSubmit} + const handleSubmit = async () => { + console.log('submit'); + + if (priceChangedProducts?.length > 0) { + console.log('priceChangedProducts', priceChangedProducts); + const validation = priceChangedProducts?.every((prod) => { + if (parseFloat(prod?.MRP) < parseFloat(prod?.SellPrice)) { + setMessageType('error'); + setMessageData( + `${prod?.ProdName}: MRP cannot be less than Sell Price` + ); + return false; + } + if (!parseFloat(prod?.SellPrice) || !parseFloat(prod?.MRP)) { + setMessageType('error'); + setMessageData(`${prod?.ProdName}: Please give Sell Price or MRP`); + return false; + } + return true; + }); + if (!validation) return; + + const data = { + AppId: AppId, + CompId: CompId, + BranchId: BranchId, + ProductDetails: priceChangedProducts, + UpdatedBy: UserId, + }; + + const res = await dispatch(PutStockPrice(data))?.unwrap(); + if (res?.data?.statusCode === 1) { + setMessageData('Price Changed Successfully'); + setMessageType('success'); + setPriceChangeModal(false); + setProductPriceChange(false); + setEditingKey(null); + setPriceChangedProducts([]); + setTableData([]); + dispatch(triggerProductCard()); + setPriceChangeProduct(null); + formRef.current.resetFields(); + } else { + setMessageData('Error Updating Product Price'); + setMessageType('error'); + } + } else { + setMessageType('error'); + setMessageData('No changes made / No sell price entered'); + } + }; + + const onComplete = useCallback(() => { + setMessageData(null); + setMessageType(null); + }, []); + + return ( + <> + + {showButton ? ( + + + + ) : ( + <> + )} + { + setPriceChangeModal(false); + setProductPriceChange(false); + setEditingKey(null); + setPriceChangedProducts([]); + formRef?.current?.resetFields(); + setPriceChangeProduct(null); + }} + handleSubmit={handleSubmit} + > +
+ {/*
Note : Click on a row to edit/modify
*/} +
+ ({ + onClick: () => { + edit(record, index); + }, + })} + /> +
-
- {/*
Note : Click on a row to edit/modify
*/} - - ({ - onClick: () => { - edit(record, index); - }, - })} - /> -
- setCurrentPage(page)} - showSizeChanger={false} - showTotal={(total, range) => `${range[0]}-${range[1]} of ${total} items`} - /> -
- -
- - - ) -} + setCurrentPage(page)} + showSizeChanger={false} + showTotal={(total, range) => + `${range[0]}-${range[1]} of ${total} items` + } + /> +
+ +
+
+ + ); +}; -export default ProductPriceChange; \ No newline at end of file +export default ProductPriceChange; diff --git a/src/Pages/BookingScreen/Components/UtillComponents/ShortcutKeyHelper.jsx b/src/Pages/BookingScreen/Components/UtillComponents/ShortcutKeyHelper.jsx index 60f9491..b314106 100644 --- a/src/Pages/BookingScreen/Components/UtillComponents/ShortcutKeyHelper.jsx +++ b/src/Pages/BookingScreen/Components/UtillComponents/ShortcutKeyHelper.jsx @@ -1,6 +1,7 @@ import React, { useState } from 'react'; -import { Modal, List, Typography, Tooltip } from 'antd'; +import { List, Typography, Tooltip } from 'antd'; import { FaKeyboard } from 'react-icons/fa'; +import { DefaultModal } from '../../../../Components/Modal/DefaultModal'; const { Title, Text } = Typography; @@ -40,15 +41,15 @@ const ShortcutKeyHelper = ({}) => {
- - Keyboard Shortcuts + Keyboard Shortcuts
} open={isModalOpen} - onCancel={() => setIsModalOpen(false)} + handleCancel={() => setIsModalOpen(false)} footer={null} width={500} > @@ -65,7 +66,7 @@ const ShortcutKeyHelper = ({}) => { )} /> - + ); }; diff --git a/src/Pages/BookingScreen/Components/UtillComponents/TableHeadersetting.jsx b/src/Pages/BookingScreen/Components/UtillComponents/TableHeadersetting.jsx new file mode 100644 index 0000000..5ba7045 --- /dev/null +++ b/src/Pages/BookingScreen/Components/UtillComponents/TableHeadersetting.jsx @@ -0,0 +1,965 @@ +import { Checkbox, Form, Modal, Row } from 'antd'; +import { DropDowns } from '../../../../Components/Forms/DropDown'; +import { InputField } from '../../../../Components/Forms/InputField'; +import { validateSafeInput } from '../../../../Services/Others'; +import { DefaultModal } from '../../../../Components/Modal/DefaultModal'; +import { CloseOutlined, ArrowRightOutlined } from '@ant-design/icons'; +import { IoMdAdd } from 'react-icons/io'; +import { useCallback, useEffect, useState } from 'react'; +import { SwatchesPicker } from 'react-color'; +import { RadioGrpButton } from '../../../../Components/Forms/RadioGroup'; +import { useSelector } from 'react-redux'; +import { + getSalesTemplate, + getTemplate, + postColorData, + postTableFontData, + putSelectionComponentData, + StoredSessionData, +} from '../../../../Features/ThemeChange/ThemeChange'; +import { useDispatch } from 'react-redux'; +import Buttons from '../../../../Components/Forms/Buttons'; +import { Messages } from '../../../../Components/Notifications/Messages'; +import './AllSalesPageSettings.scss'; + +const TableHeadersetting = ({ setModalOpen }) => { + const dispatch = useDispatch(); + const SessionData = useSelector(StoredSessionData); + const AppId = SessionData?.AppId; + const CompId = SessionData?.CompId; + const BranchId = SessionData?.BranchId; + const UserId = SessionData?.UserId; + const UserType = SessionData?.UserType; + const [messageType, setMessageType] = useState(null); + const [messageData, setMessageData] = useState(null); + const [TemplateDetails, setTemplateDetails] = useState([]); + const [TableFontData, setTableFontData] = useState([ + { FontId: 1, SessionFont: 'Arial' }, + { FontId: 2, SessionFont: 'Roboto' }, + { FontId: 3, SessionFont: 'Open Sans' }, + { FontId: 4, SessionFont: 'Lato' }, + { FontId: 5, SessionFont: 'Montserrat' }, + ]); + const [selectedTableFont, setSelectedTableFont] = useState(); + console.log(selectedTableFont, 'selectedTableFontselectedTableFont'); + const [TableFontModelopen, setTableFontModelopen] = useState(false); + const [SelectedTableColor, setSelectedTableColor] = useState(null); + const [Tableform] = Form.useForm(); + const [billingSettings, setBillingSettings] = useState(); + console.log(billingSettings, 'billingSettingsbillingSettings'); + const [SelectedBillTableCheckValues, setSelectedBillTableCheckValues] = + useState([]); + const backgroundOptionId = billingSettings?.ComponentOptionsDetails?.find( + (item) => item?.OptionName === 'Background' + )?.OptionId; + + const hasBackground = + SelectedBillTableCheckValues?.includes(backgroundOptionId); + const OverallbackgroundOptionId = + billingSettings?.ComponentOptionsDetails?.find( + (item) => item?.OptionName === 'OverallBackground' + )?.OptionId; + + const hasOverallBackground = SelectedBillTableCheckValues?.includes( + OverallbackgroundOptionId + ); + // Hold and addcustomer OptionsDetails + const [HoldButton, setHoldButton] = useState(false); + const [AddCustomerButton, setAddCustomerButton] = useState(false); + const [DineInChecked, setDineInChecked] = useState(false); + console.log(billingSettings, 'billingSettingsbillingSettings'); + const [TableBackgroundColorData, setTableBackgroundColorData] = useState([ + { + ColorId: 4, + SessionId: 55, + OptionId: 108, + FontColor: '#000000', + BackgroundColor: '#f06292', + ThemeName: 'Theme 4', + ActiveStatus: 'A', + }, + { + ColorId: 14, + SessionId: 55, + OptionId: 108, + FontColor: '#000000', + BackgroundColor: '#52C41A', + ThemeName: 'Theme 14', + ActiveStatus: 'A', + }, + { + ColorId: 23, + SessionId: 55, + OptionId: 108, + FontColor: '#000000', + BackgroundColor: '#0d47a1', + ThemeName: 'Theme 23', + ActiveStatus: 'A', + }, + { + ColorId: 25, + SessionId: 55, + OptionId: 108, + FontColor: '#000000', + BackgroundColor: '#f8bbd0', + ThemeName: 'Theme 25', + ActiveStatus: 'A', + }, + { + ColorId: 29, + SessionId: 55, + OptionId: 108, + FontColor: '#000000', + BackgroundColor: '#ffcdd2', + ThemeName: 'Theme 29', + ActiveStatus: 'A', + }, + ]); + const [BillingOverallColorsList, setBillingOverallColorsList] = useState(); + const [BillUploadColor, setBillUploadColor] = useState(false); + const [TableColorType, setTableColorType] = useState('Y'); + const [TablebackgroundColor, setTablebackgroundColor] = useState('#009b00'); + const [tableBGHex, setTableBGHex] = useState( + TablebackgroundColor?.replace('#', '').trim() + ); + const [TablefontColor, setTablefontColor] = useState('#000000'); + const [tableFontHex, setTableFontHex] = useState( + TablefontColor?.replace('#', '').trim() + ); + const [BillingUploadOverallColor, setBillingUploadOverallColor] = + useState(false); + const [BillingOverallColor, setBillingOverallColor] = useState('#000000'); + const [billingOverallHex, setBillingOverallHex] = useState( + BillingOverallColor?.replace('#', '').trim() + ); + const [selectOverallSelected, setSelectOverallSelected] = useState(true); + const [dropdownBillingOverallColor, setdropdownBillingOverallColor] = + useState(null); + const [FirstOnClick, setFirstOnClick] = useState(false); + + useEffect(() => { + GetTemplatedetails(); + }, []); + + const GetTemplatedetails = async () => { + let Data = { + CompId: CompId, + AppId: AppId, + BranchId: BranchId, + }; + const templateresponse = await dispatch(getSalesTemplate(Data)).unwrap(); + let AllDetails = templateresponse?.data?.data; + setTemplateDetails(AllDetails?.Templates); + let selectedBilling = AllDetails?.Templates?.[0]?.ComponentDetails?.find( + (item) => item?.SessionName === 'BookingBilling' + ); + let selectedNavbar = AllDetails?.Templates?.[0]?.ComponentDetails?.find( + (item) => item?.SessionName === 'BookingNavbar' + ); + let AllBillingdetails = AllDetails?.Components?.find( + (item) => item?.ComponentName === selectedBilling?.ComponentName + ); + console.log(AllDetails, selectedNavbar, 'templateresponse'); + setBillingSettings(AllBillingdetails); + const optionIds = selectedBilling?.FieldDetails?.map( + (item) => item?.OptionId + ); + setSelectedBillTableCheckValues(optionIds); + + let Allfontdata = AllDetails?.Fonts?.filter( + (item) => item.SessionId === selectedBilling?.SessionId + ); + setTableFontData(Allfontdata); + let selectedFont = AllDetails?.Templates?.[0]?.FontDetail?.find( + (item) => item?.SessionId === selectedBilling?.SessionId + ); + + setSelectedTableFont(selectedFont?.FontId); + const hasHold = selectedNavbar?.FieldDetails?.some( + (item) => item.OptionName === 'Hold' + ); + const hasAddcustomer = selectedNavbar?.FieldDetails?.some( + (item) => item.OptionName === 'AddCustomer' + ); + const hasDinein = selectedNavbar?.FieldDetails?.some( + (item) => item.OptionName === 'DineIn' + ); + setHoldButton(hasHold); + setAddCustomerButton(hasAddcustomer); + setDineInChecked(hasDinein); + let allcolordata = AllDetails?.Colors?.filter( + (item) => + item.SessionId === selectedBilling?.SessionId && + item.OptionName === 'OverallBackground' + ); + setBillingOverallColorsList(allcolordata); + let allBackcolordata = AllDetails?.Colors?.filter( + (item) => + item.SessionId === selectedBilling?.SessionId && + item.OptionName === 'Background' + ); + + setTableBackgroundColorData(allBackcolordata); + let selectedcolors = AllDetails?.Templates?.[0]?.ColorDetail?.filter( + (item) => item?.SessionName === 'BookingBilling' + ); + console.log(selectedcolors, 'selectedOverallBackgroudcolor'); + selectedcolors?.forEach((item) => { + if (item?.['BackgroundColor']) { + setSelectedTableColor(item?.['ColorId']); + } else if (item?.['OverallBackgroundColor']) { + setdropdownBillingOverallColor(item?.['ColorId']); + } + }); + // await setdropdownBillingOverallColor(selectedOverallBackgroudcolor); + // formRef.current?.setFieldsValue({ BillingOverallColor: value }); + + // setTableBackgroundColorData + console.log(Allfontdata, 'All table colors'); + // BookingBilling templateData?.['BookingBilling']?.[0] + }; + + const BillTableSelectlistonChange = (checkedValues) => { + setSelectedBillTableCheckValues(checkedValues); + }; + const handleChange = (itemId, checked) => { + setBillingSettings((prev) => + prev.map((item) => (item.id === itemId ? { ...item, checked } : item)) + ); + }; + const selectFont3 = (value) => { + setSelectedTableFont(value); + }; + const TablehandleUploadFonts = () => { + setTableFontModelopen(true); + }; + const TablehandleCancel = () => { + setTableFontModelopen(false); + Tableform.resetFields(); + }; + const selectTableColor = async (value) => { + await setSelectedTableColor(value); + // formRef.current?.setFieldsValue({ TableColor: value }); + }; + const BillhandleUploadColor = () => { + setBillUploadColor(true); + }; + const handleColorChange4 = (color, event) => { + if (TableColorType == 'Y') { + setTablebackgroundColor(color['hex']); + setTableBGHex(color?.hex?.replace('#', '').trim()); + } + if (TableColorType == 'N') { + setTablefontColor(color['hex']); + setTableFontHex(color?.hex?.replace('#', '').trim()); + } + }; + + const handleBackgroundColorSubmit = async () => { + if (TablebackgroundColor !== TablefontColor) { + let response; + try { + let postData = { + BackgroundColor: TablebackgroundColor, + FontColor: TablefontColor, + CreatedBy: UserId, + SessionId: billingSettings?.SessionId, + OptionId: backgroundOptionId, + }; + response = await dispatch(postColorData(postData)).unwrap(); + } catch (err) { + if (err['message'] == 'Request failed with status code 422') { + response = { + data: { + statusCode: 0, + response: 'Color Not Added', + data: [], + }, + }; + } + } + if (response?.data?.statusCode == 1) { + if (response?.data?.response == 'Color Already Exists') { + setMessageType('warning'); + setMessageData(response?.data?.response); + } else { + setMessageType('success'); + setMessageData(response?.data?.response); + // BillsetUploadColor(false); + } + GetTemplatedetails(); + setBillUploadColor(false); + } else { + setMessageData(response?.data?.response); + setMessageType('error'); + } + } else { + setMessageData('Please select different color for background and font'); + setMessageType('warning'); + } + }; + const TableonCancel4 = () => { + setBillUploadColor(false); + }; + const handleTableHexChange = (e) => { + if (TableColorType?.toLowerCase() === 'y') { + setTableBGHex(e?.target?.value); + if (e?.target?.value === '' || !isHexColor(`#${e.target.value}`)) { + e.target.value = '009b00'; + } + setTablebackgroundColor(`#${e.target.value}`); + } + if (TableColorType?.toLowerCase() === 'n') { + setTableFontHex(e?.target?.value); + if (e?.target?.value === '' || !isHexColor(`#${e.target.value}`)) { + e.target.value = '000000'; + } + setTablefontColor(`#${e.target.value}`); + } + }; + const handleBillingOverallHexCode = (e) => { + setBillingOverallHex(e?.target?.value); + if (e?.target?.value === '' || !isHexColor(`#${e.target.value}`)) { + e.target.value = '000000'; + } + setBillingOverallColor(`#${e.target.value}`); + }; + const handleBillingOverallColorChange = (color, event) => { + setBillingOverallColor(color['hex']); + setBillingOverallHex(color?.hex?.replace('#', '').trim()); + }; + const handleBillingOverallColorSubmit = async () => { + let response; + + try { + let postData = { + BackgroundColor: BillingOverallColor, + FontColor: '#000000', + CreatedBy: UserId, + SessionId: billingSettings?.SessionId, + OptionId: OverallbackgroundOptionId, + }; + response = await dispatch(postColorData(postData)).unwrap(); + } catch (err) { + if (err['message'] == 'Request failed with status code 422') { + response = { + data: { + statusCode: 0, + response: 'Color Not Added', + data: [], + }, + }; + } + } + if (response?.data?.statusCode == 1) { + if (response?.data?.response == 'Color Already Exists') { + setMessageType('warning'); + setMessageData(response?.data?.response); + } else { + setMessageType('success'); + setMessageData(response?.data?.response); + setBillingUploadOverallColor(false); + } + GetTemplatedetails(); + BillingUploadOverallColor(false); + } else { + setMessageData(response?.data?.response); + setMessageType('error'); + } + }; + const selectBillingOverallColor = async (value) => { + await setdropdownBillingOverallColor(value); + // formRef.current?.setFieldsValue({ BillingOverallColor: value }); + }; + const openColour4 = (value) => { + setTableColorType(value); + }; + const handleBillingUploadOverallColor = () => { + setBillingUploadOverallColor(true); + }; + + const TablehandleSubmit = async () => { + const values = await Tableform.validateFields(); + validateFontsTable(values); + }; + const validateFontsTable = async (values) => { + console.log(values, 'valuesvalues'); + const apiUrl = `https://www.googleapis.com/webfonts/v1/webfonts?key=AIzaSyDP1HqNkLI53iIAH-SB9_mt_24QdkUZ_24`; + fetch(apiUrl) + .then((response) => response.json()) + .then(async (data) => { + const fontNames = data?.items?.map((item) => item.family); + + if (fontNames.includes(formatFontName(values['TableFont']))) { + let response; + try { + let postData = { + SessionFont: formatFontName(values['TableFont']), + CreatedBy: UserId, + SessionId: billingSettings?.SessionId, + }; + response = await dispatch(postTableFontData(postData)).unwrap(); + } catch (err) { + if (err['message'] == 'Request failed with status code 422') { + response = { + data: { + statusCode: 0, + response: 'Font Not Added', + data: [], + }, + }; + } + } + if (response?.data?.statusCode == 1) { + setTableFontModelopen(false); + setMessageData(response?.data?.response); + if (response?.data?.response == 'Font Already Exists') { + setMessageType('warning'); + } else { + setMessageType('success'); + } + + dispatch(getTableFonts(BillingTableData?.[0]?.SessionId)).unwrap; + GetTemplatedetails(); + Tableform.resetFields(); + } else { + setMessageData(response?.data?.response); + setMessageType('error'); + } + } else { + setMessageType('warning'); + setMessageData('Please give the Correct google fonts Name!'); + } + }) + .catch((error) => { + console.error('Error fetching fonts:', error); + }); + }; + function formatFontName(input) { + return input + ?.toLowerCase() + .split(/\s+/) + .map((word) => word.charAt(0).toUpperCase() + word.slice(1)) // Capitalize each word + .join(' '); + } + const HandleSubmit = async () => { + console.log(TemplateDetails, 'TemplateDetails.ColorDetail'); + const result = { + AppId: AppId, + CompId: CompId, + UserId: UserId, + BranchId: BranchId, + ColorId: [ + ...(TemplateDetails?.[0]?.ColorDetail?.filter( + (c) => c.SessionName !== 'BookingBilling' + )?.map((c) => c.ColorId) || []), + + SelectedTableColor, + dropdownBillingOverallColor, + ], + FontId: TemplateDetails?.[0]?.FontDetail?.map((f) => + f.SessionName === 'BookingBilling' ? selectedTableFont : f.FontId + ), + CreatedBy: UserId, + TemplateDetails: TemplateDetails?.[0]?.ComponentDetails.map((comp) => ({ + ComponentId: comp.ComponentId, // ✅ dynamic + ComponentDetails: + comp.SessionName === 'BookingBilling' + ? SelectedBillTableCheckValues?.map((id) => ({ OptionId: id })) // ✅ NEW checked list + : comp.FieldDetails.map((field) => ({ OptionId: field.OptionId })), // existing + })), + }; + console.log(result, 'final result to submit'); + var response = await dispatch(putSelectionComponentData(result)).unwrap(); + if (response?.data?.statusCode == 1) { + if (response?.data?.response === 'Application Template Already Exists') { + setMessageType('warning'); + setMessageData('Application Template Already Exists'); + setFirstOnClick(false); + } else { + setMessageType('success'); + setMessageData('Template Details Added Successfully'); + setFirstOnClick(false); + } + await dispatch(getTemplate({ CompId, BranchId, AppId })).unwrap(); + setModalOpen(false); + } else { + setMessageType('error'); + setMessageData(response?.data?.response); + setFirstOnClick(false); + } + }; + const onComplete = useCallback(() => { + setMessageData(null); + setMessageType(null); + }, []); + + return ( + <> + +
+ + + {billingSettings?.ComponentOptionsDetails?.map((value, key) => ( + Navholdoption(value.OptionName)} + key={value?.OptionId} + disabled={ + value.OptionName === 'Hold' && HoldButton + ? true + : value.OptionName === 'AddCustomer' && AddCustomerButton + ? true + : value.OptionName === 'Item' + ? true + : value.OptionName === 'UnpaidBill' && !DineInChecked + ? true + : false + } + > + {value.OptionName} + + ))} + + + {/* {billingSettings?.ComponentOptionsDetails?.map((item) => ( +
+ handleChange(item.id, e.target.checked)} + > + {item.label} + +
+ ))} */} +
+
+
+

BillTable Font

+
+ ({ + value: option.FontId, + label: option.SessionFont, + }))} + label="Font" + onChangeFunction={selectFont3} + className="settingsales-DropDown-Selection" + isOnchanges={!!selectedTableFont} + valueData={selectedTableFont} + /> +
+ Add + +
+
+
+ + {hasBackground ? ( +
+
+
+ +

+ BillTable Background Color +

+ ({ + value: option.ColorId, + label: ( +
+
+ +     + +
+
{option.ThemeName}
+
+ ), + }))} + labelChange={true} + label="Color" + className="field-DropDown-Selection" + onChangeFunction={selectTableColor} + isOnchanges={SelectedTableColor ? true : false} + valueData={SelectedTableColor} + /> +
+
+
+ Add + +
+
+
+ ) : null} + + {hasOverallBackground ? ( +
+ { + setBillingUploadOverallColor(false); + }} + /> + } + width={400} + footer={null} + > +
+
+

+ Selected Color:{' '} +

+
+
+
+ +
+
+ + + +
+ +
+
+
+
+ +

+ BillTable Overall-Background +

+ ({ + value: option.ColorId, + label: ( +
+
+ +     + +
+
{option.ThemeName}
+
+ ), + }))} + labelChange={true} + label={ +

Overall Background

+ } + className="field-DropDown-Selection" + onChangeFunction={selectBillingOverallColor} + isOnchanges={dropdownBillingOverallColor ? true : false} + valueData={dropdownBillingOverallColor} + /> +
+
+
+ Add + +
+
+
+ ) : null} +
+ +
+
+ { + await validateSafeInput(value); // To block HTML tags & SQL keywords + return Promise.resolve(); + }, + }, + ]} + > + + +
+
+

* Google Fonts Only

+ + } + handleCancel={TablehandleCancel} + handleSubmit={TablehandleSubmit} + buttonText="SAVE" + /> + + } + width={400} + footer={null} + > +
+
+ openColour4(e)} + /> +
+ +
+
+ +
+
+

+ {' '} + Selected Background Color :{' '} +

+
+ <>| +
+
+

+ {' '} + Selected Font Color :{' '} +

+
+
+
+
+ + + +
+ +
+
+
+ } + htmlType={true} + handleSubmit={HandleSubmit} + /> +
+ + ); +}; +export default TableHeadersetting; diff --git a/src/Pages/BookingScreen/PrintTemplates/A4/A4Standard.jsx b/src/Pages/BookingScreen/PrintTemplates/A4/A4Standard.jsx index 83e48b7..5027bfb 100644 --- a/src/Pages/BookingScreen/PrintTemplates/A4/A4Standard.jsx +++ b/src/Pages/BookingScreen/PrintTemplates/A4/A4Standard.jsx @@ -97,7 +97,7 @@ const InvoiceTemplate = ({ const estimatePrintHeader = SettingData?.[0]?.SettingDtlDetails?.find( (setting) => - setting?.SettingIdName?.toLowerCase() === 'estimateprintheader', + setting?.SettingIdName?.toLowerCase() === 'estimateprintheader' )?.SettingValue === 'Y'; const keysLength = Object.keys(table2Data ?? {}).length; console.log(GlobalDiscount, Discount, 'Discount'); @@ -141,13 +141,13 @@ const InvoiceTemplate = ({ const formattedDate = `${day}-${monthNames[monthIndex]}-${year}`; const TakeawayData = table2Data?.productDetails?.filter( - (item) => item.BookingTypeName?.toLowerCase() === 'takeaway', + (item) => item.BookingTypeName?.toLowerCase() === 'takeaway' ); const DineInData = table2Data?.productDetails?.filter( - (item) => item.BookingTypeName?.toLowerCase() === 'dine in', + (item) => item.BookingTypeName?.toLowerCase() === 'dine in' ); let PaymentStatusSuccess = PaymentStatus?.filter( - (ps) => ps.PaymentStatus === 'S', + (ps) => ps.PaymentStatus === 'S' ); const isEditedBill = PaymentStatus?.some(payment => { const type = payment?.AdjustmentType?.toLowerCase(); @@ -198,22 +198,22 @@ const InvoiceTemplate = ({ }); const hasMappedOffer = offers.some((offer) => ['ItemWiseOffers', 'BundleOffers', 'QuantityWiseOffers'].includes( - offer.TableName, - ), + offer.TableName + ) ); if (hasMappedOffer) { const productTotal = productsData?.reduce( (acc, item) => acc + (item?.Type != 'C' ? item.OfferAmt : item.OfferValue || 0), - 0, + 0 ); TotalOfferAmount += productTotal; } else { const Combothere = productsData?.filter((item) => item?.Type == 'C'); const CombothereTotal = Combothere?.reduce( (acc, item) => acc + (item.OfferValue || 0), - 0, + 0 ); TotalOfferAmount += CombothereTotal; } @@ -837,8 +837,8 @@ const InvoiceTemplate = ({ flexDirection: 'column', justifyContent: chunkIndex === paginatedChunks.length - 1 && - !shouldFooterBeOnNewPage && - FormatTheme + !shouldFooterBeOnNewPage && + FormatTheme ? 'space-between' : '', height: FormatTheme @@ -893,7 +893,7 @@ const InvoiceTemplate = ({
)} {base64Image && - (PrintLogo?.SettingValue === 'Y' || LogoField) ? ( + (PrintLogo?.SettingValue === 'Y' || LogoField) ? ( Brand Logo
)} @@ -975,7 +975,7 @@ const InvoiceTemplate = ({ ? BillName : PaymentStatusSuccess?.length === 1 ? PaymentStatusSuccess?.[0]?.PaymentTypeName + - ' Bill' + ' Bill' : ''}
)} @@ -1080,146 +1080,146 @@ const InvoiceTemplate = ({ {GlobaldummyData ? GlobalSlNo && ( - S.No - ) + S.No + ) : SLNO == true && ( - - S.No - - )} + + S.No + + )} {GlobaldummyData ? GlobalItem && ( - Item - ) + Item + ) : Item == true && ( - - Item - - )} + + Item + + )} {GlobaldummyData ? GlobalHsnCode && ( - HSN - ) + HSN + ) : HsnCode == true && ( - - HSN{' '} - - )} + + HSN{' '} + + )} {GlobaldummyData ? GlobalQuantity && ( - Qty - ) + Qty + ) : Quantity == true && ( - - {' '} - {WeightasKg ? 'Qty/Kg' : 'Qty'} - - )} + + {' '} + {WeightasKg ? 'Qty/Kg' : 'Qty'} + + )} {/* UOM UOM */} {GlobaldummyData ? GlobalMRP && ( - MRP - ) + MRP + ) : MRP == true && ( - - MRP - - )} + + MRP + + )} {GlobaldummyData ? GlobalRate && ( - Rate - ) + Rate + ) : Rate == true && ( - - Rate - - )} + + Rate + + )} {GlobaldummyData ? GlobalDiscount && ( - Dis - ) + Dis + ) : Discount == true && ( - - Dis - - )} + + Dis + + )} {GlobaldummyData ? GlobalTax && ( - Tax % - ) + Tax % + ) : Tax && - table2Data?.OrderType !== 'E' && ( - - Tax % - - )} + table2Data?.OrderType !== 'E' && ( + + Tax % + + )} {GlobaldummyData ? GlobalAmount && ( - Amount - ) + Amount + ) : Amount == true && ( - - Amount - - )} + + Amount + + )} @@ -1228,251 +1228,251 @@ const InvoiceTemplate = ({ {GlobaldummyData ? GlobalSlNo && ( - - {chunkIndex * chunkSize + idx + 1} - - ) + + {chunkIndex * chunkSize + idx + 1} + + ) : SLNO == true && ( - - {chunkIndex * chunkSize + idx + 1} - - )} + + {chunkIndex * chunkSize + idx + 1} + + )} {GlobaldummyData ? GlobalItem && ( - - {item?.ProdName} - - ) + + {item?.ProdName} + + ) : Item == true && ( - -
{item?.ProdName}
- {PackageDetails?.filter( - (pkg) => pkg.ProdId === item.ProdId, - ).length > 0 ? ( -
- {PackageDetails?.filter( - (pkg) => - pkg.ProdId === item.ProdId, - )?.map((item, index) => ( - - {item.ParcelCount} PCS{' '} - {item.ParcelQty} PACK ( - {item.ParcelType}) - - ))} -
- ) : ( -
- ({item?.Size ? item?.Size : '1'}{' '} - {item?.SinglePc == 'Y' - ? 'PCS' - : item?.Type != 'C' - ? item?.UomName - : 'COMBO'} - ) -
- )} -  {' '} - {item?.BrandName !== null - ? item?.BrandName - : ''} -   - {item?.ProductIdentifierDtls?.length > 0 - ? item?.ProductIdentifierDtls?.filter( - (items) => - !( - items.SerialNumber == '' || - items.SerialNumber == null - ), - )?.map((a) => { - return ( -
{a.SerialNumber}
- ); - }) - : ''}{' '} - {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(',')} -
- ); - }) - : ''} - - )} + +
{item?.ProdName}
+ {PackageDetails?.filter( + (pkg) => pkg.ProdId === item.ProdId + ).length > 0 ? ( +
+ {PackageDetails?.filter( + (pkg) => + pkg.ProdId === item.ProdId + )?.map((item, index) => ( + + {item.ParcelCount} PCS{' '} + {item.ParcelQty} PACK ( + {item.ParcelType}) + + ))} +
+ ) : ( +
+ ({item?.Size ? item?.Size : '1'}{' '} + {item?.SinglePc == 'Y' + ? 'PCS' + : item?.Type != 'C' + ? item?.UomName + : 'COMBO'} + ) +
+ )} +  {' '} + {item?.BrandName !== null + ? item?.BrandName + : ''} +   + {item?.ProductIdentifierDtls?.length > 0 + ? item?.ProductIdentifierDtls?.filter( + (items) => + !( + items.SerialNumber == '' || + items.SerialNumber == null + ) + )?.map((a) => { + return ( +
{a.SerialNumber}
+ ); + }) + : ''}{' '} + {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(',')} +
+ ); + }) + : ''} + + )} {GlobaldummyData ? GlobalHsnCode && ( - - {item?.HSN} - - ) + + {item?.HSN} + + ) : HsnCode == true && ( - - {item?.HSN} - - )} + + {item?.HSN} + + )} {GlobaldummyData ? GlobalQuantity && ( - - {item?.SalesQty} - - ) + + {item?.SalesQty} + + ) : Quantity == true && ( - - {item?.SalesQty} - - )} + + {item?.SalesQty} + + )} {GlobaldummyData ? GlobalMRP && ( - - {item?.MRP} - - ) + + {item?.MRP} + + ) : MRP == true && ( - - {item?.SinglePc === 'Y' - ? item?.Rate - : item?.MRP} - - )} + + {item?.SinglePc === 'Y' + ? item?.Rate + : item?.MRP} + + )} {GlobaldummyData ? GlobalRate && ( - - {item?.Rate} - - ) + + {item?.Rate} + + ) : Rate == true && ( - - {' '} - {item?.Rate} - - )} + + {' '} + {item?.Rate} + + )} {GlobaldummyData ? GlobalDiscount && ( - - {item.discount} - - ) + + {item.discount} + + ) : Discount == true && ( - - {item?.Type != 'C' - ? item?.OfferAmt || 0 - : item?.OfferValue || 0} - - )} + + {item?.Type != 'C' + ? item?.OfferAmt || 0 + : item?.OfferValue || 0} + + )} {GlobaldummyData ? GlobalTax && ( - - {item?.ProdTaxPercentage} - - ) + + {item?.ProdTaxPercentage} + + ) : Tax && - table2Data?.OrderType !== 'E' && ( - - {item?.ProdTaxPercentage || 0} - - )} + table2Data?.OrderType !== 'E' && ( + + {item?.ProdTaxPercentage || 0} + + )} {GlobaldummyData ? GlobalAmount && ( - - {item?.TotalAmt} - - ) + + {item?.TotalAmt} + + ) : Amount == true && ( - - {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} + + )} - ), + ) )} @@ -1724,7 +1724,7 @@ const InvoiceTemplate = ({
{Number( - item.WithOutTaxAmount, + item.WithOutTaxAmount ).toFixed(2)}
@@ -1915,28 +1915,28 @@ const InvoiceTemplate = ({
Bank Name:{' '} {!estimatePrintHeader && - table2Data?.OrderType === 'E' + table2Data?.OrderType === 'E' ? '' : BankDetails?.[0]?.BankName}
Account No.:{' '} {!estimatePrintHeader && - table2Data?.OrderType === 'E' + table2Data?.OrderType === 'E' ? '' : BankDetails?.[0]?.AccountNo}
IFSC Code:{' '} {!estimatePrintHeader && - table2Data?.OrderType === 'E' + table2Data?.OrderType === 'E' ? '' : BankDetails?.[0]?.IFSCCode}
Branch Name:{' '} {!estimatePrintHeader && - table2Data?.OrderType === 'E' + table2Data?.OrderType === 'E' ? '' : BankDetails?.[0]?.BankBranch}
@@ -1948,80 +1948,80 @@ const InvoiceTemplate = ({
{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. -
-
- ) - : TermsnAdCondition == true && - TermsAndConditions?.length > 0 && ( -
-

- Terms & Conditions -

-
    - {TermsAndConditions?.map((item) => ( -
  1. - {item?.TermsandConditions} +

    + Terms & Conditions +

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

    + Terms & Conditions +

    +
      + {TermsAndConditions?.map((item) => ( +
    1. + {item?.TermsandConditions} +
    2. + ))} + {/*
    3. Please check the product before leaving the counter.
    4. */} +
    +
    + )}
    - -
    - ) - : Signature == true && ( -
    - {!estimatePrintHeader && - table2Data?.OrderType === 'E' ? ( - '' - ) : ( +
    - )} -
    - )} +
    + ) + : Signature == true && ( +
    + {!estimatePrintHeader && + table2Data?.OrderType === 'E' ? ( + '' + ) : ( + + )} +
    + )}

    (Common Seal)

    @@ -2097,28 +2097,28 @@ const InvoiceTemplate = ({
    {GlobaldummyData ? GlobalIsnotes && ( -
    -

    - Notes : 10 days Return policy -

    +
    +

    + Notes : 10 days Return policy +

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

    - {Notestext} -

    +
    +

    + {Notestext} +

    - {/*
    */} -
    - )} + {/*
    */} +
    + )}
    @@ -2371,7 +2371,7 @@ const InvoiceTemplate = ({ Total Amount Payable {Number( - GlobaldummyData ? 736 : table2Data?.NetAmount, + GlobaldummyData ? 736 : table2Data?.NetAmount )?.toFixed(2)} diff --git a/src/Pages/BookingScreen/PrintTemplates/A4/PrintA4Style11.jsx b/src/Pages/BookingScreen/PrintTemplates/A4/PrintA4Style11.jsx index 67c12c8..6e73f7e 100644 --- a/src/Pages/BookingScreen/PrintTemplates/A4/PrintA4Style11.jsx +++ b/src/Pages/BookingScreen/PrintTemplates/A4/PrintA4Style11.jsx @@ -336,7 +336,7 @@ const PrintA4Style11 = ({ )} {base64Image && - (PrintLogo?.SettingValue === 'Y' || LogoField) ? ( + (PrintLogo?.SettingValue === 'Y' || LogoField) ? ( Mobile: +91{' '} {GlobaldummyData ? '986XXXXXXX' : table2Data?.BrMobile} @@ -497,60 +497,60 @@ const PrintA4Style11 = ({ > {GlobaldummyData ? GlobalSlNo && ( - - S.No - - ) + + S.No + + ) : SLNO == true && ( - - S.No - - )} + + S.No + + )} {GlobaldummyData ? GlobalItem && Item : Item == true && Item} {GlobaldummyData ? GlobalHsnCode && ( - - HSN - - ) + + HSN + + ) : HsnCode == true && ( - - HSN - - )} + + HSN + + )} {GlobaldummyData ? GlobalQuantity && ( - - Qty - - ) + + Qty + + ) : Quantity == true && ( - MRP - - ) + + MRP + + ) : MRP == true && ( - - MRP - - )} + + MRP + + )} {GlobaldummyData ? GlobalRate && ( - - Rate - - ) + + Rate + + ) : Rate == true && ( - - Rate - - )} + + Rate + + )} {GlobaldummyData ? GlobalDiscount && ( - - Dis{' '} - - ) + + Dis{' '} + + ) : Discount == true && ( - - Dis{' '} - - )} + + Dis{' '} + + )} {GlobaldummyData ? GlobalTax && ( - - Tax % - - ) - : (Tax && table2Data?.OrderType !== 'E') && ( - - Tax % - - )} + + Tax % + + ) + : Tax && + table2Data?.OrderType !== 'E' && ( + + Tax % + + )} {GlobaldummyData ? GlobalAmount && ( - - Amt - - ) + + Amt + + ) : Amount == true && ( - - Amt - - )} + + Amt + + )} @@ -674,180 +675,181 @@ const PrintA4Style11 = ({ {GlobaldummyData ? GlobalSlNo && ( - - {index + 1} - - ) + + {index + 1} + + ) : SLNO == true && ( - - {chunkIndex * chunkSize + index + 1} - - )} + + {chunkIndex * chunkSize + index + 1} + + )} {GlobaldummyData ? GlobalItem && {item?.name} : Item == true && ( - -
    {item?.ProdName}
    - {PackageDetails?.filter( - (pkg) => - pkg.ProdId === item.ProdId - ).length > 0 ? ( -
    - {PackageDetails?.filter( - (pkg) => - pkg.ProdId === item.ProdId - )?.map((item, index) => ( - - {item.ParcelCount} PCS{' '} - {item.ParcelQty} PACK ( - {item.ParcelType}) - - ))} -
    - ) : ( -
    - ({item?.Size ? item?.Size : '1'}{' '} - {item?.SinglePc == 'Y' - ? 'PCS' - : item?.Type != 'C' - ? item?.UomName - : 'COMBO'} - ) -
    - )} -  {' '} - {item?.BrandName !== null - ? item?.BrandName - : ''} -   - {item?.ProductIdentifierDtls - ?.length > 0 - ? item?.ProductIdentifierDtls?.filter( - (items) => - !( - items.SerialNumber == - '' || - items.SerialNumber == null + +
    {item?.ProdName}
    + {PackageDetails?.filter( + (pkg) => + pkg.ProdId === item.ProdId + ).length > 0 ? ( +
    + {PackageDetails?.filter( + (pkg) => + pkg.ProdId === item.ProdId + )?.map((item, index) => ( + + {item.ParcelCount} PCS{' '} + {item.ParcelQty} PACK ( + {item.ParcelType}) + + ))} +
    + ) : ( +
    + ({item?.Size ? item?.Size : '1'}{' '} + {item?.SinglePc == 'Y' + ? 'PCS' + : item?.Type != 'C' + ? item?.UomName + : 'COMBO'} ) - )?.map((a) => { - return ( -
    {a.SerialNumber}
    - ); - }) - : ''}{' '} - {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(',')} -
    - ); - }) - : ''} - - )} +
    + )} +  {' '} + {item?.BrandName !== null + ? item?.BrandName + : ''} +   + {item?.ProductIdentifierDtls + ?.length > 0 + ? item?.ProductIdentifierDtls?.filter( + (items) => + !( + items.SerialNumber == + '' || + items.SerialNumber == null + ) + )?.map((a) => { + return ( +
    {a.SerialNumber}
    + ); + }) + : ''}{' '} + {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(',')} +
    + ); + }) + : ''} + + )} {GlobaldummyData ? GlobalHsnCode && ( - - {item?.discount} - - ) + + {item?.discount} + + ) : HsnCode == true && ( - - {item?.HSN} - - )} + + {item?.HSN} + + )} {GlobaldummyData ? GlobalQuantity && ( - - {item?.quantity} - - ) + + {item?.quantity} + + ) : Quantity == true && ( - - {item?.SalesQty} - - )} + + {item?.SalesQty} + + )} {GlobaldummyData ? GlobalMRP && ( - - {item?.mrp} - - ) + + {item?.mrp} + + ) : MRP == true && ( - - {item?.SinglePc === 'Y' - ? item?.Rate - : item?.MRP} - - )} + + {item?.SinglePc === 'Y' + ? item?.Rate + : item?.MRP} + + )} {GlobaldummyData ? GlobalRate && ( - - {item?.Rate} - - ) + + {item?.Rate} + + ) : Rate == true && ( - - {' '} - {item?.MRP} - - )} + + {' '} + {item?.MRP} + + )} {GlobaldummyData ? GlobalDiscount && ( - {item.discount} - ) + {item.discount} + ) : Discount == true && ( - - {item?.Type != 'C' - ? item?.OfferAmt || 0 - : item?.OfferValue || 0} - - )} + + {item?.Type != 'C' + ? item?.OfferAmt || 0 + : item?.OfferValue || 0} + + )} {GlobaldummyData ? GlobalTax && ( - {item.ProdTaxPercentage} - ) - : (Tax && table2Data?.OrderType !== 'E') && ( - - {item?.ProdTaxPercentage || 0} - - )} + {item.ProdTaxPercentage} + ) + : Tax && + table2Data?.OrderType !== 'E' && ( + + {item?.ProdTaxPercentage || 0} + + )} {GlobaldummyData ? GlobalAmount && ( - - {item?.price} - - ) + + {item?.price} + + ) : Amount == true && ( - - {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} + + )} ))} @@ -886,7 +888,7 @@ const PrintA4Style11 = ({
    ITEMS
    Qty
    {TotalOfferAmount > 0 || - table2Data?.OverallDisc ? ( + table2Data?.OverallDisc ? (
    OFFER
    ) : ( '' @@ -912,11 +914,11 @@ const PrintA4Style11 = ({ : totalQuantity} {TotalOfferAmount > 0 || - table2Data?.OverallDisc ? ( + table2Data?.OverallDisc ? (
    {Number( TotalOfferAmount + - table2Data?.OverallDisc + table2Data?.OverallDisc ).toFixed(2)}
    ) : ( @@ -939,8 +941,8 @@ const PrintA4Style11 = ({ {GlobaldummyData ? '1066' : Number( - table2Data?.NetAmount - ).toFixed(2)} + table2Data?.NetAmount + ).toFixed(2)} @@ -986,33 +988,33 @@ const PrintA4Style11 = ({ )} {GlobaldummyData ? GlobalCredit && ( -
    -
    Advance Amount:
    -
    Opening Balance:
    -
    - ) +
    +
    Advance Amount:
    +
    Opening Balance:
    +
    + ) : CreditDetails && - table2Data?.CustomerDetails?.length > - 0 && ( -
    - {/* OLD CREDIT BAL */} - {PaymentStatusSuccess?.[0] - ?.PaymentTypeName === - 'Credit' && ( + table2Data?.CustomerDetails?.length > + 0 && ( +
    + {/* OLD CREDIT BAL */} + {PaymentStatusSuccess?.[0] + ?.PaymentTypeName === + 'Credit' && ( <> {table2Data.CustomerDetails[0] .OldCreditBal > 0 ? ( @@ -1025,8 +1027,8 @@ const PrintA4Style11 = ({ }

    ) : table2Data - .CustomerDetails[0] - .OldCreditBal < 0 ? ( + .CustomerDetails[0] + .OldCreditBal < 0 ? (

    {' '} Opening Balance:{' '} @@ -1040,51 +1042,88 @@ const PrintA4Style11 = ({ )} - {/* CURRENT CREDIT BAL */} - {table2Data.CustomerDetails[0] - .CurrentCreditBal > 0 ? ( -

    - {' '} - Current Advance Amount:{' '} - { - table2Data.CustomerDetails[0] - .CurrentCreditBal - } -

    - ) : table2Data.CustomerDetails[0] - .CurrentCreditBal < 0 ? ( -

    - {' '} - Current Balance Amount:{' '} - {Math.abs( - table2Data.CustomerDetails[0] - .CurrentCreditBal - )} -

    - ) : null} -
    - )} + {/* CURRENT CREDIT BAL */} + {table2Data.CustomerDetails[0] + .CurrentCreditBal > 0 ? ( +

    + {' '} + Current Advance Amount:{' '} + { + table2Data.CustomerDetails[0] + .CurrentCreditBal + } +

    + ) : table2Data.CustomerDetails[0] + .CurrentCreditBal < 0 ? ( +

    + {' '} + Current Balance Amount:{' '} + {Math.abs( + table2Data.CustomerDetails[0] + .CurrentCreditBal + )} +

    + ) : null} +
    + )}
    - {(table2Data?.OrderType !== "E") && OrderDetailGST?.length > 0 && + {table2Data?.OrderType !== 'E' && + OrderDetailGST?.length > 0 && OrderDetailGST?.[0]?.TaxAmt > 0 && ( <> -

    - --------- GST Breakup Details -----------

    +

    + --------- GST Breakup Details + ----------- +

    - - + - - - @@ -1092,28 +1131,52 @@ const PrintA4Style11 = ({ {OrderDetailGST?.map((item) => ( - - - + + ))} @@ -1153,58 +1216,58 @@ const PrintA4Style11 = ({ {GlobaldummyData ? GlobalQrcodet && ( -
    - -
    - Scan to Pay{' '} +
    + +
    + Scan to Pay{' '} +
    +
    + ₹ + {GlobaldummyData + ? '1,066' + : Number( + table2Data?.NetAmount + ).toFixed(2)} +
    -
    - ₹ - {GlobaldummyData - ? '1,066' - : Number( - table2Data?.NetAmount - ).toFixed(2)} -
    -
    - ) + ) : Qrcodet && - paymentTypeUPI && ( -
    - -
    - Scan to Pay{' '} + paymentTypeUPI && ( +
    + +
    + Scan to Pay{' '} +
    +
    + ₹ + {GlobaldummyData + ? '1,066' + : Number( + table2Data?.NetAmount + ).toFixed(2)} +
    -
    - ₹ - {GlobaldummyData - ? '1,066' - : Number( - table2Data?.NetAmount - ).toFixed(2)} -
    -
    - )} + )}
    -

    - Notes : 10 days Return policy -

    +
    +

    + Notes : 10 days Return policy +

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

    - {Notestext} -

    +
    +

    + {Notestext} +

    -
    -
    - )} +
    +
    + )}
    {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 +

    + + + )} )} @@ -1497,60 +1560,60 @@ const PrintA4Style11 = ({ > {GlobaldummyData ? GlobalSlNo && ( - - ) + + ) : SLNO == true && ( - - )} + + )} {GlobaldummyData ? GlobalItem && : Item == true && } {GlobaldummyData ? GlobalHsnCode && ( - - ) + + ) : HsnCode == true && ( - - )} + + )} {GlobaldummyData ? GlobalQuantity && ( - - ) + + ) : Quantity == true && ( - ) + + ) : MRP == true && ( - - )} + + )} {GlobaldummyData ? GlobalRate && ( - - ) + + ) : Rate == true && ( - - )} + + )} {GlobaldummyData ? GlobalDiscount && ( - - ) + + ) : Discount == true && ( - - )} + + )} {GlobaldummyData ? GlobalTax && ( - - ) - : (Tax && table2Data?.OrderType !== 'E') && ( - - )} + + ) + : Tax && + table2Data?.OrderType !== 'E' && ( + + )} {GlobaldummyData ? GlobalAmount && ( - - ) + + ) : Amount == true && ( - - )} + + )} @@ -1676,158 +1740,159 @@ const PrintA4Style11 = ({ {GlobaldummyData ? GlobalSlNo && ( - - ) + + ) : SLNO == true && ( - - )} + + )} {GlobaldummyData ? GlobalItem && : Item == true && ( - - )} + + )} {GlobaldummyData ? GlobalHsnCode && ( - - ) + + ) : HsnCode == true && ( - - )} + + )} {GlobaldummyData ? GlobalQuantity && ( - - ) + + ) : Quantity == true && ( - - )} + + )} {GlobaldummyData ? GlobalMRP && ( - - ) + + ) : MRP == true && ( - - )} + + )} {GlobaldummyData ? GlobalRate && ( - - ) + + ) : Rate == true && ( - - )} + + )} {GlobaldummyData ? GlobalDiscount && ( - - ) + + ) : Discount == true && ( - - )} + + )} {GlobaldummyData ? GlobalTax && ( - - ) - : (Tax && table2Data?.OrderType !== 'E') && ( - - )} + + ) + : Tax && + table2Data?.OrderType !== 'E' && ( + + )} {GlobaldummyData ? GlobalAmount && ( - - ) + + ) : Amount == true && ( - - )} + + )} ))} @@ -1866,7 +1931,7 @@ const PrintA4Style11 = ({
    ITEMS
    Qty
    {TotalOfferAmount > 0 || - table2Data?.OverallDisc ? ( + table2Data?.OverallDisc ? (
    OFFER
    ) : ( '' @@ -1892,11 +1957,11 @@ const PrintA4Style11 = ({ : totalQuantity} {TotalOfferAmount > 0 || - table2Data?.OverallDisc ? ( + table2Data?.OverallDisc ? (
    {Number( TotalOfferAmount + - table2Data?.OverallDisc + table2Data?.OverallDisc ).toFixed(2)}
    ) : ( @@ -1919,8 +1984,8 @@ const PrintA4Style11 = ({ {GlobaldummyData ? '1066' : Number( - table2Data?.NetAmount - ).toFixed(2)} + table2Data?.NetAmount + ).toFixed(2)} @@ -1966,33 +2031,33 @@ const PrintA4Style11 = ({ )} {GlobaldummyData ? GlobalCredit && ( -
    -
    Advance Amount:
    -
    Opening Balance:
    -
    - ) +
    +
    Advance Amount:
    +
    Opening Balance:
    +
    + ) : CreditDetails && - table2Data?.CustomerDetails?.length > - 0 && ( -
    - {/* OLD CREDIT BAL */} - {PaymentStatusSuccess?.[0] - ?.PaymentTypeName === - 'Credit' && ( + table2Data?.CustomerDetails?.length > + 0 && ( +
    + {/* OLD CREDIT BAL */} + {PaymentStatusSuccess?.[0] + ?.PaymentTypeName === + 'Credit' && ( <> {table2Data.CustomerDetails[0] .OldCreditBal > 0 ? ( @@ -2005,8 +2070,8 @@ const PrintA4Style11 = ({ }

    ) : table2Data - .CustomerDetails[0] - .OldCreditBal < 0 ? ( + .CustomerDetails[0] + .OldCreditBal < 0 ? (

    {' '} Opening Balance:{' '} @@ -2020,51 +2085,88 @@ const PrintA4Style11 = ({ )} - {/* CURRENT CREDIT BAL */} - {table2Data.CustomerDetails[0] - .CurrentCreditBal > 0 ? ( -

    - {' '} - Current Advance Amount:{' '} - { - table2Data.CustomerDetails[0] - .CurrentCreditBal - } -

    - ) : table2Data.CustomerDetails[0] - .CurrentCreditBal < 0 ? ( -

    - {' '} - Current Balance Amount:{' '} - {Math.abs( - table2Data.CustomerDetails[0] - .CurrentCreditBal - )} -

    - ) : null} -
    - )} + {/* CURRENT CREDIT BAL */} + {table2Data.CustomerDetails[0] + .CurrentCreditBal > 0 ? ( +

    + {' '} + Current Advance Amount:{' '} + { + table2Data.CustomerDetails[0] + .CurrentCreditBal + } +

    + ) : table2Data.CustomerDetails[0] + .CurrentCreditBal < 0 ? ( +

    + {' '} + Current Balance Amount:{' '} + {Math.abs( + table2Data.CustomerDetails[0] + .CurrentCreditBal + )} +

    + ) : null} +
    + )}
    - {(table2Data?.OrderType !== "E") && OrderDetailGST?.length > 0 && + {table2Data?.OrderType !== 'E' && + OrderDetailGST?.length > 0 && OrderDetailGST?.[0]?.TaxAmt > 0 && ( <> -

    - --------- GST Breakup Details -----------

    +

    + --------- GST Breakup Details + ----------- +

    GST Rate + + GST Rate + Taxable Amount + CGST + SGST + Total
    + {item?.TaxPercentage}%{' '} - {' '} - {Number(item.WithOutTaxAmount).toFixed(2)}{' '} - - {' '} - {Number(item.CGST).toFixed(2)} - {' '} - {Number(item.SGST).toFixed(2)} + {Number( + item.WithOutTaxAmount + ).toFixed(2)}{' '} {' '} - {Number(item.TotalAmt).toFixed(2)} + {Number(item.CGST).toFixed( + 2 + )} + + {' '} + {Number(item.SGST).toFixed( + 2 + )} + + {' '} + {Number( + item.TotalAmt + ).toFixed(2)}
    - S.No - + S.No + - S.No - + S.No + ItemItem - HSN - + HSN + - HSN - + HSN + - Qty - + Qty + - MRP - + MRP + - MRP - + MRP + - Rate - + Rate + - Rate - + Rate + - Dis{' '} - + Dis{' '} + - Dis{' '} - + Dis{' '} + - Tax % - - Tax % - + Tax % + + Tax % + - Amt - + Amt + - Amt - + Amt +
    - {index + 1} - + {index + 1} + - {chunkIndex * chunkSize + index + 1} - + {chunkIndex * chunkSize + index + 1} + {item?.ProdName} -
    {item?.ProdName}
    -
    - ({item?.Size ? item?.Size : '1'}{' '} - {item?.SinglePc == 'Y' - ? 'PCS' - : item?.Type != 'C' - ? item?.UomName - : 'COMBO'} - ) -
    -  {' '} - {item?.BrandName !== null - ? item?.BrandName - : ''} -   - {item?.ProductIdentifierDtls - ?.length > 0 - ? item?.ProductIdentifierDtls?.filter( - (items) => - !( - items.SerialNumber == - '' || - items.SerialNumber == null - ) - )?.map((a) => { - return ( -
    {a.SerialNumber}
    - ); - }) - : ''}{' '} - {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(',')} -
    - ); - }) - : ''} -
    +
    {item?.ProdName}
    +
    + ({item?.Size ? item?.Size : '1'}{' '} + {item?.SinglePc == 'Y' + ? 'PCS' + : item?.Type != 'C' + ? item?.UomName + : 'COMBO'} + ) +
    +  {' '} + {item?.BrandName !== null + ? item?.BrandName + : ''} +   + {item?.ProductIdentifierDtls + ?.length > 0 + ? item?.ProductIdentifierDtls?.filter( + (items) => + !( + items.SerialNumber == + '' || + items.SerialNumber == null + ) + )?.map((a) => { + return ( +
    {a.SerialNumber}
    + ); + }) + : ''}{' '} + {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(',')} +
    + ); + }) + : ''} +
    - {item?.HSN} - + {item?.HSN} + - {item?.HSN} - + {item?.HSN} + - {item?.SalesQty} - + {item?.SalesQty} + - {item?.SalesQty} - + {item?.SalesQty} + - {item?.MRP} - + {item?.MRP} + - {item?.SinglePc === 'Y' - ? item?.Rate - : item?.MRP} - + {item?.SinglePc === 'Y' + ? item?.Rate + : item?.MRP} + - {item?.Rate} - + {item?.Rate} + - {' '} - {item?.Rate} - + {' '} + {item?.Rate} + {item.discount}{item.discount} - {item?.Type != 'C' - ? item?.OfferAmt || 0 - : item?.OfferValue || 0} - + {item?.Type != 'C' + ? item?.OfferAmt || 0 + : item?.OfferValue || 0} + {item.ProdTaxPercentage} - {item?.ProdTaxPercentage || 0} - {item.ProdTaxPercentage} + {item?.ProdTaxPercentage || 0} + - {item?.TotalAmt} - + {item?.TotalAmt} + - {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} +
    - - + - - - @@ -2072,28 +2174,52 @@ const PrintA4Style11 = ({ {OrderDetailGST?.map((item) => ( - - - + + ))} @@ -2131,58 +2257,58 @@ const PrintA4Style11 = ({ {GlobaldummyData ? GlobalQrcodet && ( -
    - -
    - Scan to Pay{' '} +
    + +
    + Scan to Pay{' '} +
    +
    + ₹ + {GlobaldummyData + ? '1,066' + : Number( + table2Data?.NetAmount + ).toFixed(2)} +
    -
    - ₹ - {GlobaldummyData - ? '1,066' - : Number( - table2Data?.NetAmount - ).toFixed(2)} -
    -
    - ) + ) : Qrcodet && - paymentTypeUPI && ( -
    - -
    - Scan to Pay{' '} + paymentTypeUPI && ( +
    + +
    + Scan to Pay{' '} +
    +
    + ₹ + {GlobaldummyData + ? '1,066' + : Number( + table2Data?.NetAmount + ).toFixed(2)} +
    -
    - ₹ - {GlobaldummyData - ? '1,066' - : Number( - table2Data?.NetAmount - ).toFixed(2)} -
    -
    - )} + )}
    -

    - Notes : 10 days Return policy -

    +
    +

    + Notes : 10 days Return policy +

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

    - {Notestext} -

    +
    +

    + {Notestext} +

    -
    -
    - )} +
    +
    + )}
    {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 +

    + + + )} )} @@ -2558,34 +2684,34 @@ const PrintA4Style11 = ({ )} {GlobaldummyData ? GlobalCredit && ( -
    -
    Advance Amount:
    -
    Opening Balance:
    -
    - ) +
    +
    Advance Amount:
    +
    Opening Balance:
    +
    + ) : CreditDetails && - table2Data?.CustomerDetails?.length > 0 && ( -
    - {/* OLD CREDIT BAL */} - {PaymentStatusSuccess?.[0]?.PaymentTypeName === - 'Credit' && ( + table2Data?.CustomerDetails?.length > 0 && ( +
    + {/* OLD CREDIT BAL */} + {PaymentStatusSuccess?.[0]?.PaymentTypeName === + 'Credit' && ( <> {table2Data.CustomerDetails[0].OldCreditBal > - 0 ? ( + 0 ? (

    Advance Amount: {table2Data.CustomerDetails[0].OldCreditBal} @@ -2603,47 +2729,68 @@ const PrintA4Style11 = ({ )} - {/* CURRENT CREDIT BAL */} - {table2Data.CustomerDetails[0].CurrentCreditBal > + {/* CURRENT CREDIT BAL */} + {table2Data.CustomerDetails[0].CurrentCreditBal > 0 ? ( -

    - {' '} - Current Advance Amount:{' '} - {table2Data.CustomerDetails[0].CurrentCreditBal} -

    - ) : table2Data.CustomerDetails[0].CurrentCreditBal < - 0 ? ( -

    - {' '} - Current Balance Amount:{' '} - {Math.abs( - table2Data.CustomerDetails[0].CurrentCreditBal - )} -

    - ) : null} -
    - )} +

    + {' '} + Current Advance Amount:{' '} + {table2Data.CustomerDetails[0].CurrentCreditBal} +

    + ) : table2Data.CustomerDetails[0].CurrentCreditBal < + 0 ? ( +

    + {' '} + Current Balance Amount:{' '} + {Math.abs( + table2Data.CustomerDetails[0].CurrentCreditBal + )} +

    + ) : null} +
    + )}
    - {(table2Data?.OrderType !== "E") && OrderDetailGST?.length > 0 && + {table2Data?.OrderType !== 'E' && + OrderDetailGST?.length > 0 && OrderDetailGST?.[0]?.TaxAmt > 0 && ( <> -

    - --------- GST Breakup Details -----------

    +

    + --------- GST Breakup Details ----------- +

    GST Rate + + GST Rate + Taxable Amount + CGST + SGST + Total
    + {item?.TaxPercentage}%{' '} - {' '} - {Number(item.WithOutTaxAmount).toFixed(2)}{' '} - - {' '} - {Number(item.CGST).toFixed(2)} - {' '} - {Number(item.SGST).toFixed(2)} + {Number( + item.WithOutTaxAmount + ).toFixed(2)}{' '} {' '} - {Number(item.TotalAmt).toFixed(2)} + {Number(item.CGST).toFixed( + 2 + )} + + {' '} + {Number(item.SGST).toFixed( + 2 + )} + + {' '} + {Number( + item.TotalAmt + ).toFixed(2)}
    - - + - - - @@ -2656,21 +2803,19 @@ const PrintA4Style11 = ({ - - @@ -2710,54 +2855,54 @@ const PrintA4Style11 = ({ {GlobaldummyData ? GlobalQrcodet && ( -
    - -
    - Scan to Pay{' '} +
    + +
    + Scan to Pay{' '} +
    +
    + ₹ + {GlobaldummyData + ? '1,066' + : Number(table2Data?.NetAmount).toFixed(2)} +
    -
    - ₹ - {GlobaldummyData - ? '1,066' - : Number(table2Data?.NetAmount).toFixed(2)} -
    -
    - ) + ) : Qrcodet && - paymentTypeUPI && ( -
    - -
    - Scan to Pay{' '} + paymentTypeUPI && ( +
    + +
    + Scan to Pay{' '} +
    +
    + ₹ + {GlobaldummyData + ? '1,066' + : Number(table2Data?.NetAmount).toFixed(2)} +
    -
    - ₹ - {GlobaldummyData - ? '1,066' - : Number(table2Data?.NetAmount).toFixed(2)} -
    -
    - )} + )}
    -

    - Notes : 10 days Return policy -

    +
    +

    + Notes : 10 days Return policy +

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

    - {Notestext} -

    +
    +

    + {Notestext} +

    -
    -
    - )} +
    +
    + )}
    {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. -
    -
    - ) - : TermsnAdCondition == true && - TermsAndConditions?.length > 0 && ( -
    -

    - Terms & Conditions -

    -
      - {TermsAndConditions?.map((item) => ( -
    1. - {item?.TermsandConditions} +

      + Terms & Conditions +

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

    + 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 +

    + + + )} )} @@ -3105,31 +3250,31 @@ const PrintA4Style11 = ({ )} {GlobaldummyData ? GlobalCredit && ( -
    -
    Advance Amount:
    -
    Opening Balance:
    -
    - ) +
    +
    Advance Amount:
    +
    Opening Balance:
    +
    + ) : CreditDetails && - table2Data?.CustomerDetails?.length > 0 && ( -
    - {/* OLD CREDIT BAL */} - {PaymentStatusSuccess?.[0]?.PaymentTypeName === - 'Credit' && ( + table2Data?.CustomerDetails?.length > 0 && ( +
    + {/* OLD CREDIT BAL */} + {PaymentStatusSuccess?.[0]?.PaymentTypeName === + 'Credit' && ( <> {table2Data.CustomerDetails[0].OldCreditBal > 0 ? (

    @@ -3149,36 +3294,47 @@ const PrintA4Style11 = ({ )} - {/* CURRENT CREDIT BAL */} - {table2Data.CustomerDetails[0].CurrentCreditBal > 0 ? ( -

    - {' '} - Current Advance Amount:{' '} - {table2Data.CustomerDetails[0].CurrentCreditBal} -

    - ) : table2Data.CustomerDetails[0].CurrentCreditBal < - 0 ? ( -

    - {' '} - Current Balance Amount:{' '} - {Math.abs( - table2Data.CustomerDetails[0].CurrentCreditBal - )} -

    - ) : null} -
    - )} + {/* CURRENT CREDIT BAL */} + {table2Data.CustomerDetails[0].CurrentCreditBal > 0 ? ( +

    + {' '} + Current Advance Amount:{' '} + {table2Data.CustomerDetails[0].CurrentCreditBal} +

    + ) : table2Data.CustomerDetails[0].CurrentCreditBal < + 0 ? ( +

    + {' '} + Current Balance Amount:{' '} + {Math.abs( + table2Data.CustomerDetails[0].CurrentCreditBal + )} +

    + ) : null} +
    + )}
    - {(table2Data?.OrderType !== "E") && OrderDetailGST?.length > 0 && + {table2Data?.OrderType !== 'E' && + OrderDetailGST?.length > 0 && OrderDetailGST?.[0]?.TaxAmt > 0 && ( <> -

    - --------- GST Breakup Details -----------

    +

    + --------- GST Breakup Details ----------- +

    GST Rate + + GST Rate + Taxable Amount + CGST + SGST + Total
    {' '} - {Number(item.WithOutTaxAmount).toFixed(2)}{' '} + {Number(item.WithOutTaxAmount).toFixed( + 2 + )}{' '} {' '} {Number(item.CGST).toFixed(2)} + {' '} {Number(item.SGST).toFixed(2)} + {' '} {Number(item.TotalAmt).toFixed(2)}
    - + @@ -3207,15 +3363,11 @@ const PrintA4Style11 = ({ {' '} {Number(item.CGST).toFixed(2)} - - @@ -3255,50 +3407,50 @@ const PrintA4Style11 = ({ {GlobaldummyData ? GlobalQrcodet && ( -
    - -
    Scan to Pay
    -
    - ₹ - {GlobaldummyData - ? '1,066' - : Number(table2Data?.NetAmount).toFixed(2)} +
    + +
    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)} +
    -
    - )} + )}
    -

    - Notes : 10 days Return policy -

    +
    +

    + Notes : 10 days Return policy +

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

    - {Notestext} -

    +
    +

    + {Notestext} +

    -
    -
    - )} +
    +
    + )}
    {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. -
    -
    - ) - : TermsnAdCondition == true && - TermsAndConditions?.length > 0 && ( -
    -

    - Terms & Conditions -

    -
      - {TermsAndConditions?.map((item) => ( -
    1. - {item?.TermsandConditions} +

      + Terms & Conditions +

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

    + 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/BookingScreen/PrintTemplates/A4/TaxInvoice.jsx b/src/Pages/BookingScreen/PrintTemplates/A4/TaxInvoice.jsx index fc9e823..f4c6f83 100644 --- a/src/Pages/BookingScreen/PrintTemplates/A4/TaxInvoice.jsx +++ b/src/Pages/BookingScreen/PrintTemplates/A4/TaxInvoice.jsx @@ -1,6 +1,9 @@ import React from 'react'; import { useSelector } from 'react-redux'; -import { GlobalPritdummyData } from '../../../../Features/ThemeChange/ThemeChange'; +import { + GlobalPritdummyData, + GlobalSelectedPrintHeaderColor, +} from '../../../../Features/ThemeChange/ThemeChange'; import { isMobile } from 'react-device-detect'; import { extractLastNumberOrderId } from '../../../../Services/Others'; import moment from 'moment'; @@ -29,6 +32,8 @@ const TaxInvoice = ({ )?.SettingValue === 'Y'; let BillName = printDatas?.PrintHdrName; let companyColour = printDatas?.PrintHdrColor ?? '#00000'; + + const SelectedHeaderColor = useSelector(GlobalSelectedPrintHeaderColor); // Function to convert number to words const numberToWords = (num) => { const a = [ @@ -481,11 +486,12 @@ const TaxInvoice = ({ {invoiceData.customerMobile && (
    Mobile: {invoiceData.customerMobile}
    )} - {(invoiceData.customerGSTIN && table2Data?.OrderType !== 'E') && ( -
    - GSTIN/UIN: {invoiceData.customerGSTIN} -
    - )} + {invoiceData.customerGSTIN && + table2Data?.OrderType !== 'E' && ( +
    + GSTIN/UIN: {invoiceData.customerGSTIN} +
    + )} {invoiceData.customerAddress.state && (
    State Name: {invoiceData.customerAddress.state}
    )} diff --git a/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle1.jsx b/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle1.jsx index 0ab9975..74a9c94 100644 --- a/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle1.jsx +++ b/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle1.jsx @@ -30,6 +30,7 @@ import { GlobalprintLogo, GlobalprintCredit, GlobalprintTax, + GlobalSelectedPrintHeaderColor, } from '../../../../Features/ThemeChange/ThemeChange'; import '../../../../Styles/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle1.scss'; import QRCode from 'react-qr-code'; @@ -95,6 +96,7 @@ const PrintStyle1 = ({ const GlobalCashierName = useSelector(GlobalprintCashierName); const GlobalLogo = useSelector(GlobalprintLogo); const GlobalCredit = useSelector(GlobalprintCredit); + const SelectedHeaderColor = useSelector(GlobalSelectedPrintHeaderColor); const GlobaltermsAndConditions = useSelector(GlobalprinttermsAndConditions); const GlobalSignatureImages = useSelector(GlobalSignatureImage); @@ -236,9 +238,12 @@ const PrintStyle1 = ({ } }); const hasMappedOffer = offers.some((offer) => - ['ItemWiseOffers', 'BundleOffers', 'QuantityWiseOffers', 'MemberShip'].includes( - offer.TableName - ) + [ + 'ItemWiseOffers', + 'BundleOffers', + 'QuantityWiseOffers', + 'MemberShip', + ].includes(offer.TableName) ); if (hasMappedOffer) { @@ -447,6 +452,7 @@ const PrintStyle1 = ({ style={{ fontSize: 'clamp(2rem, 2.5vw, 2rem)', fontWeight: '600', + color: SelectedHeaderColor, }} > {' '} @@ -3691,6 +3697,7 @@ const PrintStyle1 = ({ style={{ fontSize: 'clamp(2rem, 2.5vw, 2rem)', fontWeight: '600', + color: SelectedHeaderColor, }} > {' '} diff --git a/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle10.jsx b/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle10.jsx index 424951b..a378875 100644 --- a/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle10.jsx +++ b/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle10.jsx @@ -27,6 +27,7 @@ import { GlobalprintLogo, GlobalprintCredit, GlobalprintTax, + GlobalSelectedPrintHeaderColor, } from '../../../../Features/ThemeChange/ThemeChange'; import { GlobalUpiIDprint, @@ -121,6 +122,7 @@ const PrintStyle10 = ({ const paymentTypeUPI = PaymentStatus?.find( (ps) => ps.PaymentTypeName === 'UPI' ); + const SelectedHeaderColor = useSelector(GlobalSelectedPrintHeaderColor); const isEditedBill = PaymentStatus?.some((payment) => { const type = payment?.AdjustmentType?.toLowerCase(); @@ -419,7 +421,13 @@ const PrintStyle10 = ({
    -
    +
    {GlobaldummyData ? 'ABC Shop' : table2Data?.BrName}{' '} @@ -3078,7 +3086,10 @@ const PrintStyle10 = ({
    -
    +
    {GlobaldummyData ? 'ABC Shop' : table2Data?.BrName}{' '}
    {GlobaldummyData diff --git a/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle11.jsx b/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle11.jsx index 10d41cf..b12c765 100644 --- a/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle11.jsx +++ b/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle11.jsx @@ -29,6 +29,7 @@ import { GlobalprintLogo, GlobalprintCredit, GlobalprintTax, + GlobalSelectedPrintHeaderColor, } from '../../../../Features/ThemeChange/ThemeChange'; import { GlobalUpiIDprint, @@ -405,6 +406,7 @@ const PrintStyle11 = ({ fontWeight: '600', // fontFamily: "Lemon", fontSize: 'clamp(1rem, 2.5vw, 2.5rem)', + color: SelectedHeaderColor, }} > {GlobaldummyData ? 'XYZ Shop' : table2Data?.BrName} @@ -3051,6 +3053,7 @@ const PrintStyle11 = ({ fontWeight: '600', // fontFamily: "Lemon", fontSize: 'clamp(1rem, 2.5vw, 2.5rem)', + color: SelectedHeaderColor, }} > {GlobaldummyData ? 'XYZ Shop' : table2Data?.BrName} @@ -3155,7 +3158,7 @@ const PrintStyle11 = ({
    GST Rate + GST Rate + Taxable Amount + {' '} {Number(item.SGST).toFixed(2)} + {' '} {Number(item.TotalAmt).toFixed(2)}
    diff --git a/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle12.jsx b/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle12.jsx index e23e409..5197d9b 100644 --- a/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle12.jsx +++ b/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle12.jsx @@ -30,6 +30,7 @@ import { GlobalprintLogo, GlobalprintCredit, GlobalprintTax, + GlobalSelectedPrintHeaderColor, } from '../../../../Features/ThemeChange/ThemeChange'; import { GlobalUpiIDprint, @@ -540,6 +541,7 @@ const Printstyle12 = ({ style={{ fontSize: 'clamp(0.75rem, 2.5vw, 1.8rem)', fontWeight: '600', + color: SelectedHeaderColor, }} > {GlobaldummyData ? 'XYZ Shop' : table2Data?.BrName} @@ -1427,7 +1429,6 @@ const Printstyle12 = ({ )} )} - {table2Data?.OrderType === 'E' ? ( '' ) : ( @@ -1756,7 +1757,6 @@ const Printstyle12 = ({ : 0} - {/*
    Recived Amt @@ -2420,7 +2420,6 @@ const Printstyle12 = ({ )} )} - {!estimatePrintHeader && table2Data?.OrderType === 'E' ? ( '' ) : ( @@ -3217,6 +3216,7 @@ const Printstyle12 = ({ style={{ fontSize: 'clamp(0.75rem, 2.5vw, 1.8rem)', fontWeight: '600', + color: SelectedHeaderColor, }} > {GlobaldummyData ? 'XYZ Shop' : table2Data?.BrName} @@ -4000,7 +4000,6 @@ const Printstyle12 = ({ ))} )} - {table2Data?.OrderType === 'E' ? ( '' ) : ( diff --git a/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle2.jsx b/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle2.jsx index 0da37c3..c6180c8 100644 --- a/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle2.jsx +++ b/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle2.jsx @@ -28,6 +28,7 @@ import { GlobalprintLogo, GlobalprintCredit, GlobalprintTax, + GlobalSelectedPrintHeaderColor, } from '../../../../Features/ThemeChange/ThemeChange'; import Logo from '../../../../Images/Logo.jpg'; import QRCode from 'react-qr-code'; @@ -93,6 +94,7 @@ const Printstyle2 = ({ const paymentTypeUPI = PaymentStatus?.find( (ps) => ps.PaymentTypeName === 'UPI' ); + const SelectedHeaderColor = useSelector(GlobalSelectedPrintHeaderColor); console.log(Qrcodet, 'Qrcodet', paymentTypeUPI); const GlobalSignature = useSelector(GlobalprintSignature); const GlobaltermsAndConditions = useSelector(GlobalprinttermsAndConditions); @@ -411,7 +413,13 @@ const Printstyle2 = ({ fontWeight: '600', }} > -
    +
    {GlobaldummyData ? 'XYZ Shop' : table2Data?.BrName}
    @@ -3029,7 +3037,13 @@ const Printstyle2 = ({ fontWeight: '600', }} > -
    +
    {GlobaldummyData ? 'XYZ Shop' : table2Data?.BrName}
    diff --git a/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle4.jsx b/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle4.jsx index c164376..994362e 100644 --- a/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle4.jsx +++ b/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle4.jsx @@ -28,9 +28,13 @@ import { GlobalprintLogo, GlobalprintCredit, GlobalprintTax, + GlobalSelectedPrintHeaderColor, } from '../../../../Features/ThemeChange/ThemeChange'; import '../../../../Styles/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle4.scss'; -import { GlobalUpiIDprint, PreferenceData } from '../../../../Features/BookingScreen/BookingData/BookingData'; +import { + GlobalUpiIDprint, + PreferenceData, +} from '../../../../Features/BookingScreen/BookingData/BookingData'; import QRCode from 'react-qr-code'; import signature from '../../../../Images/signatureimage.jpg'; import { ApplicationPreferences } from '../../../../Features/BrachLogin/BranchLogin'; @@ -131,6 +135,7 @@ const Printstyle4 = ({ const paymentTypeUPI = PaymentStatus?.find( (ps) => ps.PaymentTypeName === 'UPI' ); + const SelectedHeaderColor = useSelector(GlobalSelectedPrintHeaderColor); console.log(GlobalDiscount, Discount, 'Discount'); @@ -423,6 +428,7 @@ const Printstyle4 = ({ fontWeight: '600', width: '100%', textAlign: 'center', + color: SelectedHeaderColor, }} > {GlobaldummyData ? 'XYZ Shop' : table2Data?.BrName}{' '} @@ -564,15 +570,15 @@ const Printstyle4 = ({ ) : Quantity && ( -
    - )} + + )} {GlobaldummyData ? GlobalHsnCode && (
    - {WeightasKg ? 'Qty/Kg' : 'Qty'} - + {WeightasKg ? 'Qty/Kg' : 'Qty'} + ps.PaymentTypeName === 'UPI' ); + const SelectedHeaderColor = useSelector(GlobalSelectedPrintHeaderColor); + console.log(GlobalDiscount, Discount, 'Discount'); let TermsAndConditions = printDatas?.TermsandConditions; @@ -394,6 +397,7 @@ const PrintStyle5 = ({ style={{ fontSize: 'clamp(2rem, 2.5vw, 2rem)', fontWeight: '600', + color: SelectedHeaderColor, }} > {GlobaldummyData ? 'XYZ Shop' : table2Data?.BrName} @@ -2686,6 +2690,7 @@ const PrintStyle5 = ({ style={{ fontSize: 'clamp(2rem, 2.5vw, 2rem)', fontWeight: '600', + color: SelectedHeaderColor, }} > {GlobaldummyData ? 'XYZ Shop' : table2Data?.BrName} diff --git a/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle6.jsx b/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle6.jsx index fde7306..f4ea976 100644 --- a/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle6.jsx +++ b/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle6.jsx @@ -29,6 +29,7 @@ import { GlobalprintLogo, GlobalprintCredit, GlobalprintTax, + GlobalSelectedPrintHeaderColor, } from '../../../../Features/ThemeChange/ThemeChange'; import { GlobalUpiIDprint, @@ -412,7 +413,9 @@ const Printstyle6 = ({ /> ) : null} - {GlobaldummyData ? 'XYZ Shop' : table2Data?.BrName} +
    + {GlobaldummyData ? 'XYZ Shop' : table2Data?.BrName} +
    @@ -3264,7 +3267,9 @@ const Printstyle6 = ({ /> ) : null}
    - {GlobaldummyData ? 'XYZ Shop' : table2Data?.BrName} +
    + {GlobaldummyData ? 'XYZ Shop' : table2Data?.BrName} +
    diff --git a/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle7.jsx b/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle7.jsx index 85ed1dd..6d67baa 100644 --- a/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle7.jsx +++ b/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle7.jsx @@ -25,6 +25,7 @@ import { GlobalprintLogo, GlobalprintCredit, GlobalprintTax, + GlobalSelectedPrintHeaderColor, } from '../../../../Features/ThemeChange/ThemeChange'; import Logo from '../../../../Images/Logo.jpg'; import { @@ -423,7 +424,13 @@ const PrintStyle7 = ({ width={100} /> ) : null} -
    +
    {' '} {GlobaldummyData ? 'XYZ Shop' : table2Data?.BrName}
    @@ -1591,7 +1598,7 @@ const PrintStyle7 = ({ style={{ marginLeft: '13px', padding: 0, - fontSize: '10px', + fontSize: '8px', fontWeight: '600', }} > @@ -1609,7 +1616,7 @@ const PrintStyle7 = ({ style={{ marginLeft: '13px', padding: 0, - fontSize: '10px', + fontSize: '8px', fontWeight: '600', }} > @@ -2495,7 +2502,7 @@ const PrintStyle7 = ({ style={{ marginLeft: '13px', padding: 0, - fontSize: '10px', + fontSize: '8px', fontWeight: '600', }} > @@ -2513,7 +2520,7 @@ const PrintStyle7 = ({ style={{ marginLeft: '13px', padding: 0, - fontSize: '10px', + fontSize: '8px', fontWeight: '600', }} > @@ -2869,7 +2876,13 @@ const PrintStyle7 = ({ width={100} /> ) : null} -
    +
    {' '} {GlobaldummyData ? 'XYZ Shop' : table2Data?.BrName}
    @@ -3964,7 +3977,7 @@ const PrintStyle7 = ({ style={{ marginLeft: '13px', padding: 0, - fontSize: '10px', + fontSize: '8px', fontWeight: '600', }} > @@ -3982,7 +3995,7 @@ const PrintStyle7 = ({ style={{ marginLeft: '13px', padding: 0, - fontSize: '10px', + fontSize: '8px', fontWeight: '600', }} > @@ -3996,7 +4009,7 @@ const PrintStyle7 = ({ style={{ marginLeft: '13px', padding: 0, - fontSize: '10px', + fontSize: '8px', fontWeight: '600', }} > diff --git a/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle8.jsx b/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle8.jsx index 4a347d7..42da6c2 100644 --- a/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle8.jsx +++ b/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle8.jsx @@ -28,6 +28,7 @@ import { GlobalprintLogo, GlobalprintCredit, GlobalprintTax, + GlobalSelectedPrintHeaderColor, } from '../../../../Features/ThemeChange/ThemeChange'; import Logo from '../../../../Images/Logo.jpg'; import { @@ -140,6 +141,10 @@ const Printstyle8 = ({ (ps) => ps.PaymentStatus === 'S' && ps?.LastOrderTran === 'Y' ); + const SelectedHeaderColor = useSelector(GlobalSelectedPrintHeaderColor); + + console.log(GlobalDiscount, Discount, 'Discount'); + let TermsAndConditions = printDatas?.TermsandConditions; let SignatureImg = printDatas?.Signature; let Notestext = printDatas?.Notes; @@ -436,6 +441,7 @@ const Printstyle8 = ({ style={{ fontSize: 'clamp(1.25rem, 2.5vw, 1.75rem)', fontWeight: '600', + color: SelectedHeaderColor, }} > {GlobaldummyData ? 'XYZ Shop' : table2Data?.BrName} @@ -1763,7 +1769,6 @@ const Printstyle8 = ({ padding: 0, fontSize: '15px', fontWeight: '600', - textAlign: 'center', }} > {PaymentStatusSuccess?.length === 1 @@ -1870,6 +1875,7 @@ const Printstyle8 = ({ {GlobaldummyData && GlobalCashierName && (
    -
    +
    Your Order No : {GlobaldummyData ? '01' @@ -2761,7 +2762,6 @@ const Printstyle8 = ({ padding: 0, fontSize: '15px', fontWeight: '600', - textAlign: 'center', }} > {PaymentStatusSuccess?.length === 1 @@ -2868,6 +2868,7 @@ const Printstyle8 = ({ {GlobaldummyData && GlobalCashierName && (
    -
    +
    Your Order No : {GlobaldummyData ? '01' @@ -3247,6 +3243,7 @@ const Printstyle8 = ({ style={{ fontSize: 'clamp(1.25rem, 2.5vw, 1.75rem)', fontWeight: '600', + color: SelectedHeaderColor, }} > {GlobaldummyData ? 'XYZ Shop' : table2Data?.BrName} @@ -4272,7 +4269,7 @@ const Printstyle8 = ({
    )}
    - +
    {PaymentStatusSuccess?.length === 1 @@ -4442,6 +4438,7 @@ const Printstyle8 = ({ {GlobaldummyData && GlobalCashierName && (
    -
    +
    Your Order No : {GlobaldummyData ? '01' diff --git a/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle9.jsx b/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle9.jsx index d7f4463..22fc721 100644 --- a/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle9.jsx +++ b/src/Pages/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle9.jsx @@ -28,6 +28,7 @@ import { GlobalprintLogo, GlobalprintCredit, GlobalprintTax, + GlobalSelectedPrintHeaderColor, } from '../../../../Features/ThemeChange/ThemeChange'; import Logo from '../../../../Images/Logo.jpg'; import { @@ -135,6 +136,7 @@ const PrintStyle9 = ({ (ps) => ps.PaymentStatus === 'S' && ps?.LastOrderTran === 'Y' ); + const SelectedHeaderColor = useSelector(GlobalSelectedPrintHeaderColor); let TermsAndConditions = printDatas?.TermsandConditions; let SignatureImg = printDatas?.Signature; let Notestext = printDatas?.Notes; @@ -427,6 +429,7 @@ const PrintStyle9 = ({ style={{ fontSize: 'clamp(1.5rem, 2.5vw, 2rem)', fontWeight: '600', + color: SelectedHeaderColor, }} className="PrintStyle9-Branch" > @@ -3164,6 +3167,7 @@ const PrintStyle9 = ({ style={{ fontSize: 'clamp(1.5rem, 2.5vw, 2rem)', fontWeight: '600', + color: SelectedHeaderColor, }} className="PrintStyle9-Branch" > diff --git a/src/Pages/BookingScreen/Template/SalesCountForStandard.jsx b/src/Pages/BookingScreen/Template/SalesCountForStandard.jsx index 2ec42d9..1bd9777 100644 --- a/src/Pages/BookingScreen/Template/SalesCountForStandard.jsx +++ b/src/Pages/BookingScreen/Template/SalesCountForStandard.jsx @@ -60,6 +60,7 @@ import { GoPackageDependencies } from 'react-icons/go'; import { Messages } from '../../../../ownLib/my-ui-lib.js'; import ShortcutKeyHelper from '../Components/UtillComponents/ShortcutKeyHelper.jsx'; +import AllSalesPageSettings from '../Components/UtillComponents/AllSalesPageSettings.jsx'; const SalesCountForStandard = ({ DineInAccess, @@ -830,6 +831,7 @@ const SalesCountForStandard = ({ )} {preferenceshortcutkey && } +
    {Customisebillno && } {SessionData?.FeatureAddonData?.FeatureDtls?.find( diff --git a/src/Pages/Payment/PaymentOptions/PaymentOptions.jsx b/src/Pages/Payment/PaymentOptions/PaymentOptions.jsx index 0063f77..c475635 100644 --- a/src/Pages/Payment/PaymentOptions/PaymentOptions.jsx +++ b/src/Pages/Payment/PaymentOptions/PaymentOptions.jsx @@ -33,7 +33,7 @@ import { FaCreditCard } from 'react-icons/fa'; const subDirectory = import.meta.env.BASE_URL; -function PaymentOptions() { +function PaymentOptions({ setModalOpen }) { const { SadminuserAccess } = useAuth(); let SAAccessCommonMaster = SadminuserAccess?.find( (e) => e?.MenuName === 'Payment Options' @@ -1356,6 +1356,7 @@ function PaymentOptions() { : 'Data Updated Successfully' ); await dispatch(changeSalesPaymentoption(false)); + setModalOpen(false) // ✅ Call the function here to update global state try { await fetchAndSetPaymentOptions(dispatch, { diff --git a/src/Pages/Preference/PreferenceList.jsx b/src/Pages/Preference/PreferenceList.jsx index 9bb5ac1..614f123 100644 --- a/src/Pages/Preference/PreferenceList.jsx +++ b/src/Pages/Preference/PreferenceList.jsx @@ -752,8 +752,7 @@ const PreferenceList = () => { {renderCheckbox('scanlayout', 'Do you Want Scan Layout Page?')}
    - -
    +
    div { - font-family: 'Poppins'; + font-family: "Poppins"; font-weight: 400; font-size: 14px; margin: 4px 0; @@ -154,3 +149,13 @@ } } } +.PreferencesBTN { + display: flex; + align-items: flex-start; + justify-content: flex-end; + width: 100%; + margin-top: 1rem; + .primary_Button { + width: 200px !important; + } +} diff --git a/src/Pages/PurchaseOrder/PurchaseOrder.jsx b/src/Pages/PurchaseOrder/PurchaseOrder.jsx index 49deea0..6f2f9b3 100644 --- a/src/Pages/PurchaseOrder/PurchaseOrder.jsx +++ b/src/Pages/PurchaseOrder/PurchaseOrder.jsx @@ -970,7 +970,7 @@ console.log('hi'); PostData['LocationType'] = Supplierdata?.find( (find) => find.SuppId === selecPurSupplier )?.Type; - PostData['DeliveryAddressDetails'] = deliveryAddress; + PostData['DeliveryAddressDetails'] = [deliveryAddress]; let PostPurOrder = await dispatch(postPurcOrderData(PostData)).unwrap(); if (PostPurOrder?.data?.statusCode === 1) { setMessage({ type: 'success', data: PostPurOrder?.data?.response }); @@ -2371,7 +2371,7 @@ console.log('hi'); > Address} + label={} /> Address} + label={} /> p?.PreferredCatName?.toLowerCase() === "purchase receipt bulk" + (p) => p?.PreferredCatName?.toLowerCase() === 'purchase receipt bulk' )?.PreferredCatId; const [worksheet1, setWorksheet1] = useState(null); const [editdelete, seteditdelete] = useState(''); const [Datas, setDatas] = useState(); - console.log(Datas, "Datas") + console.log(Datas, 'Datas'); const [showSupplierModal, setShowSupplierModal] = useState(false); const [suppliers, setSuppliers] = useState([]); const [selectedSupplier, setSelectedSupplier] = useState(null); @@ -96,7 +105,7 @@ const StockExcel = ({ useEffect(() => { getFieldSetup(); - }, [purchaseReceiptBulkUploadCatId]) + }, [purchaseReceiptBulkUploadCatId]); const onComplete = useCallback(() => { setMessageData(null); @@ -105,19 +114,33 @@ const StockExcel = ({ const getFieldSetup = async () => { try { - const response = await dispatch(getFieldSetupData({ AppId, CompId, BranchId, categoryId: purchaseReceiptBulkUploadCatId, Type: 'EB' })).unwrap(); + const response = await dispatch( + getFieldSetupData({ + AppId, + CompId, + BranchId, + categoryId: purchaseReceiptBulkUploadCatId, + Type: 'EB', + }) + ).unwrap(); if (response?.data?.statusCode === 1) { - console.log(response?.data?.data?.[0]?.ConfigDtl, "Field Setup Data"); - setSelectedFields(response?.data?.data?.[0]?.ConfigDtl?.filter(c => c.ConfigId && c.Access === 'Y')?.map(c => c.ConfigId) || []); - setTableFieldPreferences(response?.data?.data?.[0]?.ConfigDtl?.map(c => ({ - value: c.ConfigId, - label: c.ConfigName, - access: c.Access - })) || []); + console.log(response?.data?.data?.[0]?.ConfigDtl, 'Field Setup Data'); + setSelectedFields( + response?.data?.data?.[0]?.ConfigDtl?.filter( + (c) => c.ConfigId && c.Access === 'Y' + )?.map((c) => c.ConfigId) || [] + ); + setTableFieldPreferences( + response?.data?.data?.[0]?.ConfigDtl?.map((c) => ({ + value: c.ConfigId, + label: c.ConfigName, + access: c.Access, + })) || [] + ); setFieldValues(response?.data?.data?.[0]?.ConfigDtl); } else { - setMessageType("error"); - setMessageData("Failed to fetch field setup"); + setMessageType('error'); + setMessageData('Failed to fetch field setup'); } } catch (error) { console.error('Error fetching field setup:', error); @@ -131,7 +154,7 @@ const StockExcel = ({ slicedData.forEach((item, index) => { // Skip empty rows - if (!item || Object.values(item).every(val => !val)) return; + if (!item || Object.values(item).every((val) => !val)) return; const rowData = { key: index, @@ -164,8 +187,10 @@ const StockExcel = ({ if (String(supplierValue).trim() === 'Self') { rowData.OwnWithPaid = item['2']; // Shift all subsequent columns by 1 - Object.keys(rowData).forEach(key => { - if (!['key', 'InwardDate', 'Supplier', 'OwnWithPaid'].includes(key)) { + Object.keys(rowData).forEach((key) => { + if ( + !['key', 'InwardDate', 'Supplier', 'OwnWithPaid'].includes(key) + ) { const currentIndex = parseInt(Object.keys(rowData).indexOf(key)); rowData[key] = item[currentIndex.toString()]; } @@ -182,18 +207,26 @@ const StockExcel = ({ { key: 'BatchNo', header: 'Batch No.' }, { key: 'ModelNo', header: 'Model No.' }, { key: 'RejectedQty', header: 'Rejected Qty' }, - { key: 'FreeQty', header: 'Free Qty' } + { key: 'FreeQty', header: 'Free Qty' }, + { key: 'WholesalePrice', header: 'Wholesale Price' }, ]; // Get headers from first row to determine which optional fields exist const headers = excelData[0]; - optionalFields.forEach(field => { + optionalFields.forEach((field) => { if (headers.includes(field.header)) { rowData[field.key] = item[currentColIndex.toString()]; currentColIndex++; } }); - if (rowData?.Amount && rowData?.MRP && rowData?.SalesPrice && rowData?.ProductName && rowData?.PaymentAmount) { + if ( + rowData?.PurchaseRate && + rowData?.Amount && + rowData?.MRP && + rowData?.SalesPrice && + rowData?.ProductName && + rowData?.PaymentAmount + ) { ExcelToJsConversion.push(rowData); } }); @@ -292,12 +325,17 @@ const StockExcel = ({ // ...existing code... const handleDownload = async () => { try { - if (!supplierProducts || supplierProducts.length === 0 || !selectedSupplierData) { + if ( + !supplierProducts || + supplierProducts.length === 0 || + !selectedSupplierData + ) { setMessageData('No products available to generate Excel.'); setMessageType('warning'); return; } - const supplierDisplayName = getSupplierDisplayName(selectedSupplierData) || 'Supplier'; + const supplierDisplayName = + getSupplierDisplayName(selectedSupplierData) || 'Supplier'; // Fetch excelColumns config (optional fields access) let excelColumns = []; try { @@ -314,12 +352,17 @@ const StockExcel = ({ excelColumns = response?.data?.data?.[0]?.ConfigDtl || []; } } catch (err) { - console.warn('Failed to fetch excelColumns config, proceeding with defaults', err); + console.warn( + 'Failed to fetch excelColumns config, proceeding with defaults', + err + ); excelColumns = []; } const isOptionalFieldAllowed = (name) => { - const found = excelColumns.find((c) => String(c.ConfigName).trim() === String(name).trim()); + const found = excelColumns.find( + (c) => String(c.ConfigName).trim() === String(name).trim() + ); return found ? found.Access === 'Y' : false; }; @@ -331,7 +374,7 @@ const StockExcel = ({ allowBlank: allowBlank, showErrorMessage: true, errorTitle: 'Invalid Number', - error: 'Please enter a valid number' + error: 'Please enter a valid number', }; }; @@ -374,12 +417,20 @@ const StockExcel = ({ pushCol('Amount Per Piece', 'AmountPerPiece', true); pushCol('Number of Piece Inside', 'NumberofPieceInside', true); - if (isOptionalFieldAllowed('Manufacture Date')) pushCol('Manufacture Date', 'ManufDate', false); - if (isOptionalFieldAllowed('Expire Date')) pushCol('Expire Date', 'ExpDate', false); - if (isOptionalFieldAllowed('Batch No.')) pushCol('Batch No.', 'BatchNo', false); - if (isOptionalFieldAllowed('Model No.')) pushCol('Model No.', 'ModelNo', false); - if (isOptionalFieldAllowed('Rejected Qty')) pushCol('Rejected Qty', 'RejectedQty', false); - if (isOptionalFieldAllowed('Free Qty')) pushCol('Free Qty', 'FreeQty', false); + if (isOptionalFieldAllowed('Manufacture Date')) + pushCol('Manufacture Date', 'ManufDate', false); + if (isOptionalFieldAllowed('Expire Date')) + pushCol('Expire Date', 'ExpDate', false); + if (isOptionalFieldAllowed('Batch No.')) + pushCol('Batch No.', 'BatchNo', false); + if (isOptionalFieldAllowed('Model No.')) + pushCol('Model No.', 'ModelNo', false); + if (isOptionalFieldAllowed('Rejected Qty')) + pushCol('Rejected Qty', 'RejectedQty', false); + if (isOptionalFieldAllowed('Free Qty')) + pushCol('Free Qty', 'FreeQty', false); + if (isOptionalFieldAllowed('Wholesale Price')) + pushCol('Wholesale Price', 'WholesalePrice', false); worksheet.columns = columns.map((c) => ({ header: c.header, @@ -388,7 +439,11 @@ const StockExcel = ({ c.key === 'ProdName' || c.key === 'VariantName' ? 40 : c.key === 'Quantity' - ? 10 : c.key === 'Supplier' || c.key === 'InvoiceDeliveryChallan' || c.key === 'SupplierInvoiceNumber' ? 30 + ? 10 + : c.key === 'Supplier' || + c.key === 'InvoiceDeliveryChallan' || + c.key === 'SupplierInvoiceNumber' + ? 30 : 20, })); @@ -410,12 +465,21 @@ const StockExcel = ({ }; }); - hiddenSheet.addRow(['ProductName', 'VariantName', 'MRP', 'SellPrice', 'Number of Piece Inside', 'Amount Per Piece']); + hiddenSheet.addRow([ + 'ProductName', + 'VariantName', + 'MRP', + 'SellPrice', + 'Number of Piece Inside', + 'Amount Per Piece', + ]); let currentRow = 2; const productNames = supplierProducts.map((p) => p.ProdName); supplierProducts.forEach((product) => { - const activeVariants = (product.ProdVariantPriceDetails || []).filter(v => v.ActiveStatus === 'A'); + const activeVariants = (product.ProdVariantPriceDetails || []).filter( + (v) => v.ActiveStatus === 'A' + ); const uniqueVariantsMap = new Map(); activeVariants.forEach((variant) => { const variantName = variant.ProdVariantName; @@ -442,7 +506,8 @@ const StockExcel = ({ .trim() .replace(/[^A-Za-z0-9_]/g, '_') .replace(/^(\d)/, '_$1'); - if (!safeName) safeName = `Product_${Math.random().toString(36).slice(2, 8)}`; + if (!safeName) + safeName = `Product_${Math.random().toString(36).slice(2, 8)}`; const rangeRef = `ProductVariantMap!$B$${startRow}:$B$${endRow}`; try { workbook.definedNames.add(rangeRef, safeName); @@ -452,10 +517,41 @@ const StockExcel = ({ }); const startDataRow = 2; - const numberOfRows = 50; - for (let i = 0; i < numberOfRows; i++) { - worksheet.addRow({}); - } + const today = new Date(); + + // Pre-populate all products and variants as rows + supplierProducts.forEach((product) => { + const activeVariants = (product.ProdVariantPriceDetails || []).filter( + (v) => v.ActiveStatus === 'A' + ); + const uniqueVariantsMap = new Map(); + activeVariants.forEach((variant) => { + const variantName = variant.ProdVariantName; + if (!uniqueVariantsMap.has(variantName)) { + uniqueVariantsMap.set(variantName, variant); + } + }); + const uniqueVariants = Array.from(uniqueVariantsMap.values()); + + uniqueVariants.forEach((variant) => { + const rowData = { + InwardDate: today, + Supplier: supplierDisplayName, + ProdName: product.ProdName, + VariantName: variant.ProdVariantName, + MRP: variant.MRP || 0, + SalesPrice: variant.SellPrice || 0, + NumberofPieceInside: variant.NoOfPcs || 0, + AmountPerPiece: variant.OnePcsPrice || 0, + }; + + if (String(selectedSupplierData?.SuppName).trim() === 'Self') { + rowData.OwnWithPaid = ''; + } + + worksheet.addRow(rowData); + }); + }); const colKeyToIndex = {}; worksheet.columns.forEach((c, idx) => { @@ -473,47 +569,19 @@ const StockExcel = ({ return s; }; - const today = new Date(); const inwardDateCol = colIndex('InwardDate'); - if (inwardDateCol) { - const cell = worksheet.getCell(`${colLetter(inwardDateCol)}${startDataRow}`); - cell.value = today; - cell.numFmt = 'yyyy-mm-dd'; - } + const numberOfRows = worksheet.rowCount; - const supplierName = selectedSupplierData?.SuppName || ''; - const productNamesLiteral = productNames.join(','); - - for (let r = startDataRow; r < startDataRow + numberOfRows; r++) { + for (let r = startDataRow; r <= numberOfRows; r++) { if (colIndex('ProdName')) { const cIdx = colIndex('ProdName'); - const letter = colLetter(cIdx); - const prodCellRef = `${letter}${r}`; - const cell = worksheet.getCell(prodCellRef); - cell.dataValidation = { - type: 'list', - allowBlank: false, - formulae: [`"${productNamesLiteral}"`], - }; - cell.protection = { locked: false }; + const cell = worksheet.getCell(r, cIdx); + cell.protection = { locked: true }; } if (colIndex('VariantName')) { const cIdx = colIndex('VariantName'); - const letter = colLetter(cIdx); - const varCellRef = `${letter}${r}`; - const productColLetter = colLetter(colIndex('ProdName')); - const productCellRef = `${productColLetter}${r}`; - const formula = `INDIRECT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(${productCellRef}," ","_"),"-","_"),"&","_"),"/","_"),".","_"),"(","_"),")","_"),"[","_"),"]","_"),",","_"))`; - const cell = worksheet.getCell(varCellRef); - cell.dataValidation = { - type: 'list', - allowBlank: true, - formulae: [formula], - showErrorMessage: true, - errorTitle: 'Invalid Variant', - error: 'Please select a variant from the dropdown' - }; - cell.protection = { locked: false }; + const cell = worksheet.getCell(r, cIdx); + cell.protection = { locked: true }; } if (colIndex('Quantity')) { const cIdx = colIndex('Quantity'); @@ -544,7 +612,8 @@ const StockExcel = ({ error: 'Must be a valid number and less than total quantity', showInputMessage: true, promptTitle: 'Rejected Qty', - prompt: 'Enter rejected quantity (must be less than total quantity)' + prompt: + 'Enter rejected quantity (must be less than total quantity)', }; rejCell.protection = { locked: false }; } @@ -565,31 +634,55 @@ const StockExcel = ({ formulae: [new Date(1900, 0, 1)], showErrorMessage: true, errorTitle: 'Invalid Date', - error: 'Please enter a valid date' + error: 'Please enter a valid date', }; dCell.protection = { locked: false }; } if (colIndex('Supplier')) { const cIdx = colIndex('Supplier'); const cell = worksheet.getCell(r, cIdx); - cell.dataValidation = { type: 'list', formulae: [`"${supplierDisplayName}"`] }; - cell.value = supplierDisplayName; - cell.protection = { locked: false }; + cell.protection = { locked: true }; } + if (colIndex('OwnWithPaid')) { const cIdx = colIndex('OwnWithPaid'); const cell = worksheet.getCell(r, cIdx); - cell.dataValidation = { type: 'list', formulae: ['"Own,With Paid"'] }; + + cell.dataValidation = { + type: 'list', + formulae: ['"Own,With Paid"'], + allowBlank: true + }; + + if (!cell.value) { + cell.value = 'Own'; + } + cell.protection = { locked: false }; } + if (colIndex('InvoiceDeliveryChallan')) { const cIdx = colIndex('InvoiceDeliveryChallan'); const cell = worksheet.getCell(r, cIdx); - cell.dataValidation = { type: 'list', formulae: ['"Invoice,Delivery Challan"'] }; + + cell.dataValidation = { + type: 'list', + formulae: ['"Invoice,Delivery Challan"'], + allowBlank: true, + }; + + // ✅ Default value + if (!cell.value) { + cell.value = 'Invoice'; + } + cell.protection = { locked: false }; } + if (colIndex('SupplierInvoiceNumber')) { - worksheet.getCell(r, colIndex('SupplierInvoiceNumber')).protection = { locked: false }; + worksheet.getCell(r, colIndex('SupplierInvoiceNumber')).protection = { + locked: false, + }; } if (colIndex('SupplierInvoiceDate')) { const cell = worksheet.getCell(r, colIndex('SupplierInvoiceDate')); @@ -601,12 +694,14 @@ const StockExcel = ({ formulae: [new Date(1900, 0, 1)], showErrorMessage: true, errorTitle: 'Invalid Date', - error: 'Please enter a valid date' + error: 'Please enter a valid date', }; cell.protection = { locked: false }; } if (colIndex('DeliveryChallanNo')) { - worksheet.getCell(r, colIndex('DeliveryChallanNo')).protection = { locked: false }; + worksheet.getCell(r, colIndex('DeliveryChallanNo')).protection = { + locked: false, + }; } if (colIndex('DeliveryInvoiceDate')) { const cell = worksheet.getCell(r, colIndex('DeliveryInvoiceDate')); @@ -618,63 +713,33 @@ const StockExcel = ({ formulae: [new Date(1900, 0, 1)], showErrorMessage: true, errorTitle: 'Invalid Date', - error: 'Please enter a valid date' + error: 'Please enter a valid date', }; cell.protection = { locked: false }; } if (colIndex('MRP')) { const mrpCol = colIndex('MRP'); - const prodCol = colIndex('ProdName'); - const varCol = colIndex('VariantName'); const mrpCell = worksheet.getCell(r, mrpCol); - const prodLetter = colLetter(prodCol); - const varLetter = colLetter(varCol); - mrpCell.value = { - formula: `IF(OR(${prodLetter}${r}="",${varLetter}${r}=""),"",SUMPRODUCT((ProductVariantMap!$A$2:$A$1000=${prodLetter}${r})*(ProductVariantMap!$B$2:$B$1000=${varLetter}${r})*ProductVariantMap!$C$2:$C$1000))` - }; mrpCell.numFmt = '#,##0.00'; mrpCell.protection = { locked: false }; - addNumberValidation(mrpCell, true, 0); } if (colIndex('SalesPrice')) { const spCol = colIndex('SalesPrice'); - const prodCol = colIndex('ProdName'); - const varCol = colIndex('VariantName'); const spCell = worksheet.getCell(r, spCol); - const prodLetter = colLetter(prodCol); - const varLetter = colLetter(varCol); - spCell.value = { - formula: `IF(OR(${prodLetter}${r}="",${varLetter}${r}=""),"",SUMPRODUCT((ProductVariantMap!$A$2:$A$1000=${prodLetter}${r})*(ProductVariantMap!$B$2:$B$1000=${varLetter}${r})*ProductVariantMap!$D$2:$D$1000))` - }; spCell.numFmt = '#,##0.00'; spCell.protection = { locked: false }; - addNumberValidation(spCell, true, 0); } if (colIndex('NumberofPieceInside')) { const nopCol = colIndex('NumberofPieceInside'); - const prodCol = colIndex('ProdName'); - const varCol = colIndex('VariantName'); const nopCell = worksheet.getCell(r, nopCol); - const prodLetter = colLetter(prodCol); - const varLetter = colLetter(varCol); - nopCell.value = { - formula: `IF(OR(${prodLetter}${r}="",${varLetter}${r}=""),"",SUMPRODUCT((ProductVariantMap!$A$2:$A$1000=${prodLetter}${r})*(ProductVariantMap!$B$2:$B$1000=${varLetter}${r})*ProductVariantMap!$E$2:$E$1000))` - }; nopCell.numFmt = '#,##0'; - addNumberValidation(nopCell, true, 0); + nopCell.protection = { locked: false }; } if (colIndex('AmountPerPiece')) { const appCol = colIndex('AmountPerPiece'); - const prodCol = colIndex('ProdName'); - const varCol = colIndex('VariantName'); const appCell = worksheet.getCell(r, appCol); - const prodLetter = colLetter(prodCol); - const varLetter = colLetter(varCol); - appCell.value = { - formula: `IF(OR(${prodLetter}${r}="",${varLetter}${r}=""),"",SUMPRODUCT((ProductVariantMap!$A$2:$A$1000=${prodLetter}${r})*(ProductVariantMap!$B$2:$B$1000=${varLetter}${r})*ProductVariantMap!$F$2:$F$1000))` - }; appCell.numFmt = '#,##0.00'; - addNumberValidation(appCell, true, 0); + appCell.protection = { locked: false }; } if (colIndex('PaymentType')) { const cIdx = colIndex('PaymentType'); @@ -708,13 +773,16 @@ const StockExcel = ({ pmCell.dataValidation = { type: 'list', allowBlank: true, - formulae: [`IF(${paymentTypeLetter}${r}="Paid",ValidationHelper!$A$1:$A$3,"")`], + formulae: [ + `IF(${paymentTypeLetter}${r}="Paid",ValidationHelper!$A$1:$A$3,"")`, + ], showErrorMessage: true, errorTitle: 'Invalid Payment Mode', error: 'Select Cash, Credit, or UPI when Payment Type is Paid', showInputMessage: true, promptTitle: 'Payment Mode', - prompt: 'If Payment Type is Credit, leave empty. If Paid, select: Cash, Credit, or UPI' + prompt: + 'If Payment Type is Credit, leave empty. If Paid, select: Cash, Credit, or UPI', }; pmCell.protection = { locked: false }; } @@ -729,7 +797,7 @@ const StockExcel = ({ formulae: [new Date(1900, 0, 1)], showErrorMessage: true, errorTitle: 'Invalid Date', - error: 'Please enter a valid date' + error: 'Please enter a valid date', }; dueCell.protection = { locked: false }; } @@ -744,7 +812,7 @@ const StockExcel = ({ formulae: [new Date(1900, 0, 1)], showErrorMessage: true, errorTitle: 'Invalid Date', - error: 'Please enter a valid date' + error: 'Please enter a valid date', }; manufCell.protection = { locked: false }; } @@ -759,7 +827,7 @@ const StockExcel = ({ formulae: [new Date(1900, 0, 1)], showErrorMessage: true, errorTitle: 'Invalid Date', - error: 'Please enter a valid date' + error: 'Please enter a valid date', }; expCell.protection = { locked: false }; } @@ -769,7 +837,9 @@ const StockExcel = ({ const rLetter = colLetter(rIdx); const qLetter = colLetter(qIdx); const recCell = worksheet.getCell(`${rLetter}${r}`); - recCell.value = { formula: `IF(${qLetter}${r}="","",${qLetter}${r})` }; + recCell.value = { + formula: `IF(${qLetter}${r}="","",${qLetter}${r})`, + }; addNumberValidation(recCell, true, 0); } if (colIndex('AcceptedQty') && colIndex('Quantity')) { @@ -782,15 +852,21 @@ const StockExcel = ({ const formulaCell = worksheet.getCell(`${aLetter}${r}`); if (rejLetter) { formulaCell.value = { - formula: `IF(${qLetter}${r}="","",MAX(0,${qLetter}${r}-IF(${rejLetter}${r}="",0,${rejLetter}${r})))` + formula: `IF(${qLetter}${r}="","",MAX(0,${qLetter}${r}-IF(${rejLetter}${r}="",0,${rejLetter}${r})))`, }; } else { - formulaCell.value = { formula: `IF(${qLetter}${r}="","",${qLetter}${r})` }; + formulaCell.value = { + formula: `IF(${qLetter}${r}="","",${qLetter}${r})`, + }; } addNumberValidation(formulaCell, true, 0); formulaCell.protection = { locked: true }; } - if (colIndex('PaymentAmount') && colIndex('Quantity') && colIndex('PurchaseRate')) { + if ( + colIndex('PaymentAmount') && + colIndex('Quantity') && + colIndex('PurchaseRate') + ) { const payIdx = colIndex('PaymentAmount'); const qIdx = colIndex('Quantity'); const pIdx = colIndex('PurchaseRate'); @@ -812,7 +888,11 @@ const StockExcel = ({ formulaCell.numFmt = '#,##0.00'; addNumberValidation(formulaCell, true, 0); } - if (colIndex('Amount') && colIndex('Quantity') && colIndex('PurchaseRate')) { + if ( + colIndex('Amount') && + colIndex('Quantity') && + colIndex('PurchaseRate') + ) { const amtIdx = colIndex('Amount'); const qIdx = colIndex('Quantity'); const pIdx = colIndex('PurchaseRate'); @@ -827,11 +907,21 @@ const StockExcel = ({ formula: `IF(${qLetter}${r}="","",IF(${rejLetter}${r}="",(${qLetter}${r})*${pLetter}${r},(${qLetter}${r}-${rejLetter}${r})*${pLetter}${r}))`, }; } else { - amtCell.value = { formula: `IF(${qLetter}${r}="","",(${qLetter}${r})*${pLetter}${r})` }; + amtCell.value = { + formula: `IF(${qLetter}${r}="","",(${qLetter}${r})*${pLetter}${r})`, + }; } amtCell.numFmt = '#,##0.00'; addNumberValidation(amtCell, true, 0); } + if (colIndex('WholesalePrice')) { + const cIdx = colIndex('WholesalePrice'); + const letter = colLetter(cIdx); + const cell = worksheet.getCell(`${letter}${r}`); + cell.protection = { locked: false }; + cell.numFmt = '#,##0.00'; + addNumberValidation(cell, true, 0); + } } await worksheet.protect('', { @@ -1070,6 +1160,12 @@ const StockExcel = ({ key: 'FreeQty', editable: true, }, + { + title: 'Wholesale Price', + dataIndex: 'WholesalePrice', + key: 'WholesalePrice', + editable: true, + }, ]; const column = columns?.map((col) => { @@ -1205,7 +1301,7 @@ const StockExcel = ({ RetailPrice: row?.RetailPrice, AmountperPiece: row?.AmountperPiece, NumberofPieceInside: row?.NumberofPieceInside, - WholeSale: row?.WholeSale, + WholesalePrice: row?.WholesalePrice, Offer: row?.Offer, SplPrice: row?.SplPrice, ReceivedQuantity: row?.ReceivedQuantity, @@ -1245,31 +1341,31 @@ const StockExcel = ({ const handleFieldSetupSubmit = async () => { const postData = { - "AppId": AppId, - "CompId": CompId, - "BranchId": BranchId, - "Type": "EB", - "FormType": "PurchaseEntry", - "TypeId": purchaseReceiptBulkUploadCatId, - "ConfigDtl": selectedFields?.map((field) => ({ - "ConfigId": field, - "Access": 'Y', + AppId: AppId, + CompId: CompId, + BranchId: BranchId, + Type: 'EB', + FormType: 'PurchaseEntry', + TypeId: purchaseReceiptBulkUploadCatId, + ConfigDtl: selectedFields?.map((field) => ({ + ConfigId: field, + Access: 'Y', })), - "CreatedBy": UserId - } + CreatedBy: UserId, + }; const response = await dispatch(postFieldSetup(postData))?.unwrap(); if (response?.data?.statusCode === 1) { - setMessageType("success"); + setMessageType('success'); setMessageData(response?.data?.response); setFieldSetup(false); await getFieldSetup(); } else { - setMessageType("error"); - setMessageData("Failed to set up fields"); + setMessageType('error'); + setMessageData('Failed to set up fields'); } - } + }; const handleFieldSelect = (value) => { setSelectedFields((prev) => { @@ -1320,7 +1416,7 @@ const StockExcel = ({ } catch (error) { console.error('Error fetching suppliers:', error); setMessageData('Failed to fetch suppliers.'); - setMessageType('error') + setMessageType('error'); } }, [CompId, AppId, BranchId, dispatch]); @@ -1331,14 +1427,22 @@ const StockExcel = ({ const type = supplierData.Type; const LocationType = - type === 'Supplier' ? 'S' : type === 'Branch' ? 'B' : type === 'WareHouse' ? 'W' : ''; + type === 'Supplier' + ? 'S' + : type === 'Branch' + ? 'B' + : type === 'WareHouse' + ? 'W' + : ''; const response = await dispatch( getSupplaierIdwithTypeBasedProducts({ CompId: LocationType === 'S' ? CompId : supplierData?.SuppCompId, AppId: LocationType === 'S' ? AppId : supplierData?.SuppAppId, - BranchId: LocationType === 'S' ? BranchId : supplierData?.SuppBranchId, - SuppId: LocationType === 'S' ? supplierId : supplierData?.SuppBranchId, + BranchId: + LocationType === 'S' ? BranchId : supplierData?.SuppBranchId, + SuppId: + LocationType === 'S' ? supplierId : supplierData?.SuppBranchId, LocationType, }) )?.unwrap(); @@ -1349,25 +1453,24 @@ const StockExcel = ({ } else { setSupplierProducts([]); setMessageData('No products are mapped to this supplier.'); - setMessageType('warning') + setMessageType('warning'); } } else { setSupplierProducts([]); setMessageData('Failed to fetch supplier products.'); - setMessageType('error') + setMessageType('error'); } } catch (error) { console.error('Error fetching supplier products:', error); setMessageData('An error occurred while fetching products.'); - setMessageType('error') + setMessageType('error'); } }; - const handleSupplierBasedProducts = useCallback(async () => { if (!selectedSupplier) { setMessageData('Please select a supplier.'); - setMessageType('warning') + setMessageType('warning'); return; } @@ -1400,19 +1503,25 @@ const StockExcel = ({ onSubmit={handleFileSubmit} >
    -
    +

    UPLOAD YOUR EXCEL

    -
    +
    + +
    @@ -1549,7 +1658,9 @@ const StockExcel = ({ children={
    - +
    @@ -1558,11 +1669,16 @@ const StockExcel = ({ label="Select fields" // valueData={selectedFields} onChangeFunction={handleFieldSelect} - options={tableFieldPreferences?.filter(p => !selectedFields?.some(s => s === p.value))} /> + options={tableFieldPreferences?.filter( + (p) => !selectedFields?.some((s) => s === p.value) + )} + />
    {selectedFields - ?.map((id) => tableFieldPreferences?.find((p) => p.value === id)) + ?.map((id) => + tableFieldPreferences?.find((p) => p.value === id) + ) .filter(Boolean) .map((field) => (
    diff --git a/src/Pages/StockMaster/StockForm.jsx b/src/Pages/StockMaster/StockForm.jsx index 8d2481b..cd2d1c6 100644 --- a/src/Pages/StockMaster/StockForm.jsx +++ b/src/Pages/StockMaster/StockForm.jsx @@ -12,6 +12,7 @@ import { ArrowRightOutlined, PlusCircleOutlined, InfoCircleOutlined, + SearchOutlined, } from '@ant-design/icons'; import { Form, @@ -22,10 +23,11 @@ import { AutoComplete, Switch, } from 'antd'; -import { IoAddCircleSharp } from 'react-icons/io5'; +import { IoAddCircleSharp, IoSettingsOutline } from 'react-icons/io5'; import { ScannerInputField } from '../../Components/Forms/ScannerInputField.jsx'; import { InputField } from '../../Components/Forms/InputField.jsx'; import Buttons from '../../Components/Forms/Buttons.jsx'; +import { Modal } from 'antd'; import { Messages } from '../../Components/Notifications/Messages.jsx'; import { DeleteFilled } from '@ant-design/icons'; import { changeBreadCrumb } from '../../Features/AppPage/CenterPage.js'; @@ -74,18 +76,24 @@ import { productTypeDataSelector, getProductTypeData, bulkpostdata, + postFieldSetup, + getFieldSetupData, } from '../../Features/ProductPage/ProductPage.js'; import { postConfiguration } from '../../Features/ConfigMasterPage/ConfigMasterPage.js'; import SupplierProductMappingForm from '../SupplierProductMapping/SuplierProductMappingForm.jsx'; import { getPurchaseSupplierAndWareHouseData } from '../../Features/PurchaseOrder/PurchaseOrder.js'; import FloatLabel from '../../Components/Forms/FloatLabel/index.jsx'; -import { FaLink, FaEye, FaUpload } from 'react-icons/fa'; +import { FaLink, FaEye } from 'react-icons/fa'; +import { TbUpload } from 'react-icons/tb'; import { getSupplaierIdBasedProducts, getSupplaierIdwithTypeBasedProducts, postSupplaierProducts, } from '../../Features/SupplierProductMapping/SupplierProductMapping.js'; -import { getCommonAppPreference } from '../../Features/BrachLogin/BranchLogin.js'; +import { + ApplicationPreferences, + getCommonAppPreference, +} from '../../Features/BrachLogin/BranchLogin.js'; import { getConfigType, getPaymentOptionFeatureApi, @@ -179,16 +187,10 @@ const EditableCell = ({ className="editable-cell-value-wrap" style={{ paddingRight: 24, + cursor: 'pointer', }} onClick={toggleEdit} > - {/* {dataIndex === "CurrentAmt" && Array.isArray(record[dataIndex]) - ? record[dataIndex]?.map((item, index) => ( - - {item.CurrentAmt + "-" + item.CurrentAmt} - - )) - : children} */} { const BrandData = useSelector(brandDataSelector); const UomData = useSelector(uomDataSelector); const ProductTypeData = useSelector(productTypeDataSelector); + const appPreferences = useSelector(ApplicationPreferences); const [applicationRestrictedFields, setApplicationRestrictedFields] = useState({ DatesAndExpiry: false, BatchAndModelDetails: false, AmountPerPieceDetail: false, }); + const [selectedAdditionalColumn, setSelectedAdditionalColumn] = useState([]); + console.log(selectedAdditionalColumn, 'selectedAdditionalColumn'); + const [showColumnModal, setShowColumnModal] = useState(false); + const [tempSelectedColumns, setTempSelectedColumns] = useState([]); + const [tableFieldPreferences, setTableFieldPreferences] = useState([]); + const [selectedFields, setSelectedFields] = useState([]); const [SupplierData, setSupplierData] = useState([]); const [StockOpen, setStockOpen] = useState('N'); const [SupplierOpen, setSupplierOpen] = useState('own'); @@ -275,6 +284,7 @@ const StockForm = ({ formType }) => { const [imageSubCategoryUrl, setSubCategoryImageUrl] = useState(''); const [imageBrandUrl, setBrandImageUrl] = useState(''); const [PurchaseData, setPurchaseData] = useState([]); + console.log(PurchaseData, 'PurchaseData'); const [additionalInfoModal, setAdditionalInfoModal] = useState(false); const [selectedRowIndex, setSelectedRowIndex] = useState(null); const [selectedRowRecord, setSelectedRowRecord] = useState({}); @@ -342,6 +352,23 @@ const StockForm = ({ formType }) => { const [extractorData, setExtractorData] = useState(null); const [isLoading, setIsLoading] = useState(false); const [loadingText, setLoadingText] = useState(''); + const [filteredPurchaseData, setFilteredPurchaseData] = useState([]); + const [searchValue, setSearchValue] = useState(''); + const isSearching = Boolean(searchValue?.trim()); + useEffect(() => { + if (searchValue?.trim()) { + const search = searchValue.toLowerCase(); + + const filtered = PurchaseData.filter((item) => + item?.ProdName?.toLowerCase().includes(search) + ); + + setFilteredPurchaseData(filtered); + } else { + setFilteredPurchaseData([]); + } + }, [PurchaseData, searchValue]); + const items = [ { name: 'Home', @@ -357,6 +384,9 @@ const StockForm = ({ formType }) => { link: null, }, ]; + const categoryId = appPreferences?.find( + (p) => p?.PreferredCatName?.toLowerCase() === 'purchase entry' + )?.PreferredCatId; useEffect(() => { dispatch(changeBreadCrumb({ items: items })); dispatch( @@ -519,18 +549,23 @@ const StockForm = ({ formType }) => { }; useEffect(() => { - let total = PurchaseData?.reduce((accumulator, currentValue) => { - return accumulator + currentValue.Amount; + const total = PurchaseData?.reduce((acc, item) => { + return acc + Number(item?.Amount || 0); }, 0); - setSelInvoiceAmount(!isNaN(total) && total !== 0 ? total : null); + const invoiceAmount = !isNaN(total) && total !== 0 ? total : null; + + setSelInvoiceAmount(invoiceAmount); + formRef.current?.setFieldsValue({ - InvoiceAmount: !isNaN(total) && total !== 0 ? total : null, + InvoiceAmount: invoiceAmount, }); - let totaltax = PurchaseData?.reduce((accumulator, currentValue) => { - return accumulator + currentValue.TaxAmt; + + const totalTax = PurchaseData?.reduce((acc, item) => { + return acc + Number(item?.TaxAmt || 0); }, 0); - setTotalTaxAmount(totaltax); + + setTotalTaxAmount(totalTax); }, [PurchaseData]); const getPurchaseOrders = async () => { @@ -576,7 +611,38 @@ const StockForm = ({ formType }) => { ); return { mappedSupplierProducts, SuppId: finalList?.[0]?.SuppId }; }; - + useEffect(() => { + getFieldSetup(); + }, [categoryId]); + const getFieldSetup = async () => { + try { + const response = await dispatch( + getFieldSetupData({ AppId, CompId, BranchId, categoryId, Type: 'PE' }) + ).unwrap(); + if (response?.data?.statusCode === 1) { + console.log(response?.data?.data?.[0]?.ConfigDtl, 'Field Setup Data'); + setSelectedFields( + response?.data?.data?.[0]?.ConfigDtl?.filter( + (c) => c.ConfigId && c.Access === 'Y' + )?.map((c) => c.ConfigId) || [] + ); + setSelectedAdditionalColumn( + response?.data?.data?.[0]?.ConfigDtl?.filter( + (c) => c.ConfigId && c.Access === 'Y' + )?.map((c) => c.ConfigName) || [] + ); + setTableFieldPreferences( + response?.data?.data?.[0]?.ConfigDtl?.map((c) => ({ + value: c.ConfigId, + label: c.ConfigName, + access: c.Access, + })) || [] + ); + } + } catch (error) { + console.error('Error fetching field setup:', error); + } + }; const AddSupplierimg = async (subSupplierData) => { const addSupplierData = { CompId: getSession('CompId'), @@ -688,8 +754,8 @@ const StockForm = ({ formType }) => { const allSupplierProducts = response?.data?.data || []; const matchingProdIds = []; - const NewImageProducts=[] - console.log(unmatchedProducts,"unmatchedProductsunmatchedProducts") + const NewImageProducts = []; + console.log(unmatchedProducts, 'unmatchedProductsunmatchedProducts'); // check if the unmatched products exists in our products list unmatchedProducts.forEach((item) => { const match = allSupplierProducts?.[0]?.ProductDetails.find( @@ -699,90 +765,98 @@ const StockForm = ({ formType }) => { ); if (match) { matchingProdIds.push(match.ProdId); - } - else{ + } else { NewImageProducts.push(item?.parsedData); } }); - console.log(NewImageProducts,"NewImageProductsNewImageProducts") + console.log(NewImageProducts, 'NewImageProductsNewImageProducts'); // Bulk upload new image products if (NewImageProducts.length > 0) { - const newProductsData = NewImageProducts.map(product => ({ - AppId: AppId || 0, - CompId: CompId || "", - BranchId: BranchId || "", - CreatedBy: UserId || 0, - ProdName: product.description?.trim() || "", - ProdVariantName: "", - Size: 1 || "", - UOM: product.unit || "", - MRP: parseFloat(product.rate) || 0, - WhSalePrice: 0, - SellPrice: parseFloat(product.rate) || 0, - ProdCat: "General", - ProdSubCat: "", - Brand: "", - AutoGenerateQr: "", - QRCode: "", - StockAvailable: 'No', - TaxId: "", - HSNCode: "", - PartNumber: "", - Rack: 0, - ManufDate: "", - ExpDate: "", - AvailableFrom: "", - AvailableTo: "", - ProdLogo: "", - OnePcsAvailable: "No", - AutoGenerateSingleQr:'No', - TaxId: 'NIL - 0%', - OnePcQR: "", - TokenAvailable: 'No', - OpeningQty: 0, - QtyBasedPrice: "", - InwardDate: "", - SuppId: suppId || "", - Reference: "", - ReceivedQty: 0, - AcceptedQty: 0, - RejectedQty: 0, - RejectionReason: "", - IssuedQty: 0, - BalanceQty: 0, - InwardPrice: 0, - OfferPrice: 0, - SpecialPrice: 0, - Cess: 0, - })); + const newProductsData = NewImageProducts.map((product) => ({ + AppId: AppId || 0, + CompId: CompId || '', + BranchId: BranchId || '', + CreatedBy: UserId || 0, + ProdName: product.description?.trim() || '', + ProdVariantName: '', + Size: 1 || '', + UOM: product.unit || '', + MRP: parseFloat(product.rate) || 0, + WhSalePrice: 0, + SellPrice: parseFloat(product.rate) || 0, + ProdCat: 'General', + ProdSubCat: '', + Brand: '', + AutoGenerateQr: '', + QRCode: '', + StockAvailable: 'No', + TaxId: '', + HSNCode: '', + PartNumber: '', + Rack: 0, + ManufDate: '', + ExpDate: '', + AvailableFrom: '', + AvailableTo: '', + ProdLogo: '', + OnePcsAvailable: 'No', + AutoGenerateSingleQr: 'No', + TaxId: 'NIL - 0%', + OnePcQR: '', + TokenAvailable: 'No', + OpeningQty: 0, + QtyBasedPrice: '', + InwardDate: '', + SuppId: suppId || '', + Reference: '', + ReceivedQty: 0, + AcceptedQty: 0, + RejectedQty: 0, + RejectionReason: '', + IssuedQty: 0, + BalanceQty: 0, + InwardPrice: 0, + OfferPrice: 0, + SpecialPrice: 0, + Cess: 0, + })); - const bulkResponse = await dispatch(bulkpostdata({ ProdDetails: newProductsData })).unwrap(); - - if (bulkResponse?.data?.statusCode === 1) { - // After successful bulk upload, check the condition again - const updatedResponse = await dispatch( - getSupplaierIdBasedProducts({ CompId, AppId, BranchId, SuppId: suppId }) - ).unwrap(); - if (updatedResponse?.data?.statusCode === 1) { - const updatedAllSupplierProducts = updatedResponse?.data?.data || []; - const updatedMatchingProdIds = []; - - unmatchedProducts.forEach((item) => { - const match = updatedAllSupplierProducts?.[0]?.ProductDetails.find( - (supp) => - supp?.ProdName?.toLowerCase() === - item?.parsedData?.description?.toLowerCase() - ); - if (match) { - updatedMatchingProdIds.push(match.ProdId); - } - }); - - if (updatedMatchingProdIds.length > 0) { - matchingProdIds.push(...updatedMatchingProdIds); - } + const bulkResponse = await dispatch( + bulkpostdata({ ProdDetails: newProductsData }) + ).unwrap(); + + if (bulkResponse?.data?.statusCode === 1) { + // After successful bulk upload, check the condition again + const updatedResponse = await dispatch( + getSupplaierIdBasedProducts({ + CompId, + AppId, + BranchId, + SuppId: suppId, + }) + ).unwrap(); + if (updatedResponse?.data?.statusCode === 1) { + const updatedAllSupplierProducts = + updatedResponse?.data?.data || []; + const updatedMatchingProdIds = []; + + unmatchedProducts.forEach((item) => { + const match = + updatedAllSupplierProducts?.[0]?.ProductDetails.find( + (supp) => + supp?.ProdName?.toLowerCase() === + item?.parsedData?.description?.toLowerCase() + ); + if (match) { + updatedMatchingProdIds.push(match.ProdId); } + }); + + if (updatedMatchingProdIds.length > 0) { + matchingProdIds.push(...updatedMatchingProdIds); } + } + } } // if there is matching products, map them to the supplier if (matchingProdIds.length > 0) { @@ -828,6 +902,7 @@ const StockForm = ({ formType }) => { for (const item of matchedProducts) { if (item.matchFound) { const newProduct = await ProductDropDownChange( + item?.selectedProduct.ProdVariantName, item.selectedProdId, { label: item.selectedProduct.ProdName }, mappedSupplierProducts, @@ -914,6 +989,7 @@ const StockForm = ({ formType }) => { for (const item of matchedProducts) { if (item.matchFound) { const newProduct = await ProductDropDownChange( + item?.selectedProduct?.ProdVariantName, item.selectedProdId, { label: item.selectedProduct.ProdName }, supplierProducts, @@ -1089,7 +1165,7 @@ const StockForm = ({ formType }) => { const handleSuppInvoiceNoChange = (e) => { const value = e.target.value; formRef.current?.setFieldsValue({ SuppInvoiceNo: value }); - setExtractorData(prev => prev ? { ...prev, invoiceNo: value } : null); + setExtractorData((prev) => (prev ? { ...prev, invoiceNo: value } : null)); }; const handleInvoiceTypeChange = (value) => { @@ -1118,16 +1194,19 @@ const StockForm = ({ formType }) => { formRef?.current?.getFieldsValue(), 'formRefformRefformRefformRef' ); - if(extractorData?.invoiceNo !== null && extractorData?.invoiceNo !== ""){ - formRef?.current?.setFieldsValue({ - SuppInvoiceNo: extractorData?.invoiceNo, - }); + if ( + extractorData?.invoiceNo !== null && + extractorData?.invoiceNo !== '' + ) { + formRef?.current?.setFieldsValue({ + SuppInvoiceNo: extractorData?.invoiceNo, + }); } - + formRef?.current?.setFieldsValue({ PaymentAmount: extractorData?.TotalAmtData, }); - setPaymentAmount((extractorData?.TotalAmtData)); + setPaymentAmount(extractorData?.TotalAmtData); onSuppInvoiceDateChange( extractorData?.date, extractorData?.date?.format('DD-MM-YYYY') || '' @@ -1206,6 +1285,7 @@ const StockForm = ({ formType }) => { }; const ProductDropDownChange = async ( + VariantName, ProdId, option, productsList, @@ -1218,50 +1298,62 @@ const StockForm = ({ formType }) => { formRef?.current?.resetFields(['VarProdId']); setselectedProductVariantData(null); setSelectedProductData(ProdId); - let x = (productsList || productData)?.find( - (e) => e.ProdId == ProdId - )?.ProdName; + + // let x = (productsList || productData)?.find( + // (e) => e.ProdId == ProdId + // )?.ProdName; let OnePcsAvailable = - (productsList || productData)?.find((e) => e.ProdId == ProdId) - ?.OnePcsAvailable == 'Y'; - let variantValues1 = await dispatch( - getProdvaraiantdata({ - CompId: SupplierCompId, - AppId: SupplierAppId, - BranchId: SupplierBranchId, - prodName: x, - }) - ).unwrap(); - let variants = variantValues1?.data?.data; + (productsList || productData)?.find( + (e) => e.ProdId == ProdId && e?.ProdVariantName == VariantName + )?.OnePcsAvailable == 'Y'; + // let variantValues1 = await dispatch( + // getProdvaraiantdata({ + // CompId: SupplierCompId, + // AppId: SupplierAppId, + // BranchId: SupplierBranchId, + // prodName: x, + // }) + // ).unwrap(); + // let variants = variantValues1?.data?.data; - let cc = variants?.filter((variant) => - variant?.ProductDetail?.some((e) => e.ProdId == ProdId) - )?.[0]?.ProductDetail; + // let cc = variants?.filter((variant) => + // variant?.ProductDetail?.some((e) => e.ProdId == ProdId) + // )?.[0]?.ProductDetail; - setVariants( - cc?.[0]?.ProdVariantDetails?.map((detail) => ({ - ...detail, - ProdIdProdName: `${detail.ProdVariantName} ${detail.ProdId}`, - OnePcsAvailable, - })) - ); + // setVariants( + // cc?.[0]?.ProdVariantDetails?.map((detail) => ({ + // ...detail, + // ProdIdProdName: `${detail.ProdVariantName} ${detail.ProdId}`, + // OnePcsAvailable, + // })) + // ); if ( - cc?.[0]?.ProdVariantDetails?.length < 2 || - (extractedProduct ? cc?.[0]?.ProdVariantDetails?.length > 0 : false) + true + // cc?.[0]?.ProdVariantDetails?.length < 2 || + // (extractedProduct ? cc?.[0]?.ProdVariantDetails?.length > 0 : false) ) { // let getSuppId = (productsList || productData)?.filter((item) => item.ProdId == ProdId); formRef.current?.setFieldsValue({ ProdId: ProdId }); await setSelectedProductData(ProdId); // await setSelectedSupplierData(getSuppId?.[0]?.["SuppId"]) ,CustSuppId:getSuppId?.[0]?.["SuppId"] - if ((existingProducts || PurchaseData)?.some((e) => e.ProdId == ProdId)) { + if ( + (existingProducts || PurchaseData)?.some( + (e) => e.ProdId == ProdId && e?.ProdVariantName == VariantName + ) + ) { + const existingProduct = (existingProducts || PurchaseData)?.find( + (e) => e.ProdId == ProdId && e?.ProdVariantName == VariantName + ); setMessageType('error'); - setMessageData('Already Product Exists'); + setMessageData( + `Product "${existingProduct?.ProdName} - ${existingProduct?.ProdVariantName}" already exists` + ); return null; } else { let ProductData1 = (productsList || productData)?.find( - (e) => e.ProdId == ProdId + (e) => e.ProdId == ProdId && e?.ProdVariantName == VariantName ); let DefaultVariant = ProductData1?.ProdVariantPriceDetails?.find( (item) => item?.DefaultVariant === 'Y' && item?.ReceivedQty === 0 @@ -1275,10 +1367,13 @@ const StockForm = ({ formType }) => { SellPrice: ProductData1?.SellPrice, StockAvailable: ProductData1?.StockAvailable, OnePcsAvailable: ProductData1?.OnePcsAvailable, - NumberofPieceinside: ProductData1?.NoOfPcs, - AmountPerPiece: ProductData1?.OnePcsPrice, + // NumberofPieceinside: ProductData1?.NoOfPcs, + // AmountPerPiece: ProductData1?.OnePcsPrice, + OnePcsPrice: ProductData1?.OnePcsPrice, + NoOfPcs: ProductData1?.NoOfPcs, TaxId: ProductData1?.TaxId, TaxPercentage: ProductData1?.TaxPercentage, + ProdVariantName: ProductData1?.ProdVariantName, }; const qty = extractedProduct @@ -1304,7 +1399,7 @@ const StockForm = ({ formType }) => { RejectedQty: qty - acceptedQty, OfferPrice: 0, SpecialPrice: 0, - ProdVariantName: 'Variant 1', + // ProdVariantName: 'Variant 1', FreeItem: 0, TaxAmt: 0, TaxType: SelectedPurcTaxType ? SelectedPurcTaxType : 0, @@ -1330,6 +1425,7 @@ const StockForm = ({ formType }) => { let productName = {}; productName.label = `${matchedProduct?.ProdName} (${matchedProduct.Size} ${matchedProduct.UomName})${matchedProduct?.BrandName ? ` - ${matchedProduct?.BrandName}` : ''}`; const newProduct = await ProductDropDownChange( + matchedProduct?.ProdVariantName, matchedProduct.ProdId, productName ); @@ -1380,115 +1476,6 @@ const StockForm = ({ formType }) => { VarProdId: null, }); }; - const ProductVariantDropDownChange = (value) => { - const ProdName2 = Variants?.filter( - (item) => item.ProdIdProdName === value - )?.[0]?.ProdVariantName; - - const ProdName1 = PurchaseData?.some( - (item) => - item.ProdId === selectedProductData && - item.ProdVariantName === ProdName2 - ); - if (ProdName1) { - setMessageType('error'); - setMessageData('Already variant Exists'); - } else { - const ProdName = Variants?.filter( - (item) => item.ProdIdProdName === value - )?.[0]?.ProdVariantName; - const OnePcsAvailable = Variants?.filter( - (item) => item.ProdIdProdName === value - )?.[0]?.OnePcsAvailable; - formRef?.current?.setFieldsValue({ VarProdId: value }); - setselectedProductVariantData(ProdName); - - let ProductData1 = productData?.find( - (e) => e.ProdId == selectedProductData - ); - let mrp; - let sellprice; - if (ProdName == 'Variant 1') { - mrp = ProductData1?.MRP; - sellprice = ProductData1?.SellPrice; - } else { - mrp = ProductData1?.ProdVariantPriceDetails?.find( - (item) => item.ProdVariantName == ProdName - )?.MRP; - sellprice = ProductData1?.ProdVariantPriceDetails?.find( - (item) => item.ProdVariantName == ProdName - )?.SellPrice; - } - let DefaultVariant = ProductData1?.ProdVariantPriceDetails?.find( - (item) => item?.ProdVariantName === ProdName && item?.ReceivedQty === 0 - )?.DefaultVariant; - let ProduData2 = { - DefaultVariant: DefaultVariant, - ProdId: ProductData1?.ProdId, - MRP: mrp, - ProdName: ProductData1?.ProdName, - UomName: ProductData1?.UomName, - SellPrice: sellprice, - StockAvailable: ProductData1?.StockAvailable, - OnePcsAvailable: ProductData1?.OnePcsAvailable, - NumberofPieceinside: ProductData1?.NoOfPcs, - AmountPerPiece: ProductData1?.OnePcsPrice, - TaxId: ProductData1?.TaxId, - TaxPercentage: ProductData1?.TaxPercentage, - }; - // ProduData2["StockAvailable"]="Y" - - const localId = uuidv4(); - let tempPurData = { - ...ProduData2, - BalanceQty: 0, - InwardPrice: 0, - PurcDisc: 0, - Amount: 0, - WhSalePrice: 0, - ReceivedQty: 0, - AcceptedQty: 0, - FreeItem: 0, - RejectedQty: 0, - OfferPrice: 0, - SpecialPrice: 0, - ProdVariantName: ProdName, - // 'TaxId': PurcselectedTax ? PurcselectedTax : 0, - TaxAmt: 0, - TaxType: SelectedPurcTaxType ? SelectedPurcTaxType : 0, - PurcDiscType: 'P', - localId: localId, - PurchaseTax: 0, - }; - form?.setFieldsValue({ - [`SellPrice${localId}`]: tempPurData?.SellPrice, - [`PurchaseTax${localId}`]: tempPurData?.PurchaseTax, - }); - - setPurchaseData([tempPurData, ...PurchaseData]); - - Delete - ? (form.setFieldsValue({ - [`BalanceQty${index}`]: undefined, - [`ReceivedQty${index}`]: undefined, - [`AcceptedQty${index}`]: undefined, - [`RejectedQty${index}`]: undefined, - [`Amount${index}`]: undefined, - [`FreeQty${index}`]: undefined, - [`InwardPrice${index}`]: undefined, - [`MRP${index}`]: undefined, - [`PurcDisc${index}`]: undefined, - [`SellPrice${index}`]: undefined, - [`WhSalePrice${index}`]: undefined, - [`offerSalePrice${index}`]: undefined, - [`splSalePrice${index}`]: undefined, - [`NumberofPieceinside${index}`]: undefined, - [`AmountPerPiece${index}`]: undefined, - }), - setDelete(false)) - : ' '; - } - }; const handleTaxDropDownChange = async (TaxId) => { formProductRef.current?.setFieldsValue({ TaxId: TaxId }); @@ -1789,96 +1776,124 @@ const StockForm = ({ formType }) => { if (Delete) { form.setFieldsValue({ - BalanceQty: { [localId]: undefined }, - ReceivedQty: { [localId]: undefined }, - AcceptedQty: { [localId]: undefined }, - RejectedQty: { [localId]: undefined }, - Amount: { [localId]: undefined }, - FreeQty: { [localId]: undefined }, - InwardPrice: { [localId]: undefined }, - MRP: { [localId]: undefined }, - PurcDisc: { [localId]: undefined }, - SellPrice: { [localId]: undefined }, - WhSalePrice: { [localId]: undefined }, - offerSalePrice: { [localId]: undefined }, - splSalePrice: { [localId]: undefined }, - NumberofPieceinside: { [localId]: undefined }, - AmountPerPiece: { [localId]: undefined }, - PurcDiscType: { [localId]: undefined }, + [`BalanceQty${localId}`]: undefined, + [`ReceivedQty${localId}`]: undefined, + [`AcceptedQty${localId}`]: undefined, + [`RejectedQty${localId}`]: undefined, + [`Amount${localId}`]: undefined, + [`Freeqty${localId}`]: undefined, + [`InwardPrice${localId}`]: undefined, + [`MRP${localId}`]: undefined, + [`PurcDisc${localId}`]: undefined, + [`SellPrice${localId}`]: undefined, + [`WhSalePrice${localId}`]: undefined, + [`offerSalePrice${localId}`]: undefined, + [`splSalePrice${localId}`]: undefined, + [`NumberofPieceinside${localId}`]: undefined, + [`AmountPerPiece${localId}`]: undefined, + [`PurcDiscType${localId}`]: undefined, + [`ManufDate${localId}`]: undefined, + [`ExpDate${localId}`]: undefined, + [`OnePcsPrice${localId}`]: undefined, + [`NoOfPcs${localId}`]: undefined, }); setDelete(false); } else { form.setFieldsValue({ - BalanceQty: { [localId]: record?.BalanceQty }, - ReceivedQty: { [localId]: record?.ReceivedQty }, - AcceptedQty: { [localId]: record?.AcceptedQty }, - RejectedQty: { [localId]: record?.RejectedQty }, - PurcDiscType: { [localId]: record?.PurcDiscType }, - Amount: { [localId]: record?.Amount }, - FreeQty: { [localId]: record?.FreeItem }, - InwardPrice: { [localId]: record?.InwardPrice }, - MRP: { [localId]: record?.MRP }, - PurcDisc: { [localId]: record?.PurcDisc }, - SellPrice: { [localId]: record?.SellPrice }, - WhSalePrice: { [localId]: record?.WhSalePrice }, - offerSalePrice: { [localId]: record?.OfferPrice }, - splSalePrice: { [localId]: record?.SpecialPrice }, - NumberofPieceinside: { [localId]: record?.NumberofPieceinside }, - AmountPerPiece: { [localId]: record?.AmountPerPiece }, + [`BalanceQty${localId}`]: record?.BalanceQty, + [`ReceivedQty${localId}`]: record?.ReceivedQty, + [`AcceptedQty${localId}`]: record?.AcceptedQty, + [`RejectedQty${localId}`]: record?.RejectedQty, + [`Freeqty${localId}`]: record?.FreeItem, + [`MRP${localId}`]: record?.MRP, + [`ManufDate${localId}`]: record?.ManufDate, + [`ExpDate${localId}`]: record?.ExpDate, + [`SellPrice${localId}`]: record?.SellPrice, + [`WhSalePrice${localId}`]: record?.WhSalePrice, + [`PurcDiscType${localId}`]: record?.PurcDiscType, + [`Amount${localId}`]: record?.Amount, + [`InwardPrice${localId}`]: record?.InwardPrice, + [`PurcDisc${localId}`]: record?.PurcDisc, + [`offerSalePrice${localId}`]: record?.OfferPrice, + [`splSalePrice${localId}`]: record?.SpecialPrice, + [`OnePcsPrice${localId}`]: record?.OnePcsPrice, + [`NoOfPcs${localId}`]: record?.NoOfPcs, }); if (applicationRestrictedFields.BatchAndModelDetails) { form.setFieldsValue({ - BatchRef: { [localId]: record?.BatchRef }, + [`BatchRef${localId}`]: record?.BatchRef, }); } } }; - const save = async (index) => { + const save = async (localId) => { try { - const row = await form?.validateFields(); + const row = await form.validateFields(); const modifiedObject = {}; + for (const key in row) { - const newKey = key.slice(0, -1); // Remove the last character ("0") from the key - modifiedObject[newKey] = row[key]; + // remove localId suffix from field names + if (key.endsWith(localId)) { + const newKey = key.replace(localId, ''); + modifiedObject[newKey] = row[key]; + } } - const newData = [...PurchaseData]; - // const index = newData.findIndex((item) => recordKey === item.InwardDtlId); - if (index > -1) { - const item = newData[index]; - newData.splice(index, 1, { ...item, ...modifiedObject }); - setPurchaseData(newData); - setEditingKey(''); - } + setPurchaseData((prev) => + prev.map((item) => + item.localId === localId ? { ...item, ...modifiedObject } : item + ) + ); + + setEditingKey(''); } catch (err) { console.error('Save failed:', err); } }; - const handleKeyPress = async (e, record, index) => { + const handleKeyPress = async (e, record) => { if (e.key === 'Enter') { try { await form.validateFields(); - save(index); + save(record.localId); } catch (error) { console.error('Save failed:', error); } } }; - const openAdditionalInfoModal = (record, index) => { - console.log(record, 'recordrecord'); - if (record?.ReceivedQty === 0 || record?.ReceivedQty === '') { - setMessageType('error'); - setMessageData('Please Enter Qty'); - return; - } - setSelectedRowIndex(index); - setSelectedRowRecord(record); - setAdditionalInfoModal(true); + const formatDateForDisplay = (dateString) => { + if (!dateString) return ''; + return moment(dateString).format('DD-MMM-YY'); + }; + + const updateRowValues = (localId, updates) => { + setPurchaseData((prev) => + prev.map((item) => + item.localId === localId ? { ...item, ...updates } : item + ) + ); + + const formUpdates = {}; + Object.keys(updates).forEach((key) => { + formUpdates[`${key}${localId}`] = updates[key]; + }); + + form.setFieldsValue(formUpdates); + }; + const updateRowValue = (localId, key, value) => { + setPurchaseData((prev) => + prev.map((item) => + item.localId === localId ? { ...item, [key]: value } : item + ) + ); + + form.setFieldsValue({ + [`${key}${localId}`]: value, + }); }; const columns = [ @@ -1891,14 +1906,21 @@ const StockForm = ({ formType }) => { ), }, { - title: 'Product Name', + title: 'Name', dataIndex: 'ProdName', key: 'ProdName', align: 'left', render: (text, record, index) => ( - - {record?.ProdName + '(' + record?.ProdVariantName + ')'} - + {record?.ProdName} + ), + }, + { + title: 'Variant', + dataIndex: 'ProdVariantName', + key: 'ProdVariantName', + align: 'left', + render: (text, record, index) => ( + {record?.ProdVariantName} ), }, { @@ -1934,9 +1956,9 @@ const StockForm = ({ formType }) => { ]} > handleKeyPress(e, record, index)} + onPressEnter={(e) => handleKeyPress(e, record)} onBlur={(e) => handleQtyChange(e, record)} - onChange={(e) => handleQtyChange(e, record, index)} + onChange={(e) => handleQtyChange(e, record)} inputMode="decimal" onInput={(e) => { let cleanedValue = e.target.value.replace(/[^0-9.]/g, ''); // Remove invalid characters @@ -1961,7 +1983,7 @@ const StockForm = ({ formType }) => { { title: ( - Purchase Rate / Unit + Purchase Rate/unit ), dataIndex: 'InwardPrice', @@ -1991,9 +2013,9 @@ const StockForm = ({ formType }) => { ]} > handleKeyPress(e, record, index)} - onChange={(e) => handlePurrateChange(e, record, index)} - onBlur={(e) => handlePurrateChange(e, record, index)} + onPressEnter={(e) => handleKeyPress(e, record)} + onChange={(e) => handlePurrateChange(e, record)} + onBlur={(e) => handlePurrateChange(e, record)} inputMode="decimal" onInput={(e) => { let cleanedValue = e.target.value.replace(/[^0-9.]/g, ''); // Remove invalid characters @@ -2024,7 +2046,7 @@ const StockForm = ({ formType }) => { ), dataIndex: 'PurchaseTax', key: 'PurchaseTax', - width: 120, + // width: 120, editable: true, render: (text, record, index) => { return isEditing(record, index) ? ( @@ -2075,9 +2097,9 @@ const StockForm = ({ formType }) => { ]} > handleKeyPress(e, record, index)} - onChange={(e) => handleTaxChange(e, record, index)} - onBlur={(e) => handleTaxChange(e, record, index)} + onPressEnter={(e) => handleKeyPress(e, record)} + onChange={(e) => handleTaxChange(e, record)} + onBlur={(e) => handleTaxChange(e, record)} inputMode="decimal" onInput={(e) => { let value = e.target.value.replace(/[^0-9.]/g, ''); @@ -2104,15 +2126,54 @@ const StockForm = ({ formType }) => { key: 'Amount', editable: true, }, + ...(selectedAdditionalColumn.includes('Mrp') + ? [ + { + title: 'MRP', + dataIndex: 'MRP', + key: 'MRP', + editable: true, + // width: 150, + render: (text, record) => { + const localId = record.localId; + + return isEditing(record) ? ( + + { + const value = e.target.value; + + if (!/^\d*\.?\d*$/.test(value)) { + setMessageType('error'); + setMessageData('Only numeric values are allowed'); + return; + } + + updateRowValues(record.localId, { + MRP: value, + SellPrice: value, + }); + }} + onPressEnter={(e) => handleKeyPress(e, record)} + /> + + ) : ( + text + ); + }, + }, + ] + : []), { title: ( - Selling Price / Unit + Selling Price ), dataIndex: 'SellPrice', key: 'SellPrice', - width: 120, + width: 70, editable: true, render: (text, record, index) => { return isEditing(record, index) ? ( @@ -2125,9 +2186,9 @@ const StockForm = ({ formType }) => { ]} > handleKeyPress(e, record, index)} - onChange={(e) => handleSellPriceChange(e, record, index)} - onBlur={(e) => handleSellPriceChange(e, record, index)} + onPressEnter={(e) => handleKeyPress(e, record)} + onChange={(e) => handleSellPriceChange(e, record)} + onBlur={(e) => handleSellPriceChange(e, record)} inputMode="decimal" onInput={(e) => { let cleanedValue = e.target.value.replace(/[^0-9.]/g, ''); // Remove invalid characters @@ -2147,25 +2208,481 @@ const StockForm = ({ formType }) => { ); }, }, - { - title: 'Additional Info', - dataIndex: 'AdditionalInfo', - key: 'AdditionalInfo', - width: 120, - align: 'center', - render: (text, record, index) => { - return ( - <> - {' '} - openAdditionalInfoModal(record, index)} - className="shape-preview" - /> - - ); - }, - }, + + ...(selectedAdditionalColumn.includes('Amount Per Piece') + ? [ + { + title: 'Amount per piece', + dataIndex: 'OnePcsPrice', + key: 'OnePcsPrice', + width: 70, + editable: true, + render: (text, record, index) => { + return isEditing(record, index) ? ( + + handleKeyPress(e, record)} + onChange={(e) => { + const newData = PurchaseData.map((item) => + item.localId === record?.localId + ? { ...item, OnePcsPrice: e.target.value } + : item + ); + setPurchaseData(newData); + }} + placeholder="OnePcsPrice" + /> + + ) : ( + text + ); + }, + }, + ] + : []), + ...(selectedAdditionalColumn.includes('Amount Per Piece') + ? [ + { + title: 'Number of piece', + dataIndex: 'NoOfPcs', + key: 'NoOfPcs', + width: 70, + editable: true, + render: (text, record, index) => { + return isEditing(record, index) ? ( + + handleKeyPress(e, record)} + onChange={(e) => { + const newData = PurchaseData.map((item) => + item.localId === record?.localId + ? { ...item, NoOfPcs: e.target.value } + : item + ); + setPurchaseData(newData); + }} + placeholder="NoOfPcs" + /> + + ) : ( + text + ); + }, + }, + ] + : []), + ...(selectedAdditionalColumn.includes('Wholesale Price') + ? [ + { + title: 'Wholesale price', + dataIndex: 'WhSalePrice', + key: 'WhSalePrice', + width: 70, + editable: true, + render: (text, record) => { + return isEditing(record) ? ( + + handleKeyPress(e, record)} + onChange={(e) => { + const value = e.target.value; + + // 🚫 block non-numeric + if (!/^\d*\.?\d*$/.test(value)) return; + + updateRowValue(record.localId, 'WhSalePrice', value); + }} + /> + + ) : ( + text + ); + }, + }, + ] + : []), + + ...(selectedAdditionalColumn.includes('Manufacture Date') + ? [ + { + title: 'Manuf.Date', + dataIndex: 'ManufDate', + key: 'ManufDate', + editable: true, + render: (text, record, index) => { + return isEditing(record, index) ? ( + + { + const formattedDate = + dateString === '' + ? undefined + : moment(dateString, ['DD-MM-YYYY']).format( + 'YYYY-MM-DDTHH:mm:ss' + ); + const newData = PurchaseData.map((item) => + item.localId === record?.localId + ? { ...item, ManufDate: formattedDate } + : item + ); + setPurchaseData(newData); + form.setFieldsValue({ + [`ManufDate${record?.localId}`]: formattedDate, + }); + }} + valueData={record?.ManufDate} + cancelFuture={true} + /> + + ) : ( + formatDateForDisplay(text) + ); + }, + }, + ] + : []), + ...(selectedAdditionalColumn.includes('Expiry Date') + ? [ + { + title: 'Exp.Date', + dataIndex: 'ExpDate', + key: 'ExpDate', + editable: true, + render: (text, record, index) => { + return isEditing(record, index) ? ( + + { + const formattedDate = + dateString === '' + ? undefined + : moment(dateString, ['DD-MM-YYYY']).format( + 'YYYY-MM-DDTHH:mm:ss' + ); + const newData = PurchaseData.map((item) => + item.localId === record?.localId + ? { ...item, ExpDate: formattedDate } + : item + ); + setPurchaseData(newData); + form.setFieldsValue({ + [`ExpDate${record?.localId}`]: formattedDate, + }); + }} + valueData={record?.ExpDate} + cancelFuture={false} + /> + + ) : ( + formatDateForDisplay(text) + ); + }, + }, + ] + : []), + + ...(selectedAdditionalColumn.includes('Hsn') + ? [ + { + title: 'Hsn', + dataIndex: 'Hsn', + key: 'Hsn', + editable: true, + // width: 130, + render: (text, record, index) => { + return isEditing(record, index) ? ( + + handleKeyPress(e, record)} + onChange={(e) => { + const newData = PurchaseData.map((item) => + item.localId === record?.localId + ? { ...item, PurchaseHSNCode: e.target.value } + : item + ); + setPurchaseData(newData); + }} + placeholder="HSN code" + /> + + ) : ( + text + ); + }, + }, + ] + : []), + ...(selectedAdditionalColumn.includes('Model No') + ? [ + { + title: 'Model', + dataIndex: 'Model', + key: 'Model', + editable: true, + render: (text, record, index) => { + return isEditing(record, index) ? ( + + handleKeyPress(e, record, index)} + onChange={(e) => { + const newData = PurchaseData.map((item) => + item.localId === record?.localId + ? { ...item, ModelNumber: e.target.value } + : item + ); + setPurchaseData(newData); + }} + placeholder="Model No" + /> + + ) : ( + text + ); + }, + }, + ] + : []), + ...(selectedAdditionalColumn.includes('Batch No') + ? [ + { + title: 'Batch', + dataIndex: 'Batch', + key: 'Batch', + editable: true, + render: (text, record, index) => { + return isEditing(record, index) ? ( + + handleKeyPress(e, record, index)} + onChange={(e) => { + const newData = PurchaseData.map((item) => + item.localId === record?.localId + ? { ...item, BatchRef: e.target.value } + : item + ); + setPurchaseData(newData); + }} + placeholder="Batch No" + /> + + ) : ( + text + ); + }, + }, + ] + : []), + + ...(selectedAdditionalColumn.includes('Rejected Qty') + ? [ + { + title: 'Rejected Qty', + dataIndex: 'RejectedQty', + key: 'RejectedQty', + editable: true, + render: (text, record, index) => { + return isEditing(record, index) ? ( + + handleKeyPress(e, record, index)} + onChange={(e) => { + const inputValue = e.target.value; + const rejectedQty = parseFloat(inputValue) || 0; + const receivedQty = parseFloat(record.ReceivedQty) || 0; + + if (inputValue !== '' && rejectedQty >= receivedQty) { + setMessageType('error'); + setMessageData( + 'Rejected Qty cannot be greater than or Equal to Received Qty' + ); + form.setFieldsValue({ + [`RejectedQty${record?.localId}`]: + record.RejectedQty || 0, + }); + return; + } + + const acceptedQty = receivedQty - rejectedQty; + const totalAmount = + acceptedQty * (parseFloat(record.InwardPrice) || 0); + + const newData = PurchaseData.map((item) => + item.localId === record?.localId + ? { + ...item, + RejectedQty: parseFloat(inputValue) || 0, + AcceptedQty: acceptedQty, + Amount: totalAmount, + } + : item + ); + setPurchaseData(newData); + }} + placeholder="Rejected Qty" + /> + + ) : ( + text + ); + }, + }, + ] + : []), + + ...(selectedAdditionalColumn.includes('Free Qty') + ? [ + { + title: 'Free Qty', + dataIndex: 'Freeqty', + key: 'Freeqty', + editable: true, + render: (text, record) => { + return isEditing(record) ? ( + + handleKeyPress(e, record)} + onChange={(e) => { + const value = e.target.value; + + // 🚫 block non-numeric + if (!/^\d*$/.test(value)) return; + + updateRowValue(record.localId, 'Freeqty', value); + }} + /> + + ) : ( + text + ); + }, + }, + ] + : []), + + ...(selectedAdditionalColumn.includes('IMEI') + ? [ + { + title: 'IMEI', + dataIndex: 'AdditionalInfo', + key: 'AdditionalInfo', + width: 120, + align: 'center', + render: (text, record, index) => { + const hasQty = + record?.ReceivedQty && parseFloat(record.ReceivedQty) > 0; + return ( + <> + {' '} + { + if (hasQty) { + setSelectedRowIndex(index); + handleModelDataOpen(record); + } else { + setMessageType('error'); + setMessageData('Please Enter Qty'); + } + }} + className="shape-preview" + /> + + ); + }, + }, + ] + : []), { title: 'Action', dataIndex: 'Action', @@ -2181,174 +2698,243 @@ const StockForm = ({ formType }) => { style={{ color: '#FF4D4F', }} - onClick={() => statusFormatters(record, index)} + onClick={() => statusFormatters(record)} /> ), }, ]; - const statusFormatters = (record, index) => { + const statusFormatters = (record) => { const localId = record?.localId; - const Data = PurchaseData.filter((_, i) => i !== index); + + // Remove row using localId (not index) + const data = PurchaseData.filter((item) => item?.localId !== localId); + setDelete(true); + + // Clear form fields for this row + form.setFieldsValue({ [`BalanceQty${localId}`]: undefined, [`ReceivedQty${localId}`]: undefined, [`AcceptedQty${localId}`]: undefined, [`RejectedQty${localId}`]: undefined, - [`Amount${localId}`]: undefined, - [`FreeQty${localId}`]: undefined, - [`InwardPrice${localId}`]: undefined, + [`Freeqty${localId}`]: undefined, [`MRP${localId}`]: undefined, - [`PurcDisc${localId}`]: undefined, + [`ManufDate${localId}`]: undefined, + [`ExpDate${localId}`]: undefined, [`SellPrice${localId}`]: undefined, [`WhSalePrice${localId}`]: undefined, + [`PurcDiscType${localId}`]: undefined, + [`Amount${localId}`]: undefined, + [`InwardPrice${localId}`]: undefined, + [`PurcDisc${localId}`]: undefined, [`offerSalePrice${localId}`]: undefined, [`splSalePrice${localId}`]: undefined, + [`OnePcsPrice${localId}`]: undefined, + [`NoOfPcs${localId}`]: undefined, }); - setVariants(); - setPurchaseData(Data); + setVariants(undefined); + setPurchaseData(data); setSelectedProductData(null); - formRef?.current?.setFieldsValue({ ProdId: null }); + + formRef?.current?.setFieldsValue({ + ProdId: null, + }); }; - const handleQtyChange = (e, record, index) => { + const handleQtyChange = (e, record) => { const { localId } = record; + + const sourceData = PurchaseData; + + const findIndex = sourceData.findIndex((item) => item?.localId === localId); + + if (findIndex === -1) return; + const inputValue = e.target.value; - setDataSource([]); - setDataSourceBackup([]); - // Validate if inputValue is numeric + + // ✅ Numeric validation if (!/^\d*\.?\d*$/.test(inputValue)) { setMessageType('error'); setMessageData('Only numeric values are allowed'); return; } - const qty = inputValue; - const acceptedQty = parseFloat(qty); + const qty = Number(inputValue) || 0; + const acceptedQty = qty; - const newData = PurchaseData.map((item, index1) => { - if (index1 === index) { - return { - ...item, - Amount: - isNaN(parseFloat(item?.InwardPrice)) || isNaN(acceptedQty) - ? 0 - : parseFloat(item?.InwardPrice) * acceptedQty, - PurcDisc: 0, - BalanceQty: qty, - ReceivedQty: qty, - AcceptedQty: !isNaN(acceptedQty) ? acceptedQty : 0, - RejectedQty: !isNaN(qty - acceptedQty) ? qty - acceptedQty : 0, - ProductIdentifierDtls: [], - }; - } - return item; - }); + const newData = [...PurchaseData]; + + const item = newData[findIndex]; + + newData[findIndex] = { + ...item, + Amount: + isNaN(Number(item?.InwardPrice)) || isNaN(acceptedQty) + ? 0 + : Number(item?.InwardPrice) * acceptedQty, + PurcDisc: 0, + BalanceQty: qty, + ReceivedQty: qty, + AcceptedQty: acceptedQty, + RejectedQty: 0, + ProductIdentifierDtls: [], + }; setPurchaseData(newData); + + // ✅ Sync form values form.setFieldsValue({ - ...form.getFieldsValue(), [`PurcDisc${localId}`]: 0, [`BalanceQty${localId}`]: qty, [`ReceivedQty${localId}`]: qty, - [`AcceptedQty${localId}`]: !isNaN(acceptedQty) ? acceptedQty : 0, - [`RejectedQty${localId}`]: !isNaN(qty - acceptedQty) - ? qty - acceptedQty - : 0, - // ReceivedQty: qty, - // AcceptedQty: acceptedQty, - // RejectedQty: qty - acceptedQty, + [`AcceptedQty${localId}`]: acceptedQty, + [`RejectedQty${localId}`]: 0, }); }; - const handlePurrateChange = (e, record, index) => { - const { localId, PurcDisc, PurcDiscType, PurchaseTax } = record; + const handlePurrateChange = (e, record) => { + const { localId, PurcDisc, PurcDiscType } = record; const PurcRate = e.target.value; + + // ✅ Numeric validation if (!/^\d*\.?\d*$/.test(PurcRate)) { setMessageType('error'); setMessageData('Only numeric values are allowed'); return; } - const Amount = parseFloat(PurcRate) * record?.AcceptedQty; + + const acceptedQty = Number(record?.AcceptedQty) || 0; + const rate = Number(PurcRate) || 0; + const amount = rate * acceptedQty; + + // 🔍 Find correct index using localId + const findIndex = PurchaseData.findIndex( + (item) => item?.localId === localId + ); + + if (findIndex === -1) return; + + const item = PurchaseData[findIndex]; + + // 🧮 Discount calculation let discountAmt = 0; if (PurcDiscType === 'P') { - discountAmt = (Amount * Number(PurcDisc)) / 100; + discountAmt = (amount * Number(PurcDisc || 0)) / 100; } else { - discountAmt = Number(PurcDisc); + discountAmt = Number(PurcDisc || 0); } - // You can calculate acceptedQty based on your requirement - const newData = PurchaseData.map((item, index1) => { - if (index1 === index) { - return { - ...item, - PurcDisc: 0, - InwardPrice: Delete ? 0 : PurcRate, - Amount: !isNaN(Amount) ? Amount : 0, - TaxAmt: - (parseInt(Amount) * parseInt(item?.TaxPercentage)) / - (100 + parseInt(item?.TaxPercentage))?.toFixed(2), - }; - } - return item; - }); - formRef?.current?.setFieldsValue({ - PaymentAmount: newData?.reduce((acc, data) => acc + data?.Amount, 0), - }); - setPaymentAmount(newData?.reduce((acc, data) => acc + data?.Amount, 0)); + + // 🧮 Tax calculation + const taxPercent = Number(item?.TaxPercentage || 0); + const taxAmt = + taxPercent > 0 + ? ((amount - discountAmt) * taxPercent) / (100 + taxPercent) + : 0; + + // ✅ Update data immutably + const newData = [...PurchaseData]; + + newData[findIndex] = { + ...item, + PurcDisc: 0, + InwardPrice: Delete ? 0 : rate, + Amount: !isNaN(amount) ? amount : 0, + TaxAmt: taxAmt.toFixed(2), + }; + setPurchaseData(newData); + + // 🔄 Update payment amount + const totalAmount = newData.reduce( + (acc, data) => acc + Number(data?.Amount || 0), + 0 + ); + + setPaymentAmount(totalAmount); + + formRef?.current?.setFieldsValue({ + PaymentAmount: totalAmount, + }); + + // 🔄 Sync row form fields form.setFieldsValue({ [`PurcDisc${localId}`]: 0, - InwardPrice: { [localId]: Delete ? 0 : PurcRate }, - Amount: { [localId]: !isNaN(Amount) ? Amount : 0 }, + [`InwardPrice${localId}`]: Delete ? 0 : rate, + [`Amount${localId}`]: !isNaN(amount) ? amount : 0, }); }; - const handleSellPriceChange = (e, record, index) => { + const handleSellPriceChange = (e, record) => { const { localId } = record; const value = e?.target?.value; + + // ✅ Numeric validation if (!/^\d*\.?\d*$/.test(value)) { setMessageType('error'); setMessageData('Only numeric values are allowed'); return; } - const newData = PurchaseData?.map((item, index1) => { - if (index1 === index) { - return { - ...item, - SellPrice: value, - }; - } - return item; - }); + + // 🔍 Find correct row using localId + const findIndex = PurchaseData.findIndex( + (item) => item?.localId === localId + ); + + if (findIndex === -1) return; + + // ✅ Immutable update + const newData = [...PurchaseData]; + + newData[findIndex] = { + ...newData[findIndex], + SellPrice: value, + }; + + setPurchaseData(newData); + + // 🔄 Sync form field form.setFieldsValue({ [`SellPrice${localId}`]: value, }); - setPurchaseData(newData); }; - const handleTaxChange = (e, record, index) => { + const handleTaxChange = (e, record) => { const { localId } = record; const value = e?.target?.value; + + // ✅ Numeric validation if (!/^\d*\.?\d*$/.test(value)) { setMessageType('error'); setMessageData('Only numeric values are allowed'); return; } - const newData = PurchaseData?.map((item, index1) => { - if (index1 === index) { - return { - ...item, - PurchaseTax: parseFloat(value) || 0, - }; - } - return item; - }); - form.setFieldsValue({ - [`PurchaseTax${localId}`]: parseFloat(value) || 0, - }); + + const taxValue = Number(value) || 0; + + // 🔍 Find correct row + const findIndex = PurchaseData.findIndex( + (item) => item?.localId === localId + ); + + if (findIndex === -1) return; + + // ✅ Immutable update + const newData = [...PurchaseData]; + + newData[findIndex] = { + ...newData[findIndex], + PurchaseTax: taxValue, + }; + setPurchaseData(newData); + + // 🔄 Sync form value + form.setFieldsValue({ + [`PurchaseTax${localId}`]: taxValue, + }); }; const purchaseStatusChange = (value) => { @@ -2479,39 +3065,33 @@ const StockForm = ({ formType }) => { const onFinish = async ({ PaymentType, PaymentAmount = 0, ...values }) => { try { + // =============================== + // 1️⃣ TAX VALIDATION + // =============================== const invalidTaxItems = PurchaseData?.filter((item) => { const tax = item.PurchaseTax; - - if (tax === undefined || tax === '' || tax === null) { - return false; - } - + if (tax === undefined || tax === '' || tax === null) return false; const num = Number(tax); - - if (isNaN(num)) { - return true; - } - - if (num < 0 || num > 99) { - return true; - } - - return false; + return isNaN(num) || num < 0 || num > 99; }); - if (invalidTaxItems && invalidTaxItems.length > 0) { + if (invalidTaxItems.length > 0) { setMessageType('error'); setMessageData( - 'Please enter valid tax percentage (0-99%) for all items' + 'Please enter valid tax percentage (0–99%) for all items' ); return; } + + // =============================== + // 2️⃣ SELL PRICE > MRP CHECK + // =============================== if ( PurchaseData?.some( (item) => item.SellPrice && item.MRP && - parseFloat(item.SellPrice) > parseFloat(item.MRP) + Number(item.SellPrice) > Number(item.MRP) ) ) { setMessageType('error'); @@ -2519,158 +3099,181 @@ const StockForm = ({ formType }) => { return; } - if (PurchaseData.length === 0) { + // =============================== + // 3️⃣ NO PRODUCT CHECK + // =============================== + if (!PurchaseData || PurchaseData.length === 0) { setMessageType('error'); setMessageData('No Product Selected'); return; } - if ( - !PurchaseData?.every( - (item) => - (parseFloat(item.BalanceQty) ? parseFloat(item.BalanceQty) : 0) !== - 0 && item.Amount !== 0 - ) - ) { - setMessageType('error'); - setMessageData('Please Enter Qty And Amount'); - return; - } + // =============================== + // 4️⃣ FILTER VALID / INVALID ROWS + // =============================== + const validRows = []; + const invalidRowNumbers = []; - if (!PurchaseData?.every((item) => item.AcceptedQty !== 0)) { - setMessageType('error'); - setMessageData('Qty & Rejected Qty Should not be same'); - return; - } - if (SupplierOpen === 'paid') { - const { SuppInvoiceNo, SuppInvoiceDate } = - (await formRef?.current?.getFieldsValue()) || {}; - if (!SuppInvoiceNo && !SuppInvoiceDate) { - setMessageType('error'); - setMessageData( - `Enter The ${invoiceType === 'I' ? 'Invoice ' : 'Delivery Challan'} No and Date` - ); - return; - } else if (!SuppInvoiceNo) { - setMessageType('error'); - setMessageData( - `Enter The ${invoiceType === 'I' ? 'Invoice ' : 'Delivery Challan'} No` - ); - return; - } else if (!SuppInvoiceDate) { - setMessageType('error'); - setMessageData( - `Enter The ${invoiceType === 'I' ? 'Invoice ' : 'Delivery Challan'} Date` - ); - return; + PurchaseData.forEach((item, index) => { + const qty = Number(item.BalanceQty) || 0; + const amount = Number(item.Amount) || 0; + + if (qty > 0 && amount > 0) { + validRows.push(item); + } else { + invalidRowNumbers.push(index + 1); } - } - - const images = getUniqueImageArray(PurchaseData); - - const postData = { - ...values, - InvoiceAmount: PurchaseData?.reduce( - (acc, data) => acc + data?.Amount, - 0 - ), - CompId, - BranchId, - AppId, - CreatedBy: UserId, - PurOrderStatus: purchaseStatus, - TaxAmount: TotalTaxAmount?.toFixed(2), - BillAmount: (SelInvoiceAmount - TotalTaxAmount)?.toFixed(2), - TotalAmount: SelInvoiceAmount, - PurOrderInvoiceNo: purchaseOrderId, - PaymentStatus: 'S', - LocationType: SupplierData?.find( - (item) => item?.SuppId === selectedSupplierData - )?.Type, - ImageDetails: images || [], - }; - - const fieldsToRemove = [ - 'InwardDtlId', - 'InwardId', - 'UomName', - 'ProdName', - 'UOMName', - ]; - - const processedData = PurchaseData?.map((item) => { - const cleanItem = { ...item }; - fieldsToRemove.forEach((field) => delete cleanItem[field]); - return { - ...cleanItem, - TaxType: SelectedPurcTaxType || 0, - BalanceQty: cleanItem.AcceptedQty, - OnePcsPrice: cleanItem.AmountPerPiece, - NoOfPcs: cleanItem.NumberofPieceinside, - }; }); - const isPaidSelected = PurchaseTypeData?.some( - (item) => - item.ConfigId === SelectedPurchaseType && item.ConfigName === 'Cash' - ); - if ( - (SupplierOpen !== 'own' || selectedSupplierName) && - selectedSupplierData && - isPaidSelected - ) { - postData.PaymentAmount = PaymentAmount; - postData.PaymentType = selectedPaymentMode; - } else { - postData.PaymentType = PaymentType; - } - - postData['ProdDetails'] = processedData; - - if (formType === 'edit') { - postData['ProdId'] = editstate?.ProdId; - postData['InwardId'] = editstate?.InwardId; - postData['InwardDtlId'] = editstate?.InwardDtlId; - postData['UpdatedBy'] = UserId; - } - - let response; - try { - if (formType === 'add') { - response = await dispatch(postPurchaseData(postData)).unwrap(); - } else { - response = await dispatch(putStockData(postData)).unwrap(); - } - } catch (err) { - if (err?.message === 'Request failed with status code 422') { - response = { - data: { - statusCode: 0, - response: 'Please Give Required Fields', - data: [], - }, - }; - } - } - - if (response?.data?.statusCode === 1) { - navigate(`${subDirectory}setting/purchase-entry/`, { - state: { - Notiffy: { - messageType: 'success', - messageData: response?.data?.response, - }, - }, - }); - } else { + if (validRows.length === 0) { setMessageType('error'); - setMessageData(response?.data?.response); + setMessageData('Please enter Qty and Amount for at least one product'); + return; } - } catch (errorInfo) { - console.log('Validation Failed:', errorInfo); + + // =============================== + // 5️⃣ CONFIRMATION FOR INVALID ROWS + // =============================== + if (invalidRowNumbers.length > 0) { + Modal.confirm({ + title: '⚠️ Incomplete Product Rows', + width: 520, + centered: true, + content: ( +
    +

    + Some products are missing Qty or Amount. +

    + +

    + Affected row(s): {invalidRowNumbers.join(', ')} +

    + +

    + Are you sure you want to continue without these products? +

    +
    + ), + okText: 'Continue Anyway', + cancelText: 'Go Back', + okButtonProps: { danger: true }, + onOk: () => + proceedSubmit(validRows, values, PaymentType, PaymentAmount), + }); + + return; + } + + // If all rows valid + await proceedSubmit(validRows, values, PaymentType, PaymentAmount); + } catch (error) { + console.error(error); setMessageType('error'); - setMessageData('Please correct the highlighted fields'); - return; + setMessageData('Something went wrong'); + } + }; + const proceedSubmit = async ( + filteredPurchaseData, + values, + PaymentType, + PaymentAmount + ) => { + const images = getUniqueImageArray(filteredPurchaseData); + const postData = { + ...values, + InvoiceAmount: filteredPurchaseData.reduce( + (acc, item) => acc + Number(item.Amount || 0), + 0 + ), + CompId, + BranchId, + AppId, + CreatedBy: UserId, + PurOrderStatus: purchaseStatus, + TaxAmount: TotalTaxAmount?.toFixed(2), + BillAmount: (SelInvoiceAmount - TotalTaxAmount)?.toFixed(2), + TotalAmount: SelInvoiceAmount, + PurOrderInvoiceNo: purchaseOrderId, + PaymentStatus: 'S', + LocationType: SupplierData?.find( + (item) => item?.SuppId === selectedSupplierData + )?.Type, + ImageDetails: images || [], + }; + + const fieldsToRemove = [ + 'InwardDtlId', + 'InwardId', + 'UomName', + 'ProdName', + 'UOMName', + ]; + + const processedData = filteredPurchaseData.map((item) => { + const cleanItem = { ...item }; + fieldsToRemove.forEach((field) => delete cleanItem[field]); + + return { + ...cleanItem, + TaxType: SelectedPurcTaxType || 0, + BalanceQty: cleanItem.AcceptedQty, + OnePcsPrice: cleanItem.OnePcsPrice, + NoOfPcs: cleanItem.NoOfPcs, + }; + }); + + const isPaidSelected = PurchaseTypeData?.some( + (item) => + item.ConfigId === SelectedPurchaseType && item.ConfigName === 'Cash' + ); + + if ( + (SupplierOpen !== 'own' || selectedSupplierName) && + selectedSupplierData && + isPaidSelected + ) { + postData.PaymentAmount = PaymentAmount; + postData.PaymentType = selectedPaymentMode; + } else { + postData.PaymentType = PaymentType; + } + + postData.ProdDetails = processedData; + + if (formType === 'edit') { + postData.ProdId = editstate?.ProdId; + postData.InwardId = editstate?.InwardId; + postData.InwardDtlId = editstate?.InwardDtlId; + postData.UpdatedBy = UserId; + } + + let response; + try { + response = + formType === 'add' + ? await dispatch(postPurchaseData(postData)).unwrap() + : await dispatch(putStockData(postData)).unwrap(); + } catch (err) { + response = { + data: { + statusCode: 0, + response: 'Please Give Required Fields', + }, + }; + } + + if (response?.data?.statusCode === 1) { + navigate(`${subDirectory}setting/purchase-entry/`, { + state: { + Notiffy: { + messageType: 'success', + messageData: response?.data?.response, + }, + }, + }); + } else { + setMessageType('error'); + setMessageData(response?.data?.response); } }; @@ -3003,74 +3606,6 @@ const StockForm = ({ formType }) => { // command - const handleRejectedQty = () => { - const formData = productAddInfoRef?.current?.getFieldsValue(); - const rejectedQty = - formData?.RejectedQty === '' ? 0 : parseFloat(formData?.RejectedQty); - const receivedQty = parseFloat(formData.ReceivedQty) - ? parseFloat(formData.ReceivedQty) - : 0; - let acceptedQty = receivedQty; - let newRejectedQty = 0; - - if (isNaN(rejectedQty)) { - newRejectedQty = ''; - } else if (rejectedQty >= receivedQty) { - setMessageType('error'); - setMessageData( - 'Rejected Qty cannot be greater than or Equal to Received Qty' - ); - } else { - newRejectedQty = rejectedQty; - acceptedQty = receivedQty - rejectedQty; - } - let totalAmount = - acceptedQty * (parseFloat(selectedRowRecord?.InwardPrice) || 0); - - setSelectedRowRecord((prev) => ({ - ...prev, - AcceptedQty: acceptedQty, - RejectedQty: newRejectedQty === '' ? 0 : newRejectedQty, - ProductIdentifierDtls: [], - Amount: totalAmount, - })); - - productAddInfoRef?.current?.setFieldsValue({ - RejectedQty: newRejectedQty === '' ? 0 : newRejectedQty, - AcceptedQty: acceptedQty, - }); - }; - - const handleFreeQtyChange = (e) => { - const inputValue = e?.target?.value; - - if (!/^\d*\.?\d*$/.test(inputValue)) { - setMessageType('error'); - setMessageData('Only numeric values are allowed'); - return; - } - - const freeQty = inputValue === '' ? '' : parseFloat(inputValue); - - setSelectedRowRecord((prev) => ({ - ...prev, - FreeItem: freeQty, - })); - }; - - const handleMRPChange = (e) => { - let value = e?.target?.value === '' ? 0 : parseFloat(e?.target?.value); - productAddInfoRef?.current?.setFieldsValue({ SellPrice: null, MRP: value }); - setSelectedRowRecord((prev) => ({ ...prev, SellPrice: null, MRP: value })); - productAddInfoRef?.current?.validateFields(); - }; - - const handleHSNChange = (e) => { - const value = e?.target?.value; - productAddInfoRef?.current?.setFieldsValue({ PurchaseHSNCode: value }); - setSelectedRowRecord((prev) => ({ ...prev, PurchaseHSNCode: value })); - }; - const validateSellPrice = (record) => (_, value) => { if (!value) { return Promise.reject('Selling Price is required'); @@ -3091,103 +3626,7 @@ const StockForm = ({ formType }) => { return Promise.resolve(); }; - const handleAmountPerPiecechange = (e) => { - const inputValue = e?.target?.value; - - const amountPerPiece = inputValue === '' ? '' : parseFloat(inputValue); - - if (selectedRowRecord?.OnePcsAvailable === 'Y') { - setSelectedRowRecord((prev) => ({ - ...prev, - AmountPerPiece: amountPerPiece, - })); - } - }; - - const handleNumberofPieceinsidechange = (e) => { - const inputValue = e?.target?.value; - - const numberOfPieceInside = inputValue === '' ? '' : parseFloat(inputValue); - - if (selectedRowRecord?.OnePcsAvailable === 'Y') { - setSelectedRowRecord((prev) => ({ - ...prev, - NumberofPieceinside: numberOfPieceInside, - })); - } - }; - - const handleManufactureDate = (date, dateString) => { - const formattedDate = - dateString === '' - ? undefined - : moment(dateString, ['DD-MM-YYYY']).format('YYYY-MM-DDTHH:mm:ss'); - productAddInfoRef?.current?.setFieldsValue({ - ManufDate: date, - }); - setSelectedRowRecord((prev) => ({ ...prev, ManufDate: formattedDate })); - }; - - const handleExpireDate = (date, dateString) => { - const formattedDate = - dateString === '' - ? undefined - : moment(dateString, ['DD-MM-YYYY']).format('YYYY-MM-DDTHH:mm:ss'); - productAddInfoRef?.current?.setFieldsValue({ - ExpDate: date, - }); - setSelectedRowRecord((prev) => ({ ...prev, ExpDate: formattedDate })); - }; - - const handleBatchRefChange = (e) => { - const value = parseInt(e?.target?.value); - if (!/^\d*\.?\d*$/.test(value)) { - return; - } - productAddInfoRef?.current?.setFieldsValue({ - BatchRef: value, - }); - setSelectedRowRecord((prev) => ({ ...prev, BatchRef: value })); - }; - - const handleModelNoChange = (e) => { - const value = parseInt(e?.target?.value); - if (!/^\d*\.?\d*$/.test(value)) { - return; - } - productAddInfoRef?.current?.setFieldsValue({ - ModelNumber: value, - }); - setSelectedRowRecord((prev) => ({ ...prev, ModelNumber: value })); - }; - - const handleAddtnlDtlsSubmit = async (values) => { - if ( - selectedRowIndex == null || - !Array.isArray(PurchaseData) || - selectedRowIndex >= PurchaseData.length - ) { - return; - } - - const newData = { ...selectedRowRecord, ...values }; - - const updatedData = PurchaseData.map((item, index) => - index === selectedRowIndex ? newData : item - ); - console.log(updatedData, 'updatedData'); - setPurchaseData(updatedData); - await handleAdditionalInfoClose(); - }; - - const handleAdditionalInfoClose = async () => { - setAdditionalInfoModal(false); - setSelectedRowIndex(null); - setSelectedRowRecord({}); - await productAddInfoRef?.current?.resetFields(); - }; - - const handleModelDataOpen = () => { + const handleModelDataOpen = (selectedRowRecord) => { const acceptedQty = parseInt(selectedRowRecord?.AcceptedQty) || 0; const productIdentifiers = selectedRowRecord?.ProductIdentifierDtls || []; @@ -3249,12 +3688,43 @@ const StockForm = ({ formType }) => { IMEI2: item.imei2 || '', MacId: item.Macid || '', })); - setSelectedRowRecord((prev) => ({ - ...prev, - ProductIdentifierDtls: productIdentifierDtls, - })); - }; + const newData = PurchaseData.map((item, index) => + index === selectedRowIndex + ? { ...item, ProductIdentifierDtls: productIdentifierDtls } + : item + ); + setPurchaseData(newData); + }; + const handleFieldSetupSubmit = async () => { + const postData = { + AppId: AppId, + CompId: CompId, + BranchId: BranchId, + Type: 'PE', + FormType: 'Purchase Entry', + TypeId: categoryId, + ConfigDtl: selectedFields?.map((field) => ({ + ConfigId: field, + Access: 'Y', + })), + CreatedBy: UserId, + }; + + const response = await dispatch(postFieldSetup(postData))?.unwrap(); + + if (response?.data?.statusCode === 1) { + setSelectedAdditionalColumn([...tempSelectedColumns]); + setShowColumnModal(false); + setTempSelectedColumns([]); + setMessageType('success'); + setMessageData(response?.data?.response); + await getFieldSetup(); + } else { + setMessageType('error'); + setMessageData('Failed to set up fields'); + } + }; const handleModalSubmited = () => { setIsModalOpen(false); }; @@ -3362,7 +3832,7 @@ const StockForm = ({ formType }) => {
    )}
    -
    +
    { className="pruchaseCatBTN scan-receipt-btn" onClick={() => setExtractorModalVisible(true)} > -

    Scan Receipt (Auto-Fill)

    + {' '} +

    Scan Receipt (Auto-Fill)

    {
    -
    + {
    -
    +

    Supplier Details

    @@ -3791,8 +4262,13 @@ const StockForm = ({ formType }) => { className="field-DropDown" value={selectedProductName} filterOption={(input, option) => { + const [prodId, variantName] = + option.value.split('_'); const product = productData.find( - (p) => p.ProdId === option.value + (p) => + p.ProdId === prodId && + (p.ProdVariantName || 'Variant1') === + variantName ); const nameMatch = option.label ?.toLowerCase() @@ -3805,14 +4281,21 @@ const StockForm = ({ formType }) => { options={ !scanner ? productData?.map((option) => ({ - value: option.ProdId, - label: `${option.ProdName} (${option.Size} ${option.UomName})${option?.BrandName ? ` - ${option?.BrandName}` : ''}`, + value: `${option.ProdId}_${option.ProdVariantName}`, + label: `${option.ProdName} (${option.Size} ${option.UomName})${option?.BrandName ? ` - ${option?.BrandName}` : ''} - ${option.ProdVariantName}`, })) : [] } onSelect={async (value, option) => { + const [prodId, variantName] = value.split('_'); + const product = productData.find( + (p) => + p.ProdId === prodId && + p.ProdVariantName === variantName + ); const newProduct = await ProductDropDownChange( - value, + product?.ProdVariantName, + prodId, option ); if (newProduct) { @@ -3851,22 +4334,67 @@ const StockForm = ({ formType }) => { />
    - {/* - - */} - setIsModalOpen(true)} /> + setIsModalOpen(true)} + size={18} + /> + + + + {isModalOpen && ( { onMappingAdded={handleModalSubmited} /> )} - {Variants?.length > 1 && ( - - ({ - value: option.ProdIdProdName, - label: option.ProdVariantName, - }))} - label={'Variant Name'} - className="field-DropDown" - onChangeFunction={(e) => - ProductVariantDropDownChange(e) - } - valueData={selectedProductVariantData} - disabled={editstate?.ProdId ? true : false} - /> - {/* - +
    { + setTempSelectedColumns([ + ...selectedAdditionalColumn, + ]); + setShowColumnModal(true); + }} + > + + - */} - - )} + +
    +
    + } + onChange={(e) => { + const value = e.target.value.toLowerCase(); + setSearchValue(value); + }} + style={{ width: '300px' }} + /> +
    +
    { maxwidth: '500px', overflowX: 'auto', scrollbarWidth: 'thin', + maxHeight: '50vh', }} > - + {/* 0 ? filteredPurchaseData : PurchaseData} columns={columns} rowClassName="editable-row" onRow={(record, index) => ({ @@ -3932,48 +4474,74 @@ const StockForm = ({ formType }) => { }, })} pagination={false} + /> */} + +
    ({ + onClick: () => { + edit(record); + }, + })} + pagination={false} + locale={{ + emptyText: isSearching + ? 'No matching products found' + : 'No data', + }} /> - {PurchaseData?.length > 0 && ( -
    -
    - -
    - {PurchaseData.reduce( - (acc, data) => acc + data?.Amount, - 0 - )?.toFixed(2)} -
    -
    - {!orderType && ( -
    - -
    - )} -
    - )} - -
    - } - /> -
    + + {PurchaseData?.length > 0 && ( +
    +
    + +
    + {PurchaseData.reduce( + (acc, data) => acc + data?.Amount, + 0 + )?.toFixed(2)} +
    +
    + {!orderType && ( +
    + +
    + )} +
    + )} + + } + /> + { title="IMEI /Serial Number / Mac Id" open={imeiSerialOpen} footer={true} + width={600} buttonText="Submit" children={ -
    +
    'editable-row'} @@ -5201,365 +5770,57 @@ const StockForm = ({ formType }) => { handleSubmit={handleModelDataSumbitOrClose} handleCancel={handleModelDataSumbitOrClose} > + -

    {`${selectedRowRecord?.ProdName} (${selectedRowRecord?.ProdVariantName})`}

    -
    -
    - - - - - { - let cleanedValue = e.target.value.replace( - /[^0-9.]/g, - '' - ); - const parts = cleanedValue.split('.'); - - if (cleanedValue.startsWith('.')) { - cleanedValue = '0' + cleanedValue; - } - - e.target.value = - parts.length > 2 - ? `${parts[0]}.${parts.slice(1).join('')}` - : cleanedValue; - }} - /> - - - - - { - if ( - value === undefined || - value === null || - value === '' - ) { - return Promise.resolve(); - } - - if (!/^[0-9]\d*(\.\d+)?$/.test(value)) { - return Promise.reject( - 'Please enter a valid FreeQty' - ); - } - - if (value.toString().length > 10) { - return Promise.reject( - 'FreeQty cannot exceed more than 10 characters' - ); - } - - return Promise.resolve(); - }, - }, - ]} - > - - -
    - { - if (value === undefined || value === '') - return Promise.resolve(); - - if (value.length > 30) { - return Promise.reject( - 'HSN cannot exceed 30 characters' - ); - } - - return Promise.resolve(); - }, - }, - ]} - > - { + setShowColumnModal(false); + setSelectedFields([ + ...selectedAdditionalColumn + .map( + (col) => + tableFieldPreferences?.find((pref) => pref.label === col) + ?.value + ) + .filter(Boolean), + ]); + setTempSelectedColumns([...selectedAdditionalColumn]); + }} + > +
    + {tableFieldPreferences?.map((option) => ( +
    + +
    + ))} +
    +
    + setExtractorModalVisible(false)} diff --git a/src/Pages/StockMaster/StockList.jsx b/src/Pages/StockMaster/StockList.jsx index b7bad33..e32cc5e 100644 --- a/src/Pages/StockMaster/StockList.jsx +++ b/src/Pages/StockMaster/StockList.jsx @@ -11,7 +11,11 @@ import { Tables } from '../../Components/Tables/Table'; import FormHeader from '../PageComponents/FormHeader.jsx'; import Search from '../../Components/Forms/Search.jsx'; import Buttons from '../../Components/Forms/Buttons'; -import { getSession, dateFormatChange, ExtractDateFormate } from '../../Services/Others'; +import { + getSession, + dateFormatChange, + ExtractDateFormate, +} from '../../Services/Others'; import { Messages } from '../../Components/Notifications/Messages'; import { getStockData, @@ -175,12 +179,16 @@ const StockList = () => { }; const getPreference = async () => { const data = { AppId: AppId, CompId: CompId, BranchId: BranchId }; - const { data: res } = await dispatch(getPreferenceData(data)).unwrap() - const decimalSetting = res?.data?.[0]?.SettingDtlDetails?.find((setting) => setting?.SettingIdName?.toLowerCase() === "decimal" && setting?.SettingValue === 'Y'); + const { data: res } = await dispatch(getPreferenceData(data)).unwrap(); + const decimalSetting = res?.data?.[0]?.SettingDtlDetails?.find( + (setting) => + setting?.SettingIdName?.toLowerCase() === 'decimal' && + setting?.SettingValue === 'Y' + ); if (decimalSetting) { - setAllowDecimal(true) + setAllowDecimal(true); } - } + }; const actionsFormatter = async (row, rowIndex) => { navigate( `${subDirectory}setting/purchase-entry/update`, @@ -200,11 +208,15 @@ const StockList = () => { }; const handlePrevImage = () => { - setCurrentImageIndex(prev => prev > 0 ? prev - 1 : productImageDetails.length - 1); + setCurrentImageIndex((prev) => + prev > 0 ? prev - 1 : productImageDetails.length - 1 + ); }; const handleNextImage = () => { - setCurrentImageIndex(prev => prev < productImageDetails.length - 1 ? prev + 1 : 0); + setCurrentImageIndex((prev) => + prev < productImageDetails.length - 1 ? prev + 1 : 0 + ); }; const handleProductmodalCancel = () => { @@ -218,7 +230,7 @@ const StockList = () => { setImageModal(false); setProductImageDetails([]); setCurrentImageIndex(0); - } + }; // WRITED BY SREE function safeRound(amountStr) { if (amountStr == null) return allowDecimal ? '0.00' : '0'; @@ -254,7 +266,8 @@ const StockList = () => { ), filteredValue: [searchedText], onFilter: (value, record) => { - return extractLastNumberOrderId(record.InvoiceNo, record?.FYStatus)?.toString() + return extractLastNumberOrderId(record.InvoiceNo, record?.FYStatus) + ?.toString() .toLowerCase() .includes(value.toLowerCase()); }, @@ -273,11 +286,8 @@ const StockList = () => { key: 'CustSuppName', align: 'center', render: (text, row) => ( - - {row?.CustSuppName || '-'} - + {row?.CustSuppName || '-'} ), - }, { title: 'Supp Invoice No', @@ -285,11 +295,8 @@ const StockList = () => { key: 'SuppInvoiceNo', align: 'center', render: (text, row) => ( - - {row?.SuppInvoiceNo || '-'} - + {row?.SuppInvoiceNo || '-'} ), - }, { @@ -323,17 +330,17 @@ const StockList = () => { align: 'center', render: (data, record) => { if (data?.length > 0) { - return viewImages(data)} - /> + return ( + viewImages(data)} + /> + ); } else { - return

    -

    + return

    -

    ; } - } - - , - } + }, + }, ]; const Proddetailcolumns = [ { @@ -529,9 +536,11 @@ const StockList = () => { useEffect(() => { let updatedExceldatasubmit = Exceldatasubmit?.map((excelItem) => { - - const [productName, sizeAndUom] = (excelItem?.ProductName?.split(' (')) || []; - const [size, uomName] = (sizeAndUom ? sizeAndUom.slice(0, -1).split(' ') : []); + const [productName, sizeAndUom] = + excelItem?.ProductName?.split(' (') || []; + const [size, uomName] = sizeAndUom + ? sizeAndUom.slice(0, -1).split(' ') + : []; const matchingProduct = Productdata?.find( (product) => @@ -584,17 +593,17 @@ const StockList = () => { // Helper function to check if product already exists in ProdDetails const isDuplicateProduct = (prodDetails, newItem) => { - return prodDetails.some(item => - item.ProdName === newItem.ProdName && - item.VariantName === newItem.VariantName && - item.MRP === newItem.MRP && - item.SalesPrice === newItem.SalesPrice && - item.Quantity === newItem.Quantity && - item.RejectedQty === newItem.RejectedQty + return prodDetails.some( + (item) => + item.ProdName === newItem.ProdName && + item.VariantName === newItem.VariantName && + item.MRP === newItem.MRP && + item.SalesPrice === newItem.SalesPrice && + item.Quantity === newItem.Quantity && + item.RejectedQty === newItem.RejectedQty ); }; - const handleSubmit = async () => { let FilterData = Exceldatasubmit?.filter((a) => a['ProductName'] != ''); if (FilterData && FilterData.length > 0) { @@ -618,7 +627,7 @@ const StockList = () => { DeliveryInvoiceDate: data.DeliveryInvoiceDate, DueDate: data.DueDate, }, - products: [] + products: [], }; } @@ -636,7 +645,6 @@ const StockList = () => { }; const formattedData = Object.values(groupedData).map((group) => { - const { groupInfo, products } = group; // Calculate totals based on products @@ -666,25 +674,33 @@ const StockList = () => { PaymentMode: groupInfo.PaymentMode, PaymentAmount: PaymentAmount.toFixed(2), InvoiceDate: groupInfo.InwardDate - ? moment(groupInfo.InwardDate, 'YYYY-MM-DD').format('YYYY-MM-DDTHH:mm:ss') + ? moment(groupInfo.InwardDate, 'YYYY-MM-DD').format( + 'YYYY-MM-DDTHH:mm:ss' + ) : null, SuppInvoiceNo: groupInfo.SupplierInvoiceNumber, SuppInvoiceDate: groupInfo.SupplierInvoiceDate - ? moment(groupInfo.SupplierInvoiceDate, 'YYYY-MM-DD').format('YYYY-MM-DDTHH:mm:ss') + ? moment(groupInfo.SupplierInvoiceDate, 'YYYY-MM-DD').format( + 'YYYY-MM-DDTHH:mm:ss' + ) : null, DeliveryChallanNo: groupInfo.DeliveryChallanNo, DeliveryInvoiceDate: groupInfo.DeliveryInvoiceDate - ? moment(groupInfo.DeliveryInvoiceDate, 'YYYY-MM-DD').format('YYYY-MM-DDTHH:mm:ss') + ? moment(groupInfo.DeliveryInvoiceDate, 'YYYY-MM-DD').format( + 'YYYY-MM-DDTHH:mm:ss' + ) : null, DueDate: groupInfo.DueDate - ? moment(groupInfo.DueDate, 'YYYY-MM-DD').format('YYYY-MM-DDTHH:mm:ss') + ? moment(groupInfo.DueDate, 'YYYY-MM-DD').format( + 'YYYY-MM-DDTHH:mm:ss' + ) : null, InvoiceAmount: Totalamount.toFixed(2), TaxAmount: Totaltax.toFixed(2), TotalAmount: Totalamount.toFixed(2), BillAmount: Billamount.toFixed(2), - PaymentStatus: "S", - PurOrderStatus: "P", + PaymentStatus: 'S', + PurOrderStatus: 'P', ProdDetails: products.map((item) => ({ ProdName: item.ProductName, ProdVariantName: item.VariantName, @@ -694,10 +710,14 @@ const StockList = () => { AcceptedQty: item.AcceptedQty, FreeQty: item.FreeQty, ManufDate: item.ManufactureDate - ? moment(item.ManufactureDate, 'YYYY-MM-DD').format('YYYY-MM-DDTHH:mm:ss') + ? moment(item.ManufactureDate, 'YYYY-MM-DD').format( + 'YYYY-MM-DDTHH:mm:ss' + ) : null, ExpDate: item.ExpireDate - ? moment(item.ExpireDate, 'YYYY-MM-DD').format('YYYY-MM-DDTHH:mm:ss') + ? moment(item.ExpireDate, 'YYYY-MM-DD').format( + 'YYYY-MM-DDTHH:mm:ss' + ) : null, BatchNo: item.BatchNo, ModelNo: item.ModelNo, @@ -707,6 +727,7 @@ const StockList = () => { SellPrice: item.SalesPrice, OnePcsPrice: item.AmountPerPiece, NoOfPcs: item.NumberofPieceInside, + WhSalePrice: item.WholesalePrice })), }; }); @@ -905,31 +926,35 @@ const StockList = () => { width={600} className={'padding-less-modal'} children={ -
    +
    {productImageDetails?.length > 0 && ( -
    +
    {productImageDetails.length > 1 && ( <> )} -
    +
    {productImageDetails.length > 1 && ( <> @@ -937,7 +962,14 @@ const StockList = () => { )}
    )} -
    +
    {currentImageIndex + 1} of {productImageDetails.length}
    diff --git a/src/Styles/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/BSBillingEditQuantity.scss b/src/Styles/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/BSBillingEditQuantity.scss index 6d5bd00..d5a9582 100644 --- a/src/Styles/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/BSBillingEditQuantity.scss +++ b/src/Styles/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/BSBillingEditQuantity.scss @@ -42,22 +42,30 @@ justify-content: center; border-radius: 10px; } -.grid-container { +.gridEQcontainer { display: grid; grid-template-columns: auto auto auto; - padding: 5px; + padding: 12px; + border-radius: 6px; background: #e1eef1; margin: 5px; } -.grid-item { +.gridEQitem { background-color: rgba(255, 255, 255, 0.8); // border: 1px solid rgba(0, 0, 0, 0.8); padding: 5px; font-size: 30px; text-align: center; - border-radius: 25px; - margin: 6px; - // margin-left: 10px; + border-radius: 30px; + margin: 5px; + height: 60px; + width: 90%; + cursor: pointer; + font-family: "Poppins"; + display: flex; + align-items: center; + justify-content: center; + font-weight: 400; } .grid-item-add { background-color: var(--SELECTED_COLOR); @@ -90,14 +98,27 @@ flex-direction: row; align-items: center; column-gap: 0.5rem; - font-family: 'Poppins'; + font-family: "Poppins", sans-serif; } .EditQuantity-Quantitybox { width: 5rem; height: 2rem; border: none; background-color: #eff3f3; + border: 1px solid #e4e4e4; padding-left: 5px; + border-radius: 4px; + font-family: "Poppins", sans-serif; + font-size: 15px; + font-weight: 400; + letter-spacing: 0.3px; + outline: none !important; + &:focus { + border-color: #a6daff; + } + &:active { + border-color: #a6daff; + } } .EditQuantity-Pricebox { width: 5rem; @@ -110,6 +131,14 @@ height: 2rem; width: 2rem; border: none; + border: 1px solid #ffdfdf; + border-radius: 4px; + cursor: pointer; + display: flex; + align-items: center; + justify-content: center; + background-color: #ffeded; + color: #c21919; } .EditQuantity-PriceChange { display: flex; diff --git a/src/Styles/BookingScreen/Components/BSBillingTables/BSPacking/BSPacking.scss b/src/Styles/BookingScreen/Components/BSBillingTables/BSPacking/BSPacking.scss index c55eef7..6df86b0 100644 --- a/src/Styles/BookingScreen/Components/BSBillingTables/BSPacking/BSPacking.scss +++ b/src/Styles/BookingScreen/Components/BSBillingTables/BSPacking/BSPacking.scss @@ -41,10 +41,10 @@ $white: #ffffff; .packing-container { max-width: 50rem; // margin: 0 auto; - padding: 1.5rem; - @include gradient-bg(#eff6ff, #e0e7ff); + margin: 1rem 0; + padding: 1rem; + @include gradient-bg(#e6f1ff, #dfe7ff); border-radius: 1rem; - box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1); // Header section .header { @@ -119,15 +119,15 @@ $white: #ffffff; .rows-header { display: grid; // grid-template-columns: 120px 120px 120px 120px 100px; // Type, Qty, Count, Total, Action - grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr ; + grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr; background: $gray-100; - padding: 0.75rem 1rem; + padding: 0.5rem 0.5rem; font-weight: 600; font-size: 0.875rem; color: $gray-700; border-radius: 0.5rem; border: 1px solid $gray-200; - margin-bottom: 0.50rem; + margin-bottom: 0.5rem; .header-cell { text-align: center; @@ -279,9 +279,8 @@ $white: #ffffff; gap: 0.5rem; .action-button { - - width: 2.0rem; - height: 2.0rem; + width: 2rem; + height: 2rem; border-radius: 50%; border: none; color: $white; @@ -311,7 +310,7 @@ $white: #ffffff; min-width: 2rem; .total-display { - padding: 0.25rem 0.70rem; + padding: 0.25rem 0.7rem; background: $gray-50; // border: 1px solid $gray-200; // border-radius: 0.5rem; @@ -338,8 +337,7 @@ $white: #ffffff; background: $white; border-radius: 0.75rem; padding: 1.5rem; - box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1); - border: 2px solid $gray-100; + border: 2px solid #d6e1ff; .summary-content { display: flex; diff --git a/src/Styles/BookingScreen/Components/BSCategories/BSCategoryHorizontal.scss b/src/Styles/BookingScreen/Components/BSCategories/BSCategoryHorizontal.scss index 481d7cb..1014ca4 100644 --- a/src/Styles/BookingScreen/Components/BSCategories/BSCategoryHorizontal.scss +++ b/src/Styles/BookingScreen/Components/BSCategories/BSCategoryHorizontal.scss @@ -325,7 +325,7 @@ } .CategoryHorizontalNew { - padding: 1rem 1rem; + padding: 10px 10px; font-family: 'Inter', sans-serif; display: flex; align-items: center; diff --git a/src/Styles/BookingScreen/Components/BSNavbar/BSNavbar3.scss b/src/Styles/BookingScreen/Components/BSNavbar/BSNavbar3.scss index 4e4645d..02b1696 100644 --- a/src/Styles/BookingScreen/Components/BSNavbar/BSNavbar3.scss +++ b/src/Styles/BookingScreen/Components/BSNavbar/BSNavbar3.scss @@ -116,7 +116,7 @@ .CustomerActions { display: flex; align-items: center; - gap: 0.1rem; + gap: 0.3rem; .RiVerifiedBadgeFill { transition: all 0.2s ease-in-out; diff --git a/src/Styles/PurchaseReturn/purchasereturn.scss b/src/Styles/PurchaseReturn/purchasereturn.scss index 269a723..7a80b25 100644 --- a/src/Styles/PurchaseReturn/purchasereturn.scss +++ b/src/Styles/PurchaseReturn/purchasereturn.scss @@ -338,7 +338,7 @@ display: flex; align-items: center; gap: 7px; - padding: 10px 16px; + padding: 8px 16px; background-color: #0bad77; border-radius: 7px; color: white; @@ -346,7 +346,7 @@ font-family: 'Poppins'; font-weight: 400; white-space: nowrap; - font-size: 14px; + font-size: 13.5px; transition: all 0.2s; &:hover { background-color: #069666; @@ -356,15 +356,15 @@ display: flex; align-items: center; gap: 7px; - padding: 10px 16px; - background-color: #0ea5e9; + padding: 8px 16px; + background-color: #1292ee; border-radius: 7px; color: white; cursor: pointer; - font-family: 'Poppins'; + font-family: "Poppins"; font-weight: 400; white-space: nowrap; - font-size: 14px; + font-size: 13.5px; transition: all 0.2s; &:hover { background-color: #0985be; diff --git a/src/Styles/Reports/KOT/kot.scss b/src/Styles/Reports/KOT/kot.scss index 4aa8107..fe9faa2 100644 --- a/src/Styles/Reports/KOT/kot.scss +++ b/src/Styles/Reports/KOT/kot.scss @@ -71,7 +71,7 @@ .kot-date { display: flex; font-size: 14px; - font-family: 'Gilroy'; + font-family: "Gilroy"; font-weight: 500; border-radius: 5px; color: #212529 !important; @@ -122,7 +122,7 @@ right: 0; } .ant-segmented-item-label { - font-family: 'Poppins'; + font-family: "Poppins"; font-size: 12px !important; } .ant-segmented-item-selected { @@ -134,9 +134,7 @@ } } -.kot-search-dev - :where(.css-dev-only-do-not-override-2i2tap).ant-segmented - .ant-segmented-group { +.kot-search-dev :where(.css-dev-only-do-not-override-2i2tap).ant-segmented .ant-segmented-group { position: relative; display: flex; //srinath @@ -149,9 +147,7 @@ rgba(0, 0, 0, 0.3) 0px 3px 7px -3px; } -.kot-search-dev - :where(.css-dev-only-do-not-override-2i2tap).ant-segmented - .ant-segmented-item-selected { +.kot-search-dev :where(.css-dev-only-do-not-override-2i2tap).ant-segmented .ant-segmented-item-selected { background-color: #ffffff; box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.03), @@ -168,6 +164,13 @@ margin: 12px 0 12px 0; height: 70vh; overflow: scroll; + + .ant-table-thead { + background-color: #2c88ee !important; + } + .ant-table-cell { + padding: 6px !important; + } @media (max-width: 768px) { height: 60vh; scrollbar-width: thin; @@ -179,7 +182,7 @@ } table { tbody { - font-family: 'Poppins'; + font-family: "Poppins"; > tr:nth-child(even) { background-color: #b4b4b4; } @@ -221,7 +224,7 @@ transition: all 0.2s ease; min-width: 70px; text-align: center; - font-family: 'Poppins', sans-serif; + font-family: "Poppins", sans-serif; color: #fff; -webkit-text-stroke-width: 0.1px; diff --git a/src/Styles/Stock/StockMaster.scss b/src/Styles/Stock/StockMaster.scss index f04cd93..8274819 100644 --- a/src/Styles/Stock/StockMaster.scss +++ b/src/Styles/Stock/StockMaster.scss @@ -36,13 +36,14 @@ } .Product-table { + table { border-spacing: unset; } } .Product-table .ant-input { - width: 5rem !important; + width: 4rem !important; } .Product-table .ant-picker { @@ -87,7 +88,7 @@ width: 180px !important; } - > div:nth-child(2) { + >div:nth-child(2) { p { display: none !important; } @@ -145,7 +146,7 @@ max-width: 130px !important; } - > td:nth-child(3) { + >td:nth-child(3) { .ant-input { width: max-content !important; max-width: 70px !important; @@ -153,7 +154,7 @@ } } - > td:nth-child(5) { + >td:nth-child(5) { .ant-input { width: max-content !important; max-width: 100px !important; @@ -202,6 +203,8 @@ flex-direction: row; gap: 1.5rem; padding-top: 0.5rem; + justify-content: space-between; + width: 100%; & .field-DropDown { width: 200px !important; @@ -299,8 +302,8 @@ } } -.inputForm .ant-table-content { - width: 70vw; +.inputFormSTOCKFORM .ant-table-content { + width: 100% !important; } .pe-inward-date { @@ -322,24 +325,22 @@ } .purchase-status { - > div:nth-child(1) { + >div:nth-child(1) { display: flex; align-items: center; gap: 10px; - > p { + >p { padding-bottom: 0 !important; } } } .purchase-status-data { - margin-top: 10px; display: flex; align-items: center; gap: 30px; justify-content: flex-end; - padding: 1rem 3rem; width: 100%; } @@ -447,7 +448,7 @@ .invoice-date { .ant-form-item-control-input-content { - > label { + >label { font-family: 'Poppins'; font-weight: 500; } @@ -473,7 +474,7 @@ gap: 1rem; margin-bottom: 10px; - > button { + >button { font-family: 'Poppins'; background-color: #ef4444; color: #fff; @@ -481,8 +482,8 @@ align-items: center; .ant-btn-icon { - > span { - > svg { + >span { + >svg { width: 13px; height: 13px; } @@ -516,6 +517,8 @@ } .stockformTabele { + width: 80vw; + .float-label, .ant-select { width: 60px !important; @@ -563,9 +566,7 @@ width: 100%; } - .inputForm .ant-table-content { - width: 100vw; - } + .stock-input { // width: 100vw; @@ -607,13 +608,12 @@ width: 100%; } - .inputForm .ant-table-content { - width: 100vw; - } + .stock-input { width: 100vw; } + .tipsForUpload { ul li { font-size: 10px !important; @@ -689,14 +689,17 @@ top: 0; opacity: 1; } + 50% { opacity: 0.8; } + 100% { top: calc(100% - 3px); opacity: 1; } } + .preview-text-data { display: flex; flex-direction: column; @@ -724,6 +727,7 @@ font-weight: 500; } } + .loading-overlay { position: absolute; top: 0; @@ -761,12 +765,66 @@ 0% { transform: rotate(0deg); } + 100% { transform: rotate(360deg); } } + .purchase-receipt-table { .ant-input { padding-top: 6px !important; } + + .ant-table-cell { + padding: 5px !important; + } } + + +.addallProductTBN { + border: none; + outline: none; + padding: 8px 16px; + width: max-content; + font-family: "Poppins"; + font-weight: 500; + font-size: 14px; + cursor: pointer; + background-color: #1292ee; + height: max-content; + color: #fff; + border-radius: 4px; +} + +.productSearchRecipt { + display: flex; + align-items: center; + flex-wrap: nowrap; + flex-direction: row-reverse; + gap: 1rem; + + .ant-input-affix-wrapper { + width: 250px !important; + } + + .ant-input { + padding: 3px 14px 6px 11px !important; + } +} + +.finalSubmitPRBTN { + display: flex; + align-items: center; + justify-content: flex-end; + gap: 1rem; + margin-top: 1rem; +} + +.imeiSNTable { + + .ant-input { + padding: 4px 4px !important; + text-align: center; + } +} \ No newline at end of file