added offer for combo sales screen

This commit is contained in:
unknown 2026-01-30 10:05:20 +05:30
parent 2094f326dd
commit c202f7eac4
8 changed files with 3428 additions and 914 deletions

View File

@ -89,7 +89,9 @@ const BSBillingEditQuantity = (props) => {
const templateData = useSelector(getTemplateData); const templateData = useSelector(getTemplateData);
const OfferCheckedInSetup = templateData?.BookingNavbar?.[1].some( const OfferCheckedInSetup = templateData?.BookingNavbar?.[1].some(
(item) => item?.OptionName == 'Offer' (item) => item?.OptionName == 'Offer'
); ) || (templateData?.BookingCombo1?.[1]?.some(
(item) => item?.OptionName == 'Offer'
));
const [ClearQuantity, setClearQuantity] = useState(false); const [ClearQuantity, setClearQuantity] = useState(false);
const CartOrderDetails = useSelector(GlobalOrderCardDetails); const CartOrderDetails = useSelector(GlobalOrderCardDetails);
const SettingDataSelector = useSelector(PreferenceData); const SettingDataSelector = useSelector(PreferenceData);
@ -3156,7 +3158,9 @@ const BSBillingEditQuantity = (props) => {
const UpdatedCartItemWithOffer = { const UpdatedCartItemWithOffer = {
...updatedProduct, ...updatedProduct,
Offer: updatedProduct.Offer || bestOffer?.OfferAmount, Offer: (bestOffer?.OfferMode === 'I' || bestOffer?.OfferMode === 'Q') ?
bestOffer?.OfferAmount || updatedProduct.Offer :
updatedProduct.Offer || bestOffer?.OfferAmount,
OfferType: updatedProduct?.OfferType || bestOffer?.OfferType, OfferType: updatedProduct?.OfferType || bestOffer?.OfferType,
OfferMessage: updatedProduct?.OfferMessage || bestOffer?.OfferMessage, OfferMessage: updatedProduct?.OfferMessage || bestOffer?.OfferMessage,
}; };
@ -3169,7 +3173,12 @@ const BSBillingEditQuantity = (props) => {
c.OrderRate === updatedProduct.OrderRate && c.OrderRate === updatedProduct.OrderRate &&
c.BookingTypeName === updatedProduct.BookingTypeName && c.BookingTypeName === updatedProduct.BookingTypeName &&
!c.SalesId && !c.SalesId &&
(c?.OfferType !== 'B' && c?.OfferType !== 'P' && c?.OfferType !== 'L' ((c?.OfferModeType && c?.OfferMode === 'B'
? true
: c?.OfferMode !== 'B')
&& c?.OfferMode !== 'P'
&& c?.OfferMode !== 'C' && c?.OfferMode !== 'O'
&& c?.OfferMode !== 'L'
? true ? true
: c?.Offer === 0); : c?.Offer === 0);

View File

@ -2270,9 +2270,12 @@ const ComboSalesBillTable = () => {
className="discPerTd" className="discPerTd"
onClick={() => editField && handleEditQuantity(row)} onClick={() => editField && handleEditQuantity(row)}
> >
{row?.OfferType === 'F' {row?.Offer > 0
? `${row.Offer}` ? `${(
: `${row.Offer || '-'}`} (row.Offer / (row?.OrderQty * row?.OrderRate)) *
100
).toFixed(2)}%`
: '-'}
</td> </td>
)} )}
@ -2283,7 +2286,7 @@ const ComboSalesBillTable = () => {
className="discAmtTd" className="discAmtTd"
onClick={() => editField && handleEditQuantity(row)} onClick={() => editField && handleEditQuantity(row)}
> >
{row.discAmt || '-'} {row.Offer || '-'}
</td> </td>
)} )}

View File

@ -230,6 +230,8 @@ import CardPopover from '../BSBillingTables/StandardTable/Utils/CardPopover.jsx'
import UpiPopover from '../BSBillingTables/StandardTable/Utils/UpiPopOver.jsx'; import UpiPopover from '../BSBillingTables/StandardTable/Utils/UpiPopOver.jsx';
import { useDateStore } from '../../../../Features/BookingScreen/BookingData/DateStore.js'; import { useDateStore } from '../../../../Features/BookingScreen/BookingData/DateStore.js';
import { getPaymentOptionsData } from '../../../../Features/BookingScreen/BookingData/KioskBookingData.js'; import { getPaymentOptionsData } from '../../../../Features/BookingScreen/BookingData/KioskBookingData.js';
import { GlobalFreeProdList, GlobalOfferAppliedProducts, GlobalOverAllOfferAmt } from '../../../../Features/Offer/Offernew/BookingOffernew.js';
import BSNavBarTable from '../UtillComponents/BSNavBarTable.jsx';
const subDirectory = import.meta.env.ENV_BASE_URL; const subDirectory = import.meta.env.ENV_BASE_URL;
const MainHomeUrl = import.meta.env.ENV_MAIN_BASE_URL; const MainHomeUrl = import.meta.env.ENV_MAIN_BASE_URL;
@ -449,6 +451,7 @@ const BSC1Payment = (props) => {
const [OpenFailData, SetOpenFailData] = useState(false); const [OpenFailData, SetOpenFailData] = useState(false);
const [paymentfeataddon, setpaymentfeataddon] = useState(false); const [paymentfeataddon, setpaymentfeataddon] = useState(false);
const [isFloatMenuOpen, setIsFloatMenuOpen] = useState(false); const [isFloatMenuOpen, setIsFloatMenuOpen] = useState(false);
const Discount = useSelector(GlobalOverAllOfferAmt);
const OverAllSales = useSelector(GlobalOverAllDiscSales); const OverAllSales = useSelector(GlobalOverAllDiscSales);
const OverAllEstimate = useSelector(GlobalOverAllDiscEstimate); const OverAllEstimate = useSelector(GlobalOverAllDiscEstimate);
const [blink, setBlink] = useState(false); const [blink, setBlink] = useState(false);
@ -475,6 +478,8 @@ const BSC1Payment = (props) => {
// for customised invoice number // for customised invoice number
const { invoiceDate, clearInvoiceDate } = useDateStore(); const { invoiceDate, clearInvoiceDate } = useDateStore();
const CurrentOrderId = useSelector(GlobalCurrentOrderId); const CurrentOrderId = useSelector(GlobalCurrentOrderId);
const FreeProdList = useSelector(GlobalFreeProdList);
const offerAppliedProducts = useSelector(GlobalOfferAppliedProducts);
console.log(BSComboData, 'BSComboData'); console.log(BSComboData, 'BSComboData');
const canHold = const canHold =
@ -619,7 +624,9 @@ const BSC1Payment = (props) => {
} }
let withdiscTotal = let withdiscTotal =
Total - ((OverAllSales || 0) + (OverAllEstimate || 0)); Total - ((OverAllSales || 0) + (OverAllEstimate || 0) +
(Discount > 0 ? Discount : 0));
setTotalAmount( setTotalAmount(
withdiscTotal >= 0 withdiscTotal >= 0
@ -651,6 +658,7 @@ const BSC1Payment = (props) => {
OverAllEstimate, OverAllEstimate,
globalTipAmount, globalTipAmount,
OtherServiceTicketClaim, OtherServiceTicketClaim,
Discount
]); ]);
useEffect(() => { useEffect(() => {
let data = { let data = {
@ -1983,9 +1991,11 @@ const BSC1Payment = (props) => {
: 'S', : 'S',
SinglePc: a.SinglePc, SinglePc: a.SinglePc,
BookingType: a.BookingTypeName === 'Dine In' ? DineinId : TakAwayId, BookingType: a.BookingTypeName === 'Dine In' ? DineinId : TakAwayId,
OfferValue: a?.Type === 'C' ? a?.OfferPrice : a.Offer, OfferValue: a?.Type === 'C' ? a?.OfferValue : a.Offer,
OfferAmt: a?.Type === 'C' ? a?.TotalAmt : a.Offer, OfferAmt: a?.Type === 'C' ? a?.TotalAmt : a.Offer,
OfferType: a?.Type === 'C' ? a?.OfferType : '', OfferType: a?.Type === 'C' ? a?.OfferType : '',
OfferMode: a?.OfferMode,
OfferMessage: a?.OfferMessage,
CounterName: a?.TokenAvailable === 'Y' ? a?.CounterName : null, CounterName: a?.TokenAvailable === 'Y' ? a?.CounterName : null,
ProductIdentifierDtls: a.ProductIdentifierDtls, ProductIdentifierDtls: a.ProductIdentifierDtls,
ModelNumber: a.ModelNumber, ModelNumber: a.ModelNumber,
@ -1995,9 +2005,9 @@ const BSC1Payment = (props) => {
const NotSlectedTypeFind = temporderdetail?.find( const NotSlectedTypeFind = temporderdetail?.find(
(a) => a?.BookingType != SelectedBookingType (a) => a?.BookingType != SelectedBookingType
); );
let updatedOfferDetails = OrderOfferDetail; let updatedOfferDetails = offerAppliedProducts;
if (GlobEstBooking !== 'Sales') { if (GlobEstBooking !== 'Sales') {
updatedOfferDetails = OrderOfferDetail?.filter( updatedOfferDetails = offerAppliedProducts?.filter(
(item) => (item) =>
!( !(
item.TableName === 'LoyaltyPoints' && item.TableName === 'LoyaltyPoints' &&
@ -2148,6 +2158,12 @@ const BSC1Payment = (props) => {
}, },
], ],
OrderOfferDetail: updatedOfferDetails, OrderOfferDetail: updatedOfferDetails,
RefDetails: [
{
FreeProdList: FreeProdList,
OfferAppliedProductList: offerAppliedProducts,
},
],
}; };
let PostData = temppostdata; let PostData = temppostdata;

File diff suppressed because it is too large Load Diff

View File

@ -2422,7 +2422,8 @@ const BSItemCard = (props) => {
((cartItem?.OfferModeType && cartItem?.OfferMode === 'B' ((cartItem?.OfferModeType && cartItem?.OfferMode === 'B'
? true ? true
: cartItem?.OfferMode !== 'B') && : cartItem?.OfferMode !== 'B') &&
cartItem?.OfferMode !== 'P' && cartItem?.OfferMode !== 'P' && cartItem?.OfferMode !== 'C' &&
cartItem?.OfferMode !== 'O' &&
cartItem?.OfferMode !== 'L' cartItem?.OfferMode !== 'L'
? true ? true
: cartItem?.Offer === 0) : cartItem?.Offer === 0)
@ -2432,7 +2433,8 @@ const BSItemCard = (props) => {
(cartItem) => (cartItem) =>
itemMatchCondition(cartItem) && itemMatchCondition(cartItem) &&
(cartItem?.OfferMode !== 'B' && (cartItem?.OfferMode !== 'B' &&
cartItem?.OfferMode !== 'P' && cartItem?.OfferMode !== 'P' && cartItem?.OfferMode !== 'C' &&
cartItem?.OfferMode !== 'O' &&
cartItem?.OfferMode !== 'L' cartItem?.OfferMode !== 'L'
? true ? true
: cartItem?.Offer === 0) : cartItem?.Offer === 0)
@ -2447,7 +2449,8 @@ const BSItemCard = (props) => {
((cartItem?.OfferModeType && cartItem?.OfferMode === 'B' ((cartItem?.OfferModeType && cartItem?.OfferMode === 'B'
? true ? true
: cartItem?.OfferMode !== 'B') && : cartItem?.OfferMode !== 'B') &&
cartItem?.OfferMode !== 'P' && cartItem?.OfferMode !== 'P' && cartItem?.OfferMode !== 'C' &&
cartItem?.OfferMode !== 'O' &&
cartItem?.OfferMode !== 'L' cartItem?.OfferMode !== 'L'
? true ? true
: cartItem?.Offer === 0) : cartItem?.Offer === 0)
@ -2459,7 +2462,8 @@ const BSItemCard = (props) => {
!( !(
itemMatchCondition(cartItem) && itemMatchCondition(cartItem) &&
(cartItem?.OfferMode !== 'B' && (cartItem?.OfferMode !== 'B' &&
cartItem?.OfferMode !== 'P' && cartItem?.OfferMode !== 'P' && cartItem?.OfferMode !== 'C' &&
cartItem?.OfferMode !== 'O' &&
cartItem?.OfferMode !== 'L' cartItem?.OfferMode !== 'L'
? true ? true
: cartItem?.Offer === 0) : cartItem?.Offer === 0)
@ -2600,7 +2604,7 @@ const BSItemCard = (props) => {
); );
dispatch(changeOfferAppliedProductsForLoyalty(updated)); dispatch(changeOfferAppliedProductsForLoyalty(updated));
dispatch(changeFreeProductForLoyalty(offerList[0])); dispatch(changeFreeProductForLoyalty(offerList[0]));
} else if (offerMode === 'P') { } else if (offerMode === 'P' || offerMode === 'C' || offerMode === 'O') {
const updated = buildOfferFromChangesForPromoCodes( const updated = buildOfferFromChangesForPromoCodes(
PromoCodeOffersDatas?.[0], PromoCodeOffersDatas?.[0],
offerList, offerList,
@ -2722,7 +2726,9 @@ const BSItemCard = (props) => {
const offers = chooseOfferFun(item, cartData); const offers = chooseOfferFun(item, cartData);
if (!offers?.length) { if (!offers?.length) {
const indexToCheck = addFirst ? 0 : cartData.length - 1;
const productToCheck = cartData?.[addFirst ? 0 : cartData?.length - 1]; const productToCheck = cartData?.[addFirst ? 0 : cartData?.length - 1];
let updatedCartData = cartData;
if (productToCheck?.OfferMode && productToCheck?.Offer > 0) { if (productToCheck?.OfferMode && productToCheck?.Offer > 0) {
dispatch( dispatch(
RemoveOfferAppliedProduct({ RemoveOfferAppliedProduct({
@ -2731,6 +2737,19 @@ const BSItemCard = (props) => {
OfferType: productToCheck?.OfferMode, OfferType: productToCheck?.OfferMode,
}) })
); );
updatedCartData = cartData.map((item, idx) =>
idx === indexToCheck
? {
...item,
Offer: null,
OfferMessage: undefined,
OfferMode: undefined,
OfferModeType: false,
OfferType: undefined,
OfferValue: null,
}
: item
);
} }
const { const {
@ -2738,7 +2757,7 @@ const BSItemCard = (props) => {
updatedFreeProdList, updatedFreeProdList,
updatedOfferAppliedProducts, updatedOfferAppliedProducts,
hasChanges, hasChanges,
} = processFreeProducts(cartData, FreeProdList); } = processFreeProducts(updatedCartData, FreeProdList);
if (hasChanges) { if (hasChanges) {
dispatch(changeOrderCardDetails(updatedOrderCardDetails)); dispatch(changeOrderCardDetails(updatedOrderCardDetails));
@ -2777,9 +2796,9 @@ const BSItemCard = (props) => {
const UpdatedCartItemWithOffer = { const UpdatedCartItemWithOffer = {
...item, ...item,
Offer: sameProduct Offer: (sameProduct || bestOffer?.OfferMode === 'I' || bestOffer?.OfferMode === 'Q')
? bestOffer?.OfferAmount || item.Offer ? (bestOffer?.OfferAmount || item.Offer)
: item.Offer || bestOffer?.OfferAmount, : (item.Offer || bestOffer?.OfferAmount),
OfferType: item?.OfferType || bestOffer?.OfferType, OfferType: item?.OfferType || bestOffer?.OfferType,
OfferMessage: item?.OfferMessage || bestOffer?.OfferMessage, OfferMessage: item?.OfferMessage || bestOffer?.OfferMessage,
OfferMode: item?.OfferMode || bestOffer?.OfferMode, OfferMode: item?.OfferMode || bestOffer?.OfferMode,
@ -2794,7 +2813,8 @@ const BSItemCard = (props) => {
((c?.OfferModeType && c?.OfferMode === 'B' ((c?.OfferModeType && c?.OfferMode === 'B'
? true ? true
: c?.OfferMode !== 'B') && : c?.OfferMode !== 'B') &&
c?.OfferMode !== 'P' && c?.OfferMode !== 'P' && c?.OfferMode !== 'C' &&
c?.OfferMode !== 'O' &&
c?.OfferMode !== 'L' c?.OfferMode !== 'L'
? true ? true
: c?.Offer === 0); : c?.Offer === 0);
@ -3400,7 +3420,7 @@ const BSItemCard = (props) => {
); );
// STEP 2: Check if item is a paid product that can be converted to free // STEP 2: Check if item is a paid product that can be converted to free
const availableFreeProduct = availableFreeProdList?.find( const availableFreeProduct = updatedFreeProdList?.find(
(prod) => (prod) =>
prod?.FreeProdId === item?.ProdId && prod?.FreeProdId === item?.ProdId &&
prod?.RemainingQty > 0 && prod?.RemainingQty > 0 &&
@ -3815,7 +3835,7 @@ const BSItemCard = (props) => {
parseInt(totalSelectedProductQty || 0) + parseInt(totalSelectedProductQty || 0) +
parseInt(reorderComboConsumed || 0); parseInt(reorderComboConsumed || 0);
} }
} catch (_) {} } catch (_) { }
let getCurrentProdDtl = orderDetails?.filter( let getCurrentProdDtl = orderDetails?.filter(
(a) => a?.ProdName === ProdName (a) => a?.ProdName === ProdName
); );
@ -4016,7 +4036,7 @@ const BSItemCard = (props) => {
parseInt(totalSelectedProductQty || 0) + parseInt(totalSelectedProductQty || 0) +
parseInt(reorderComboConsumed || 0); parseInt(reorderComboConsumed || 0);
} }
} catch (_) {} } catch (_) { }
let getCurrentProdDtl = orderDetails?.filter((a) => a?.ProdId === ProdId); let getCurrentProdDtl = orderDetails?.filter((a) => a?.ProdId === ProdId);
let totalOrderQty = getCurrentProdDtl?.reduce((accumulator, card) => { let totalOrderQty = getCurrentProdDtl?.reduce((accumulator, card) => {
return ( return (
@ -4052,7 +4072,7 @@ const BSItemCard = (props) => {
}, 0); }, 0);
totalOrderQty = totalOrderQty =
parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0); parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0);
} catch (_) {} } catch (_) { }
let OverallProdQty = totalOrderQty - totalSelectedProductQty; let OverallProdQty = totalOrderQty - totalSelectedProductQty;
if ( if (
parseInt(ItemQuantity) > parseInt(ItemQuantity) >
@ -4138,7 +4158,7 @@ const BSItemCard = (props) => {
parseInt(totalSelectedProductQty || 0) + parseInt(totalSelectedProductQty || 0) +
parseInt(reorderComboConsumed || 0); parseInt(reorderComboConsumed || 0);
} }
} catch (_) {} } catch (_) { }
let getCurrentProdDtl = orderDetails?.filter((a) => a?.ProdId === ProdId); let getCurrentProdDtl = orderDetails?.filter((a) => a?.ProdId === ProdId);
let totalOrderQty = getCurrentProdDtl?.reduce((accumulator, card) => { let totalOrderQty = getCurrentProdDtl?.reduce((accumulator, card) => {
return ( return (
@ -4177,7 +4197,7 @@ const BSItemCard = (props) => {
}, 0); }, 0);
totalOrderQty = totalOrderQty =
parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0); parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0);
} catch (_) {} } catch (_) { }
let OverallProdQty = totalOrderQty - totalSelectedProductQty; let OverallProdQty = totalOrderQty - totalSelectedProductQty;
if ( if (
parseInt(ItemQuantity) > parseInt(ItemQuantity) >
@ -4269,7 +4289,7 @@ const BSItemCard = (props) => {
parseInt(totalSelectedProductQty || 0) + parseInt(totalSelectedProductQty || 0) +
parseInt(reorderComboConsumed || 0); parseInt(reorderComboConsumed || 0);
} }
} catch (_) {} } catch (_) { }
let getCurrentProdDtl = orderDetails?.filter( let getCurrentProdDtl = orderDetails?.filter(
(a) => a?.ProdId === ProdId && a?.InwardDtlId === InwardDtlId (a) => a?.ProdId === ProdId && a?.InwardDtlId === InwardDtlId
); );
@ -4312,7 +4332,7 @@ const BSItemCard = (props) => {
}, 0); }, 0);
totalOrderQty = totalOrderQty =
parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0); parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0);
} catch (_) {} } catch (_) { }
let OverallProdQty = totalOrderQty - totalSelectedProductQty; let OverallProdQty = totalOrderQty - totalSelectedProductQty;
if ( if (
@ -4396,7 +4416,7 @@ const BSItemCard = (props) => {
parseInt(totalSelectedProductQty || 0) + parseInt(totalSelectedProductQty || 0) +
parseInt(reorderComboConsumed || 0); parseInt(reorderComboConsumed || 0);
} }
} catch (_) {} } catch (_) { }
let getCurrentProdDtl = orderDetails?.filter( let getCurrentProdDtl = orderDetails?.filter(
(a) => a?.ProdId === ProdId && a?.InwardDtlId === InwardDtlId (a) => a?.ProdId === ProdId && a?.InwardDtlId === InwardDtlId
); );
@ -4443,7 +4463,7 @@ const BSItemCard = (props) => {
}, 0); }, 0);
totalOrderQty = totalOrderQty =
parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0); parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0);
} catch (_) {} } catch (_) { }
let OverallProdQty = totalOrderQty - totalSelectedProductQty; let OverallProdQty = totalOrderQty - totalSelectedProductQty;
if ( if (

View File

@ -68,12 +68,12 @@ export const useSaleswiseOfferWatcher = () => {
const BOOKING_TYPE = "DineIn"; const BOOKING_TYPE = "DineIn";
// Helper function to create offer payload // Helper function to create offer payload
const createOfferPayload = (offer) => ({ const createOfferPayload = (offer, discount = null) => ({
OfferId: offer.OfferId || "", OfferId: offer.OfferId || "",
OfferAmount: offer.OfferAmt || 0, OfferAmount: discount || offer.OfferAmt || 0,
OfferMode: offer.OfferType, OfferMode: offer.OfferType,
AcuvalOfferAmount: offer.OfferAmt, AcuvalOfferAmount: discount || offer.OfferAmt,
OfferValue: offer.OfferAmt || 0, OfferValue: discount || offer.OfferAmt || 0,
TableName: offer.TableName || "", TableName: offer.TableName || "",
TableUniqueName: offer.TableUniqueName || "", TableUniqueName: offer.TableUniqueName || "",
TableUniqueId: offer.TableUniqueId || "", TableUniqueId: offer.TableUniqueId || "",
@ -117,7 +117,7 @@ export const useSaleswiseOfferWatcher = () => {
console.log("💡 NetAmount:", netAmount); console.log("💡 NetAmount:", netAmount);
console.log("👉 Applying best offer:", bestOffer.offer); console.log("👉 Applying best offer:", bestOffer.offer);
dispatch(ChangeOfferAppliedProducts(createOfferPayload(bestOffer.offer))); dispatch(ChangeOfferAppliedProducts(createOfferPayload(bestOffer.offer, bestOffer?.discount)));
} else { } else {
// Remove any existing sales offers // Remove any existing sales offers
dispatch(RemoveOfferAppliedProduct({ dispatch(RemoveOfferAppliedProduct({

View File

@ -108,9 +108,12 @@ const BSCustomerSelect = ({ TopName = null }) => {
offerOption offerOption
} = useMemo(() => { } = useMemo(() => {
const navbarOptions = layoutData?.BookingNavbar?.[1]; const navbarOptions = layoutData?.BookingNavbar?.[1];
const comboOptions = layoutData?.BookingCombo1?.[1];
return { return {
offerOption: navbarOptions?.find( offerOption: navbarOptions?.find(
(option) => option?.OptionName?.toLowerCase() === 'offer' (option) => option?.OptionName?.toLowerCase() === 'offer'
) || comboOptions?.find(
(option) => option?.OptionName?.toLowerCase() === 'offer'
), ),
}; };
}, [layoutData]); }, [layoutData]);
@ -121,7 +124,7 @@ const BSCustomerSelect = ({ TopName = null }) => {
}, [OrderOfferDetails]); }, [OrderOfferDetails]);
const loyaltyFreeProductsInCart = useMemo(() => { const loyaltyFreeProductsInCart = useMemo(() => {
return OrderOfferDetails?.filter((offer) => offer?.FreeProductsList?.OfferMode === 'L' && offer?.FreeProductsList?.TableUniqueName === "FreeProduct") || []; return OrderOfferDetails?.filter((offer) => (offer?.FreeProductsList?.OfferMode === 'L' || offer?.OfferMode === 'L') && (offer?.FreeProductsList?.TableUniqueName === "FreeProduct" || offer?.TableUniqueName === "FreeProduct")) || [];
}, [OrderOfferDetails]); }, [OrderOfferDetails]);
const filteredLoyaltyFreeProducts = useMemo(() => { const filteredLoyaltyFreeProducts = useMemo(() => {
@ -573,6 +576,23 @@ const BSCustomerSelect = ({ TopName = null }) => {
const updatedOrderOfferDetails = OrderOfferDetails?.filter( const updatedOrderOfferDetails = OrderOfferDetails?.filter(
offer => !(offer?.OfferMode === 'L' && offer?.TableUniqueName === "Cash") offer => !(offer?.OfferMode === 'L' && offer?.TableUniqueName === "Cash")
); );
let updatedOrderCardDetails = OrderCardDetail?.map(item => {
if (item?.OfferMode === 'L') {
return {
...item,
Offer: null,
OfferMessage: undefined,
OfferMode: undefined,
OfferModeType: false,
OfferType: undefined,
OfferValue: null,
}
} else {
return item
}
}) || [];
dispatch(changeOrderCardDetails(updatedOrderCardDetails));
dispatch(changeFullOfferAppliedProducts(updatedOrderOfferDetails)); dispatch(changeFullOfferAppliedProducts(updatedOrderOfferDetails));
setLoyaltyModal(false); setLoyaltyModal(false);
}; };
@ -699,7 +719,19 @@ const BSCustomerSelect = ({ TopName = null }) => {
dispatch(changeOrderCardDetails(updatedOrderCardDetails)); dispatch(changeOrderCardDetails(updatedOrderCardDetails));
setClearPopoverVisible(false); setClearPopoverVisible(false);
dispatch(ChangeFullFreeProductList(freeProductList.filter(item => item.OfferMode !== 'L'))); dispatch(ChangeFullFreeProductList(freeProductList.filter(item => item.OfferMode !== 'L')));
dispatch(changeFullOfferAppliedProducts(OrderOfferDetails?.filter(item => item.OfferMode !== 'L'))); dispatch(changeFullOfferAppliedProducts(OrderOfferDetails?.filter(item => {
// if OfferMode exists and is 'L' remove
if (item?.OfferMode && item.OfferMode === 'L') return false;
// if FreeProductsList OfferMode exists and is 'L' remove
if (
item?.FreeProductsList?.OfferMode &&
item.FreeProductsList.OfferMode === 'L'
)
return false;
return true;
})));
setSelectedProducts([]); setSelectedProducts([]);
setProductQuantities({}); setProductQuantities({});
}; };

View File

@ -83,6 +83,7 @@ import {
changeTipAmount, changeTipAmount,
changeChairLevelServiceDefault, changeChairLevelServiceDefault,
changeDefaultBookingType, changeDefaultBookingType,
getCustomerForHold,
} from '../../Features/BookingScreen/BookingData/BookingData'; } from '../../Features/BookingScreen/BookingData/BookingData';
import { ApplicationPreferences, getBranchDetail } from '../../Features/BrachLogin/BranchLogin'; import { ApplicationPreferences, getBranchDetail } from '../../Features/BrachLogin/BranchLogin';
import '../../Styles/Tablebooking/TableBooking.scss'; import '../../Styles/Tablebooking/TableBooking.scss';
@ -130,6 +131,8 @@ import DiningTableCompass from './Compass.jsx';
import Compass from './Compass.jsx'; import Compass from './Compass.jsx';
import { DropDowns } from "../../Components/Forms/DropDown.jsx"; import { DropDowns } from "../../Components/Forms/DropDown.jsx";
import MergeBill from "./MergeBill/MergeBill.jsx"; import MergeBill from "./MergeBill/MergeBill.jsx";
import { ChangeFullFreeProductList, changeFullOfferAppliedProducts, changeLoyaltyConsumedQuantities } from "../../Features/Offer/Offernew/BookingOffernew.js";
import { v4 as uuidv4 } from 'uuid';
const subDirectory = import.meta.env.BASE_URL; const subDirectory = import.meta.env.BASE_URL;
const MainHomeUrl = import.meta.env.ENV_Main_BASE_URL; const MainHomeUrl = import.meta.env.ENV_Main_BASE_URL;
@ -1038,32 +1041,84 @@ const TableBooking = ({ PaymentStatus }) => {
ExtraChargeDetails, ExtraChargeDetails,
CustSuppId, CustSuppId,
OrderOfferDetails, OrderOfferDetails,
RefDetails,
OrderId
} = OrderDetails; } = OrderDetails;
RefDetails?.[0]?.FreeProdList &&
dispatch(ChangeFullFreeProductList(RefDetails?.[0]?.FreeProdList));
RefDetails?.[0]?.OfferAppliedProductList &&
dispatch(changeFullOfferAppliedProducts(RefDetails?.[0]?.OfferAppliedProductList));
const loyaltyFreeProductOfferApplied =
RefDetails?.[0]?.OfferAppliedProductList?.filter(
(off) =>
off?.FreeProductsList?.OfferMode === 'L' &&
off?.TableUniqueName === 'FreeProduct'
);
const updatedOrderCardDetails = OrderDtlDetails?.map((item) => ({
...item,
Offer: item?.OfferAmt,
localId: uuidv4(),
OfferMode: item?.OfferMode ? item?.OfferMode?.trim() : null,
}));
dispatch(changeOrderType('Reorder')); dispatch(changeOrderType('Reorder'));
dispatch(changeBookingType('Dine In')); dispatch(changeBookingType('Dine In'));
dispatch(changeReorderHoldDetails(OrderDetails)); dispatch(changeReorderHoldDetails(OrderDetails));
dispatch(changeReorderProductDetails(OrderDtlDetails)); dispatch(changeReorderProductDetails(updatedOrderCardDetails));
dispatch(ChangeTotalAmount(ExtraChargeDetails)); dispatch(ChangeTotalAmount(ExtraChargeDetails));
dispatch(changeSelectedTableDetails(OrderDetails?.SalesTableLinkDetails)); dispatch(changeSelectedTableDetails(OrderDetails?.SalesTableLinkDetails));
dispatch(changeOrderCardDetails(OrderDtlDetails)); dispatch(changeOrderCardDetails(updatedOrderCardDetails));
if (CustSuppId) { if (CustSuppId) {
dispatch(changeSelectedCustId(CustSuppId)); dispatch(changeSelectedCustId(CustSuppId));
let res = await dispatch( let res = await dispatch(
getAllCustomer({ CompId: CompId, AppId: AppId, branchId: BranchId }) getCustomerForHold({
CompId: CompId,
AppId: AppId,
branchId: BranchId,
OrderId: OrderId,
})
).unwrap(); ).unwrap();
if (res?.data?.statusCode === 1) { if (res?.data?.statusCode === 1) {
const { CustId, CustName, CustMobile } = res?.data?.data?.find( const { CustId, CustName, CustMobile, LoyaltyPointsDetail, TotalLoyaltyPoints } = res?.data?.data?.find(
(item) => item.CustId === CustSuppId (item) => item.CustId === CustSuppId
); );
const data = { const data = {
CustId: CustId, CustId: CustId,
CustName: CustName, CustName: CustName,
label: CustName, label: CustName ? CustName : CustMobile,
value: CustMobile, value: CustMobile,
LoyaltyPointsDetail: LoyaltyPointsDetail,
TotalLoyaltyPoints: TotalLoyaltyPoints
}; };
dispatch(changeOrderOfferDetail([...OrderOfferDetails])); dispatch(changeOrderOfferDetail([...OrderOfferDetails]));
dispatch(changeSelectedOption(data)); dispatch(changeSelectedOption(data));
dispatch(ChangeSelectedCustDisable(true)); dispatch(ChangeSelectedCustDisable(true));
if (loyaltyFreeProductOfferApplied?.length > 0) {
const loyaltyProdQuantities = {};
loyaltyFreeProductOfferApplied.forEach((off) => {
const freeProdDtls = off?.FreeProductsList;
const freeProdOfferId =
freeProdDtls?.ProdVariantDetails?.[0]?.StockDetails?.[0]
?.ProdOfferId;
const key = [
freeProdDtls?.OfferId,
freeProdDtls?.FreeProdId,
freeProdDtls?.FreeProdVariantName,
freeProdOfferId,
].join('|');
loyaltyProdQuantities[key] = freeProdDtls?.FreeQty || 0;
});
if (Object.keys(loyaltyProdQuantities).length > 0) {
dispatch(changeLoyaltyConsumedQuantities(loyaltyProdQuantities));
}
console.log(loyaltyProdQuantities, 'loyaltyProdQuantities');
}
} else if (res?.data?.statusCode == 0) { } else if (res?.data?.statusCode == 0) {
const OrderOffer = OrderOfferDetails?.filter( const OrderOffer = OrderOfferDetails?.filter(
(fil) => (fil) =>
@ -1072,18 +1127,18 @@ const TableBooking = ({ PaymentStatus }) => {
fil.TableUniqueName === 'UniqueId' fil.TableUniqueName === 'UniqueId'
) )
); );
if (OfferCheckedInSetup && preferenceOffer) { // if (OfferCheckedInSetup && preferenceOffer) {
applyOffer(OrderDtlDetails, OrderOffer); // applyOffer(OrderDtlDetails, OrderOffer);
} else { // } else {
dispatch(changeOrderCardDetails(OrderDtlDetails)); dispatch(changeOrderCardDetails(updatedOrderCardDetails));
} // }
} }
} else { } else {
if (OfferCheckedInSetup && preferenceOffer) { // if (OfferCheckedInSetup && preferenceOffer) {
applyOffer(OrderDtlDetails, OrderOfferDetails); // applyOffer(OrderDtlDetails, OrderOfferDetails);
} else { // } else {
dispatch(changeOrderCardDetails(OrderDtlDetails)); dispatch(changeOrderCardDetails(updatedOrderCardDetails));
} // }
} }
if (SelectedChair?.length > 0) { if (SelectedChair?.length > 0) {