Merge pull request 'added offer for combo sales screen' (#36) from temp/gokul-offer-add-on-sales-sccreen-for-combo into main
Reviewed-on: Pozomind/pozo-retail-app#36
This commit is contained in:
commit
fadf942865
|
|
@ -89,7 +89,9 @@ const BSBillingEditQuantity = (props) => {
|
|||
const templateData = useSelector(getTemplateData);
|
||||
const OfferCheckedInSetup = templateData?.BookingNavbar?.[1].some(
|
||||
(item) => item?.OptionName == 'Offer'
|
||||
);
|
||||
) || (templateData?.BookingCombo1?.[1]?.some(
|
||||
(item) => item?.OptionName == 'Offer'
|
||||
));
|
||||
const [ClearQuantity, setClearQuantity] = useState(false);
|
||||
const CartOrderDetails = useSelector(GlobalOrderCardDetails);
|
||||
const SettingDataSelector = useSelector(PreferenceData);
|
||||
|
|
@ -3156,7 +3158,9 @@ const BSBillingEditQuantity = (props) => {
|
|||
|
||||
const UpdatedCartItemWithOffer = {
|
||||
...updatedProduct,
|
||||
Offer: updatedProduct.Offer || bestOffer?.OfferAmount,
|
||||
Offer: (bestOffer?.OfferMode === 'I' || bestOffer?.OfferMode === 'Q') ?
|
||||
bestOffer?.OfferAmount || updatedProduct.Offer :
|
||||
updatedProduct.Offer || bestOffer?.OfferAmount,
|
||||
OfferType: updatedProduct?.OfferType || bestOffer?.OfferType,
|
||||
OfferMessage: updatedProduct?.OfferMessage || bestOffer?.OfferMessage,
|
||||
};
|
||||
|
|
@ -3169,7 +3173,12 @@ const BSBillingEditQuantity = (props) => {
|
|||
c.OrderRate === updatedProduct.OrderRate &&
|
||||
c.BookingTypeName === updatedProduct.BookingTypeName &&
|
||||
!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
|
||||
: c?.Offer === 0);
|
||||
|
||||
|
|
|
|||
|
|
@ -2270,9 +2270,12 @@ const ComboSalesBillTable = () => {
|
|||
className="discPerTd"
|
||||
onClick={() => editField && handleEditQuantity(row)}
|
||||
>
|
||||
{row?.OfferType === 'F'
|
||||
? `₹${row.Offer}`
|
||||
: `${row.Offer || '-'}`}
|
||||
{row?.Offer > 0
|
||||
? `${(
|
||||
(row.Offer / (row?.OrderQty * row?.OrderRate)) *
|
||||
100
|
||||
).toFixed(2)}%`
|
||||
: '-'}
|
||||
</td>
|
||||
)}
|
||||
|
||||
|
|
@ -2283,7 +2286,7 @@ const ComboSalesBillTable = () => {
|
|||
className="discAmtTd"
|
||||
onClick={() => editField && handleEditQuantity(row)}
|
||||
>
|
||||
{row.discAmt || '-'}
|
||||
{row.Offer || '-'}
|
||||
</td>
|
||||
)}
|
||||
|
||||
|
|
|
|||
|
|
@ -230,6 +230,8 @@ import CardPopover from '../BSBillingTables/StandardTable/Utils/CardPopover.jsx'
|
|||
import UpiPopover from '../BSBillingTables/StandardTable/Utils/UpiPopOver.jsx';
|
||||
import { useDateStore } from '../../../../Features/BookingScreen/BookingData/DateStore.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 MainHomeUrl = import.meta.env.ENV_MAIN_BASE_URL;
|
||||
|
|
@ -449,6 +451,7 @@ const BSC1Payment = (props) => {
|
|||
const [OpenFailData, SetOpenFailData] = useState(false);
|
||||
const [paymentfeataddon, setpaymentfeataddon] = useState(false);
|
||||
const [isFloatMenuOpen, setIsFloatMenuOpen] = useState(false);
|
||||
const Discount = useSelector(GlobalOverAllOfferAmt);
|
||||
const OverAllSales = useSelector(GlobalOverAllDiscSales);
|
||||
const OverAllEstimate = useSelector(GlobalOverAllDiscEstimate);
|
||||
const [blink, setBlink] = useState(false);
|
||||
|
|
@ -475,6 +478,8 @@ const BSC1Payment = (props) => {
|
|||
// for customised invoice number
|
||||
const { invoiceDate, clearInvoiceDate } = useDateStore();
|
||||
const CurrentOrderId = useSelector(GlobalCurrentOrderId);
|
||||
const FreeProdList = useSelector(GlobalFreeProdList);
|
||||
const offerAppliedProducts = useSelector(GlobalOfferAppliedProducts);
|
||||
|
||||
console.log(BSComboData, 'BSComboData');
|
||||
const canHold =
|
||||
|
|
@ -619,7 +624,9 @@ const BSC1Payment = (props) => {
|
|||
}
|
||||
|
||||
let withdiscTotal =
|
||||
Total - ((OverAllSales || 0) + (OverAllEstimate || 0));
|
||||
Total - ((OverAllSales || 0) + (OverAllEstimate || 0) +
|
||||
(Discount > 0 ? Discount : 0));
|
||||
|
||||
|
||||
setTotalAmount(
|
||||
withdiscTotal >= 0
|
||||
|
|
@ -651,6 +658,7 @@ const BSC1Payment = (props) => {
|
|||
OverAllEstimate,
|
||||
globalTipAmount,
|
||||
OtherServiceTicketClaim,
|
||||
Discount
|
||||
]);
|
||||
useEffect(() => {
|
||||
let data = {
|
||||
|
|
@ -1983,9 +1991,11 @@ const BSC1Payment = (props) => {
|
|||
: 'S',
|
||||
SinglePc: a.SinglePc,
|
||||
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,
|
||||
OfferType: a?.Type === 'C' ? a?.OfferType : '',
|
||||
OfferMode: a?.OfferMode,
|
||||
OfferMessage: a?.OfferMessage,
|
||||
CounterName: a?.TokenAvailable === 'Y' ? a?.CounterName : null,
|
||||
ProductIdentifierDtls: a.ProductIdentifierDtls,
|
||||
ModelNumber: a.ModelNumber,
|
||||
|
|
@ -1995,9 +2005,9 @@ const BSC1Payment = (props) => {
|
|||
const NotSlectedTypeFind = temporderdetail?.find(
|
||||
(a) => a?.BookingType != SelectedBookingType
|
||||
);
|
||||
let updatedOfferDetails = OrderOfferDetail;
|
||||
let updatedOfferDetails = offerAppliedProducts;
|
||||
if (GlobEstBooking !== 'Sales') {
|
||||
updatedOfferDetails = OrderOfferDetail?.filter(
|
||||
updatedOfferDetails = offerAppliedProducts?.filter(
|
||||
(item) =>
|
||||
!(
|
||||
item.TableName === 'LoyaltyPoints' &&
|
||||
|
|
@ -2148,6 +2158,12 @@ const BSC1Payment = (props) => {
|
|||
},
|
||||
],
|
||||
OrderOfferDetail: updatedOfferDetails,
|
||||
RefDetails: [
|
||||
{
|
||||
FreeProdList: FreeProdList,
|
||||
OfferAppliedProductList: offerAppliedProducts,
|
||||
},
|
||||
],
|
||||
};
|
||||
let PostData = temppostdata;
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -2422,7 +2422,8 @@ const BSItemCard = (props) => {
|
|||
((cartItem?.OfferModeType && cartItem?.OfferMode === 'B'
|
||||
? true
|
||||
: cartItem?.OfferMode !== 'B') &&
|
||||
cartItem?.OfferMode !== 'P' &&
|
||||
cartItem?.OfferMode !== 'P' && cartItem?.OfferMode !== 'C' &&
|
||||
cartItem?.OfferMode !== 'O' &&
|
||||
cartItem?.OfferMode !== 'L'
|
||||
? true
|
||||
: cartItem?.Offer === 0)
|
||||
|
|
@ -2432,7 +2433,8 @@ const BSItemCard = (props) => {
|
|||
(cartItem) =>
|
||||
itemMatchCondition(cartItem) &&
|
||||
(cartItem?.OfferMode !== 'B' &&
|
||||
cartItem?.OfferMode !== 'P' &&
|
||||
cartItem?.OfferMode !== 'P' && cartItem?.OfferMode !== 'C' &&
|
||||
cartItem?.OfferMode !== 'O' &&
|
||||
cartItem?.OfferMode !== 'L'
|
||||
? true
|
||||
: cartItem?.Offer === 0)
|
||||
|
|
@ -2447,7 +2449,8 @@ const BSItemCard = (props) => {
|
|||
((cartItem?.OfferModeType && cartItem?.OfferMode === 'B'
|
||||
? true
|
||||
: cartItem?.OfferMode !== 'B') &&
|
||||
cartItem?.OfferMode !== 'P' &&
|
||||
cartItem?.OfferMode !== 'P' && cartItem?.OfferMode !== 'C' &&
|
||||
cartItem?.OfferMode !== 'O' &&
|
||||
cartItem?.OfferMode !== 'L'
|
||||
? true
|
||||
: cartItem?.Offer === 0)
|
||||
|
|
@ -2459,7 +2462,8 @@ const BSItemCard = (props) => {
|
|||
!(
|
||||
itemMatchCondition(cartItem) &&
|
||||
(cartItem?.OfferMode !== 'B' &&
|
||||
cartItem?.OfferMode !== 'P' &&
|
||||
cartItem?.OfferMode !== 'P' && cartItem?.OfferMode !== 'C' &&
|
||||
cartItem?.OfferMode !== 'O' &&
|
||||
cartItem?.OfferMode !== 'L'
|
||||
? true
|
||||
: cartItem?.Offer === 0)
|
||||
|
|
@ -2600,7 +2604,7 @@ const BSItemCard = (props) => {
|
|||
);
|
||||
dispatch(changeOfferAppliedProductsForLoyalty(updated));
|
||||
dispatch(changeFreeProductForLoyalty(offerList[0]));
|
||||
} else if (offerMode === 'P') {
|
||||
} else if (offerMode === 'P' || offerMode === 'C' || offerMode === 'O') {
|
||||
const updated = buildOfferFromChangesForPromoCodes(
|
||||
PromoCodeOffersDatas?.[0],
|
||||
offerList,
|
||||
|
|
@ -2722,7 +2726,9 @@ const BSItemCard = (props) => {
|
|||
const offers = chooseOfferFun(item, cartData);
|
||||
|
||||
if (!offers?.length) {
|
||||
const indexToCheck = addFirst ? 0 : cartData.length - 1;
|
||||
const productToCheck = cartData?.[addFirst ? 0 : cartData?.length - 1];
|
||||
let updatedCartData = cartData;
|
||||
if (productToCheck?.OfferMode && productToCheck?.Offer > 0) {
|
||||
dispatch(
|
||||
RemoveOfferAppliedProduct({
|
||||
|
|
@ -2731,6 +2737,19 @@ const BSItemCard = (props) => {
|
|||
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 {
|
||||
|
|
@ -2738,7 +2757,7 @@ const BSItemCard = (props) => {
|
|||
updatedFreeProdList,
|
||||
updatedOfferAppliedProducts,
|
||||
hasChanges,
|
||||
} = processFreeProducts(cartData, FreeProdList);
|
||||
} = processFreeProducts(updatedCartData, FreeProdList);
|
||||
|
||||
if (hasChanges) {
|
||||
dispatch(changeOrderCardDetails(updatedOrderCardDetails));
|
||||
|
|
@ -2777,9 +2796,9 @@ const BSItemCard = (props) => {
|
|||
|
||||
const UpdatedCartItemWithOffer = {
|
||||
...item,
|
||||
Offer: sameProduct
|
||||
? bestOffer?.OfferAmount || item.Offer
|
||||
: item.Offer || bestOffer?.OfferAmount,
|
||||
Offer: (sameProduct || bestOffer?.OfferMode === 'I' || bestOffer?.OfferMode === 'Q')
|
||||
? (bestOffer?.OfferAmount || item.Offer)
|
||||
: (item.Offer || bestOffer?.OfferAmount),
|
||||
OfferType: item?.OfferType || bestOffer?.OfferType,
|
||||
OfferMessage: item?.OfferMessage || bestOffer?.OfferMessage,
|
||||
OfferMode: item?.OfferMode || bestOffer?.OfferMode,
|
||||
|
|
@ -2794,7 +2813,8 @@ const BSItemCard = (props) => {
|
|||
((c?.OfferModeType && c?.OfferMode === 'B'
|
||||
? true
|
||||
: c?.OfferMode !== 'B') &&
|
||||
c?.OfferMode !== 'P' &&
|
||||
c?.OfferMode !== 'P' && c?.OfferMode !== 'C' &&
|
||||
c?.OfferMode !== 'O' &&
|
||||
c?.OfferMode !== 'L'
|
||||
? true
|
||||
: 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
|
||||
const availableFreeProduct = availableFreeProdList?.find(
|
||||
const availableFreeProduct = updatedFreeProdList?.find(
|
||||
(prod) =>
|
||||
prod?.FreeProdId === item?.ProdId &&
|
||||
prod?.RemainingQty > 0 &&
|
||||
|
|
@ -3815,7 +3835,7 @@ const BSItemCard = (props) => {
|
|||
parseInt(totalSelectedProductQty || 0) +
|
||||
parseInt(reorderComboConsumed || 0);
|
||||
}
|
||||
} catch (_) {}
|
||||
} catch (_) { }
|
||||
let getCurrentProdDtl = orderDetails?.filter(
|
||||
(a) => a?.ProdName === ProdName
|
||||
);
|
||||
|
|
@ -4016,7 +4036,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 (
|
||||
|
|
@ -4052,7 +4072,7 @@ const BSItemCard = (props) => {
|
|||
}, 0);
|
||||
totalOrderQty =
|
||||
parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0);
|
||||
} catch (_) {}
|
||||
} catch (_) { }
|
||||
let OverallProdQty = totalOrderQty - totalSelectedProductQty;
|
||||
if (
|
||||
parseInt(ItemQuantity) >
|
||||
|
|
@ -4138,7 +4158,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 (
|
||||
|
|
@ -4177,7 +4197,7 @@ const BSItemCard = (props) => {
|
|||
}, 0);
|
||||
totalOrderQty =
|
||||
parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0);
|
||||
} catch (_) {}
|
||||
} catch (_) { }
|
||||
let OverallProdQty = totalOrderQty - totalSelectedProductQty;
|
||||
if (
|
||||
parseInt(ItemQuantity) >
|
||||
|
|
@ -4269,7 +4289,7 @@ const BSItemCard = (props) => {
|
|||
parseInt(totalSelectedProductQty || 0) +
|
||||
parseInt(reorderComboConsumed || 0);
|
||||
}
|
||||
} catch (_) {}
|
||||
} catch (_) { }
|
||||
let getCurrentProdDtl = orderDetails?.filter(
|
||||
(a) => a?.ProdId === ProdId && a?.InwardDtlId === InwardDtlId
|
||||
);
|
||||
|
|
@ -4312,7 +4332,7 @@ const BSItemCard = (props) => {
|
|||
}, 0);
|
||||
totalOrderQty =
|
||||
parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0);
|
||||
} catch (_) {}
|
||||
} catch (_) { }
|
||||
|
||||
let OverallProdQty = totalOrderQty - totalSelectedProductQty;
|
||||
if (
|
||||
|
|
@ -4396,7 +4416,7 @@ const BSItemCard = (props) => {
|
|||
parseInt(totalSelectedProductQty || 0) +
|
||||
parseInt(reorderComboConsumed || 0);
|
||||
}
|
||||
} catch (_) {}
|
||||
} catch (_) { }
|
||||
let getCurrentProdDtl = orderDetails?.filter(
|
||||
(a) => a?.ProdId === ProdId && a?.InwardDtlId === InwardDtlId
|
||||
);
|
||||
|
|
@ -4443,7 +4463,7 @@ const BSItemCard = (props) => {
|
|||
}, 0);
|
||||
totalOrderQty =
|
||||
parseInt(totalOrderQty || 0) + parseInt(comboConsumed || 0);
|
||||
} catch (_) {}
|
||||
} catch (_) { }
|
||||
|
||||
let OverallProdQty = totalOrderQty - totalSelectedProductQty;
|
||||
if (
|
||||
|
|
|
|||
|
|
@ -68,12 +68,12 @@ export const useSaleswiseOfferWatcher = () => {
|
|||
const BOOKING_TYPE = "DineIn";
|
||||
|
||||
// Helper function to create offer payload
|
||||
const createOfferPayload = (offer) => ({
|
||||
const createOfferPayload = (offer, discount = null) => ({
|
||||
OfferId: offer.OfferId || "",
|
||||
OfferAmount: offer.OfferAmt || 0,
|
||||
OfferAmount: discount || offer.OfferAmt || 0,
|
||||
OfferMode: offer.OfferType,
|
||||
AcuvalOfferAmount: offer.OfferAmt,
|
||||
OfferValue: offer.OfferAmt || 0,
|
||||
AcuvalOfferAmount: discount || offer.OfferAmt,
|
||||
OfferValue: discount || offer.OfferAmt || 0,
|
||||
TableName: offer.TableName || "",
|
||||
TableUniqueName: offer.TableUniqueName || "",
|
||||
TableUniqueId: offer.TableUniqueId || "",
|
||||
|
|
@ -117,7 +117,7 @@ export const useSaleswiseOfferWatcher = () => {
|
|||
console.log("💡 NetAmount:", netAmount);
|
||||
console.log("👉 Applying best offer:", bestOffer.offer);
|
||||
|
||||
dispatch(ChangeOfferAppliedProducts(createOfferPayload(bestOffer.offer)));
|
||||
dispatch(ChangeOfferAppliedProducts(createOfferPayload(bestOffer.offer, bestOffer?.discount)));
|
||||
} else {
|
||||
// Remove any existing sales offers
|
||||
dispatch(RemoveOfferAppliedProduct({
|
||||
|
|
|
|||
|
|
@ -108,9 +108,12 @@ const BSCustomerSelect = ({ TopName = null }) => {
|
|||
offerOption
|
||||
} = useMemo(() => {
|
||||
const navbarOptions = layoutData?.BookingNavbar?.[1];
|
||||
const comboOptions = layoutData?.BookingCombo1?.[1];
|
||||
return {
|
||||
offerOption: navbarOptions?.find(
|
||||
(option) => option?.OptionName?.toLowerCase() === 'offer'
|
||||
) || comboOptions?.find(
|
||||
(option) => option?.OptionName?.toLowerCase() === 'offer'
|
||||
),
|
||||
};
|
||||
}, [layoutData]);
|
||||
|
|
@ -121,7 +124,7 @@ const BSCustomerSelect = ({ TopName = null }) => {
|
|||
}, [OrderOfferDetails]);
|
||||
|
||||
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]);
|
||||
|
||||
const filteredLoyaltyFreeProducts = useMemo(() => {
|
||||
|
|
@ -573,6 +576,23 @@ const BSCustomerSelect = ({ TopName = null }) => {
|
|||
const updatedOrderOfferDetails = OrderOfferDetails?.filter(
|
||||
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));
|
||||
setLoyaltyModal(false);
|
||||
};
|
||||
|
|
@ -699,7 +719,19 @@ const BSCustomerSelect = ({ TopName = null }) => {
|
|||
dispatch(changeOrderCardDetails(updatedOrderCardDetails));
|
||||
setClearPopoverVisible(false);
|
||||
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([]);
|
||||
setProductQuantities({});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ import {
|
|||
changeTipAmount,
|
||||
changeChairLevelServiceDefault,
|
||||
changeDefaultBookingType,
|
||||
getCustomerForHold,
|
||||
} from '../../Features/BookingScreen/BookingData/BookingData';
|
||||
import { ApplicationPreferences, getBranchDetail } from '../../Features/BrachLogin/BranchLogin';
|
||||
import '../../Styles/Tablebooking/TableBooking.scss';
|
||||
|
|
@ -130,6 +131,8 @@ import DiningTableCompass from './Compass.jsx';
|
|||
import Compass from './Compass.jsx';
|
||||
import { DropDowns } from "../../Components/Forms/DropDown.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 MainHomeUrl = import.meta.env.ENV_Main_BASE_URL;
|
||||
|
|
@ -1038,32 +1041,84 @@ const TableBooking = ({ PaymentStatus }) => {
|
|||
ExtraChargeDetails,
|
||||
CustSuppId,
|
||||
OrderOfferDetails,
|
||||
RefDetails,
|
||||
OrderId
|
||||
} = 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(changeBookingType('Dine In'));
|
||||
dispatch(changeReorderHoldDetails(OrderDetails));
|
||||
dispatch(changeReorderProductDetails(OrderDtlDetails));
|
||||
dispatch(changeReorderProductDetails(updatedOrderCardDetails));
|
||||
dispatch(ChangeTotalAmount(ExtraChargeDetails));
|
||||
dispatch(changeSelectedTableDetails(OrderDetails?.SalesTableLinkDetails));
|
||||
dispatch(changeOrderCardDetails(OrderDtlDetails));
|
||||
dispatch(changeOrderCardDetails(updatedOrderCardDetails));
|
||||
if (CustSuppId) {
|
||||
dispatch(changeSelectedCustId(CustSuppId));
|
||||
let res = await dispatch(
|
||||
getAllCustomer({ CompId: CompId, AppId: AppId, branchId: BranchId })
|
||||
getCustomerForHold({
|
||||
CompId: CompId,
|
||||
AppId: AppId,
|
||||
branchId: BranchId,
|
||||
OrderId: OrderId,
|
||||
})
|
||||
).unwrap();
|
||||
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
|
||||
);
|
||||
const data = {
|
||||
CustId: CustId,
|
||||
CustName: CustName,
|
||||
label: CustName,
|
||||
label: CustName ? CustName : CustMobile,
|
||||
value: CustMobile,
|
||||
LoyaltyPointsDetail: LoyaltyPointsDetail,
|
||||
TotalLoyaltyPoints: TotalLoyaltyPoints
|
||||
};
|
||||
dispatch(changeOrderOfferDetail([...OrderOfferDetails]));
|
||||
dispatch(changeSelectedOption(data));
|
||||
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) {
|
||||
const OrderOffer = OrderOfferDetails?.filter(
|
||||
(fil) =>
|
||||
|
|
@ -1072,18 +1127,18 @@ const TableBooking = ({ PaymentStatus }) => {
|
|||
fil.TableUniqueName === 'UniqueId'
|
||||
)
|
||||
);
|
||||
if (OfferCheckedInSetup && preferenceOffer) {
|
||||
applyOffer(OrderDtlDetails, OrderOffer);
|
||||
} else {
|
||||
dispatch(changeOrderCardDetails(OrderDtlDetails));
|
||||
}
|
||||
// if (OfferCheckedInSetup && preferenceOffer) {
|
||||
// applyOffer(OrderDtlDetails, OrderOffer);
|
||||
// } else {
|
||||
dispatch(changeOrderCardDetails(updatedOrderCardDetails));
|
||||
// }
|
||||
}
|
||||
} else {
|
||||
if (OfferCheckedInSetup && preferenceOffer) {
|
||||
applyOffer(OrderDtlDetails, OrderOfferDetails);
|
||||
} else {
|
||||
dispatch(changeOrderCardDetails(OrderDtlDetails));
|
||||
}
|
||||
// if (OfferCheckedInSetup && preferenceOffer) {
|
||||
// applyOffer(OrderDtlDetails, OrderOfferDetails);
|
||||
// } else {
|
||||
dispatch(changeOrderCardDetails(updatedOrderCardDetails));
|
||||
// }
|
||||
}
|
||||
|
||||
if (SelectedChair?.length > 0) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue