From 58e1a5e7a73240946fc9ffc4e3f0f0ec3e1d1e20 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 24 Feb 2026 14:24:20 +0530 Subject: [PATCH 1/4] Constrain the overall qty --- src/Pages/Preference/PreferenceList.jsx | 364 +++++++++++++----------- 1 file changed, 201 insertions(+), 163 deletions(-) diff --git a/src/Pages/Preference/PreferenceList.jsx b/src/Pages/Preference/PreferenceList.jsx index 130e3ab..7c039d0 100644 --- a/src/Pages/Preference/PreferenceList.jsx +++ b/src/Pages/Preference/PreferenceList.jsx @@ -1,6 +1,6 @@ import { useCallback, useEffect, useRef, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; -import { Form, Checkbox, Radio, Divider } from 'antd'; +import { Form, Checkbox, Radio, Divider, InputNumber } from 'antd'; import { ArrowRightOutlined } from '@ant-design/icons'; import FormHeader from '../PageComponents/FormHeader.jsx'; import Buttons from '../../Components/Forms/Buttons.jsx'; @@ -57,68 +57,71 @@ const PreferenceList = () => { const settingsList = tableValue[0]?.SettingDtlDetails ?? preferenceConfigs; const allSettingsMap = {}; - settingsList?.forEach(({ SettingIdName, SettingValue }) => { - allSettingsMap[SettingIdName?.toLowerCase()] = SettingValue; + settingsList?.forEach(({ SettingIdName, SettingValue, SettingCount }) => { + allSettingsMap[SettingIdName?.toLowerCase()] = { value: SettingValue, count: SettingCount }; }); - console.log(allSettingsMap, 'allSettingsMapallSettingsMapallSettingsMap'); + console.log(settingsList, 'settingsList'); const buildInitialValues = () => ({ - dashboard: allSettingsMap['dashboard'] === 'Y', - shortcutkeys: allSettingsMap['shortcutkeys'] === 'Y', - autoreceivestock: allSettingsMap['autoreceivestock'] === 'Y', - decimal: allSettingsMap['decimal'] === 'Y', + dashboard: allSettingsMap['dashboard']?.value === 'Y', + shortcutkeys: allSettingsMap['shortcutkeys']?.value === 'Y', + autoreceivestock: allSettingsMap['autoreceivestock']?.value === 'Y', + decimal: allSettingsMap['decimal']?.value === 'Y', enabledModules: [ - ...(allSettingsMap['dinein'] === 'Y' ? ['dinein'] : []), - ...(allSettingsMap['estimation'] === 'Y' ? ['estimation'] : []), + ...(allSettingsMap['dinein']?.value === 'Y' ? ['dinein'] : []), + ...(allSettingsMap['estimation']?.value === 'Y' ? ['estimation'] : []), ], - searchfocus: allSettingsMap['searchfocus'] === 'Y', - addproductcard: allSettingsMap['addproductcard'] === 'Y', + searchfocus: allSettingsMap['searchfocus']?.value === 'Y', + addproductcard: allSettingsMap['addproductcard']?.value === 'Y', enabledFeatures: [ - ...(allSettingsMap['parking'] === 'Y' ? ['parking'] : []), - ...(allSettingsMap['offer'] === 'Y' ? ['offer'] : []), + ...(allSettingsMap['parking']?.value === 'Y' ? ['parking'] : []), + ...(allSettingsMap['offer']?.value === 'Y' ? ['offer'] : []), ], - stockselection: allSettingsMap['stockselection'] === 'Y', - weightasquantity: allSettingsMap['weightasquantity'] === 'Y', - expiredselection: allSettingsMap['expiredselection'] === 'Y', - 'sales mode': allSettingsMap['sales mode'] === 'Y', - billitemsorder: allSettingsMap['billitemsorder'] === 'Y', - preorderpricechange: allSettingsMap['preorderpricechange'] === 'Y', + stockselection: allSettingsMap['stockselection']?.value === 'Y', + weightasquantity: allSettingsMap['weightasquantity']?.value === 'Y', + expiredselection: allSettingsMap['expiredselection']?.value === 'Y', + 'sales mode': allSettingsMap['sales mode']?.value === 'Y', + billitemsorder: allSettingsMap['billitemsorder']?.value === 'Y', + preorderpricechange: allSettingsMap['preorderpricechange']?.value === 'Y', + quantityrestriction: allSettingsMap['overalllimit']?.value === 'Y' || allSettingsMap['itemwiselimit']?.value === 'Y', + quantityrestrictiontype: allSettingsMap['overalllimit']?.value === 'Y' ? 'overall' : allSettingsMap['itemwiselimit']?.value === 'Y' ? 'itemwise' : 'overall', + maxquantity: allSettingsMap['overalllimit']?.value === 'Y' ? allSettingsMap['overalllimit']?.count || 1 : allSettingsMap['itemwiselimit']?.value === 'Y' ? allSettingsMap['itemwiselimit']?.count || 1 : 1, billOption: ['whatsapp', 'sms', 'email'].some( - (k) => allSettingsMap[k] === 'Y' + (k) => allSettingsMap[k]?.value === 'Y' ) ? 'pdf' : 'print', pdfSendOptions: ['whatsapp', 'email', 'sms'].filter( - (k) => allSettingsMap[k] === 'Y' + (k) => allSettingsMap[k]?.value === 'Y' ), - tokenonly: allSettingsMap['tokenonly'] === 'Y', + tokenonly: allSettingsMap['tokenonly']?.value === 'Y', allproductindividualtoken: - allSettingsMap['allproductindividualtoken'] === 'Y', + allSettingsMap['allproductindividualtoken']?.value === 'Y', printOptions: ['printuom', 'printlogo', 'printgreetings'].filter( - (k) => allSettingsMap[k] === 'Y' + (k) => allSettingsMap[k]?.value === 'Y' ), - mobilea4: allSettingsMap['mobilea4'] === 'Y', - estimateprintheader: allSettingsMap['estimateprintheader'] === 'Y', - scanlayout: allSettingsMap['scanlayout'] === 'Y', - verifyproduct: allSettingsMap['verifyproduct'] === 'Y', - customisedbillnumber: allSettingsMap['customisedbillnumber'] === 'Y', - upiqr: allSettingsMap['upiqr'] === 'Y', - lowstockreport: allSettingsMap['lowstockreport'] === 'Y', - weeklysalesreport: allSettingsMap['weeklysalesreport'] === 'Y', - notificationblink: allSettingsMap['notificationblink'] === 'Y', - onlineindivdualslots: allSettingsMap['onlineindivdualslots'] === 'Y', - editbill: allSettingsMap['editbill'] === 'Y', + mobilea4: allSettingsMap['mobilea4']?.value === 'Y', + estimateprintheader: allSettingsMap['estimateprintheader']?.value === 'Y', + scanlayout: allSettingsMap['scanlayout']?.value === 'Y', + verifyproduct: allSettingsMap['verifyproduct']?.value === 'Y', + customisedbillnumber: allSettingsMap['customisedbillnumber']?.value === 'Y', + upiqr: allSettingsMap['upiqr']?.value === 'Y', + lowstockreport: allSettingsMap['lowstockreport']?.value === 'Y', + weeklysalesreport: allSettingsMap['weeklysalesreport']?.value === 'Y', + notificationblink: allSettingsMap['notificationblink']?.value === 'Y', + onlineindivdualslots: allSettingsMap['onlineindivdualslots']?.value === 'Y', + editbill: allSettingsMap['editbill']?.value === 'Y', notification: [ - ...(allSettingsMap['onbilltime'] === 'Y' ? ['onbilltime'] : []), - ...(allSettingsMap['1daybefore'] === 'Y' ? ['1daybefore'] : []), - ...(allSettingsMap['1hourbefore'] === 'Y' ? ['1hourbefore'] : []), + ...(allSettingsMap['onbilltime']?.value === 'Y' ? ['onbilltime'] : []), + ...(allSettingsMap['1daybefore']?.value === 'Y' ? ['1daybefore'] : []), + ...(allSettingsMap['1hourbefore']?.value === 'Y' ? ['1hourbefore'] : []), ], BookingOptionsandmethod: [ - ...(allSettingsMap['allow individual booking'] === 'Y' + ...(allSettingsMap['allow individual booking']?.value === 'Y' ? ['allow individual booking'] : []), - ...(allSettingsMap['single booking only'] === 'Y' + ...(allSettingsMap['single booking only']?.value === 'Y' ? ['single booking only'] : []), ], @@ -310,6 +313,8 @@ const PreferenceList = () => { weeklysalesreport: values.weeklysalesreport, notificationblink: values.notificationblink, editbill: values.editbill, + overalllimit: values.quantityrestriction && values.quantityrestrictiontype === 'overall', + itemwiselimit: values.quantityrestriction && values.quantityrestrictiontype === 'itemwise', }; const arrayValues = { @@ -340,6 +345,7 @@ const PreferenceList = () => { SettingId: setting.SettingId, Comments: setting.Comments || 'Enter Comment', SettingValue: isChecked ? 'Y' : 'N', + SettingCount: ((key === 'overalllimit' || key === 'itemwiselimit') && isChecked) ? parseFloat(values.maxquantity) || null : null }; }); @@ -482,25 +488,25 @@ const PreferenceList = () => { {(allSettingsMap['onlineindividualslots'] !== undefined || allSettingsMap['allow individual booking'] !== undefined || allSettingsMap['single booking only'] !== undefined) && ( - - - {allSettingsMap['allow individual booking'] !== - undefined && ( - - Allow online individual booking - - )} - {allSettingsMap['single booking only'] !== undefined && ( - - Allow single booking Only - - )} - - - )} + + + {allSettingsMap['allow individual booking'] !== + undefined && ( + + Allow online individual booking + + )} + {allSettingsMap['single booking only'] !== undefined && ( + + Allow single booking Only + + )} + + + )} @@ -532,23 +538,23 @@ const PreferenceList = () => { {(allSettingsMap['onbilltime'] !== undefined || allSettingsMap['1daybefore'] !== undefined || allSettingsMap['1hourbefore'] !== undefined) && ( - - - {allSettingsMap['onbilltime'] !== undefined && ( - On Bill Time - )} - {allSettingsMap['1daybefore'] !== undefined && ( - 1 Day Before - )} - {allSettingsMap['1hourbefore'] !== undefined && ( - 1 Hour Before - )} - - - )} + + + {allSettingsMap['onbilltime'] !== undefined && ( + On Bill Time + )} + {allSettingsMap['1daybefore'] !== undefined && ( + 1 Day Before + )} + {allSettingsMap['1hourbefore'] !== undefined && ( + 1 Hour Before + )} + + + )}
{ {(allSettingsMap['offer'] !== undefined || allSettingsMap['parking'] !== undefined) && ( - - - {allSettingsMap['parking'] !== undefined && ( - Parking - )} - {allSettingsMap['offer'] !== undefined && ( - Offer - )} - - - )} + + + {allSettingsMap['parking'] !== undefined && ( + Parking + )} + {allSettingsMap['offer'] !== undefined && ( + Offer + )} + + + )} {((allSettingsMap['dinein'] !== undefined && dinePreference) || allSettingsMap['estimation'] !== undefined) && ( - - - {allSettingsMap['dinein'] !== undefined && - dinePreference && ( - Dine-In + + + {allSettingsMap['dinein'] !== undefined && + dinePreference && ( + Dine-In + )} + {allSettingsMap['estimation'] !== undefined && ( + Estimation )} - {allSettingsMap['estimation'] !== undefined && ( - Estimation - )} - - - )} + + + )} {renderCheckbox('stockselection', 'Enable stock selection?')} {renderCheckbox('weightasquantity', 'Use Weight as Quantity?')} @@ -630,6 +636,38 @@ const PreferenceList = () => { {renderCheckbox('scanlayout', 'Do you Want Scan Layout Page?')} {renderCheckbox('upiqr', 'Do you want to show the UPI QR code?')} {/* {renderCheckbox('editbill', 'Do you want to edit the previously created bill?')} */} + + {(allSettingsMap['overalllimit'] !== undefined || allSettingsMap['itemwiselimit'] !== undefined) && ( + <> + + Yes + + + prev.quantityrestriction !== curr.quantityrestriction}> + {({ getFieldValue }) => getFieldValue('quantityrestriction') && ( + <> + + formRef.current?.setFieldsValue({ maxquantity: undefined })}> + Overall Order Quantity + Item-wise Quantity + + + + + + + + )} + + + )}
@@ -652,46 +690,46 @@ const PreferenceList = () => { {['whatsapp', 'sms', 'email'].some( (k) => allSettingsMap[k] !== undefined ) && ( - <> - - - Print Bill - Send PDF - - + <> + + + Print Bill + Send PDF + + - - prev.billOption !== curr.billOption - } - > - {({ getFieldValue }) => - getFieldValue('billOption') === 'pdf' && ( - - - {allSettingsMap['whatsapp'] !== undefined && ( - WhatsApp - )} - {allSettingsMap['email'] !== undefined && ( - Email - )} - {allSettingsMap['sms'] !== undefined && ( - SMS - )} - - - ) - } - - - )} + + prev.billOption !== curr.billOption + } + > + {({ getFieldValue }) => + getFieldValue('billOption') === 'pdf' && ( + + + {allSettingsMap['whatsapp'] !== undefined && ( + WhatsApp + )} + {allSettingsMap['email'] !== undefined && ( + Email + )} + {allSettingsMap['sms'] !== undefined && ( + SMS + )} + + + ) + } + + + )} {renderCheckbox( 'tokenonly', @@ -721,25 +759,25 @@ const PreferenceList = () => { {['printuom', 'printlogo', 'printgreetings'].some( (k) => allSettingsMap[k] !== undefined ) && ( - - - {allSettingsMap['printuom'] !== undefined && ( - - Unit of Measure (UOM) - - )} - {allSettingsMap['printlogo'] !== undefined && ( - Branch Logo - )} - {allSettingsMap['printgreetings'] !== undefined && ( - Greetings - )} - - - )} + + + {allSettingsMap['printuom'] !== undefined && ( + + Unit of Measure (UOM) + + )} + {allSettingsMap['printlogo'] !== undefined && ( + Branch Logo + )} + {allSettingsMap['printgreetings'] !== undefined && ( + Greetings + )} + + + )} {renderCheckbox( 'mobilea4', From 70444d3028674390e2200b057f4ef8c0383328ea Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 24 Feb 2026 14:33:29 +0530 Subject: [PATCH 2/4] kisok quantity constrain --- src/Pages/Kiosk/CardPage/CardPage1.jsx | 23 ++++- src/Pages/Kiosk/CardPage/CardPage2.jsx | 123 +++++++++++++---------- src/Pages/Kiosk/CardPage/CardPage3.jsx | 122 ++++++++++++---------- src/Pages/Kiosk/CardPage/CardPage4.jsx | 95 ++++++++++------- src/Pages/Kiosk/KioskBookingPage.jsx | 19 ++-- src/Pages/Kiosk/OrderCart/OrderCart1.jsx | 86 ++++++++++------ src/Pages/Kiosk/OrderCart/OrderCart2.jsx | 87 ++++++++++------ src/Pages/Kiosk/OrderCart/OrderCart3.jsx | 85 ++++++++++------ src/Pages/Kiosk/OrderView/OrderView1.jsx | 86 ++++++++++------ src/Pages/Kiosk/OrderView/OrderView2.jsx | 85 ++++++++++------ src/Pages/Kiosk/OrderView/OrderView3.jsx | 93 ++++++++++------- 11 files changed, 556 insertions(+), 348 deletions(-) diff --git a/src/Pages/Kiosk/CardPage/CardPage1.jsx b/src/Pages/Kiosk/CardPage/CardPage1.jsx index 1a228b5..414ba88 100644 --- a/src/Pages/Kiosk/CardPage/CardPage1.jsx +++ b/src/Pages/Kiosk/CardPage/CardPage1.jsx @@ -1,6 +1,6 @@ import React, { useEffect, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; -import { Drawer } from 'antd'; +import { Drawer, message } from 'antd'; import { DefaultModal } from '../../../Components/Modal/DefaultModal'; import { changeKioskPageName, @@ -16,10 +16,12 @@ import { GlobalBookingTypeKiosk, } from '../../../Features/BookingScreen/BookingData/KioskBookingData'; import horizontal from '../../../Images/defaultItemImg.png'; -import { getConfigType } from '../../../Features/BookingScreen/BookingData/BookingData'; +import { getConfigType, PreferenceData } from '../../../Features/BookingScreen/BookingData/BookingData'; +import { calculateOverAllQtyLimit } from '../../../utils/calculations.js'; const CardPage1 = (props) => { const dispatch = useDispatch(); + const preferenceDatas = useSelector(PreferenceData); const kioskCategoriesCard = useSelector(GlobalProductCardListKiosk); const KioskOrderDetails = useSelector(GlobalKioskOrderDetails); const getKioskLightColourdata = useSelector(getKioskLightColour); @@ -35,7 +37,13 @@ const CardPage1 = (props) => { const UomPrint = SettingDataSelector?.[0]?.SettingDtlDetails.filter( (i) => i.SettingIdName === 'PrintUom' )?.[0]; - + const overAllLimitPreferenece = + preferenceDatas?.[0]?.['SettingDtlDetails']?.find( + (item) => (item.SettingIdName?.toLowerCase() === 'overalllimit') && item?.SettingValue === 'Y'); + const itemWiseLimitPreferenece = + preferenceDatas?.[0]?.['SettingDtlDetails']?.find( + (item) => item.SettingIdName?.toLowerCase() === 'itemwiselimit' && item?.SettingValue === 'Y'); + const maxQtyLimit = itemWiseLimitPreferenece?.SettingCount || overAllLimitPreferenece?.SettingCount || null; useEffect(() => { getBookingTypeId(); }, []); @@ -49,6 +57,15 @@ const CardPage1 = (props) => { //Card on click function const CardOnClick = async (item, Parameter) => { + if ((overAllLimitPreferenece || itemWiseLimitPreferenece) && maxQtyLimit) { + if (overAllLimitPreferenece) { + const calculatedOverAllQty = calculateOverAllQtyLimit(KioskOrderDetails); + if ((calculatedOverAllQty + 1) > maxQtyLimit) { + message.warning(`Overall Quantity Limit Exceeds than ${maxQtyLimit}`) + return; + } + } + } setOnePeiceFlow(Parameter === 'OnePeiceProduct'); const transformedItem = { diff --git a/src/Pages/Kiosk/CardPage/CardPage2.jsx b/src/Pages/Kiosk/CardPage/CardPage2.jsx index 64696bf..d694a4a 100644 --- a/src/Pages/Kiosk/CardPage/CardPage2.jsx +++ b/src/Pages/Kiosk/CardPage/CardPage2.jsx @@ -1,6 +1,6 @@ import React, { useEffect, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; -import { Drawer } from 'antd'; +import { Drawer, message } from 'antd'; import { DefaultModal } from '../../../Components/Modal/DefaultModal'; import { changeKioskPageName, @@ -15,10 +15,12 @@ import { changeKioskOrderDetails, } from '../../../Features/BookingScreen/BookingData/KioskBookingData'; import horizontal from '../../../Images/defaultItemImg.png'; -import { getConfigType } from '../../../Features/BookingScreen/BookingData/BookingData'; +import { getConfigType, PreferenceData } from '../../../Features/BookingScreen/BookingData/BookingData'; +import { calculateOverAllQtyLimit } from '../../../utils/calculations.js'; const CardPage2 = (props) => { const dispatch = useDispatch(); + const preferenceDatas = useSelector(PreferenceData); const kioskCategoriesCard = useSelector(GlobalProductCardListKiosk); const KioskOrderDetails = useSelector(GlobalKioskOrderDetails); const getKioskLightColourdata = useSelector(getKioskLightColour); @@ -35,6 +37,13 @@ const CardPage2 = (props) => { (i) => i.SettingIdName === 'PrintUom' )?.[0]; + const overAllLimitPreferenece = + preferenceDatas?.[0]?.['SettingDtlDetails']?.find( + (item) => (item.SettingIdName?.toLowerCase() === 'overalllimit') && item?.SettingValue === 'Y'); + const itemWiseLimitPreferenece = + preferenceDatas?.[0]?.['SettingDtlDetails']?.find( + (item) => item.SettingIdName?.toLowerCase() === 'itemwiselimit' && item?.SettingValue === 'Y'); + const maxQtyLimit = itemWiseLimitPreferenece?.SettingCount || overAllLimitPreferenece?.SettingCount || null; useEffect(() => { getBookingTypeId(); }, []); @@ -48,6 +57,16 @@ const CardPage2 = (props) => { //Card on click function const CardOnClick = async (item, Parameter) => { + if ((overAllLimitPreferenece || itemWiseLimitPreferenece) && maxQtyLimit) { + if (overAllLimitPreferenece) { + const calculatedOverAllQty = calculateOverAllQtyLimit(KioskOrderDetails); + if ((calculatedOverAllQty + 1) > maxQtyLimit) { + message.warning(`Overall Quantity Limit Exceeds than ${maxQtyLimit}`) + return; + } + } + } + setOnePeiceFlow(Parameter === 'OnePeiceProduct'); const transformedItem = { @@ -81,11 +100,11 @@ const CardPage2 = (props) => { (cartItem) => cartItem?.ProdId === item?.ProductDetail?.[0]?.ProdId && cartItem?.InwardDtlId === - item?.ProductDetail?.[0]?.ProdVariantDetails?.[0]?.StockDetails?.[0] - ?.InwardDtlId && + item?.ProductDetail?.[0]?.ProdVariantDetails?.[0]?.StockDetails?.[0] + ?.InwardDtlId && cartItem?.OrderRate === - item?.ProductDetail?.[0]?.ProdVariantDetails?.[0]?.StockDetails?.[0] - ?.SellPrice + item?.ProductDetail?.[0]?.ProdVariantDetails?.[0]?.StockDetails?.[0] + ?.SellPrice ); if (Isincart && Isincart?.StockAvailable === 'Y') { if (Isincart?.BalanceQty > Isincart?.OrderQty) { @@ -131,13 +150,13 @@ const CardPage2 = (props) => { (cartItem) => cartItem?.ProdId === qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && cartItem?.OrderRate === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.SellPrice + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.SellPrice ); console.log(Isincart, item, KioskOrderDetails, 'IsincartsingleVarient'); if (Isincart && Isincart?.StockAvailable === 'Y') { @@ -236,7 +255,7 @@ const CardPage2 = (props) => { SinglePc: onePcs ? 'Y' : 'N', NoOfPcs: onePcs ? a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.NoOfPcs + ?.StockDetails?.[stockIndex]?.NoOfPcs : null, ProdVariantName: a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] @@ -261,14 +280,14 @@ const CardPage2 = (props) => { ?.StockDetails?.[stockIndex]?.InwardId, MRP: onePcs ? a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.OnePcsPrice + ?.StockDetails?.[stockIndex]?.OnePcsPrice : a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.MRP, + ?.StockDetails?.[stockIndex]?.MRP, OrderRate: onePcs ? a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.OnePcsPrice + ?.StockDetails?.[stockIndex]?.OnePcsPrice : a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.SellPrice, + ?.StockDetails?.[stockIndex]?.SellPrice, SuppId: a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] ?.StockDetails?.[stockIndex]?.SuppId, @@ -312,28 +331,28 @@ const CardPage2 = (props) => { cartItem // if the item is already in the cart, increase the quantity of the item ) => cartItem.ProdId === item.ProdId && - cartItem.InwardDtlId === item.InwardDtlId && - cartItem.OrderRate === item.OrderRate && - cartItem.BookingTypeName === item.BookingTypeName + cartItem.InwardDtlId === item.InwardDtlId && + cartItem.OrderRate === item.OrderRate && + cartItem.BookingTypeName === item.BookingTypeName ? { - ...cartItem, - OrderQty: cartItem.OrderQty + 1, - TotalAmt: (cartItem.OrderQty + 1) * cartItem.OrderRate, - TaxAmt: ( + ...cartItem, + OrderQty: cartItem.OrderQty + 1, + TotalAmt: (cartItem.OrderQty + 1) * cartItem.OrderRate, + TaxAmt: ( + ((cartItem.OrderQty + 1) * + cartItem.OrderRate * + cartItem.TaxPercentage) / + (100 + cartItem.TaxPercentage) + ).toFixed(2), + WithoutTaxRate: + (cartItem.OrderQty + 1) * cartItem.OrderRate - + ( ((cartItem.OrderQty + 1) * cartItem.OrderRate * cartItem.TaxPercentage) / (100 + cartItem.TaxPercentage) ).toFixed(2), - WithoutTaxRate: - (cartItem.OrderQty + 1) * cartItem.OrderRate - - ( - ((cartItem.OrderQty + 1) * - cartItem.OrderRate * - cartItem.TaxPercentage) / - (100 + cartItem.TaxPercentage) - ).toFixed(2), - } + } : cartItem // otherwise, return the cart item ) ) @@ -515,9 +534,9 @@ const CardPage2 = (props) => { card?.OverAllQty, KioskOrderDetails ) > 0) || - card?.ProductDetail?.some( - (item) => item?.StockAvailable !== 'Y' - ) + card?.ProductDetail?.some( + (item) => item?.StockAvailable !== 'Y' + ) ? 'CardPage2-container' : 'CardPage2-container-dis ' } @@ -540,9 +559,9 @@ const CardPage2 = (props) => { card?.OverAllQty, KioskOrderDetails ) > 0) || - card?.ProductDetail?.some( - (item) => item?.StockAvailable !== 'Y' - ) ? ( + card?.ProductDetail?.some( + (item) => item?.StockAvailable !== 'Y' + ) ? ( '' ) : (
{ card?.ProductDetail?.some( (item) => item?.StockAvailable !== 'Y' )) && ( -

- {' '} - - ₹ - - {ItemSellingPrice(card)}  - - ({ItemSize(card)} {ItemUomName(card)}) - -

- )} +

+ {' '} + + ₹ + + {ItemSellingPrice(card)}  + + ({ItemSize(card)} {ItemUomName(card)}) + +

+ )}
) )} @@ -723,7 +742,7 @@ const CardPage2 = (props) => { KioskOrderDetails, item?.ProdVariantName ) > 0 || - qtydata?.ProductDetail?.[QtyIndex]?.StockAvailable !== + qtydata?.ProductDetail?.[QtyIndex]?.StockAvailable !== 'Y' ? 'ProVariantCard' : 'ProVariantCard-dis' @@ -739,7 +758,7 @@ const CardPage2 = (props) => { KioskOrderDetails, item?.ProdVariantName ) > 0 || - qtydata?.ProductDetail?.[QtyIndex]?.StockAvailable !== + qtydata?.ProductDetail?.[QtyIndex]?.StockAvailable !== 'Y' ? (
₹ {item?.StockDetails?.[0]?.SellPrice}
) : ( diff --git a/src/Pages/Kiosk/CardPage/CardPage3.jsx b/src/Pages/Kiosk/CardPage/CardPage3.jsx index 2ac1b9f..d1553b5 100644 --- a/src/Pages/Kiosk/CardPage/CardPage3.jsx +++ b/src/Pages/Kiosk/CardPage/CardPage3.jsx @@ -1,5 +1,5 @@ import React, { useEffect, useState } from 'react'; -import { Drawer } from 'antd'; +import { Drawer, message } from 'antd'; import { IoCheckmarkCircle } from 'react-icons/io5'; import { DefaultModal } from '../../../Components/Modal/DefaultModal'; import defaultimage from '../../../Images/defaultItemImg.png'; @@ -14,10 +14,12 @@ import { import { settingDataSelector } from '../../../Features/PreferenceMaster/PreferenceMaster.js'; import horizontal from '../../../Images/defaultItemImg.png'; import { getKioskLightColour } from '../../../Features/Kiosk/kiosk'; -import { getConfigType } from '../../../Features/BookingScreen/BookingData/BookingData'; +import { getConfigType, PreferenceData } from '../../../Features/BookingScreen/BookingData/BookingData'; +import { calculateOverAllQtyLimit } from '../../../utils/calculations.js'; const CardPage3 = (props) => { const dispatch = useDispatch(); + const preferenceDatas = useSelector(PreferenceData); const kioskCategoriesCard = useSelector(GlobalProductCardListKiosk); const KioskOrderDetails = useSelector(GlobalKioskOrderDetails); console.log(KioskOrderDetails, 'KioskOrderDetailsKioskOrderDetails'); @@ -35,6 +37,13 @@ const CardPage3 = (props) => { const UomPrint = SettingDataSelector?.[0]?.SettingDtlDetails.filter( (i) => i.SettingIdName === 'PrintUom' )?.[0]; + const overAllLimitPreferenece = + preferenceDatas?.[0]?.['SettingDtlDetails']?.find( + (item) => (item.SettingIdName?.toLowerCase() === 'overalllimit') && item?.SettingValue === 'Y'); + const itemWiseLimitPreferenece = + preferenceDatas?.[0]?.['SettingDtlDetails']?.find( + (item) => item.SettingIdName?.toLowerCase() === 'itemwiselimit' && item?.SettingValue === 'Y'); + const maxQtyLimit = itemWiseLimitPreferenece?.SettingCount || overAllLimitPreferenece?.SettingCount || null; const onClose = () => { setopenQuantity(false); }; @@ -47,6 +56,15 @@ const CardPage3 = (props) => { }, []); //Card on click function const CardOnClick = async (item, Parameter) => { + if ((overAllLimitPreferenece || itemWiseLimitPreferenece) && maxQtyLimit) { + if (overAllLimitPreferenece) { + const calculatedOverAllQty = calculateOverAllQtyLimit(KioskOrderDetails); + if ((calculatedOverAllQty + 1) > maxQtyLimit) { + message.warning(`Overall Quantity Limit Exceeds than ${maxQtyLimit}`) + return; + } + } + } setOnePeiceFlow(Parameter === 'OnePeiceProduct'); const transformedItem = { @@ -80,11 +98,11 @@ const CardPage3 = (props) => { (cartItem) => cartItem?.ProdId === item?.ProductDetail?.[0]?.ProdId && cartItem?.InwardDtlId === - item?.ProductDetail?.[0]?.ProdVariantDetails?.[0]?.StockDetails?.[0] - ?.InwardDtlId && + item?.ProductDetail?.[0]?.ProdVariantDetails?.[0]?.StockDetails?.[0] + ?.InwardDtlId && cartItem?.OrderRate === - item?.ProductDetail?.[0]?.ProdVariantDetails?.[0]?.StockDetails?.[0] - ?.SellPrice + item?.ProductDetail?.[0]?.ProdVariantDetails?.[0]?.StockDetails?.[0] + ?.SellPrice ); if (Isincart && Isincart?.StockAvailable === 'Y') { if (Isincart?.BalanceQty > Isincart?.OrderQty) { @@ -131,13 +149,13 @@ const CardPage3 = (props) => { (cartItem) => cartItem?.ProdId === qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && cartItem?.OrderRate === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.SellPrice + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.SellPrice ); console.log(Isincart, item, KioskOrderDetails, 'IsincartsingleVarient'); if (Isincart && Isincart?.StockAvailable === 'Y') { @@ -234,7 +252,7 @@ const CardPage3 = (props) => { SinglePc: onePcs ? 'Y' : 'N', NoOfPcs: onePcs ? a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.NoOfPcs + ?.StockDetails?.[stockIndex]?.NoOfPcs : null, ProdVariantName: a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] @@ -259,14 +277,14 @@ const CardPage3 = (props) => { ?.StockDetails?.[stockIndex]?.InwardId, MRP: onePcs ? a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.OnePcsPrice + ?.StockDetails?.[stockIndex]?.OnePcsPrice : a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.MRP, + ?.StockDetails?.[stockIndex]?.MRP, OrderRate: onePcs ? a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.OnePcsPrice + ?.StockDetails?.[stockIndex]?.OnePcsPrice : a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.SellPrice, + ?.StockDetails?.[stockIndex]?.SellPrice, SuppId: a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] ?.StockDetails?.[stockIndex]?.SuppId, @@ -310,28 +328,28 @@ const CardPage3 = (props) => { cartItem // if the item is already in the cart, increase the quantity of the item ) => cartItem.ProdId === item.ProdId && - cartItem.InwardDtlId === item.InwardDtlId && - cartItem.OrderRate === item.OrderRate && - cartItem.BookingTypeName === item.BookingTypeName + cartItem.InwardDtlId === item.InwardDtlId && + cartItem.OrderRate === item.OrderRate && + cartItem.BookingTypeName === item.BookingTypeName ? { - ...cartItem, - OrderQty: cartItem.OrderQty + 1, - TotalAmt: (cartItem.OrderQty + 1) * cartItem.OrderRate, - TaxAmt: ( + ...cartItem, + OrderQty: cartItem.OrderQty + 1, + TotalAmt: (cartItem.OrderQty + 1) * cartItem.OrderRate, + TaxAmt: ( + ((cartItem.OrderQty + 1) * + cartItem.OrderRate * + cartItem.TaxPercentage) / + (100 + cartItem.TaxPercentage) + ).toFixed(2), + WithoutTaxRate: + (cartItem.OrderQty + 1) * cartItem.OrderRate - + ( ((cartItem.OrderQty + 1) * cartItem.OrderRate * cartItem.TaxPercentage) / (100 + cartItem.TaxPercentage) ).toFixed(2), - WithoutTaxRate: - (cartItem.OrderQty + 1) * cartItem.OrderRate - - ( - ((cartItem.OrderQty + 1) * - cartItem.OrderRate * - cartItem.TaxPercentage) / - (100 + cartItem.TaxPercentage) - ).toFixed(2), - } + } : cartItem // otherwise, return the cart item ) ) @@ -516,9 +534,9 @@ const CardPage3 = (props) => { card?.OverAllQty, KioskOrderDetails ) > 0) || - card?.ProductDetail?.some( - (item) => item?.StockAvailable !== 'Y' - ) + card?.ProductDetail?.some( + (item) => item?.StockAvailable !== 'Y' + ) ? 'CardPage3-container' : 'CardPage3-container-dis' } @@ -529,10 +547,10 @@ const CardPage3 = (props) => { {KioskOrderDetails?.some( (item) => item?.ProdName === card?.ProdName ) && ( -
- -
- )} +
+ +
+ )} { card?.OverAllQty, KioskOrderDetails ) > 0) || - card?.ProductDetail?.some( - (item) => item?.StockAvailable !== 'Y' - ) ? ( + card?.ProductDetail?.some( + (item) => item?.StockAvailable !== 'Y' + ) ? ( '' ) : (
{ card?.ProductDetail?.some( (item) => item?.StockAvailable !== 'Y' )) && ( -

- ₹{ItemSellingPrice(card)}  - - ({ItemSize(card)} {ItemUomName(card)}) - -

- )} +

+ ₹{ItemSellingPrice(card)}  + + ({ItemSize(card)} {ItemUomName(card)}) + +

+ )}
) )} @@ -724,7 +742,7 @@ const CardPage3 = (props) => { KioskOrderDetails, item?.ProdVariantName ) > 0 || - qtydata?.ProductDetail?.[QtyIndex]?.StockAvailable !== + qtydata?.ProductDetail?.[QtyIndex]?.StockAvailable !== 'Y' ? 'ProVariantCard' : 'ProVariantCard-dis' @@ -740,7 +758,7 @@ const CardPage3 = (props) => { KioskOrderDetails, item?.ProdVariantName ) > 0 || - qtydata?.ProductDetail?.[QtyIndex]?.StockAvailable !== + qtydata?.ProductDetail?.[QtyIndex]?.StockAvailable !== 'Y' ? (
₹{item?.StockDetails?.[0]?.SellPrice}
) : ( diff --git a/src/Pages/Kiosk/CardPage/CardPage4.jsx b/src/Pages/Kiosk/CardPage/CardPage4.jsx index dbee12c..c11ccfd 100644 --- a/src/Pages/Kiosk/CardPage/CardPage4.jsx +++ b/src/Pages/Kiosk/CardPage/CardPage4.jsx @@ -3,7 +3,7 @@ import { useDispatch, useSelector } from 'react-redux'; import { AiFillPlusCircle, AiFillMinusCircle } from 'react-icons/ai'; import { BsHandbag } from 'react-icons/bs'; import { DefaultModal } from '../../../Components/Modal/DefaultModal'; -import { Drawer } from 'antd'; +import { Drawer, message } from 'antd'; import '../../../Styles/Kiosk/CardPage/CardPage4.scss'; import { GlobalBookingTypeKiosk, @@ -14,10 +14,12 @@ import { import { settingDataSelector } from '../../../Features/PreferenceMaster/PreferenceMaster.js'; import horizontal from '../../../Images/defaultItemImg.png'; import { getKioskLightColour } from '../../../Features/Kiosk/kiosk'; -import { getConfigType } from '../../../Features/BookingScreen/BookingData/BookingData'; +import { getConfigType, PreferenceData } from '../../../Features/BookingScreen/BookingData/BookingData'; +import { calculateOverAllQtyLimit } from '../../../utils/calculations.js'; const CardPage4 = (props) => { const dispatch = useDispatch(); + const preferenceDatas = useSelector(PreferenceData); const kioskCategoriesCard = useSelector(GlobalProductCardListKiosk); const KioskOrderDetails = useSelector(GlobalKioskOrderDetails); console.log(KioskOrderDetails, 'KioskOrderDetails'); @@ -36,7 +38,13 @@ const CardPage4 = (props) => { const UomPrint = SettingDataSelector?.[0]?.SettingDtlDetails.filter( (i) => i.SettingIdName === 'PrintUom' )?.[0]; - + const overAllLimitPreferenece = + preferenceDatas?.[0]?.['SettingDtlDetails']?.find( + (item) => (item.SettingIdName?.toLowerCase() === 'overalllimit') && item?.SettingValue === 'Y'); + const itemWiseLimitPreferenece = + preferenceDatas?.[0]?.['SettingDtlDetails']?.find( + (item) => item.SettingIdName?.toLowerCase() === 'itemwiselimit' && item?.SettingValue === 'Y'); + const maxQtyLimit = itemWiseLimitPreferenece?.SettingCount || overAllLimitPreferenece?.SettingCount || null; useEffect(() => { getBookingTypeId(); }, []); @@ -79,6 +87,15 @@ const CardPage4 = (props) => { //Card on click function const CardOnClick = async (item, Parameter) => { + if ((overAllLimitPreferenece || itemWiseLimitPreferenece) && maxQtyLimit) { + if (overAllLimitPreferenece) { + const calculatedOverAllQty = calculateOverAllQtyLimit(KioskOrderDetails); + if ((calculatedOverAllQty + 1) > maxQtyLimit) { + message.warning(`Overall Quantity Limit Exceeds than ${maxQtyLimit}`) + return; + } + } + } setOnePeiceFlow(Parameter === 'OnePeiceProduct'); const transformedItem = { @@ -112,11 +129,11 @@ const CardPage4 = (props) => { (cartItem) => cartItem?.ProdId === item?.ProductDetail?.[0]?.ProdId && cartItem?.InwardDtlId === - item?.ProductDetail?.[0]?.ProdVariantDetails?.[0]?.StockDetails?.[0] - ?.InwardDtlId && + item?.ProductDetail?.[0]?.ProdVariantDetails?.[0]?.StockDetails?.[0] + ?.InwardDtlId && cartItem?.OrderRate === - item?.ProductDetail?.[0]?.ProdVariantDetails?.[0]?.StockDetails?.[0] - ?.SellPrice + item?.ProductDetail?.[0]?.ProdVariantDetails?.[0]?.StockDetails?.[0] + ?.SellPrice ); if (Isincart && Isincart?.StockAvailable === 'Y') { if (Isincart?.BalanceQty > Isincart?.OrderQty) { @@ -162,13 +179,13 @@ const CardPage4 = (props) => { (cartItem) => cartItem?.ProdId === qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && cartItem?.OrderRate === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.SellPrice + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.SellPrice ); if (Isincart && Isincart?.StockAvailable === 'Y') { @@ -259,7 +276,7 @@ const CardPage4 = (props) => { SinglePc: onePcs ? 'Y' : 'N', NoOfPcs: onePcs ? a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.NoOfPcs + ?.StockDetails?.[stockIndex]?.NoOfPcs : null, ProdVariantName: a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] @@ -284,14 +301,14 @@ const CardPage4 = (props) => { ?.StockDetails?.[stockIndex]?.InwardId, MRP: onePcs ? a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.OnePcsPrice + ?.StockDetails?.[stockIndex]?.OnePcsPrice : a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.MRP, + ?.StockDetails?.[stockIndex]?.MRP, OrderRate: onePcs ? a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.OnePcsPrice + ?.StockDetails?.[stockIndex]?.OnePcsPrice : a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.SellPrice, + ?.StockDetails?.[stockIndex]?.SellPrice, SuppId: a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] ?.StockDetails?.[stockIndex]?.SuppId, @@ -335,28 +352,28 @@ const CardPage4 = (props) => { cartItem // if the item is already in the cart, increase the quantity of the item ) => cartItem.ProdId === item.ProdId && - cartItem.InwardDtlId === item.InwardDtlId && - cartItem.OrderRate === item.OrderRate && - cartItem?.BookingTypeName === item?.BookingTypeName + cartItem.InwardDtlId === item.InwardDtlId && + cartItem.OrderRate === item.OrderRate && + cartItem?.BookingTypeName === item?.BookingTypeName ? { - ...cartItem, - OrderQty: cartItem.OrderQty + 1, - TotalAmt: (cartItem.OrderQty + 1) * cartItem.OrderRate, - TaxAmt: ( + ...cartItem, + OrderQty: cartItem.OrderQty + 1, + TotalAmt: (cartItem.OrderQty + 1) * cartItem.OrderRate, + TaxAmt: ( + ((cartItem.OrderQty + 1) * + cartItem.OrderRate * + cartItem.TaxPercentage) / + (100 + cartItem.TaxPercentage) + ).toFixed(2), + WithoutTaxRate: + (cartItem.OrderQty + 1) * cartItem.OrderRate - + ( ((cartItem.OrderQty + 1) * cartItem.OrderRate * cartItem.TaxPercentage) / (100 + cartItem.TaxPercentage) ).toFixed(2), - WithoutTaxRate: - (cartItem.OrderQty + 1) * cartItem.OrderRate - - ( - ((cartItem.OrderQty + 1) * - cartItem.OrderRate * - cartItem.TaxPercentage) / - (100 + cartItem.TaxPercentage) - ).toFixed(2), - } + } : cartItem // otherwise, return the cart item ) ) @@ -583,9 +600,9 @@ const CardPage4 = (props) => { card?.OverAllQty, KioskOrderDetails ) > 0) || - card?.ProductDetail?.some( - (item) => item?.StockAvailable !== 'Y' - ) ? ( + card?.ProductDetail?.some( + (item) => item?.StockAvailable !== 'Y' + ) ? (
CardOnClick(card)} @@ -745,7 +762,7 @@ const CardPage4 = (props) => { KioskOrderDetails, item?.ProdVariantName ) > 0 || - qtydata?.ProductDetail?.[QtyIndex]?.StockAvailable !== + qtydata?.ProductDetail?.[QtyIndex]?.StockAvailable !== 'Y' ? 'ProVariantCard' : 'ProVariantCard-dis' @@ -761,7 +778,7 @@ const CardPage4 = (props) => { KioskOrderDetails, item?.ProdVariantName ) > 0 || - qtydata?.ProductDetail?.[QtyIndex]?.StockAvailable !== + qtydata?.ProductDetail?.[QtyIndex]?.StockAvailable !== 'Y' ? (
₹{item?.StockDetails?.[0]?.SellPrice}
) : ( diff --git a/src/Pages/Kiosk/KioskBookingPage.jsx b/src/Pages/Kiosk/KioskBookingPage.jsx index 8313af3..025d6c1 100644 --- a/src/Pages/Kiosk/KioskBookingPage.jsx +++ b/src/Pages/Kiosk/KioskBookingPage.jsx @@ -1,4 +1,4 @@ -import { useEffect, useState } from 'react'; +import { useEffect, useState } from 'react'; import { useSelector, useDispatch } from 'react-redux'; import axios from 'axios'; import { Skeleton } from 'antd'; @@ -70,6 +70,11 @@ const KioskBookingPage = () => { }, []); const fetchData = async () => { + dispatch(getPreferenceData({ + CompId: SessionDtl?.CompId, + BranchId: SessionDtl?.BranchId, + AppId: SessionDtl?.AppId, + })).unwrap(); const queryParams = await getQueryParams(); console.log('queryParams', queryParams); @@ -143,7 +148,7 @@ const KioskBookingPage = () => { responseData?.SessionId != null && responseData?.SessionId != undefined && sessionStore('SessionId', responseData?.SessionId); - responseData?.DeviceAddress != null && + responseData?.DeviceAddress != null && responseData?.DeviceAddress != undefined && sessionStore('DeviceAddress', MACAddress); sessionStore('hasRefreshed', true); @@ -160,10 +165,12 @@ const KioskBookingPage = () => { AppId: responseData?.AppId, DeviceMacAddress: MACAddress })).unwrap(); - - dispatch(getPreferenceData({ CompId: responseData?.CompId, + + dispatch(getPreferenceData({ + CompId: responseData?.CompId, BranchId: responseData?.BranchId, - AppId: responseData?.AppId,})).unwrap(); + AppId: responseData?.AppId, + })).unwrap(); dispatch( getProductCategories({ CompId: responseData?.CompId, @@ -274,7 +281,7 @@ const KioskBookingPage = () => { AppId: AppId, }) ).unwrap(); - + if (Response?.data?.statusCode == 1) { dispatch( getProductCardListKiosk({ diff --git a/src/Pages/Kiosk/OrderCart/OrderCart1.jsx b/src/Pages/Kiosk/OrderCart/OrderCart1.jsx index 39926b9..ab1f3d1 100644 --- a/src/Pages/Kiosk/OrderCart/OrderCart1.jsx +++ b/src/Pages/Kiosk/OrderCart/OrderCart1.jsx @@ -4,9 +4,22 @@ import { changeKioskOrderDetails } from '../../../Features/BookingScreen/Booking import PozoDineInIcon from '../KioskIcons/KioskDineIn'; import TakeAway from '../KioskIcons/KioskTakeAway'; import '../../../Styles/Kiosk/OrderCart/OrderCart1.scss'; +import { useSelector } from 'react-redux'; +import { PreferenceData } from '../../../Features/BookingScreen/BookingData/BookingData'; +import { message } from 'antd'; +import { calculateOverAllQtyLimit } from '../../../utils/calculations'; const KisokOrderCart1 = (props) => { const dispatch = useDispatch(); + const preferenceDatas = useSelector(PreferenceData); + const overAllLimitPreferenece = + preferenceDatas?.[0]?.['SettingDtlDetails']?.find( + (item) => (item.SettingIdName?.toLowerCase() === 'overalllimit') && item?.SettingValue === 'Y'); + const itemWiseLimitPreferenece = + preferenceDatas?.[0]?.['SettingDtlDetails']?.find( + (item) => item.SettingIdName?.toLowerCase() === 'itemwiselimit' && item?.SettingValue === 'Y'); + const maxQtyLimit = itemWiseLimitPreferenece?.SettingCount || overAllLimitPreferenece?.SettingCount || null; + const KioskOrderDetails = props?.KioskOrderDetails; const removeFromCart = async (item) => { await dispatch( @@ -24,6 +37,15 @@ const KisokOrderCart1 = (props) => { ); }; const increase = async (item) => { + if ((overAllLimitPreferenece || itemWiseLimitPreferenece) && maxQtyLimit) { + if (overAllLimitPreferenece) { + const calculatedOverAllQty = calculateOverAllQtyLimit(KioskOrderDetails); + if ((calculatedOverAllQty + 1) > maxQtyLimit) { + message.warning(`Overall Quantity Limit Exceeds than ${maxQtyLimit}`) + return; + } + } + } await dispatch( changeKioskOrderDetails( KioskOrderDetails?.map( @@ -31,28 +53,28 @@ const KisokOrderCart1 = (props) => { cartItem // if the item is already in the cart, increase the quantity of the item ) => cartItem.ProdId === item.ProdId && - cartItem.InwardDtlId === item.InwardDtlId && - cartItem.OrderRate === item.OrderRate && - cartItem?.BookingTypeName === item?.BookingTypeName + cartItem.InwardDtlId === item.InwardDtlId && + cartItem.OrderRate === item.OrderRate && + cartItem?.BookingTypeName === item?.BookingTypeName ? { - ...cartItem, - OrderQty: cartItem.OrderQty + 1, - TotalAmt: (cartItem.OrderQty + 1) * cartItem.OrderRate, - TaxAmt: ( + ...cartItem, + OrderQty: cartItem.OrderQty + 1, + TotalAmt: (cartItem.OrderQty + 1) * cartItem.OrderRate, + TaxAmt: ( + ((cartItem.OrderQty + 1) * + cartItem.OrderRate * + cartItem.TaxPercentage) / + (100 + cartItem.TaxPercentage) + ).toFixed(2), + WithoutTaxRate: + (cartItem.OrderQty + 1) * cartItem.OrderRate - + ( ((cartItem.OrderQty + 1) * cartItem.OrderRate * cartItem.TaxPercentage) / (100 + cartItem.TaxPercentage) ).toFixed(2), - WithoutTaxRate: - (cartItem.OrderQty + 1) * cartItem.OrderRate - - ( - ((cartItem.OrderQty + 1) * - cartItem.OrderRate * - cartItem.TaxPercentage) / - (100 + cartItem.TaxPercentage) - ).toFixed(2), - } + } : cartItem // otherwise, return the cart item ) ) @@ -76,28 +98,28 @@ const KisokOrderCart1 = (props) => { cartItem // if the item is already in the cart, increase the quantity of the item ) => cartItem.ProdId === item.ProdId && - cartItem.InwardDtlId === item.InwardDtlId && - cartItem.OrderRate === item.OrderRate && - cartItem?.BookingTypeName === item?.BookingTypeName + cartItem.InwardDtlId === item.InwardDtlId && + cartItem.OrderRate === item.OrderRate && + cartItem?.BookingTypeName === item?.BookingTypeName ? { - ...cartItem, - OrderQty: cartItem.OrderQty - 1, - TotalAmt: (cartItem.OrderQty - 1) * cartItem.OrderRate, - TaxAmt: ( + ...cartItem, + OrderQty: cartItem.OrderQty - 1, + TotalAmt: (cartItem.OrderQty - 1) * cartItem.OrderRate, + TaxAmt: ( + ((cartItem.OrderQty - 1) * + cartItem.OrderRate * + cartItem.TaxPercentage) / + (100 + cartItem.TaxPercentage) + ).toFixed(2), + WithoutTaxRate: + (cartItem.OrderQty - 1) * cartItem.OrderRate - + ( ((cartItem.OrderQty - 1) * cartItem.OrderRate * cartItem.TaxPercentage) / (100 + cartItem.TaxPercentage) ).toFixed(2), - WithoutTaxRate: - (cartItem.OrderQty - 1) * cartItem.OrderRate - - ( - ((cartItem.OrderQty - 1) * - cartItem.OrderRate * - cartItem.TaxPercentage) / - (100 + cartItem.TaxPercentage) - ).toFixed(2), - } + } : cartItem // otherwise, return the cart item ) ) diff --git a/src/Pages/Kiosk/OrderCart/OrderCart2.jsx b/src/Pages/Kiosk/OrderCart/OrderCart2.jsx index 7789636..7b2e35d 100644 --- a/src/Pages/Kiosk/OrderCart/OrderCart2.jsx +++ b/src/Pages/Kiosk/OrderCart/OrderCart2.jsx @@ -6,9 +6,22 @@ import '../../../Styles/Kiosk/OrderCart/OrderCart2.scss'; import PozoDineInIcon from '../KioskIcons/KioskDineIn'; import TakeAway from '../KioskIcons/KioskTakeAway'; import { color } from 'highcharts'; +import { calculateOverAllQtyLimit } from '../../../utils/calculations'; +import { PreferenceData } from '../../../Features/BookingScreen/BookingData/BookingData'; +import { useSelector } from 'react-redux'; +import { message } from 'antd'; const KisokOrderCart2 = (props) => { const dispatch = useDispatch(); + const preferenceDatas = useSelector(PreferenceData); + const overAllLimitPreferenece = + preferenceDatas?.[0]?.['SettingDtlDetails']?.find( + (item) => (item.SettingIdName?.toLowerCase() === 'overalllimit') && item?.SettingValue === 'Y'); + const itemWiseLimitPreferenece = + preferenceDatas?.[0]?.['SettingDtlDetails']?.find( + (item) => item.SettingIdName?.toLowerCase() === 'itemwiselimit' && item?.SettingValue === 'Y'); + const maxQtyLimit = itemWiseLimitPreferenece?.SettingCount || overAllLimitPreferenece?.SettingCount || null; + const KioskOrderDetails = props?.KioskOrderDetails; const removeFromCart = async (item) => { @@ -27,6 +40,16 @@ const KisokOrderCart2 = (props) => { ); }; const increase = async (item) => { + if ((overAllLimitPreferenece || itemWiseLimitPreferenece) && maxQtyLimit) { + if (overAllLimitPreferenece) { + const calculatedOverAllQty = calculateOverAllQtyLimit(KioskOrderDetails); + if ((calculatedOverAllQty + 1) > maxQtyLimit) { + message.warning(`Overall Quantity Limit Exceeds than ${maxQtyLimit}`) + return; + } + } + } + await dispatch( changeKioskOrderDetails( KioskOrderDetails?.map( @@ -34,28 +57,28 @@ const KisokOrderCart2 = (props) => { cartItem // if the item is already in the cart, increase the quantity of the item ) => cartItem.ProdId === item.ProdId && - cartItem.InwardDtlId === item.InwardDtlId && - cartItem.OrderRate === item.OrderRate && - cartItem?.BookingTypeName === item?.BookingTypeName + cartItem.InwardDtlId === item.InwardDtlId && + cartItem.OrderRate === item.OrderRate && + cartItem?.BookingTypeName === item?.BookingTypeName ? { - ...cartItem, - OrderQty: cartItem.OrderQty + 1, - TotalAmt: (cartItem.OrderQty + 1) * cartItem.OrderRate, - TaxAmt: ( + ...cartItem, + OrderQty: cartItem.OrderQty + 1, + TotalAmt: (cartItem.OrderQty + 1) * cartItem.OrderRate, + TaxAmt: ( + ((cartItem.OrderQty + 1) * + cartItem.OrderRate * + cartItem.TaxPercentage) / + (100 + cartItem.TaxPercentage) + ).toFixed(2), + WithoutTaxRate: + (cartItem.OrderQty + 1) * cartItem.OrderRate - + ( ((cartItem.OrderQty + 1) * cartItem.OrderRate * cartItem.TaxPercentage) / (100 + cartItem.TaxPercentage) ).toFixed(2), - WithoutTaxRate: - (cartItem.OrderQty + 1) * cartItem.OrderRate - - ( - ((cartItem.OrderQty + 1) * - cartItem.OrderRate * - cartItem.TaxPercentage) / - (100 + cartItem.TaxPercentage) - ).toFixed(2), - } + } : cartItem // otherwise, return the cart item ) ) @@ -79,28 +102,28 @@ const KisokOrderCart2 = (props) => { cartItem // if the item is already in the cart, increase the quantity of the item ) => cartItem.ProdId === item.ProdId && - cartItem.InwardDtlId === item.InwardDtlId && - cartItem.OrderRate === item.OrderRate && - cartItem.BookingTypeName === item.BookingTypeName + cartItem.InwardDtlId === item.InwardDtlId && + cartItem.OrderRate === item.OrderRate && + cartItem.BookingTypeName === item.BookingTypeName ? { - ...cartItem, - OrderQty: cartItem.OrderQty - 1, - TotalAmt: (cartItem.OrderQty - 1) * cartItem.OrderRate, - TaxAmt: ( + ...cartItem, + OrderQty: cartItem.OrderQty - 1, + TotalAmt: (cartItem.OrderQty - 1) * cartItem.OrderRate, + TaxAmt: ( + ((cartItem.OrderQty - 1) * + cartItem.OrderRate * + cartItem.TaxPercentage) / + (100 + cartItem.TaxPercentage) + ).toFixed(2), + WithoutTaxRate: + (cartItem.OrderQty - 1) * cartItem.OrderRate - + ( ((cartItem.OrderQty - 1) * cartItem.OrderRate * cartItem.TaxPercentage) / (100 + cartItem.TaxPercentage) ).toFixed(2), - WithoutTaxRate: - (cartItem.OrderQty - 1) * cartItem.OrderRate - - ( - ((cartItem.OrderQty - 1) * - cartItem.OrderRate * - cartItem.TaxPercentage) / - (100 + cartItem.TaxPercentage) - ).toFixed(2), - } + } : cartItem // otherwise, return the cart item ) ) diff --git a/src/Pages/Kiosk/OrderCart/OrderCart3.jsx b/src/Pages/Kiosk/OrderCart/OrderCart3.jsx index dfe3333..51f4a37 100644 --- a/src/Pages/Kiosk/OrderCart/OrderCart3.jsx +++ b/src/Pages/Kiosk/OrderCart/OrderCart3.jsx @@ -8,10 +8,22 @@ import { import PozoDineInIcon from '../KioskIcons/KioskDineIn'; import TakeAway from '../KioskIcons/KioskTakeAway'; import '../../../Styles/Kiosk/OrderCart/OrderCart3.scss'; +import { calculateOverAllQtyLimit } from '../../../utils/calculations'; +import { message } from 'antd'; +import { PreferenceData } from '../../../Features/BookingScreen/BookingData/BookingData'; const KisokOrderCart3 = (props) => { const dispatch = useDispatch(); const getKioskDarkColourdata = useSelector(getKioskDarkColour); + const preferenceDatas = useSelector(PreferenceData); + const overAllLimitPreferenece = + preferenceDatas?.[0]?.['SettingDtlDetails']?.find( + (item) => (item.SettingIdName?.toLowerCase() === 'overalllimit') && item?.SettingValue === 'Y'); + const itemWiseLimitPreferenece = + preferenceDatas?.[0]?.['SettingDtlDetails']?.find( + (item) => item.SettingIdName?.toLowerCase() === 'itemwiselimit' && item?.SettingValue === 'Y'); + const maxQtyLimit = itemWiseLimitPreferenece?.SettingCount || overAllLimitPreferenece?.SettingCount || null; + const BookingTypeBoth = useSelector(GlobalKioskBookingTypeBoth); const KioskOrderDetails = props?.KioskOrderDetails; @@ -31,6 +43,15 @@ const KisokOrderCart3 = (props) => { ); }; const increase = async (item) => { + if ((overAllLimitPreferenece || itemWiseLimitPreferenece) && maxQtyLimit) { + if (overAllLimitPreferenece) { + const calculatedOverAllQty = calculateOverAllQtyLimit(KioskOrderDetails); + if ((calculatedOverAllQty + 1) > maxQtyLimit) { + message.warning(`Overall Quantity Limit Exceeds than ${maxQtyLimit}`) + return; + } + } + } await dispatch( changeKioskOrderDetails( KioskOrderDetails?.map( @@ -38,28 +59,28 @@ const KisokOrderCart3 = (props) => { cartItem // if the item is already in the cart, increase the quantity of the item ) => cartItem.ProdId === item.ProdId && - cartItem.InwardDtlId === item.InwardDtlId && - cartItem.OrderRate === item.OrderRate && - cartItem?.BookingTypeName === item?.BookingTypeName + cartItem.InwardDtlId === item.InwardDtlId && + cartItem.OrderRate === item.OrderRate && + cartItem?.BookingTypeName === item?.BookingTypeName ? { - ...cartItem, - OrderQty: cartItem.OrderQty + 1, - TotalAmt: (cartItem.OrderQty + 1) * cartItem.OrderRate, - TaxAmt: ( + ...cartItem, + OrderQty: cartItem.OrderQty + 1, + TotalAmt: (cartItem.OrderQty + 1) * cartItem.OrderRate, + TaxAmt: ( + ((cartItem.OrderQty + 1) * + cartItem.OrderRate * + cartItem.TaxPercentage) / + (100 + cartItem.TaxPercentage) + ).toFixed(2), + WithoutTaxRate: + (cartItem.OrderQty + 1) * cartItem.OrderRate - + ( ((cartItem.OrderQty + 1) * cartItem.OrderRate * cartItem.TaxPercentage) / (100 + cartItem.TaxPercentage) ).toFixed(2), - WithoutTaxRate: - (cartItem.OrderQty + 1) * cartItem.OrderRate - - ( - ((cartItem.OrderQty + 1) * - cartItem.OrderRate * - cartItem.TaxPercentage) / - (100 + cartItem.TaxPercentage) - ).toFixed(2), - } + } : cartItem // otherwise, return the cart item ) ) @@ -81,28 +102,28 @@ const KisokOrderCart3 = (props) => { cartItem // if the item is already in the cart, increase the quantity of the item ) => cartItem.ProdId === item.ProdId && - cartItem.InwardDtlId === item.InwardDtlId && - cartItem.OrderRate === item.OrderRate && - cartItem?.BookingTypeName === item?.BookingTypeName + cartItem.InwardDtlId === item.InwardDtlId && + cartItem.OrderRate === item.OrderRate && + cartItem?.BookingTypeName === item?.BookingTypeName ? { - ...cartItem, - OrderQty: cartItem.OrderQty - 1, - TotalAmt: (cartItem.OrderQty - 1) * cartItem.OrderRate, - TaxAmt: ( + ...cartItem, + OrderQty: cartItem.OrderQty - 1, + TotalAmt: (cartItem.OrderQty - 1) * cartItem.OrderRate, + TaxAmt: ( + ((cartItem.OrderQty - 1) * + cartItem.OrderRate * + cartItem.TaxPercentage) / + (100 + cartItem.TaxPercentage) + ).toFixed(2), + WithoutTaxRate: + (cartItem.OrderQty - 1) * cartItem.OrderRate - + ( ((cartItem.OrderQty - 1) * cartItem.OrderRate * cartItem.TaxPercentage) / (100 + cartItem.TaxPercentage) ).toFixed(2), - WithoutTaxRate: - (cartItem.OrderQty - 1) * cartItem.OrderRate - - ( - ((cartItem.OrderQty - 1) * - cartItem.OrderRate * - cartItem.TaxPercentage) / - (100 + cartItem.TaxPercentage) - ).toFixed(2), - } + } : cartItem // otherwise, return the cart item ) ) diff --git a/src/Pages/Kiosk/OrderView/OrderView1.jsx b/src/Pages/Kiosk/OrderView/OrderView1.jsx index 2e18916..d5fcf51 100644 --- a/src/Pages/Kiosk/OrderView/OrderView1.jsx +++ b/src/Pages/Kiosk/OrderView/OrderView1.jsx @@ -16,6 +16,9 @@ import KioskFooter3 from '../Components/KioskFooter3'; import PozoDineInIcon from '../KioskIcons/KioskDineIn'; import TakeAway from '../KioskIcons/KioskTakeAway'; import '../../../Styles/Kiosk/OrderView/OrderView1.scss'; +import { PreferenceData } from '../../../Features/BookingScreen/BookingData/BookingData'; +import { calculateOverAllQtyLimit } from '../../../utils/calculations'; +import { message } from 'antd'; const OrderView1 = (props) => { const KioskThemeData = props?.hasOwnProperty('KioskThemeData') @@ -24,6 +27,14 @@ const OrderView1 = (props) => { const dispatch = useDispatch(); const KioskOrderDetails = useSelector(GlobalKioskOrderDetails); const getKioskLightColourdata = useSelector(getKioskLightColour); + const preferenceDatas = useSelector(PreferenceData); + const overAllLimitPreferenece = + preferenceDatas?.[0]?.['SettingDtlDetails']?.find( + (item) => (item.SettingIdName?.toLowerCase() === 'overalllimit') && item?.SettingValue === 'Y'); + const itemWiseLimitPreferenece = + preferenceDatas?.[0]?.['SettingDtlDetails']?.find( + (item) => item.SettingIdName?.toLowerCase() === 'itemwiselimit' && item?.SettingValue === 'Y'); + const maxQtyLimit = itemWiseLimitPreferenece?.SettingCount || overAllLimitPreferenece?.SettingCount || null; const BackToCategory = async () => { await dispatch(changeKioskPageName('categoryPage')); @@ -44,6 +55,17 @@ const OrderView1 = (props) => { ); }; const increase = async (item) => { + + + if ((overAllLimitPreferenece || itemWiseLimitPreferenece) && maxQtyLimit) { + if (overAllLimitPreferenece) { + const calculatedOverAllQty = calculateOverAllQtyLimit(KioskOrderDetails); + if ((calculatedOverAllQty + 1) > maxQtyLimit) { + message.warning(`Overall Quantity Limit Exceeds than ${maxQtyLimit}`) + return; + } + } + } await dispatch( changeKioskOrderDetails( KioskOrderDetails?.map( @@ -51,28 +73,28 @@ const OrderView1 = (props) => { cartItem // if the item is already in the cart, increase the quantity of the item ) => cartItem.ProdId === item.ProdId && - cartItem.InwardDtlId === item.InwardDtlId && - cartItem.OrderRate === item.OrderRate && - cartItem?.BookingTypeName === item?.BookingTypeName + cartItem.InwardDtlId === item.InwardDtlId && + cartItem.OrderRate === item.OrderRate && + cartItem?.BookingTypeName === item?.BookingTypeName ? { - ...cartItem, - OrderQty: cartItem.OrderQty + 1, - TotalAmt: (cartItem.OrderQty + 1) * cartItem.OrderRate, - TaxAmt: ( + ...cartItem, + OrderQty: cartItem.OrderQty + 1, + TotalAmt: (cartItem.OrderQty + 1) * cartItem.OrderRate, + TaxAmt: ( + ((cartItem.OrderQty + 1) * + cartItem.OrderRate * + cartItem.TaxPercentage) / + (100 + cartItem.TaxPercentage) + ).toFixed(2), + WithoutTaxRate: + (cartItem.OrderQty + 1) * cartItem.OrderRate - + ( ((cartItem.OrderQty + 1) * cartItem.OrderRate * cartItem.TaxPercentage) / (100 + cartItem.TaxPercentage) ).toFixed(2), - WithoutTaxRate: - (cartItem.OrderQty + 1) * cartItem.OrderRate - - ( - ((cartItem.OrderQty + 1) * - cartItem.OrderRate * - cartItem.TaxPercentage) / - (100 + cartItem.TaxPercentage) - ).toFixed(2), - } + } : cartItem // otherwise, return the cart item ) ) @@ -96,28 +118,28 @@ const OrderView1 = (props) => { cartItem // if the item is already in the cart, increase the quantity of the item ) => cartItem.ProdId === item.ProdId && - cartItem.InwardDtlId === item.InwardDtlId && - cartItem.OrderRate === item.OrderRate && - cartItem?.BookingTypeName === item?.BookingTypeName + cartItem.InwardDtlId === item.InwardDtlId && + cartItem.OrderRate === item.OrderRate && + cartItem?.BookingTypeName === item?.BookingTypeName ? { - ...cartItem, - OrderQty: cartItem.OrderQty - 1, - TotalAmt: (cartItem.OrderQty - 1) * cartItem.OrderRate, - TaxAmt: ( + ...cartItem, + OrderQty: cartItem.OrderQty - 1, + TotalAmt: (cartItem.OrderQty - 1) * cartItem.OrderRate, + TaxAmt: ( + ((cartItem.OrderQty - 1) * + cartItem.OrderRate * + cartItem.TaxPercentage) / + (100 + cartItem.TaxPercentage) + ).toFixed(2), + WithoutTaxRate: + (cartItem.OrderQty - 1) * cartItem.OrderRate - + ( ((cartItem.OrderQty - 1) * cartItem.OrderRate * cartItem.TaxPercentage) / (100 + cartItem.TaxPercentage) ).toFixed(2), - WithoutTaxRate: - (cartItem.OrderQty - 1) * cartItem.OrderRate - - ( - ((cartItem.OrderQty - 1) * - cartItem.OrderRate * - cartItem.TaxPercentage) / - (100 + cartItem.TaxPercentage) - ).toFixed(2), - } + } : cartItem // otherwise, return the cart item ) ) diff --git a/src/Pages/Kiosk/OrderView/OrderView2.jsx b/src/Pages/Kiosk/OrderView/OrderView2.jsx index 5acb0b6..28532c8 100644 --- a/src/Pages/Kiosk/OrderView/OrderView2.jsx +++ b/src/Pages/Kiosk/OrderView/OrderView2.jsx @@ -18,6 +18,9 @@ import { IoMdClose } from 'react-icons/io'; import defaultImg from '../../../Images/defaultItemImg.png'; import PozoDineInIcon from '../KioskIcons/KioskDineIn'; import TakeAway from '../KioskIcons/KioskTakeAway'; +import { calculateOverAllQtyLimit } from '../../../utils/calculations'; +import { message } from 'antd'; +import { PreferenceData } from '../../../Features/BookingScreen/BookingData/BookingData'; const KioskOrderView2 = (props) => { console.log(props, 'propsprops'); @@ -25,6 +28,15 @@ const KioskOrderView2 = (props) => { ? props['KioskThemeData'] : null; const dispatch = useDispatch(); + const preferenceDatas = useSelector(PreferenceData); + const overAllLimitPreferenece = + preferenceDatas?.[0]?.['SettingDtlDetails']?.find( + (item) => (item.SettingIdName?.toLowerCase() === 'overalllimit') && item?.SettingValue === 'Y'); + const itemWiseLimitPreferenece = + preferenceDatas?.[0]?.['SettingDtlDetails']?.find( + (item) => item.SettingIdName?.toLowerCase() === 'itemwiselimit' && item?.SettingValue === 'Y'); + const maxQtyLimit = itemWiseLimitPreferenece?.SettingCount || overAllLimitPreferenece?.SettingCount || null; + const KioskOrderDetails = useSelector(GlobalKioskOrderDetails); const getKioskLightColourdata = useSelector(getKioskLightColour); console.log(KioskOrderDetails, 'KioskOrderDetailsh'); @@ -54,6 +66,15 @@ const KioskOrderView2 = (props) => { ); }; const increase = async (item) => { + if ((overAllLimitPreferenece || itemWiseLimitPreferenece) && maxQtyLimit) { + if (overAllLimitPreferenece) { + const calculatedOverAllQty = calculateOverAllQtyLimit(KioskOrderDetails); + if ((calculatedOverAllQty + 1) > maxQtyLimit) { + message.warning(`Overall Quantity Limit Exceeds than ${maxQtyLimit}`) + return; + } + } + } await dispatch( changeKioskOrderDetails( KioskOrderDetails?.map( @@ -61,28 +82,28 @@ const KioskOrderView2 = (props) => { cartItem // if the item is already in the cart, increase the quantity of the item ) => cartItem.ProdId === item.ProdId && - cartItem.InwardDtlId === item.InwardDtlId && - cartItem.OrderRate === item.OrderRate && - cartItem?.BookingTypeName === item?.BookingTypeName + cartItem.InwardDtlId === item.InwardDtlId && + cartItem.OrderRate === item.OrderRate && + cartItem?.BookingTypeName === item?.BookingTypeName ? { - ...cartItem, - OrderQty: cartItem.OrderQty + 1, - TotalAmt: (cartItem.OrderQty + 1) * cartItem.OrderRate, - TaxAmt: ( + ...cartItem, + OrderQty: cartItem.OrderQty + 1, + TotalAmt: (cartItem.OrderQty + 1) * cartItem.OrderRate, + TaxAmt: ( + ((cartItem.OrderQty + 1) * + cartItem.OrderRate * + cartItem.TaxPercentage) / + (100 + cartItem.TaxPercentage) + ).toFixed(2), + WithoutTaxRate: + (cartItem.OrderQty + 1) * cartItem.OrderRate - + ( ((cartItem.OrderQty + 1) * cartItem.OrderRate * cartItem.TaxPercentage) / (100 + cartItem.TaxPercentage) ).toFixed(2), - WithoutTaxRate: - (cartItem.OrderQty + 1) * cartItem.OrderRate - - ( - ((cartItem.OrderQty + 1) * - cartItem.OrderRate * - cartItem.TaxPercentage) / - (100 + cartItem.TaxPercentage) - ).toFixed(2), - } + } : cartItem // otherwise, return the cart item ) ) @@ -106,28 +127,28 @@ const KioskOrderView2 = (props) => { cartItem // if the item is already in the cart, increase the quantity of the item ) => cartItem.ProdId === item.ProdId && - cartItem.InwardDtlId === item.InwardDtlId && - cartItem.OrderRate === item.OrderRate && - cartItem.BookingTypeName === item.BookingTypeName + cartItem.InwardDtlId === item.InwardDtlId && + cartItem.OrderRate === item.OrderRate && + cartItem.BookingTypeName === item.BookingTypeName ? { - ...cartItem, - OrderQty: cartItem.OrderQty - 1, - TotalAmt: (cartItem.OrderQty - 1) * cartItem.OrderRate, - TaxAmt: ( + ...cartItem, + OrderQty: cartItem.OrderQty - 1, + TotalAmt: (cartItem.OrderQty - 1) * cartItem.OrderRate, + TaxAmt: ( + ((cartItem.OrderQty - 1) * + cartItem.OrderRate * + cartItem.TaxPercentage) / + (100 + cartItem.TaxPercentage) + ).toFixed(2), + WithoutTaxRate: + (cartItem.OrderQty - 1) * cartItem.OrderRate - + ( ((cartItem.OrderQty - 1) * cartItem.OrderRate * cartItem.TaxPercentage) / (100 + cartItem.TaxPercentage) ).toFixed(2), - WithoutTaxRate: - (cartItem.OrderQty - 1) * cartItem.OrderRate - - ( - ((cartItem.OrderQty - 1) * - cartItem.OrderRate * - cartItem.TaxPercentage) / - (100 + cartItem.TaxPercentage) - ).toFixed(2), - } + } : cartItem // otherwise, return the cart item ) ) diff --git a/src/Pages/Kiosk/OrderView/OrderView3.jsx b/src/Pages/Kiosk/OrderView/OrderView3.jsx index f87c047..d9ecf12 100644 --- a/src/Pages/Kiosk/OrderView/OrderView3.jsx +++ b/src/Pages/Kiosk/OrderView/OrderView3.jsx @@ -18,6 +18,9 @@ import { import KioskFooter3 from '../Components/KioskFooter3'; import PozoDineInIcon from '../KioskIcons/KioskDineIn'; import TakeAway from '../KioskIcons/KioskTakeAway'; +import { PreferenceData } from '../../../Features/BookingScreen/BookingData/BookingData'; +import { calculateOverAllQtyLimit } from '../../../utils/calculations'; +import { message } from 'antd'; const KioskOrderView = (props) => { console.log(props, 'propsprops'); @@ -27,6 +30,14 @@ const KioskOrderView = (props) => { const dispatch = useDispatch(); const KioskOrderDetails = useSelector(GlobalKioskOrderDetails); const getKioskLightColourdata = useSelector(getKioskLightColour); + const preferenceDatas = useSelector(PreferenceData); + const overAllLimitPreferenece = + preferenceDatas?.[0]?.['SettingDtlDetails']?.find( + (item) => (item.SettingIdName?.toLowerCase() === 'overalllimit') && item?.SettingValue === 'Y'); + const itemWiseLimitPreferenece = + preferenceDatas?.[0]?.['SettingDtlDetails']?.find( + (item) => item.SettingIdName?.toLowerCase() === 'itemwiselimit' && item?.SettingValue === 'Y'); + const maxQtyLimit = itemWiseLimitPreferenece?.SettingCount || overAllLimitPreferenece?.SettingCount || null; const BackToCategory = async () => { await dispatch(changeKioskPageName('categoryPage')); @@ -47,6 +58,16 @@ const KioskOrderView = (props) => { ); }; const increase = async (item) => { + + if ((overAllLimitPreferenece || itemWiseLimitPreferenece) && maxQtyLimit) { + if (overAllLimitPreferenece) { + const calculatedOverAllQty = calculateOverAllQtyLimit(KioskOrderDetails); + if ((calculatedOverAllQty + 1) > maxQtyLimit) { + message.warning(`Overall Quantity Limit Exceeds than ${maxQtyLimit}`) + return; + } + } + } await dispatch( changeKioskOrderDetails( KioskOrderDetails?.map( @@ -54,28 +75,28 @@ const KioskOrderView = (props) => { cartItem // if the item is already in the cart, increase the quantity of the item ) => cartItem.ProdId === item.ProdId && - cartItem.InwardDtlId === item.InwardDtlId && - cartItem.OrderRate === item.OrderRate && - cartItem?.BookingTypeName === item?.BookingTypeName + cartItem.InwardDtlId === item.InwardDtlId && + cartItem.OrderRate === item.OrderRate && + cartItem?.BookingTypeName === item?.BookingTypeName ? { - ...cartItem, - OrderQty: cartItem.OrderQty + 1, - TotalAmt: (cartItem.OrderQty + 1) * cartItem.OrderRate, - TaxAmt: ( + ...cartItem, + OrderQty: cartItem.OrderQty + 1, + TotalAmt: (cartItem.OrderQty + 1) * cartItem.OrderRate, + TaxAmt: ( + ((cartItem.OrderQty + 1) * + cartItem.OrderRate * + cartItem.TaxPercentage) / + (100 + cartItem.TaxPercentage) + ).toFixed(2), + WithoutTaxRate: + (cartItem.OrderQty + 1) * cartItem.OrderRate - + ( ((cartItem.OrderQty + 1) * cartItem.OrderRate * cartItem.TaxPercentage) / (100 + cartItem.TaxPercentage) ).toFixed(2), - WithoutTaxRate: - (cartItem.OrderQty + 1) * cartItem.OrderRate - - ( - ((cartItem.OrderQty + 1) * - cartItem.OrderRate * - cartItem.TaxPercentage) / - (100 + cartItem.TaxPercentage) - ).toFixed(2), - } + } : cartItem // otherwise, return the cart item ) ) @@ -98,28 +119,28 @@ const KioskOrderView = (props) => { cartItem // if the item is already in the cart, increase the quantity of the item ) => cartItem.ProdId === item.ProdId && - cartItem.InwardDtlId === item.InwardDtlId && - cartItem.OrderRate === item.OrderRate && - cartItem?.BookingTypeName === item?.BookingTypeName + cartItem.InwardDtlId === item.InwardDtlId && + cartItem.OrderRate === item.OrderRate && + cartItem?.BookingTypeName === item?.BookingTypeName ? { - ...cartItem, - OrderQty: cartItem.OrderQty - 1, - TotalAmt: (cartItem.OrderQty - 1) * cartItem.OrderRate, - TaxAmt: ( + ...cartItem, + OrderQty: cartItem.OrderQty - 1, + TotalAmt: (cartItem.OrderQty - 1) * cartItem.OrderRate, + TaxAmt: ( + ((cartItem.OrderQty - 1) * + cartItem.OrderRate * + cartItem.TaxPercentage) / + (100 + cartItem.TaxPercentage) + ).toFixed(2), + WithoutTaxRate: + (cartItem.OrderQty - 1) * cartItem.OrderRate - + ( ((cartItem.OrderQty - 1) * cartItem.OrderRate * cartItem.TaxPercentage) / (100 + cartItem.TaxPercentage) ).toFixed(2), - WithoutTaxRate: - (cartItem.OrderQty - 1) * cartItem.OrderRate - - ( - ((cartItem.OrderQty - 1) * - cartItem.OrderRate * - cartItem.TaxPercentage) / - (100 + cartItem.TaxPercentage) - ).toFixed(2), - } + } : cartItem // otherwise, return the cart item ) ) @@ -201,10 +222,10 @@ const KioskOrderView = (props) => { {!item?.ProdVariantName?.toLowerCase().includes( 'variant' ) && ( - - {item?.ProdVariantName}{' '} - - )}{' '} + + {item?.ProdVariantName}{' '} + + )}{' '} {item?.Size}{' '} {item?.SinglePc == 'Y' ? 'PCS' : item?.UomName}
From 608aa917b3a8e28e391b9f964be12ec40ae0d0d3 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 24 Feb 2026 14:40:44 +0530 Subject: [PATCH 3/4] kisok quantity constrain --- .../BSBillingEditQuantity.jsx | 262 ++--- .../ComboEditQtyAndRate.jsx | 217 ++-- .../Components/BSItemCards/BSItemCard.jsx | 983 +++++++++--------- src/utils/calculations.js | 5 + 4 files changed, 773 insertions(+), 694 deletions(-) create mode 100644 src/utils/calculations.js diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/BSBillingEditQuantity.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/BSBillingEditQuantity.jsx index 4a3942d..d309960 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/BSBillingEditQuantity.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingEditQuantity/BSBillingEditQuantity.jsx @@ -41,6 +41,7 @@ import { import { validateOffers } from '../../BSItemCards/ValidateOffer.jsx'; import { v4 as uuidv4 } from 'uuid'; import WeightCalculatePrice from './WeightCalculatePrice.jsx'; +import { calculateOverAllQtyLimit } from '../../../../../utils/calculations.js'; const BSBillingEditQuantity = (props) => { const dispatch = useDispatch(); @@ -49,7 +50,7 @@ const BSBillingEditQuantity = (props) => { const priceChangeInputRef = useRef(null); const reductionInputRef = useRef(null); - const { setIndex = () => {} } = props; + const { setIndex = () => { } } = props; const [disableSubmitButton, setDisableSubmitButton] = useState(false); const SessionData = useSelector(StoredSessionData); @@ -64,6 +65,14 @@ const BSBillingEditQuantity = (props) => { (state) => state?.BookingOFferNew?.OverAllProductBasedProducts, shallowEqual ); + + const overAllLimitPreferenece = + preferenceDatas?.[0]?.['SettingDtlDetails']?.find( + (item) => (item.SettingIdName?.toLowerCase() === 'overalllimit') && item?.SettingValue === 'Y'); + const itemWiseLimitPreferenece = + preferenceDatas?.[0]?.['SettingDtlDetails']?.find( + (item) => item.SettingIdName?.toLowerCase() === 'itemwiselimit' && item?.SettingValue === 'Y'); + const maxQtyLimit = itemWiseLimitPreferenece?.SettingCount || overAllLimitPreferenece?.SettingCount || null; const preferenceOffer = preferenceDatas?.[0]?.['SettingDtlDetails']?.find( (item) => item.SettingIdName === 'Offer' @@ -103,23 +112,23 @@ const BSBillingEditQuantity = (props) => { const OrderType = useSelector(GlobalOrderType); const [BillOrderPre, setBillOrderPre] = useState(null); const SHORTKEY_TO_RADIO = { - price: 'Price', - quantity: 'qty', - Parcel: 'Parcel', - weightAmount: 'weightAmount' -}; -const [RadioBtnSelection, setRadioBtnSelection] = useState(() => { - if (props?.shortKeyMethod && SHORTKEY_TO_RADIO[props.shortKeyMethod]) { - return SHORTKEY_TO_RADIO[props.shortKeyMethod]; - } - if (ItemData?.ScaleType !== 'weight') { - return 'Quantity'; - } - if (PriceChangeaccess) { - return 'Price'; - } - return 'Parcel'; -}); + price: 'Price', + quantity: 'qty', + Parcel: 'Parcel', + weightAmount: 'weightAmount' + }; + const [RadioBtnSelection, setRadioBtnSelection] = useState(() => { + if (props?.shortKeyMethod && SHORTKEY_TO_RADIO[props.shortKeyMethod]) { + return SHORTKEY_TO_RADIO[props.shortKeyMethod]; + } + if (ItemData?.ScaleType !== 'weight') { + return 'Quantity'; + } + if (PriceChangeaccess) { + return 'Price'; + } + return 'Parcel'; + }); // const [RadioBtnSelection, setRadioBtnSelection] = useState( // props?.shortKeyMethod == 'price' // ? 'Price' @@ -334,6 +343,7 @@ const [RadioBtnSelection, setRadioBtnSelection] = useState(() => { }; const calculateOverAllQty = (item, filterItems) => { + if (!item) return 0; const totalUsedQty = @@ -435,6 +445,18 @@ const [RadioBtnSelection, setRadioBtnSelection] = useState(() => { (e) => e?.localId == localId ); const editedProduct = CartOrderDetails[editedProductIndex]; + + if ((overAllLimitPreferenece || itemWiseLimitPreferenece) && maxQtyLimit) { + if (overAllLimitPreferenece) { + const calculatedOverAllQty = calculateOverAllQtyLimit(CartOrderDetails?.filter((_, index) => index !== editedProductIndex)); + if ((calculatedOverAllQty + editedQty) > maxQtyLimit) { + setMessageData(`Overall Quantity Limit Exceeds than ${maxQtyLimit}`); + setMessageType('warning'); + return; + } + } + } + const productBookingType = editedProduct?.BookingTypeName; const isItemInCart = CartOrderDetails?.find( (cartItem) => @@ -728,7 +750,7 @@ const [RadioBtnSelection, setRadioBtnSelection] = useState(() => { 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 ); @@ -862,7 +884,7 @@ const [RadioBtnSelection, setRadioBtnSelection] = useState(() => { cartItem?.InwardDtlId === editedProduct?.InwardDtlId && cartItem?.OrderRate === editedProduct?.OrderRate && cartItem?.BookingTypeName !== - editedProduct?.BookingTypeName && + editedProduct?.BookingTypeName && !cartItem?.OfferMode && cartItem?.Offer === 0 ); @@ -876,7 +898,7 @@ const [RadioBtnSelection, setRadioBtnSelection] = useState(() => { cartItem?.InwardDtlId === editedProduct?.InwardDtlId && cartItem?.OrderRate === editedProduct?.OrderRate && cartItem?.BookingTypeName !== - editedProduct?.BookingTypeName && + editedProduct?.BookingTypeName && cartItem?.OfferMode === editedProduct?.OfferMode && cartItem?.Offer > 0 ); @@ -1009,7 +1031,7 @@ const [RadioBtnSelection, setRadioBtnSelection] = useState(() => { ) ) && product?.OfferId === - editedProduct?.OfferMessage?.[0]?.OfferId && + editedProduct?.OfferMessage?.[0]?.OfferId && product?.OfferMode === editedProduct?.OfferMode ) { const freeQty = @@ -1042,7 +1064,7 @@ const [RadioBtnSelection, setRadioBtnSelection] = useState(() => { // Also check main offer conditions const isMatchingOffer = offerProduct?.OfferId === - editedProduct?.OfferMessage?.[0]?.OfferId && + editedProduct?.OfferMessage?.[0]?.OfferId && offerProduct?.OfferMode === editedProduct?.OfferMode; if (hasMatchingFreeProduct && isMatchingOffer) { @@ -1125,7 +1147,7 @@ const [RadioBtnSelection, setRadioBtnSelection] = useState(() => { ) ) && product?.OfferId === - editedProduct?.OfferMessage?.[0]?.OfferId && + editedProduct?.OfferMessage?.[0]?.OfferId && product?.OfferMode === editedProduct?.OfferMode ) { return { @@ -1155,7 +1177,7 @@ const [RadioBtnSelection, setRadioBtnSelection] = useState(() => { // Also check main offer conditions const isMatchingOffer = offerProduct?.OfferId === - editedProduct?.OfferMessage?.[0]?.OfferId && + editedProduct?.OfferMessage?.[0]?.OfferId && offerProduct?.OfferMode === editedProduct?.OfferMode; if (hasMatchingFreeProduct && isMatchingOffer) { @@ -1342,7 +1364,7 @@ const [RadioBtnSelection, setRadioBtnSelection] = useState(() => { // Also check main offer conditions const isMatchingOffer = offerProduct?.OfferId === - editedProduct?.OfferMessage?.[0]?.OfferId && + editedProduct?.OfferMessage?.[0]?.OfferId && offerProduct?.OfferMode === editedProduct?.OfferMode; if (hasMatchingFreeProduct && isMatchingOffer) { @@ -1444,7 +1466,7 @@ const [RadioBtnSelection, setRadioBtnSelection] = useState(() => { // Also check main offer conditions const isMatchingOffer = offerProduct?.OfferId === - editedProduct?.OfferMessage?.[0]?.OfferId && + editedProduct?.OfferMessage?.[0]?.OfferId && offerProduct?.OfferMode === editedProduct?.OfferMode; if (hasMatchingFreeProduct && isMatchingOffer) { @@ -1598,7 +1620,7 @@ const [RadioBtnSelection, setRadioBtnSelection] = useState(() => { ) && cartItem?.Offer && isFreeProductApplicable?.OfferId === - cartItem?.OfferMessage?.[0]?.OfferId + cartItem?.OfferMessage?.[0]?.OfferId ); } ); @@ -1887,11 +1909,11 @@ const [RadioBtnSelection, setRadioBtnSelection] = useState(() => { 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, @@ -1925,11 +1947,11 @@ const [RadioBtnSelection, setRadioBtnSelection] = useState(() => { // 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 @@ -2070,7 +2092,7 @@ const [RadioBtnSelection, setRadioBtnSelection] = useState(() => { cartItem?.Offer > 0 && isFreeProductApplicable?.OfferMode === cartItem?.OfferMode && isFreeProductApplicable?.OfferId === - cartItem?.OfferMessage?.[0]?.OfferId + cartItem?.OfferMessage?.[0]?.OfferId ); } ); @@ -2173,11 +2195,11 @@ const [RadioBtnSelection, setRadioBtnSelection] = useState(() => { 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 ) { @@ -2248,12 +2270,12 @@ const [RadioBtnSelection, setRadioBtnSelection] = useState(() => { 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, @@ -2287,13 +2309,13 @@ const [RadioBtnSelection, setRadioBtnSelection] = useState(() => { // 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 @@ -2375,11 +2397,11 @@ const [RadioBtnSelection, setRadioBtnSelection] = useState(() => { 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 ) { @@ -2432,11 +2454,11 @@ const [RadioBtnSelection, setRadioBtnSelection] = useState(() => { 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 ) { @@ -2525,11 +2547,11 @@ const [RadioBtnSelection, setRadioBtnSelection] = useState(() => { 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 ) { @@ -2558,11 +2580,11 @@ const [RadioBtnSelection, setRadioBtnSelection] = useState(() => { 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 ) { @@ -2592,11 +2614,11 @@ const [RadioBtnSelection, setRadioBtnSelection] = useState(() => { 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 ) { @@ -2695,12 +2717,12 @@ const [RadioBtnSelection, setRadioBtnSelection] = useState(() => { 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, @@ -2734,12 +2756,12 @@ const [RadioBtnSelection, setRadioBtnSelection] = useState(() => { // 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 @@ -2818,11 +2840,11 @@ const [RadioBtnSelection, setRadioBtnSelection] = useState(() => { 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 ) { @@ -2881,11 +2903,11 @@ const [RadioBtnSelection, setRadioBtnSelection] = useState(() => { 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 ) { @@ -2957,12 +2979,12 @@ const [RadioBtnSelection, setRadioBtnSelection] = useState(() => { 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, @@ -2996,12 +3018,12 @@ const [RadioBtnSelection, setRadioBtnSelection] = useState(() => { // 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 @@ -3156,17 +3178,17 @@ const [RadioBtnSelection, setRadioBtnSelection] = useState(() => { 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 ) ) @@ -3202,10 +3224,10 @@ const [RadioBtnSelection, setRadioBtnSelection] = useState(() => { ((c?.OfferModeType && c?.OfferMode === 'B' ? true : c?.OfferMode !== 'B') && - c?.OfferMode !== 'P' && - c?.OfferMode !== 'C' && - c?.OfferMode !== 'O' && - c?.OfferMode !== 'L' + c?.OfferMode !== 'P' && + c?.OfferMode !== 'C' && + c?.OfferMode !== 'O' && + c?.OfferMode !== 'L' ? true : c?.Offer === 0); @@ -3397,8 +3419,8 @@ const [RadioBtnSelection, setRadioBtnSelection] = useState(() => { // parseFloat(enteredDiscount) < parseFloat(sellingPrice) || // parseFloat(enteredDiscount) === parseFloat(sellingPrice) // ) { - setEditedPrice(enteredDiscount); - setDisableSubmitButton(true); + setEditedPrice(enteredDiscount); + setDisableSubmitButton(true); // } else { // setMessageType('error'); // setMessageData('Please Give less than value for sell price'); @@ -3467,8 +3489,8 @@ const [RadioBtnSelection, setRadioBtnSelection] = useState(() => { setClearQuantity(false); }; const isKg = - props?.Productdata?.Size == 1 && - ["KG", "KGS"].includes(props?.Productdata?.UomName?.toUpperCase()); + props?.Productdata?.Size == 1 && + ["KG", "KGS"].includes(props?.Productdata?.UomName?.toUpperCase()); return (
@@ -3688,7 +3710,7 @@ const [RadioBtnSelection, setRadioBtnSelection] = useState(() => { ? `${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} /> )} @@ -3751,7 +3773,7 @@ const [RadioBtnSelection, setRadioBtnSelection] = useState(() => { ? `${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/ComboBillTableEdit/ComboEditQtyAndRate.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/ComboBillTableEdit/ComboEditQtyAndRate.jsx index 4d274fc..6f699c1 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/ComboBillTableEdit/ComboEditQtyAndRate.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/ComboBillTableEdit/ComboEditQtyAndRate.jsx @@ -30,6 +30,7 @@ import { import { validateOffers } from '../../BSItemCards/ValidateOffer.jsx'; import { v4 as uuidv4 } from 'uuid'; import './ComboBillTableEdit.scss'; +import { calculateOverAllQtyLimit } from '../../../../../utils/calculations.js'; const ComboEditQtyAndRate = (props) => { const dispatch = useDispatch(); @@ -37,9 +38,9 @@ const ComboEditQtyAndRate = (props) => { const quantityInputRef = useRef(null); const priceChangeInputRef = useRef(null); const { - setIndex = () => {}, - setEditQtyCombo = () => {}, - setEditRateCombo = () => {}, + setIndex = () => { }, + setEditQtyCombo = () => { }, + setEditRateCombo = () => { }, } = props; const [disableSubmitButton, setDisableSubmitButton] = useState(false); @@ -51,10 +52,19 @@ const ComboEditQtyAndRate = (props) => { const applyOffer = useApplyOfferto_CardDetail(); const preferenceDatas = useSelector(PreferenceData); const EmpAccessDetail = useSelector(GlobalEmpAccessDetail); + const overAllLimitPreferenece = + preferenceDatas?.[0]?.['SettingDtlDetails']?.find( + (item) => (item.SettingIdName?.toLowerCase() === 'overalllimit') && item?.SettingValue === 'Y'); + const itemWiseLimitPreferenece = + preferenceDatas?.[0]?.['SettingDtlDetails']?.find( + (item) => item.SettingIdName?.toLowerCase() === 'itemwiselimit' && item?.SettingValue === 'Y'); + const maxQtyLimit = itemWiseLimitPreferenece?.SettingCount || overAllLimitPreferenece?.SettingCount || null; + const OverAllproductBasedOfferDatas = useSelector( (state) => state?.BookingOFferNew?.OverAllProductBasedProducts, shallowEqual ); + console.log(overAllLimitPreferenece, "itemWiseLimitPreferenece") const preferenceOffer = preferenceDatas?.[0]?.['SettingDtlDetails']?.find( (item) => item.SettingIdName === 'Offer' @@ -251,7 +261,16 @@ const ComboEditQtyAndRate = (props) => { item?.SinglePc === 'Y' ? item?.OverAllPcs : item?.BalanceQty; return availableQty - totalUsedQty; }; + + const quantityValidation = async (val) => { + + setQuantity(val) + + } const AddProductQuantity = async () => { + // debugger + + let newPrice = editedPrice > 0 ? editedPrice : props.Productdata.OrderRate; await dispatch(changeHoldOrderDtl(false)); await dispatch(changePreviousOrderLength(CartOrderDetails?.length)); @@ -312,6 +331,20 @@ const ComboEditQtyAndRate = (props) => { let editedProductIndex = CartOrderDetails?.findIndex( (e) => e?.localId == localId ); + if ((overAllLimitPreferenece || itemWiseLimitPreferenece) && maxQtyLimit) { + if (overAllLimitPreferenece) { + let removeProds1 = CartOrderDetails?.find((_, index) => index == editedProductIndex) + let removeProds = CartOrderDetails?.filter((_, index) => index !== editedProductIndex) + + const calculatedOverAllQty = calculateOverAllQtyLimit(removeProds); + if ((calculatedOverAllQty + editedQty) > maxQtyLimit) { + setMessageData(`Overall Quantity Limit Exceeds than ${maxQtyLimit}`); + setMessageType('warning'); + setQuantity(removeProds1?.OrderQty || 1) + return; + } + } + } const editedProduct = CartOrderDetails[editedProductIndex]; const productBookingType = editedProduct?.BookingTypeName; const isItemInCart = CartOrderDetails?.find( @@ -591,7 +624,7 @@ const ComboEditQtyAndRate = (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 ); @@ -725,7 +758,7 @@ const ComboEditQtyAndRate = (props) => { cartItem?.InwardDtlId === editedProduct?.InwardDtlId && cartItem?.OrderRate === editedProduct?.OrderRate && cartItem?.BookingTypeName !== - editedProduct?.BookingTypeName && + editedProduct?.BookingTypeName && !cartItem?.OfferMode && cartItem?.Offer === 0 ); @@ -739,7 +772,7 @@ const ComboEditQtyAndRate = (props) => { cartItem?.InwardDtlId === editedProduct?.InwardDtlId && cartItem?.OrderRate === editedProduct?.OrderRate && cartItem?.BookingTypeName !== - editedProduct?.BookingTypeName && + editedProduct?.BookingTypeName && cartItem?.OfferMode === editedProduct?.OfferMode && cartItem?.Offer > 0 ); @@ -872,7 +905,7 @@ const ComboEditQtyAndRate = (props) => { ) ) && product?.OfferId === - editedProduct?.OfferMessage?.[0]?.OfferId && + editedProduct?.OfferMessage?.[0]?.OfferId && product?.OfferMode === editedProduct?.OfferMode ) { const freeQty = @@ -905,7 +938,7 @@ const ComboEditQtyAndRate = (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) { @@ -984,7 +1017,7 @@ const ComboEditQtyAndRate = (props) => { ) ) && product?.OfferId === - editedProduct?.OfferMessage?.[0]?.OfferId && + editedProduct?.OfferMessage?.[0]?.OfferId && product?.OfferMode === editedProduct?.OfferMode ) { return { @@ -1014,7 +1047,7 @@ const ComboEditQtyAndRate = (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) { @@ -1201,7 +1234,7 @@ const ComboEditQtyAndRate = (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) { @@ -1303,7 +1336,7 @@ const ComboEditQtyAndRate = (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) { @@ -1457,7 +1490,7 @@ const ComboEditQtyAndRate = (props) => { ) && cartItem?.Offer && isFreeProductApplicable?.OfferId === - cartItem?.OfferMessage?.[0]?.OfferId + cartItem?.OfferMessage?.[0]?.OfferId ); } ); @@ -1746,11 +1779,11 @@ const ComboEditQtyAndRate = (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, @@ -1784,11 +1817,11 @@ const ComboEditQtyAndRate = (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 @@ -1929,7 +1962,7 @@ const ComboEditQtyAndRate = (props) => { cartItem?.Offer > 0 && isFreeProductApplicable?.OfferMode === cartItem?.OfferMode && isFreeProductApplicable?.OfferId === - cartItem?.OfferMessage?.[0]?.OfferId + cartItem?.OfferMessage?.[0]?.OfferId ); } ); @@ -2032,11 +2065,11 @@ const ComboEditQtyAndRate = (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 ) { @@ -2107,12 +2140,12 @@ const ComboEditQtyAndRate = (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, @@ -2146,13 +2179,13 @@ const ComboEditQtyAndRate = (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 @@ -2234,11 +2267,11 @@ const ComboEditQtyAndRate = (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 ) { @@ -2291,11 +2324,11 @@ const ComboEditQtyAndRate = (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 ) { @@ -2384,11 +2417,11 @@ const ComboEditQtyAndRate = (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 ) { @@ -2417,11 +2450,11 @@ const ComboEditQtyAndRate = (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 ) { @@ -2451,11 +2484,11 @@ const ComboEditQtyAndRate = (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 ) { @@ -2554,12 +2587,12 @@ const ComboEditQtyAndRate = (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, @@ -2593,12 +2626,12 @@ const ComboEditQtyAndRate = (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 @@ -2677,11 +2710,11 @@ const ComboEditQtyAndRate = (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 ) { @@ -2740,11 +2773,11 @@ const ComboEditQtyAndRate = (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 ) { @@ -2816,12 +2849,12 @@ const ComboEditQtyAndRate = (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, @@ -2855,12 +2888,12 @@ const ComboEditQtyAndRate = (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 @@ -3014,17 +3047,17 @@ const ComboEditQtyAndRate = (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 ) ) @@ -3060,10 +3093,10 @@ const ComboEditQtyAndRate = (props) => { ((c?.OfferModeType && c?.OfferMode === 'B' ? true : c?.OfferMode !== 'B') && - c?.OfferMode !== 'P' && - c?.OfferMode !== 'C' && - c?.OfferMode !== 'O' && - c?.OfferMode !== 'L' + c?.OfferMode !== 'P' && + c?.OfferMode !== 'C' && + c?.OfferMode !== 'O' && + c?.OfferMode !== 'L' ? true : c?.Offer === 0); @@ -3227,7 +3260,7 @@ const ComboEditQtyAndRate = (props) => { type="number" value={Quantity} min="0" - onChange={(e) => setQuantity(e.target.value)} + onChange={(e) => quantityValidation(e.target.value)} onBlur={() => { if (Quantity && Quantity.trim() !== '') { AddProductQuantity(); diff --git a/src/Pages/BookingScreen/Components/BSItemCards/BSItemCard.jsx b/src/Pages/BookingScreen/Components/BSItemCards/BSItemCard.jsx index b120a6c..7740cbe 100644 --- a/src/Pages/BookingScreen/Components/BSItemCards/BSItemCard.jsx +++ b/src/Pages/BookingScreen/Components/BSItemCards/BSItemCard.jsx @@ -123,6 +123,7 @@ import { MdOutlineAddShoppingCart } from 'react-icons/md'; import { bulkpostdata } from '../../../../Features/ProductPage/ProductPage.js'; import ProductPriceChange from '../UtillComponents/ProductPriceChange.jsx'; import ExpireConfirmModal from '../BookingFunctionality/ExpireConfirmModal.jsx'; +import { calculateOverAllQtyLimit } from '../../../../utils/calculations.js'; export function SortableCard({ id, children, item }) { const { @@ -164,6 +165,13 @@ const BSItemCard = (props) => { // const applyOffer = useApplyOfferto_CardDetail(); const preferenceDatas = useSelector(PreferenceData, shallowEqual); const { selectedDate } = useDateStore(); + const overAllLimitPreferenece = + preferenceDatas?.[0]?.['SettingDtlDetails']?.find( + (item) => (item.SettingIdName?.toLowerCase() === 'overalllimit') && item?.SettingValue === 'Y'); + const itemWiseLimitPreferenece = + preferenceDatas?.[0]?.['SettingDtlDetails']?.find( + (item) => item.SettingIdName?.toLowerCase() === 'itemwiselimit' && item?.SettingValue === 'Y'); + const maxQtyLimit = itemWiseLimitPreferenece?.SettingCount || overAllLimitPreferenece?.SettingCount || null; const preferenceOffer = preferenceDatas?.[0]?.['SettingDtlDetails']?.find( (item) => item.SettingIdName === 'Offer' @@ -180,7 +188,6 @@ const BSItemCard = (props) => { // GlobalAddCustomerDetails, // shallowEqual // ); - const offerAppliedProducts = useSelector( GlobalOfferAppliedProducts, shallowEqual @@ -618,7 +625,7 @@ const BSItemCard = (props) => { WithoutTaxRate: availableFreeQty * item.OrderRate - (availableFreeQty * item.OrderRate * item.TaxPercentage) / - 100, + 100, Offer: availableFreeQty * item.OrderRate, }; @@ -667,7 +674,7 @@ const BSItemCard = (props) => { ((existingPaidItem.OrderQty + excessQty) * item.OrderRate * item.TaxPercentage) / - 100, + 100, }; ModifiedData.push(mergedPaidItem); @@ -702,7 +709,7 @@ const BSItemCard = (props) => { data?.InwardDtlId === item?.InwardDtlId && data?.ProdId === item?.ProdId && data?.OfferMessage?.[0]?.OfferId === - item?.OfferMessage?.[0]?.OfferId + item?.OfferMessage?.[0]?.OfferId ); if (isAlreadyExists !== -1) { @@ -722,11 +729,11 @@ const BSItemCard = (props) => { ).toFixed(2), WithoutTaxRate: (ModifiedData[isAlreadyExists].OrderQty + item.OrderQty) * - item.OrderRate - + item.OrderRate - ((ModifiedData[isAlreadyExists].OrderQty + item.OrderQty) * item.OrderRate * item.TaxPercentage) / - 100, + 100, Offer: (ModifiedData[isAlreadyExists].OrderQty + item.OrderQty) * item.OrderRate, @@ -752,10 +759,10 @@ const BSItemCard = (props) => { const appliedOfferAlreadyExists = AppliedOffers.findIndex( (offer) => offer?.FreeProductsList?.FreeProdId === - matchingFreeProduct?.FreeProdId && + matchingFreeProduct?.FreeProdId && offer?.TableName === matchingFreeProduct?.TableName && offer?.TableUniqueName === - matchingFreeProduct?.TableUniqueName && + matchingFreeProduct?.TableUniqueName && offer?.OfferId === matchingFreeProduct?.OfferId && offer?.OfferMode === matchingFreeProduct?.OfferMode && offer?.FreeProductsList?.ProdVariantDetails?.[0] @@ -1001,7 +1008,7 @@ const BSItemCard = (props) => { ? [] : SelectedDatas : ItemCard?.length == 0 || - (ItemCard?.[0]?.AppId === 0 && ItemCard?.[0]?.CompId === 0) + (ItemCard?.[0]?.AppId === 0 && ItemCard?.[0]?.CompId === 0) ? noSubcatCardData : ItemCard : ''; @@ -1106,14 +1113,14 @@ const BSItemCard = (props) => { ProdSubCat: ProdSubCat, ...(AvailableDate && selectedDate ? { - date: Array.isArray(selectedDate) - ? selectedDate - .map((d) => (d?.format ? d.format('YYYY-MM-DD') : d)) - .join(',') - : selectedDate?.format - ? selectedDate.format('YYYY-MM-DD') - : selectedDate, - } + date: Array.isArray(selectedDate) + ? selectedDate + .map((d) => (d?.format ? d.format('YYYY-MM-DD') : d)) + .join(',') + : selectedDate?.format + ? selectedDate.format('YYYY-MM-DD') + : selectedDate, + } : {}), }; //mohan @@ -1160,14 +1167,14 @@ const BSItemCard = (props) => { prodCat: ProdCat, ...(AvailableDate && selectedDate ? { - date: Array.isArray(selectedDate) - ? selectedDate - .map((d) => (d?.format ? d.format('YYYY-MM-DD') : d)) - .join(',') - : selectedDate?.format - ? selectedDate.format('YYYY-MM-DD') - : selectedDate, - } + date: Array.isArray(selectedDate) + ? selectedDate + .map((d) => (d?.format ? d.format('YYYY-MM-DD') : d)) + .join(',') + : selectedDate?.format + ? selectedDate.format('YYYY-MM-DD') + : selectedDate, + } : {}), }; @@ -1372,13 +1379,13 @@ const BSItemCard = (props) => { (cartItem) => cartItem?.ProdId === item?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && cartItem?.OrderRate === - item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - VarientIndex - ]?.StockDetails?.[0]?.SellPrice && + item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + VarientIndex + ]?.StockDetails?.[0]?.SellPrice && !cartItem?.SalesId ); @@ -1387,9 +1394,9 @@ const BSItemCard = (props) => { (cartItem) => cartItem?.ProdId === item?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) !cartItem?.SalesId ); @@ -1431,11 +1438,11 @@ const BSItemCard = (props) => { (cartItem) => cartItem?.ProdId === item?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[0]?.InwardDtlId && + item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] + ?.StockDetails?.[0]?.InwardDtlId && cartItem?.OrderRate === - item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[0]?.SellPrice && + item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] + ?.StockDetails?.[0]?.SellPrice && !cartItem?.SalesId ); @@ -1444,9 +1451,9 @@ const BSItemCard = (props) => { (cartItem) => cartItem?.ProdId === item?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) !cartItem?.SalesId ); @@ -1527,13 +1534,13 @@ const BSItemCard = (props) => { (cartItem) => cartItem?.ProdId === qtydata?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - index.key - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + index.key + ]?.StockDetails?.[0]?.InwardDtlId && cartItem?.OrderRate === - qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - index.key - ]?.StockDetails?.[0]?.SellPrice && + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + index.key + ]?.StockDetails?.[0]?.SellPrice && !cartItem?.SalesId ); @@ -1541,11 +1548,11 @@ const BSItemCard = (props) => { let Isincartonepc = CartOrderDetails?.filter( (cartItem) => cartItem?.ProdId === - qtydata?.ProductDetail?.[QtyIndex]?.ProdId && + qtydata?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - index.key - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + index.key + ]?.StockDetails?.[0]?.InwardDtlId && // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) !cartItem?.SalesId ); @@ -1613,13 +1620,13 @@ const BSItemCard = (props) => { (cartItem) => cartItem?.ProdId === qtydata?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - index.key - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + index.key + ]?.StockDetails?.[0]?.InwardDtlId && cartItem?.OrderRate === - qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - index.key - ]?.StockDetails?.[0]?.SellPrice && + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + index.key + ]?.StockDetails?.[0]?.SellPrice && !cartItem?.SalesId ); @@ -1628,9 +1635,9 @@ const BSItemCard = (props) => { (cartItem) => cartItem?.ProdId === qtydata?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - index.key - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + index.key + ]?.StockDetails?.[0]?.InwardDtlId && // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) !cartItem?.SalesId ); @@ -1798,15 +1805,15 @@ const BSItemCard = (props) => { let Isincart = CartOrderDetails?.find( (cartItem) => cartItem?.ProdId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && cartItem?.OrderRate === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.SellPrice && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.SellPrice && !cartItem?.SalesId ); @@ -1814,11 +1821,11 @@ const BSItemCard = (props) => { let Isincartonepc = CartOrderDetails?.filter( (cartItem) => cartItem?.ProdId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) !cartItem?.SalesId ); @@ -1897,15 +1904,15 @@ const BSItemCard = (props) => { let Isincart = CartOrderDetails?.find( (cartItem) => cartItem?.ProdId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && cartItem?.OrderRate === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.SellPrice && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.SellPrice && !cartItem?.SalesId ); @@ -1913,11 +1920,11 @@ const BSItemCard = (props) => { let Isincartonepc = CartOrderDetails?.filter( (cartItem) => cartItem?.ProdId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) !cartItem?.SalesId ); @@ -2073,6 +2080,18 @@ const BSItemCard = (props) => { }; const AddOrderDetails = async (item) => { + + if ((overAllLimitPreferenece || itemWiseLimitPreferenece) && maxQtyLimit) { + if (overAllLimitPreferenece) { + const calculatedOverAllQty = calculateOverAllQtyLimit(CartOrderDetails); + if ((calculatedOverAllQty + 1) > maxQtyLimit) { + setMessageData(`Overall Quantity Limit Exceeds than ${maxQtyLimit}`); + setMessageType('warning'); + return; + } + } + } + if (preOrder) { await handlePreOrder(item); } else { @@ -2165,15 +2184,15 @@ const BSItemCard = (props) => { const isExistsInFreeProdList = hasOffer ? FreeProdList?.filter( - (f) => - f?.FreeProdId === item?.ProdId && - f?.ProdVariantDetails?.some((variant) => - variant?.StockDetails?.some( - (stock) => stock?.FreeInwardDtlId === item?.InwardDtlId - ) - ) && - f?.RemainingQty > 0 - ) + (f) => + f?.FreeProdId === item?.ProdId && + f?.ProdVariantDetails?.some((variant) => + variant?.StockDetails?.some( + (stock) => stock?.FreeInwardDtlId === item?.InwardDtlId + ) + ) && + f?.RemainingQty > 0 + ) : []; const calculateTaxAmounts = (qty, rate, taxPercentage) => { @@ -2240,10 +2259,10 @@ const BSItemCard = (props) => { ((cartItem?.OfferModeType && cartItem?.OfferMode === 'B' ? true : cartItem?.OfferMode !== 'B') && - cartItem?.OfferMode !== 'P' && - cartItem?.OfferMode !== 'C' && - cartItem?.OfferMode !== 'O' && - cartItem?.OfferMode !== 'L' + cartItem?.OfferMode !== 'P' && + cartItem?.OfferMode !== 'C' && + cartItem?.OfferMode !== 'O' && + cartItem?.OfferMode !== 'L' ? true : cartItem?.Offer === 0) ); @@ -2254,10 +2273,10 @@ const BSItemCard = (props) => { ((cartItem?.OfferModeType && cartItem?.OfferMode === 'B' ? true : cartItem?.OfferMode !== 'B') && - cartItem?.OfferMode !== 'P' && - cartItem?.OfferMode !== 'C' && - cartItem?.OfferMode !== 'O' && - cartItem?.OfferMode !== 'L' + cartItem?.OfferMode !== 'P' && + cartItem?.OfferMode !== 'C' && + cartItem?.OfferMode !== 'O' && + cartItem?.OfferMode !== 'L' ? true : cartItem?.Offer === 0) ); @@ -2271,10 +2290,10 @@ const BSItemCard = (props) => { ((cartItem?.OfferModeType && cartItem?.OfferMode === 'B' ? true : cartItem?.OfferMode !== 'B') && - cartItem?.OfferMode !== 'P' && - cartItem?.OfferMode !== 'C' && - cartItem?.OfferMode !== 'O' && - cartItem?.OfferMode !== 'L' + cartItem?.OfferMode !== 'P' && + cartItem?.OfferMode !== 'C' && + cartItem?.OfferMode !== 'O' && + cartItem?.OfferMode !== 'L' ? true : cartItem?.Offer === 0) ) @@ -2287,10 +2306,10 @@ const BSItemCard = (props) => { ((cartItem?.OfferModeType && cartItem?.OfferMode === 'B' ? true : cartItem?.OfferMode !== 'B') && - cartItem?.OfferMode !== 'P' && - cartItem?.OfferMode !== 'C' && - cartItem?.OfferMode !== 'O' && - cartItem?.OfferMode !== 'L' + cartItem?.OfferMode !== 'P' && + cartItem?.OfferMode !== 'C' && + cartItem?.OfferMode !== 'O' && + cartItem?.OfferMode !== 'L' ? true : cartItem?.Offer === 0) ) @@ -2311,8 +2330,8 @@ const BSItemCard = (props) => { isItemInCart, item?.OtherProduct === 'Others' || item?.ScaleType === 'weight' ? ( - (item?.OrderQty || 0) + parseFloat(isItemInCart?.OrderQty) - )?.toFixed(3) + (item?.OrderQty || 0) + parseFloat(isItemInCart?.OrderQty) + )?.toFixed(3) : null ); const updatedData = addFirst @@ -2338,8 +2357,8 @@ const BSItemCard = (props) => { isItemInCartHold, item?.OtherProduct === 'Others' || item?.ScaleType === 'weight' ? ( - (item?.OrderQty || 0) + parseFloat(isItemInCartHold?.OrderQty) - )?.toFixed(3) + (item?.OrderQty || 0) + parseFloat(isItemInCartHold?.OrderQty) + )?.toFixed(3) : null ); const updatedData = addFirst @@ -2566,14 +2585,14 @@ const BSItemCard = (props) => { updatedCartData = cartData.map((item, idx) => idx === indexToCheck ? { - ...item, - Offer: null, - OfferMessage: undefined, - OfferMode: undefined, - OfferModeType: false, - OfferType: undefined, - OfferValue: null, - } + ...item, + Offer: null, + OfferMessage: undefined, + OfferMode: undefined, + OfferModeType: false, + OfferType: undefined, + OfferValue: null, + } : item ); } @@ -2624,8 +2643,8 @@ const BSItemCard = (props) => { ...item, Offer: sameProduct || - bestOffer?.OfferMode === 'I' || - bestOffer?.OfferMode === 'Q' + bestOffer?.OfferMode === 'I' || + bestOffer?.OfferMode === 'Q' ? bestOffer?.OfferAmount || item.Offer : item.Offer || bestOffer?.OfferAmount, OfferType: item?.OfferType || bestOffer?.OfferType, @@ -2642,10 +2661,10 @@ const BSItemCard = (props) => { ((c?.OfferModeType && c?.OfferMode === 'B' ? true : c?.OfferMode !== 'B') && - c?.OfferMode !== 'P' && - c?.OfferMode !== 'C' && - c?.OfferMode !== 'O' && - c?.OfferMode !== 'L' + c?.OfferMode !== 'P' && + c?.OfferMode !== 'C' && + c?.OfferMode !== 'O' && + c?.OfferMode !== 'L' ? true : c?.Offer === 0); @@ -3032,10 +3051,10 @@ const BSItemCard = (props) => { return FreeProdList.map((f, i) => i === index ? { - ...existing, - ...newFreeProd, - ProdVariantDetails: existing.ProdVariantDetails, - } + ...existing, + ...newFreeProd, + ProdVariantDetails: existing.ProdVariantDetails, + } : f ); } else { @@ -3105,7 +3124,7 @@ const BSItemCard = (props) => { const cycleSize = buyQty + getQty; const fullCycles = Math.floor( freeCartItem?.reduce((acc, fc) => acc + (fc?.OrderQty || 0), 0) / - cycleSize + cycleSize ); const totalFreeQty = fullCycles * getQty; @@ -3663,7 +3682,7 @@ const BSItemCard = (props) => { parseInt(totalSelectedProductQty || 0) + parseInt(reorderComboConsumed || 0); } - } catch (_) {} + } catch (_) { } let getCurrentProdDtl = orderDetails?.filter( (a) => a?.ProdName === ProdName ); @@ -3864,7 +3883,7 @@ const BSItemCard = (props) => { parseInt(totalSelectedProductQty || 0) + parseInt(reorderComboConsumed || 0); } - } catch (_) {} + } catch (_) { } let getCurrentProdDtl = orderDetails?.filter((a) => a?.ProdId === ProdId); let totalOrderQty = getCurrentProdDtl?.reduce((accumulator, card) => { return ( @@ -3900,7 +3919,7 @@ const BSItemCard = (props) => { }, 0); totalOrderQty = parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0); - } catch (_) {} + } catch (_) { } let OverallProdQty = totalOrderQty - totalSelectedProductQty; if ( parseInt(ItemQuantity) > @@ -3986,7 +4005,7 @@ const BSItemCard = (props) => { parseInt(totalSelectedProductQty || 0) + parseInt(reorderComboConsumed || 0); } - } catch (_) {} + } catch (_) { } let getCurrentProdDtl = orderDetails?.filter((a) => a?.ProdId === ProdId); let totalOrderQty = getCurrentProdDtl?.reduce((accumulator, card) => { return ( @@ -4025,7 +4044,7 @@ const BSItemCard = (props) => { }, 0); totalOrderQty = parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0); - } catch (_) {} + } catch (_) { } let OverallProdQty = totalOrderQty - totalSelectedProductQty; if ( parseInt(ItemQuantity) > @@ -4117,7 +4136,7 @@ const BSItemCard = (props) => { parseInt(totalSelectedProductQty || 0) + parseInt(reorderComboConsumed || 0); } - } catch (_) {} + } catch (_) { } let getCurrentProdDtl = orderDetails?.filter( (a) => a?.ProdId === ProdId && a?.InwardDtlId === InwardDtlId ); @@ -4160,7 +4179,7 @@ const BSItemCard = (props) => { }, 0); totalOrderQty = parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0); - } catch (_) {} + } catch (_) { } let OverallProdQty = totalOrderQty - totalSelectedProductQty; if ( @@ -4244,7 +4263,7 @@ const BSItemCard = (props) => { parseInt(totalSelectedProductQty || 0) + parseInt(reorderComboConsumed || 0); } - } catch (_) {} + } catch (_) { } let getCurrentProdDtl = orderDetails?.filter( (a) => a?.ProdId === ProdId && a?.InwardDtlId === InwardDtlId ); @@ -4291,7 +4310,7 @@ const BSItemCard = (props) => { }, 0); totalOrderQty = parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0); - } catch (_) {} + } catch (_) { } let OverallProdQty = totalOrderQty - totalSelectedProductQty; if ( @@ -4469,7 +4488,7 @@ const BSItemCard = (props) => { 0 || - record.StockCount === 'Stock Not Maintained' + record.StockCount === 'Stock Not Maintained' ? { color: '#000', cursor: 'pointer' } : { color: '#f49898', cursor: 'not-allowed' } } @@ -4499,7 +4518,7 @@ const BSItemCard = (props) => { 0 || - record.StockCount === 'Stock Not Maintained' + record.StockCount === 'Stock Not Maintained' ? { color: '#000', cursor: 'pointer' } : { color: '#f49898', cursor: 'not-allowed' } } @@ -4529,7 +4548,7 @@ const BSItemCard = (props) => { 0 || - record.StockCount === 'Stock Not Maintained' + record.StockCount === 'Stock Not Maintained' ? { color: '#000', cursor: 'pointer' } : { color: '#f49898', cursor: 'not-allowed' } } @@ -4704,17 +4723,17 @@ const BSItemCard = (props) => { qtydata?.ProductDetail?.[QtyIndex]?.StockAvailable === 'Y' ? onePeiceFlow ? returnVariantStock( - qtydata?.ProductDetail?.[QtyIndex]?.ProdId, - item?.OverAllPcs, - CartOrderDetails, - item?.ProdVariantName - ) + qtydata?.ProductDetail?.[QtyIndex]?.ProdId, + item?.OverAllPcs, + CartOrderDetails, + item?.ProdVariantName + ) : returnVariantStock( - qtydata?.ProductDetail?.[QtyIndex]?.ProdId, - item?.OverAllQty, - CartOrderDetails, - item?.ProdVariantName - ) + qtydata?.ProductDetail?.[QtyIndex]?.ProdId, + item?.OverAllQty, + CartOrderDetails, + item?.ProdVariantName + ) : 'Stock Not Maintained', VariantAvailableFrom: item?.AvailableFrom, VariantAvailableTo: item?.AvailableTo, @@ -4736,20 +4755,20 @@ const BSItemCard = (props) => { 'Batch No': item?.BatchRef, StockCount: onePeiceFlow ? returnCountStock( - item?.ProdId, - item?.OverAllPcs, - CartOrderDetails, - item?.InwardDtlId, - 'Y' - ) + item?.ProdId, + item?.OverAllPcs, + CartOrderDetails, + item?.InwardDtlId, + 'Y' + ) : returnCountStock( - item?.ProdId, - item?.BalanceQty, - CartOrderDetails, - item?.InwardDtlId, - 'N', - item?.OverAllPcs - ), + item?.ProdId, + item?.BalanceQty, + CartOrderDetails, + item?.InwardDtlId, + 'N', + item?.OverAllPcs + ), 'Stock Date': ExtractDateFormate(item?.InwardDate), Price: onePeiceFlow ? item?.OnePcsPrice : item?.SellPrice, ExpDate: @@ -5899,9 +5918,9 @@ const BSItemCard = (props) => { allProducts.forEach((product) => { const brandName = product.BrandName && - product.BrandName !== 'null' && - product.BrandName !== 'undefined' && - product.BrandName.trim() !== '' + product.BrandName !== 'null' && + product.BrandName !== 'undefined' && + product.BrandName.trim() !== '' ? product.BrandName : 'Others'; @@ -5935,13 +5954,13 @@ const BSItemCard = (props) => { const result = prodname ? (cardData || [])?.filter( - (item) => - normalize(item.ProdName).includes(normalize(prodname)) || - normalize(item.ProdCatName).includes(normalize(prodname)) || - item.ProductDetail?.some((detail) => - normalize(detail.ProdName).includes(normalize(prodname)) - ) - ) + (item) => + normalize(item.ProdName).includes(normalize(prodname)) || + normalize(item.ProdCatName).includes(normalize(prodname)) || + item.ProductDetail?.some((detail) => + normalize(detail.ProdName).includes(normalize(prodname)) + ) + ) : cardData; console.log(prodQty, 'cardDatacardData', result, prodname); @@ -5961,8 +5980,8 @@ const BSItemCard = (props) => { CardOnclick( result?.[0], result?.[0]?.OnePcsAvailable === 'Y' && - preferenceSingleSales && - 'OnePeiceProduct' + preferenceSingleSales && + 'OnePeiceProduct' ); // AddOrderDetails2(result?.[0]) } else if (item?.OverAllQty < prodQty) { @@ -6021,8 +6040,8 @@ const BSItemCard = (props) => { zIndex: '12', top: templateData?.BookingLayout?.[0] === 'Layout5' || - templateData?.BookingLayout?.[0] === 'Layout4' || - templateData?.BookingLayout?.[0] === 'Layout6' + templateData?.BookingLayout?.[0] === 'Layout4' || + templateData?.BookingLayout?.[0] === 'Layout6' ? '2.5rem' : '', }} @@ -6102,21 +6121,21 @@ const BSItemCard = (props) => { }} className={ (item?.OverAllQty !== undefined && - !preferenceSingleSales + !preferenceSingleSales ? returnCount( - item?.ProductDetail?.[0]?.ProdName, - item?.OverAllQty, - CartOrderDetails, - item?.OverAllPcs - ) + item?.ProductDetail?.[0]?.ProdName, + item?.OverAllQty, + CartOrderDetails, + item?.OverAllPcs + ) : returnOnepcCount( - item?.ProductDetail?.[0]?.ProdName, - item?.OverAllPcs, - CartOrderDetails - ) > 0) || - item?.ProductDetail?.some( - (item) => item?.StockAvailable !== 'Y' - ) + item?.ProductDetail?.[0]?.ProdName, + item?.OverAllPcs, + CartOrderDetails + ) > 0) || + item?.ProductDetail?.some( + (item) => item?.StockAvailable !== 'Y' + ) ? 'BkPrdCardActive' : 'BkPrdCardDeActive' } @@ -6154,39 +6173,39 @@ const BSItemCard = (props) => { cardFunction?.Background && (SelectedCardColor ? SelectedCardColor?.[ - 'BackgroundColor' - ] + 'BackgroundColor' + ] : ''), padding: !cardFunction?.ImageUp && - !cardFunction?.ImageDown + !cardFunction?.ImageDown ? cardFunction?.SmallImage && - '5px 9px' + '5px 9px' : '8px 2px', flexDirection: cardFunction?.ImageRight && - 'row-reverse' + 'row-reverse' ? cardFunction?.ImageRight && - 'row-reverse' + 'row-reverse' : cardFunction?.ImageUp && 'column' ? cardFunction?.ImageUp && - 'column' + 'column' : cardFunction?.ImageDown && - 'column-reverse' + 'column-reverse' ? cardFunction?.ImageDown && - 'column-reverse' + 'column-reverse' : cardFunction?.ImageLeft && - 'row', + 'row', borderRadius: cardFunction?.EdgeCurve && '6px', width: !cardFunction?.ImageUp && - !cardFunction?.ImageDown && - !cardFunction?.BigImage && - !cardFunction?.ImageRight && - cardFunction?.SmallImage && - (cardFunction?.ImageUp || - cardFunction?.ImageDown) + !cardFunction?.ImageDown && + !cardFunction?.BigImage && + !cardFunction?.ImageRight && + cardFunction?.SmallImage && + (cardFunction?.ImageUp || + cardFunction?.ImageDown) ? '6rem' : cardFunction?.BigImage && '9rem', height: @@ -6219,19 +6238,19 @@ const BSItemCard = (props) => { if ( !( (item?.OverAllQty !== undefined && - !preferenceSingleSales + !preferenceSingleSales ? returnCount( - item?.ProductDetail?.[0] - ?.ProdName, - item?.OverAllQty, - CartOrderDetails - ) + item?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllQty, + CartOrderDetails + ) : returnOnepcCount( - item?.ProductDetail?.[0] - ?.ProdName, - item?.OverAllPcs, - CartOrderDetails - ) > 0) || + item?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllPcs, + CartOrderDetails + ) > 0) || item?.ProductDetail?.some( (item) => item?.StockAvailable !== 'Y' @@ -6243,8 +6262,8 @@ const BSItemCard = (props) => { CardOnclick( item, item?.OnePcsAvailable === 'Y' && - preferenceSingleSales && - 'OnePeiceProduct' + preferenceSingleSales && + 'OnePeiceProduct' ); } }} @@ -6253,39 +6272,39 @@ const BSItemCard = (props) => { > {(cardFunction?.BigImage || cardFunction?.SmallImage) && ( - - )} + : defaultimage + } + alt="" + /> + )}
{ cardFunction?.Background && (SelectedCardColor ? SelectedCardColor?.[ - 'BackgroundColor' - ] + 'BackgroundColor' + ] : ''), position: !cardFunction?.BigImage @@ -6319,7 +6338,7 @@ const BSItemCard = (props) => { height: cardFunction?.SmallImage ? '5.5rem' : !cardFunction?.BigImage && - '5.5rem', + '5.5rem', alignItems: !cardFunction?.BigImage && !cardFunction?.SmallImage && @@ -6342,11 +6361,11 @@ const BSItemCard = (props) => { 'uppercase', width: !cardFunction?.SmallImage ? cardFunction?.BigImage && - '120px' + '120px' : cardFunction?.SmallImage && - !cardFunction?.ImageUp && - !cardFunction?.ImageDown && - '85px', + !cardFunction?.ImageUp && + !cardFunction?.ImageDown && + '85px', // Width: cardFunction?.BigImage && "70px", fontSize: !cardFunction?.BigImage && @@ -6368,24 +6387,24 @@ const BSItemCard = (props) => { > {item?.ProdName}{' '} {(item?.OverAllQty !== undefined && - !preferenceSingleSales + !preferenceSingleSales ? returnCount( - item?.ProductDetail?.[0] - ?.ProdName, - item?.OverAllQty, - CartOrderDetails, - item - ) + item?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllQty, + CartOrderDetails, + item + ) : returnOnepcCount( - item?.ProductDetail?.[0] - ?.ProdName, - item?.OverAllPcs, - CartOrderDetails - ) > 0) || - item?.ProductDetail?.some( - (item) => - item?.StockAvailable !== 'Y' - ) ? ( + item?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllPcs, + CartOrderDetails + ) > 0) || + item?.ProductDetail?.some( + (item) => + item?.StockAvailable !== 'Y' + ) ? ( '' ) : (

{ fontSize: !cardFunction?.SmallImage ? cardFunction?.BigImage && - '12px' + '12px' : '12px', textAlign: 'center', lineHeight: '2', @@ -6424,8 +6443,8 @@ const BSItemCard = (props) => { : '', color: SelectedCardColor ? SelectedCardColor?.[ - 'FontColor' - ] + 'FontColor' + ] : '', }} > @@ -6473,19 +6492,19 @@ const BSItemCard = (props) => { count={ !preferenceSingleSales ? returnCount( - item - ?.ProductDetail?.[0] - ?.ProdName, - item?.OverAllQty, - CartOrderDetails - ) + item + ?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllQty, + CartOrderDetails + ) : returnOnepcCount( - item - ?.ProductDetail?.[0] - ?.ProdName, - item?.OverAllPcs, - CartOrderDetails - ) + item + ?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllPcs, + CartOrderDetails + ) } overflowCount={10000} > @@ -6537,14 +6556,14 @@ const BSItemCard = (props) => { item?.OverAllPcs, CartOrderDetails ) > 0 || - item?.ProductDetail?.some( - (product) => - product?.StockAvailable !== - 'Y' - ) + item?.ProductDetail?.some( + (product) => + product?.StockAvailable !== + 'Y' + ) ? cardFunction?.Background ? SelectedCardColor?.BackgroundColor || - '#000000' + '#000000' : '#fff' : '#ff4d4f', }} @@ -6586,39 +6605,39 @@ const BSItemCard = (props) => { cardFunction?.Background && (SelectedCardColor ? SelectedCardColor?.[ - 'BackgroundColor' - ] + 'BackgroundColor' + ] : ''), padding: !cardFunction?.ImageUp && - !cardFunction?.ImageDown + !cardFunction?.ImageDown ? cardFunction?.SmallImage && - '5px 9px' + '5px 9px' : '8px 2px', flexDirection: cardFunction?.ImageRight && - 'row-reverse' + 'row-reverse' ? cardFunction?.ImageRight && - 'row-reverse' + 'row-reverse' : cardFunction?.ImageUp && 'column' ? cardFunction?.ImageUp && - 'column' + 'column' : cardFunction?.ImageDown && - 'column-reverse' + 'column-reverse' ? cardFunction?.ImageDown && - 'column-reverse' + 'column-reverse' : cardFunction?.ImageLeft && - 'row', + 'row', borderRadius: cardFunction?.EdgeCurve && '6px', width: !cardFunction?.ImageUp && - !cardFunction?.ImageDown && - !cardFunction?.BigImage && - !cardFunction?.ImageRight && - cardFunction?.SmallImage && - (cardFunction?.ImageUp || - cardFunction?.ImageDown) + !cardFunction?.ImageDown && + !cardFunction?.BigImage && + !cardFunction?.ImageRight && + cardFunction?.SmallImage && + (cardFunction?.ImageUp || + cardFunction?.ImageDown) ? '6rem' : cardFunction?.BigImage && '9rem', height: @@ -6636,19 +6655,19 @@ const BSItemCard = (props) => { if ( !( (item?.OverAllQty !== undefined && - !preferenceSingleSales + !preferenceSingleSales ? returnCount( - item?.ProductDetail?.[0] - ?.ProdName, - item?.OverAllQty, - CartOrderDetails - ) + item?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllQty, + CartOrderDetails + ) : returnOnepcCount( - item?.ProductDetail?.[0] - ?.ProdName, - item?.OverAllPcs, - CartOrderDetails - ) > 0) || + item?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllPcs, + CartOrderDetails + ) > 0) || item?.ProductDetail?.some( (item) => item?.StockAvailable !== 'Y' @@ -6660,48 +6679,48 @@ const BSItemCard = (props) => { CardOnclick( item, item?.OnePcsAvailable === 'Y' && - preferenceSingleSales && - 'OnePeiceProduct' + preferenceSingleSales && + 'OnePeiceProduct' ); } }} - // data-aos="zoom-in" data-aos-duration="600" + // data-aos="zoom-in" data-aos-duration="600" > {(cardFunction?.BigImage || cardFunction?.SmallImage) && ( - - )} + : defaultimage + } + alt="" + /> + )}

{ cardFunction?.Background && (SelectedCardColor ? SelectedCardColor?.[ - 'BackgroundColor' - ] + 'BackgroundColor' + ] : ''), position: !cardFunction?.BigImage @@ -6735,7 +6754,7 @@ const BSItemCard = (props) => { height: cardFunction?.SmallImage ? '5.5rem' : !cardFunction?.BigImage && - '4.5rem', + '4.5rem', alignItems: !cardFunction?.BigImage && !cardFunction?.SmallImage && @@ -6755,11 +6774,11 @@ const BSItemCard = (props) => { 'uppercase', width: !cardFunction?.SmallImage ? cardFunction?.BigImage && - '120px' + '120px' : cardFunction?.SmallImage && - !cardFunction?.ImageUp && - !cardFunction?.ImageDown && - '85px', + !cardFunction?.ImageUp && + !cardFunction?.ImageDown && + '85px', // Width: cardFunction?.BigImage && "70px", fontSize: !cardFunction?.BigImage && @@ -6781,24 +6800,24 @@ const BSItemCard = (props) => { > {item?.ProdName}{' '} {(item?.OverAllQty !== undefined && - !preferenceSingleSales + !preferenceSingleSales ? returnCount( - item?.ProductDetail?.[0] - ?.ProdName, - item?.OverAllQty, - CartOrderDetails, - item - ) + item?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllQty, + CartOrderDetails, + item + ) : returnOnepcCount( - item?.ProductDetail?.[0] - ?.ProdName, - item?.OverAllPcs, - CartOrderDetails - ) > 0) || - item?.ProductDetail?.some( - (item) => - item?.StockAvailable !== 'Y' - ) ? ( + item?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllPcs, + CartOrderDetails + ) > 0) || + item?.ProductDetail?.some( + (item) => + item?.StockAvailable !== 'Y' + ) ? ( '' ) : (

{ fontSize: !cardFunction?.SmallImage ? cardFunction?.BigImage && - '12px' + '12px' : '12px', textAlign: 'center', lineHeight: '2', @@ -6837,8 +6856,8 @@ const BSItemCard = (props) => { : '', color: SelectedCardColor ? SelectedCardColor?.[ - 'FontColor' - ] + 'FontColor' + ] : '', }} > @@ -6883,19 +6902,19 @@ const BSItemCard = (props) => { count={ !preferenceSingleSales ? returnCount( - item - ?.ProductDetail?.[0] - ?.ProdName, - item?.OverAllQty, - CartOrderDetails - ) + item + ?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllQty, + CartOrderDetails + ) : returnOnepcCount( - item - ?.ProductDetail?.[0] - ?.ProdName, - item?.OverAllPcs, - CartOrderDetails - ) + item + ?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllPcs, + CartOrderDetails + ) } overflowCount={10000} > @@ -6946,14 +6965,14 @@ const BSItemCard = (props) => { item?.OverAllPcs, CartOrderDetails ) > 0 || - item?.ProductDetail?.some( - (product) => - product?.StockAvailable !== - 'Y' - ) + item?.ProductDetail?.some( + (product) => + product?.StockAvailable !== + 'Y' + ) ? cardFunction?.Background ? SelectedCardColor?.BackgroundColor || - '#000000' + '#000000' : '#fff' : '#ff4d4f', }} @@ -6968,21 +6987,21 @@ const BSItemCard = (props) => {

0) || - item?.ProductDetail?.some( - (item) => item?.StockAvailable !== 'Y' - ) + item?.ProductDetail?.[0]?.ProdName, + item?.OverAllPcs, + CartOrderDetails + ) > 0) || + item?.ProductDetail?.some( + (item) => item?.StockAvailable !== 'Y' + ) ? 'card4Main card4Main-active' : 'card4Main card4Main-deactive' } @@ -7005,17 +7024,17 @@ const BSItemCard = (props) => { if ( !( (item?.OverAllQty !== undefined && - !preferenceSingleSales + !preferenceSingleSales ? returnCount( - item?.ProductDetail?.[0]?.ProdName, - item?.OverAllQty, - CartOrderDetails - ) + item?.ProductDetail?.[0]?.ProdName, + item?.OverAllQty, + CartOrderDetails + ) : returnOnepcCount( - item?.ProductDetail?.[0]?.ProdName, - item?.OverAllPcs, - CartOrderDetails - ) > 0) || + item?.ProductDetail?.[0]?.ProdName, + item?.OverAllPcs, + CartOrderDetails + ) > 0) || item?.ProductDetail?.some( (item) => item?.StockAvailable !== 'Y' ) @@ -7030,8 +7049,8 @@ const BSItemCard = (props) => { CardOnclick( item, item?.OnePcsAvailable === 'Y' && - preferenceSingleSales && - 'OnePeiceProduct' + preferenceSingleSales && + 'OnePeiceProduct' ); // This will trigger if you're clicking outside the "One Piece" button } @@ -7073,7 +7092,7 @@ const BSItemCard = (props) => { height={60} src={ item?.ProductDetail?.[0]?.ProdLogo === - '' + '' ? defaultimage : item?.ProductDetail?.[0]?.ProdLogo ? item?.ProductDetail?.[0]?.ProdLogo @@ -7088,21 +7107,21 @@ const BSItemCard = (props) => {
{item?.ProdName} {(item?.OverAllQty !== undefined && - !preferenceSingleSales + !preferenceSingleSales ? returnCount( - item?.ProductDetail?.[0]?.ProdName, - item?.OverAllQty, - CartOrderDetails, - item - ) + item?.ProductDetail?.[0]?.ProdName, + item?.OverAllQty, + CartOrderDetails, + item + ) : returnOnepcCount( - item?.ProductDetail?.[0]?.ProdName, - item?.OverAllPcs, - CartOrderDetails - ) > 0) || - item?.ProductDetail?.some( - (item) => item?.StockAvailable !== 'Y' - ) ? ( + item?.ProductDetail?.[0]?.ProdName, + item?.OverAllPcs, + CartOrderDetails + ) > 0) || + item?.ProductDetail?.some( + (item) => item?.StockAvailable !== 'Y' + ) ? ( '' ) : (

{ )}

{((item?.OverAllQty !== undefined && - !preferenceSingleSales + !preferenceSingleSales ? returnCount( - item?.ProductDetail?.[0]?.ProdName, - item?.OverAllQty, - CartOrderDetails, - item - ) + item?.ProductDetail?.[0]?.ProdName, + item?.OverAllQty, + CartOrderDetails, + item + ) : returnOnepcCount( - item?.ProductDetail?.[0]?.ProdName, - item?.OverAllPcs, - CartOrderDetails - ) > 0) || + item?.ProductDetail?.[0]?.ProdName, + item?.OverAllPcs, + CartOrderDetails + ) > 0) || item?.ProductDetail?.some( (item) => item?.StockAvailable !== 'Y' )) && ( -
-
- ₹ {ItemSellingPrice(item)} -
+
+
+ ₹ {ItemSellingPrice(item)} +
-
- <> - ({ItemSize(item)} {ItemUomName(item)}) - +
+ <> + ({ItemSize(item)} {ItemUomName(item)}) + +
-
- )} + )}
{/* Stock Count Badge */} @@ -7168,17 +7187,17 @@ const BSItemCard = (props) => { count={ !preferenceSingleSales ? returnCount( - item?.ProductDetail?.[0] - ?.ProdName, - item?.OverAllQty, - CartOrderDetails - ) + item?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllQty, + CartOrderDetails + ) : returnOnepcCount( - item?.ProductDetail?.[0] - ?.ProdName, - item?.OverAllPcs, - CartOrderDetails - ) + item?.ProductDetail?.[0] + ?.ProdName, + item?.OverAllPcs, + CartOrderDetails + ) } overflowCount={10000} > @@ -7227,13 +7246,13 @@ const BSItemCard = (props) => { item?.OverAllPcs, CartOrderDetails ) > 0 || - item?.ProductDetail?.some( - (product) => - product?.StockAvailable !== 'Y' - ) + item?.ProductDetail?.some( + (product) => + product?.StockAvailable !== 'Y' + ) ? cardFunction?.Background ? SelectedCardColor?.BackgroundColor || - '#000000' + '#000000' : '#fff' : '#ff4d4f', }} @@ -7624,16 +7643,16 @@ const BSItemCard = (props) => { ]?.ProdVariantName?.toLowerCase()?.includes( 'variant' ) && ( - - ( - { - qtydata?.ProductDetail?.[QtyIndex] - ?.ProdVariantDetails?.[VarientIndex] - ?.ProdVariantName - } - ){' '} - - )} + + ( + { + qtydata?.ProductDetail?.[QtyIndex] + ?.ProdVariantDetails?.[VarientIndex] + ?.ProdVariantName + } + ){' '} + + )}

diff --git a/src/utils/calculations.js b/src/utils/calculations.js new file mode 100644 index 0000000..8643d30 --- /dev/null +++ b/src/utils/calculations.js @@ -0,0 +1,5 @@ +export const calculateOverAllQtyLimit = (orders) => { + return orders?.reduce((acc, cartItem) => { + return acc + (cartItem?.OrderQty || 0); + }, 0) +} \ No newline at end of file From 5f5ca994094cbc2cf5e588009cab6d6b2e6721c2 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 24 Feb 2026 14:59:52 +0530 Subject: [PATCH 4/4] constrain Qty --- .../BSBillingTable5/BsBill.jsx | 35 +- .../Components/BSCombo/BSC1Search.jsx | 332 +++++++++--------- 2 files changed, 208 insertions(+), 159 deletions(-) diff --git a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable5/BsBill.jsx b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable5/BsBill.jsx index bc40f50..25c95a4 100644 --- a/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable5/BsBill.jsx +++ b/src/Pages/BookingScreen/Components/BSBillingTables/BSBillingTable5/BsBill.jsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from 'react'; +import React, { useCallback, useEffect, useState } from 'react'; import { shallowEqual, useDispatch, useSelector } from 'react-redux'; import { Popconfirm, Tooltip } from 'antd'; import { AiOutlineClose, AiFillDelete } from 'react-icons/ai'; @@ -79,6 +79,8 @@ import BSEditTotalAmt from '../BSEditTotalAmount/BSEditTotalAmt.jsx'; import BSImeiDetails from '../BSImeiDetails/BSImeiDetails.jsx'; import { useUtilsComponent } from '../../../../../Services/utils.js'; import CustomerPriceHistory from '../../UtillComponents/CustomerPriceHistory.jsx'; +import { calculateOverAllQtyLimit } from '../../../../../utils/calculations.js'; +import { Messages } from '../../../../../../ownLib/my-ui-lib.js'; const BsBill = () => { const { removeExtraCharge } = useUtilsComponent(); @@ -108,6 +110,8 @@ const BsBill = () => { setting?.SettingValue === 'Y' ); const [count, setCount] = useState(1); + const [messageType, setMessageType] = useState(null); + const [messageData, setMessageData] = useState(null); const [EditQuantity, setEditQuantity] = useState(false); const [Modaldata, setModaldata] = useState([]); const TableData = useSelector(GlobalOrderCardDetails); @@ -141,6 +145,14 @@ const BsBill = () => { const OrderType = useSelector(GlobalOrderType); const GlobEstBooking = useSelector(GlobalEstimateBooking); const GlobalExtraCharge = useSelector(globalExtraTotalAmount); + const overAllLimitPreferenece = + preferenceDatas?.[0]?.['SettingDtlDetails']?.find( + (item) => (item.SettingIdName?.toLowerCase() === 'overalllimit') && item?.SettingValue === 'Y'); + const itemWiseLimitPreferenece = + preferenceDatas?.[0]?.['SettingDtlDetails']?.find( + (item) => item.SettingIdName?.toLowerCase() === 'itemwiselimit' && item?.SettingValue === 'Y'); + const maxQtyLimit = itemWiseLimitPreferenece?.SettingCount || overAllLimitPreferenece?.SettingCount || null; + const OtherServicesglobal = useSelector(GlobalOtherSevices); @@ -2123,8 +2135,22 @@ const BsBill = () => { const handleEditQuantityCancel = () => { setEditQuantity(false); }; - + const onComplete = useCallback(() => { + setMessageData(null); + setMessageType(null); + }, []); const increase = async (item) => { + + if ((overAllLimitPreferenece || itemWiseLimitPreferenece) && maxQtyLimit) { + if (overAllLimitPreferenece) { + const calculatedOverAllQty = calculateOverAllQtyLimit(TableData); + if ((calculatedOverAllQty + 1) > maxQtyLimit) { + setMessageData(`Overall Quantity Limit Exceeds than ${maxQtyLimit}`); + setMessageType('warning'); + return; + } + } + } const OtherOrderDatas = TableData?.filter( (cartItem) => !( @@ -3049,6 +3075,11 @@ const BsBill = () => { }; return (
+ import('../BookingFunctionality/FeaturesFunctionalities') ); import { isMobile } from 'react-device-detect'; -import BarcodeScanner from '../UtillComponents/BarcodeScanner.jsx'; import { getTemplateData, StoredSessionData, } from '../../../../Features/ThemeChange/ThemeChange.js'; import { v4 as uuidv4 } from 'uuid'; -import BSNavBarWeightScale from '../UtillComponents/BSNavBarWeightScale.jsx'; import { changeFreeProductForLoyalty, ChangeFreeProductList, @@ -89,6 +87,7 @@ import { import { Global_PromoCodeOffers } from '../../../../Features/Offer/Offer.js'; import { validateOffers } from '../BSItemCards/ValidateOffer.jsx'; import { useSaleswiseOfferWatcher } from '../BSItemCards/SalesWiseOffer.jsx'; +import { calculateOverAllQtyLimit } from '../../../../utils/calculations.js'; const ExpireConfirmModal = lazy( () => import('../BookingFunctionality/ExpireConfirmModal.jsx') ); @@ -134,6 +133,13 @@ export default function BSC1Search(props) { const FeatureAddonData = useSelector(GlobalFeatAddOnData); useSaleswiseOfferWatcher(); const preferenceDatas = useSelector(PreferenceData); + const overAllLimitPreferenece = + preferenceDatas?.[0]?.['SettingDtlDetails']?.find( + (item) => (item.SettingIdName?.toLowerCase() === 'overalllimit') && item?.SettingValue === 'Y'); + const itemWiseLimitPreferenece = + preferenceDatas?.[0]?.['SettingDtlDetails']?.find( + (item) => item.SettingIdName?.toLowerCase() === 'itemwiselimit' && item?.SettingValue === 'Y'); + const maxQtyLimit = itemWiseLimitPreferenece?.SettingCount || overAllLimitPreferenece?.SettingCount || null; const preferenceOffer = preferenceDatas?.[0]?.['SettingDtlDetails']?.find( (item) => item.SettingIdName === 'Offer' @@ -705,7 +711,7 @@ export default function BSC1Search(props) { WithoutTaxRate: availableFreeQty * item.OrderRate - (availableFreeQty * item.OrderRate * item.TaxPercentage) / - 100, + 100, Offer: availableFreeQty * item.OrderRate, }; @@ -754,7 +760,7 @@ export default function BSC1Search(props) { ((existingPaidItem.OrderQty + excessQty) * item.OrderRate * item.TaxPercentage) / - 100, + 100, }; ModifiedData.push(mergedPaidItem); @@ -789,7 +795,7 @@ export default function BSC1Search(props) { data?.InwardDtlId === item?.InwardDtlId && data?.ProdId === item?.ProdId && data?.OfferMessage?.[0]?.OfferId === - item?.OfferMessage?.[0]?.OfferId + item?.OfferMessage?.[0]?.OfferId ); if (isAlreadyExists !== -1) { @@ -809,11 +815,11 @@ export default function BSC1Search(props) { ).toFixed(2), WithoutTaxRate: (ModifiedData[isAlreadyExists].OrderQty + item.OrderQty) * - item.OrderRate - + item.OrderRate - ((ModifiedData[isAlreadyExists].OrderQty + item.OrderQty) * item.OrderRate * item.TaxPercentage) / - 100, + 100, Offer: (ModifiedData[isAlreadyExists].OrderQty + item.OrderQty) * item.OrderRate, @@ -839,10 +845,10 @@ export default function BSC1Search(props) { const appliedOfferAlreadyExists = AppliedOffers.findIndex( (offer) => offer?.FreeProductsList?.FreeProdId === - matchingFreeProduct?.FreeProdId && + matchingFreeProduct?.FreeProdId && offer?.TableName === matchingFreeProduct?.TableName && offer?.TableUniqueName === - matchingFreeProduct?.TableUniqueName && + matchingFreeProduct?.TableUniqueName && offer?.OfferId === matchingFreeProduct?.OfferId && offer?.OfferMode === matchingFreeProduct?.OfferMode && offer?.FreeProductsList?.ProdVariantDetails?.[0] @@ -1171,7 +1177,7 @@ export default function BSC1Search(props) { const getPreferenceStock = async () => { const PreferenceStckDtl = preferenceDatas?.[0]?.SettingDtlDetails; - const StockPreference = PreferenceStckDtl.find( + const StockPreference = PreferenceStckDtl?.find( (item) => item.SettingIdName === 'StockSelection' ); @@ -1673,7 +1679,7 @@ export default function BSC1Search(props) { 0 || - record.StockCount === 'Stock Not Maintained' + record.StockCount === 'Stock Not Maintained' ? { color: '#000', cursor: 'pointer' } : { color: '#f49898', cursor: 'not-allowed' } } @@ -1703,7 +1709,7 @@ export default function BSC1Search(props) { 0 || - record.StockCount === 'Stock Not Maintained' + record.StockCount === 'Stock Not Maintained' ? { color: '#000', cursor: 'pointer' } : { color: '#f49898', cursor: 'not-allowed' } } @@ -1733,7 +1739,7 @@ export default function BSC1Search(props) { 0 || - record.StockCount === 'Stock Not Maintained' + record.StockCount === 'Stock Not Maintained' ? { color: '#000', cursor: 'pointer' } : { color: '#f49898', cursor: 'not-allowed' } } @@ -1897,11 +1903,11 @@ export default function BSC1Search(props) { StockCount: qtydata?.ProductDetail?.[0]?.StockAvailable === 'Y' ? returnVariantStock( - qtydata?.ProductDetail?.[QtyIndex]?.ProdId, - item?.OverAllQty, - CartOrderDetails, - item?.ProdVariantName - ) + qtydata?.ProductDetail?.[QtyIndex]?.ProdId, + item?.OverAllQty, + CartOrderDetails, + item?.ProdVariantName + ) : 'Stock Not Maintained', }); }); @@ -1917,17 +1923,17 @@ export default function BSC1Search(props) { 'Batch No': item?.BatchRef, StockCount: onePeiceFlow ? returnCountStock( - item?.ProdId, - item?.BalanceQty, - CartOrderDetails, - item?.InwardDtlId - ) * item?.NoOfPcs + item?.ProdId, + item?.BalanceQty, + CartOrderDetails, + item?.InwardDtlId + ) * item?.NoOfPcs : returnCountStock( - item?.ProdId, - item?.BalanceQty, - CartOrderDetails, - item?.InwardDtlId - ), + item?.ProdId, + item?.BalanceQty, + CartOrderDetails, + item?.InwardDtlId + ), 'Stock Date': StockDate(item?.InwardDate), Price: onePeiceFlow ? item?.OnePcsPrice : item?.SellPrice, ExpDate: @@ -1981,13 +1987,13 @@ export default function BSC1Search(props) { (cartItem) => cartItem?.ProdId === item?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && cartItem?.OrderRate === - item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - VarientIndex - ]?.StockDetails?.[0]?.SellPrice && + item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + VarientIndex + ]?.StockDetails?.[0]?.SellPrice && !cartItem?.SalesId ); @@ -1996,9 +2002,9 @@ export default function BSC1Search(props) { (cartItem) => cartItem?.ProdId === item?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) !cartItem?.SalesId ); @@ -2040,11 +2046,11 @@ export default function BSC1Search(props) { (cartItem) => cartItem?.ProdId === item?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[0]?.InwardDtlId && + item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] + ?.StockDetails?.[0]?.InwardDtlId && cartItem?.OrderRate === - item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[0]?.SellPrice && + item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] + ?.StockDetails?.[0]?.SellPrice && !cartItem?.SalesId ); @@ -2053,9 +2059,9 @@ export default function BSC1Search(props) { (cartItem) => cartItem?.ProdId === item?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) !cartItem?.SalesId ); @@ -2133,13 +2139,13 @@ export default function BSC1Search(props) { (cartItem) => cartItem?.ProdId === qtydata?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - index.key - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + index.key + ]?.StockDetails?.[0]?.InwardDtlId && cartItem?.OrderRate === - qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - index.key - ]?.StockDetails?.[0]?.SellPrice && + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + index.key + ]?.StockDetails?.[0]?.SellPrice && !cartItem?.SalesId ); @@ -2147,11 +2153,11 @@ export default function BSC1Search(props) { let Isincartonepc = CartOrderDetails?.filter( (cartItem) => cartItem?.ProdId === - qtydata?.ProductDetail?.[QtyIndex]?.ProdId && + qtydata?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) !cartItem?.SalesId ); @@ -2215,11 +2221,11 @@ export default function BSC1Search(props) { (cartItem) => cartItem?.ProdId === qtydata?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[index.key] - ?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[index.key] + ?.StockDetails?.[0]?.InwardDtlId && cartItem?.OrderRate === - qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[index.key] - ?.StockDetails?.[0]?.SellPrice && + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[index.key] + ?.StockDetails?.[0]?.SellPrice && !cartItem?.SalesId ); @@ -2228,9 +2234,9 @@ export default function BSC1Search(props) { (cartItem) => cartItem?.ProdId === qtydata?.ProductDetail?.[QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ - VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[ + VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) !cartItem?.SalesId ); @@ -2305,15 +2311,15 @@ export default function BSC1Search(props) { let Isincart = CartOrderDetails?.find( (cartItem) => cartItem?.ProdId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && cartItem?.OrderRate === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.SellPrice && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.SellPrice && !cartItem?.SalesId ); @@ -2321,11 +2327,11 @@ export default function BSC1Search(props) { let Isincartonepc = CartOrderDetails?.filter( (cartItem) => cartItem?.ProdId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndexs - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndexs + ]?.StockDetails?.[0]?.InwardDtlId && // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) !cartItem?.SalesId ); @@ -2403,15 +2409,15 @@ export default function BSC1Search(props) { let Isincart = CartOrderDetails?.find( (cartItem) => cartItem?.ProdId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && cartItem?.OrderRate === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.SellPrice && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.SellPrice && !cartItem?.SalesId ); @@ -2419,11 +2425,11 @@ export default function BSC1Search(props) { let Isincartonepc = CartOrderDetails?.filter( (cartItem) => cartItem?.ProdId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId && cartItem?.InwardDtlId === - qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ - item?.VarientIndex - ]?.StockDetails?.[0]?.InwardDtlId && + qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[ + item?.VarientIndex + ]?.StockDetails?.[0]?.InwardDtlId && // (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice) !cartItem?.SalesId ); @@ -2543,7 +2549,7 @@ export default function BSC1Search(props) { const isKgsProduct = (a?.ProductDetail?.[QtyIndex]?.UomName?.toLowerCase() === 'kgs' || a?.ProductDetail?.[QtyIndex]?.UomName?.toLowerCase() === - 'kg'?.toLowerCase()) && + 'kg'?.toLowerCase()) && a?.ProductDetail?.[QtyIndex]?.Size === '1'; if ( @@ -2556,11 +2562,11 @@ export default function BSC1Search(props) { parseFloat( onePcs ? (a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.OnePcsPrice / - 1000) * - (parseFloat(WeightScaleWeight) * 1000) + ?.StockDetails?.[stockIndex]?.OnePcsPrice / + 1000) * + (parseFloat(WeightScaleWeight) * 1000) : a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.SellPrice / 1000 + ?.StockDetails?.[stockIndex]?.SellPrice / 1000 ) * (parseFloat(WeightScaleWeight) * 1000); let data = { @@ -2616,9 +2622,9 @@ export default function BSC1Search(props) { ?.StockDetails?.[stockIndex]?.InwardId, MRP: onePcs ? a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.OnePcsPrice + ?.StockDetails?.[stockIndex]?.OnePcsPrice : a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.MRP, + ?.StockDetails?.[stockIndex]?.MRP, FullProductIdentifierDtls: a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] ?.StockDetails?.[stockIndex]?.ProductIdentifierDtls, @@ -2726,19 +2732,19 @@ export default function BSC1Search(props) { ?.StockDetails?.[stockIndex]?.InwardId, MRP: onePcs ? a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.OnePcsPrice + ?.StockDetails?.[stockIndex]?.OnePcsPrice : a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.MRP, + ?.StockDetails?.[stockIndex]?.MRP, OrderRate: onePcs ? a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.OnePcsPrice + ?.StockDetails?.[stockIndex]?.OnePcsPrice : a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.SellPrice, + ?.StockDetails?.[stockIndex]?.SellPrice, SellingPrice: onePcs ? a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.OnePcsPrice + ?.StockDetails?.[stockIndex]?.OnePcsPrice : a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] - ?.StockDetails?.[stockIndex]?.SellPrice, + ?.StockDetails?.[stockIndex]?.SellPrice, SuppId: a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex] ?.StockDetails?.[stockIndex]?.SuppId, @@ -2821,6 +2827,18 @@ export default function BSC1Search(props) { }; const AddOrderDetails = async (item) => { + + if ((overAllLimitPreferenece || itemWiseLimitPreferenece) && maxQtyLimit) { + if (overAllLimitPreferenece) { + const calculatedOverAllQty = calculateOverAllQtyLimit(CartOrderDetails); + if ((calculatedOverAllQty + 1) > maxQtyLimit) { + setMessageData(`Overall Quantity Limit Exceeds than ${maxQtyLimit}`); + setMessageType('warning'); + return; + } + } + } + if (preOrder) { await handlePreOrder(item); } else { @@ -2911,15 +2929,15 @@ export default function BSC1Search(props) { const isExistsInFreeProdList = hasOffer ? FreeProdList?.filter( - (f) => - f?.FreeProdId === item?.ProdId && - f?.ProdVariantDetails?.some((variant) => - variant?.StockDetails?.some( - (stock) => stock?.FreeInwardDtlId === item?.InwardDtlId - ) - ) && - f?.RemainingQty > 0 - ) + (f) => + f?.FreeProdId === item?.ProdId && + f?.ProdVariantDetails?.some((variant) => + variant?.StockDetails?.some( + (stock) => stock?.FreeInwardDtlId === item?.InwardDtlId + ) + ) && + f?.RemainingQty > 0 + ) : []; const calculateTaxAmounts = (qty, rate, taxPercentage) => { @@ -2986,10 +3004,10 @@ export default function BSC1Search(props) { ((cartItem?.OfferModeType && cartItem?.OfferMode === 'B' ? true : cartItem?.OfferMode !== 'B') && - cartItem?.OfferMode !== 'P' && - cartItem?.OfferMode !== 'C' && - cartItem?.OfferMode !== 'O' && - cartItem?.OfferMode !== 'L' + cartItem?.OfferMode !== 'P' && + cartItem?.OfferMode !== 'C' && + cartItem?.OfferMode !== 'O' && + cartItem?.OfferMode !== 'L' ? true : cartItem?.Offer === 0) ); @@ -3006,10 +3024,10 @@ export default function BSC1Search(props) { (cartItem) => itemMatchCondition(cartItem) && (cartItem?.OfferMode !== 'B' && - cartItem?.OfferMode !== 'P' && - cartItem?.OfferMode !== 'C' && - cartItem?.OfferMode !== 'O' && - cartItem?.OfferMode !== 'L' + cartItem?.OfferMode !== 'P' && + cartItem?.OfferMode !== 'C' && + cartItem?.OfferMode !== 'O' && + cartItem?.OfferMode !== 'L' ? true : cartItem?.Offer === 0) ); @@ -3023,10 +3041,10 @@ export default function BSC1Search(props) { ((cartItem?.OfferModeType && cartItem?.OfferMode === 'B' ? true : cartItem?.OfferMode !== 'B') && - cartItem?.OfferMode !== 'P' && - cartItem?.OfferMode !== 'L' && - cartItem?.OfferMode !== 'C' && - cartItem?.OfferMode !== 'O' + cartItem?.OfferMode !== 'P' && + cartItem?.OfferMode !== 'L' && + cartItem?.OfferMode !== 'C' && + cartItem?.OfferMode !== 'O' ? true : cartItem?.Offer === 0) ) @@ -3037,10 +3055,10 @@ export default function BSC1Search(props) { !( itemMatchCondition(cartItem) && (cartItem?.OfferMode !== 'B' && - cartItem?.OfferMode !== 'P' && - cartItem?.OfferMode !== 'L' && - cartItem?.OfferMode !== 'C' && - cartItem?.OfferMode !== 'O' + cartItem?.OfferMode !== 'P' && + cartItem?.OfferMode !== 'L' && + cartItem?.OfferMode !== 'C' && + cartItem?.OfferMode !== 'O' ? true : cartItem?.Offer === 0) ) @@ -3113,8 +3131,8 @@ export default function BSC1Search(props) { isItemInCart, item?.OtherProduct === 'Others' || item?.ScaleType === 'weight' ? ( - (item?.OrderQty || 0) + parseFloat(isItemInCart?.OrderQty) - )?.toFixed(3) + (item?.OrderQty || 0) + parseFloat(isItemInCart?.OrderQty) + )?.toFixed(3) : null ); const updatedData = addFirst @@ -3241,9 +3259,9 @@ export default function BSC1Search(props) { isItemInCartHold, item?.OtherProduct === 'Others' || item?.ScaleType === 'weight' ? ( - (item?.OrderQty || 0) + - parseFloat(isItemInCartHold?.OrderQty) - )?.toFixed(3) + (item?.OrderQty || 0) + + parseFloat(isItemInCartHold?.OrderQty) + )?.toFixed(3) : null ); const updatedData = addFirst @@ -3495,14 +3513,14 @@ export default function BSC1Search(props) { updatedCartData = cartData.map((item, idx) => idx === indexToCheck ? { - ...item, - Offer: null, - OfferMessage: undefined, - OfferMode: undefined, - OfferModeType: false, - OfferType: undefined, - OfferValue: null, - } + ...item, + Offer: null, + OfferMessage: undefined, + OfferMode: undefined, + OfferModeType: false, + OfferType: undefined, + OfferValue: null, + } : item ); } @@ -3553,8 +3571,8 @@ export default function BSC1Search(props) { ...item, Offer: sameProduct || - bestOffer?.OfferMode === 'I' || - bestOffer?.OfferMode === 'Q' + bestOffer?.OfferMode === 'I' || + bestOffer?.OfferMode === 'Q' ? bestOffer?.OfferAmount || item.Offer : item.Offer || bestOffer?.OfferAmount, OfferType: item?.OfferType || bestOffer?.OfferType, @@ -3571,10 +3589,10 @@ export default function BSC1Search(props) { ((c?.OfferModeType && c?.OfferMode === 'B' ? true : c?.OfferMode !== 'B') && - c?.OfferMode !== 'P' && - c?.OfferMode !== 'C' && - c?.OfferMode !== 'O' && - c?.OfferMode !== 'L' + c?.OfferMode !== 'P' && + c?.OfferMode !== 'C' && + c?.OfferMode !== 'O' && + c?.OfferMode !== 'L' ? true : c?.Offer === 0); @@ -3882,10 +3900,10 @@ export default function BSC1Search(props) { return FreeProdList.map((f, i) => i === index ? { - ...existing, - ...newFreeProd, - ProdVariantDetails: existing.ProdVariantDetails, - } + ...existing, + ...newFreeProd, + ProdVariantDetails: existing.ProdVariantDetails, + } : f ); } else { @@ -3955,7 +3973,7 @@ export default function BSC1Search(props) { const cycleSize = buyQty + getQty; const fullCycles = Math.floor( freeCartItem?.reduce((acc, fc) => acc + (fc?.OrderQty || 0), 0) / - cycleSize + cycleSize ); const totalFreeQty = fullCycles * getQty; @@ -4559,15 +4577,15 @@ export default function BSC1Search(props) { {option.ProductDetail?.filter( (item) => item.OnePcsAvailable == 'Y' ).length !== 0 && ( - { - setOnePeiceFlow(true); - }} - /> - )} + { + setOnePeiceFlow(true); + }} + /> + )} ), @@ -4601,7 +4619,7 @@ export default function BSC1Search(props) { OnfocusTrue()} + // onClick={() => OnfocusTrue()} /> {ProductSearch?.length > 5 && @@ -4697,8 +4715,8 @@ export default function BSC1Search(props) {