Merge pull request 'same product offer message display' (#312) from bug-fix-260326 into main

Reviewed-on: Pozomind/pozo-retail-app#312
This commit is contained in:
karthikalakshmi 2026-03-26 10:01:33 +05:30
commit 5c4f867a4a
3 changed files with 412 additions and 344 deletions

View File

@ -54,7 +54,7 @@ const BSBillingEditQuantity = (props) => {
const quantityInputRef = useRef(null);
const priceChangeInputRef = useRef(null);
const reductionInputRef = useRef(null);
const { setIndex = () => {} } = props;
const { setIndex = () => { } } = props;
const [disableSubmitButton, setDisableSubmitButton] = useState(false);
console.log(disableSubmitButton, 'disableSubmitButton');
@ -522,7 +522,15 @@ const BSBillingEditQuantity = (props) => {
cartItem?.InwardDtlId === editedProduct?.InwardDtlId &&
cartItem?.OrderRate === editedProduct?.OrderRate &&
cartItem?.BookingTypeName === editedProduct?.BookingTypeName &&
!cartItem?.SalesId
!cartItem?.SalesId && ((cartItem?.OfferModeType && cartItem?.OfferMode === 'B'
? true
: cartItem?.OfferMode !== 'B') &&
cartItem?.OfferMode !== 'P' &&
cartItem?.OfferMode !== 'C' &&
cartItem?.OfferMode !== 'O' &&
cartItem?.OfferMode !== 'L'
? true
: cartItem?.Offer === 0)
);
// changing for one piece stock checking
const isItemInCartfilter = CartOrderDetails?.filter(
@ -530,7 +538,15 @@ const BSBillingEditQuantity = (props) => {
cartItem?.ProdId === editedProduct?.ProdId &&
cartItem?.InwardDtlId === editedProduct?.InwardDtlId &&
cartItem?.OrderRate !== editedProduct?.OrderRate &&
!cartItem?.SalesId
!cartItem?.SalesId && ((cartItem?.OfferModeType && cartItem?.OfferMode === 'B'
? true
: cartItem?.OfferMode !== 'B') &&
cartItem?.OfferMode !== 'P' &&
cartItem?.OfferMode !== 'C' &&
cartItem?.OfferMode !== 'O' &&
cartItem?.OfferMode !== 'L'
? true
: cartItem?.Offer === 0)
);
const isItemInCartHold = CartOrderDetails?.find(
@ -538,7 +554,15 @@ const BSBillingEditQuantity = (props) => {
cartItem?.ProdId === editedProduct?.ProdId &&
cartItem?.InwardDtlId === editedProduct.InwardDtlId &&
cartItem?.OrderRate === editedProduct?.OrderRate &&
cartItem?.BookingTypeName === editedProduct?.BookingTypeName
cartItem?.BookingTypeName === editedProduct?.BookingTypeName && ((cartItem?.OfferModeType && cartItem?.OfferMode === 'B'
? true
: cartItem?.OfferMode !== 'B') &&
cartItem?.OfferMode !== 'P' &&
cartItem?.OfferMode !== 'C' &&
cartItem?.OfferMode !== 'O' &&
cartItem?.OfferMode !== 'L'
? true
: cartItem?.Offer === 0)
); // check if the item is already in the cart
const isItemInCartHoldfilter = CartOrderDetails?.filter(
(cartItem) =>
@ -547,7 +571,15 @@ const BSBillingEditQuantity = (props) => {
!(
(cartItem?.OrderRate === editedProduct?.OrderRate)
// && cartItem?.BookingTypeName === editedProduct?.BookingTypeName
)
) && ((cartItem?.OfferModeType && cartItem?.OfferMode === 'B'
? true
: cartItem?.OfferMode !== 'B') &&
cartItem?.OfferMode !== 'P' &&
cartItem?.OfferMode !== 'C' &&
cartItem?.OfferMode !== 'O' &&
cartItem?.OfferMode !== 'L'
? true
: cartItem?.Offer === 0)
);
if (
@ -809,7 +841,7 @@ const BSBillingEditQuantity = (props) => {
return (
cartItem?.InwardDtlId === editedProduct?.InwardDtlId &&
cartItem?.OfferMessage?.[0]?.OfferId ===
editedProduct?.OfferMessage?.[0]?.OfferId &&
editedProduct?.OfferMessage?.[0]?.OfferId &&
cartItem?.OfferMode === editedProduct?.OfferMode &&
cartItem?.BookingTypeName !== editedProduct?.BookingTypeName
);
@ -943,7 +975,7 @@ const BSBillingEditQuantity = (props) => {
cartItem?.InwardDtlId === editedProduct?.InwardDtlId &&
cartItem?.OrderRate === editedProduct?.OrderRate &&
cartItem?.BookingTypeName !==
editedProduct?.BookingTypeName &&
editedProduct?.BookingTypeName &&
!cartItem?.OfferMode &&
cartItem?.Offer === 0
);
@ -957,7 +989,7 @@ const BSBillingEditQuantity = (props) => {
cartItem?.InwardDtlId === editedProduct?.InwardDtlId &&
cartItem?.OrderRate === editedProduct?.OrderRate &&
cartItem?.BookingTypeName !==
editedProduct?.BookingTypeName &&
editedProduct?.BookingTypeName &&
cartItem?.OfferMode === editedProduct?.OfferMode &&
cartItem?.Offer > 0
);
@ -1090,7 +1122,7 @@ const BSBillingEditQuantity = (props) => {
)
) &&
product?.OfferId ===
editedProduct?.OfferMessage?.[0]?.OfferId &&
editedProduct?.OfferMessage?.[0]?.OfferId &&
product?.OfferMode === editedProduct?.OfferMode
) {
const freeQty =
@ -1123,7 +1155,7 @@ const BSBillingEditQuantity = (props) => {
// Also check main offer conditions
const isMatchingOffer =
offerProduct?.OfferId ===
editedProduct?.OfferMessage?.[0]?.OfferId &&
editedProduct?.OfferMessage?.[0]?.OfferId &&
offerProduct?.OfferMode === editedProduct?.OfferMode;
if (hasMatchingFreeProduct && isMatchingOffer) {
@ -1206,7 +1238,7 @@ const BSBillingEditQuantity = (props) => {
)
) &&
product?.OfferId ===
editedProduct?.OfferMessage?.[0]?.OfferId &&
editedProduct?.OfferMessage?.[0]?.OfferId &&
product?.OfferMode === editedProduct?.OfferMode
) {
return {
@ -1236,7 +1268,7 @@ const BSBillingEditQuantity = (props) => {
// Also check main offer conditions
const isMatchingOffer =
offerProduct?.OfferId ===
editedProduct?.OfferMessage?.[0]?.OfferId &&
editedProduct?.OfferMessage?.[0]?.OfferId &&
offerProduct?.OfferMode === editedProduct?.OfferMode;
if (hasMatchingFreeProduct && isMatchingOffer) {
@ -1423,7 +1455,7 @@ const BSBillingEditQuantity = (props) => {
// Also check main offer conditions
const isMatchingOffer =
offerProduct?.OfferId ===
editedProduct?.OfferMessage?.[0]?.OfferId &&
editedProduct?.OfferMessage?.[0]?.OfferId &&
offerProduct?.OfferMode === editedProduct?.OfferMode;
if (hasMatchingFreeProduct && isMatchingOffer) {
@ -1525,7 +1557,7 @@ const BSBillingEditQuantity = (props) => {
// Also check main offer conditions
const isMatchingOffer =
offerProduct?.OfferId ===
editedProduct?.OfferMessage?.[0]?.OfferId &&
editedProduct?.OfferMessage?.[0]?.OfferId &&
offerProduct?.OfferMode === editedProduct?.OfferMode;
if (hasMatchingFreeProduct && isMatchingOffer) {
@ -1679,7 +1711,7 @@ const BSBillingEditQuantity = (props) => {
) &&
cartItem?.Offer &&
isFreeProductApplicable?.OfferId ===
cartItem?.OfferMessage?.[0]?.OfferId
cartItem?.OfferMessage?.[0]?.OfferId
);
}
);
@ -1968,11 +2000,11 @@ const BSBillingEditQuantity = (props) => {
product?.ProdId === editedProduct?.ProdId &&
product?.InwardDtlId === editedProduct?.InwardDtlId &&
product?.OfferId ===
(sameBookingTypeProduct?.OfferMessage?.[0]?.OfferId ||
otherBookingTypeProduct?.OfferMessage?.[0]?.OfferId) &&
(sameBookingTypeProduct?.OfferMessage?.[0]?.OfferId ||
otherBookingTypeProduct?.OfferMessage?.[0]?.OfferId) &&
product?.OfferMode ===
(sameBookingTypeProduct?.OfferMode ||
otherBookingTypeProduct?.OfferMode)
(sameBookingTypeProduct?.OfferMode ||
otherBookingTypeProduct?.OfferMode)
) {
return {
...product,
@ -2006,11 +2038,11 @@ const BSBillingEditQuantity = (props) => {
// Also check main offer conditions
const isMatchingOffer =
offerProduct?.OfferId ===
(sameBookingTypeProduct?.OfferMessage?.[0]?.OfferId ||
otherBookingTypeProduct?.OfferMessage?.[0]?.OfferId) &&
(sameBookingTypeProduct?.OfferMessage?.[0]?.OfferId ||
otherBookingTypeProduct?.OfferMessage?.[0]?.OfferId) &&
offerProduct?.OfferMode ===
(sameBookingTypeProduct?.OfferMode ||
otherBookingTypeProduct?.OfferMode);
(sameBookingTypeProduct?.OfferMode ||
otherBookingTypeProduct?.OfferMode);
if (hasMatchingFreeProduct && isMatchingOffer) {
// Get loyalty points from the matching free product
@ -2151,7 +2183,7 @@ const BSBillingEditQuantity = (props) => {
cartItem?.Offer > 0 &&
isFreeProductApplicable?.OfferMode === cartItem?.OfferMode &&
isFreeProductApplicable?.OfferId ===
cartItem?.OfferMessage?.[0]?.OfferId
cartItem?.OfferMessage?.[0]?.OfferId
);
}
);
@ -2254,11 +2286,11 @@ const BSBillingEditQuantity = (props) => {
if (
cartItem.ProdId === otherBookingTypeProduct.ProdId &&
cartItem.InwardDtlId ===
otherBookingTypeProduct.InwardDtlId &&
otherBookingTypeProduct.InwardDtlId &&
cartItem.BookingTypeName ===
otherBookingTypeProduct.BookingTypeName &&
otherBookingTypeProduct.BookingTypeName &&
cartItem.OrderRate ===
otherBookingTypeProduct.OrderRate &&
otherBookingTypeProduct.OrderRate &&
cartItem.OfferMode &&
cartItem.Offer > 0
) {
@ -2329,12 +2361,12 @@ const BSBillingEditQuantity = (props) => {
product?.ProdId === editedProduct?.ProdId &&
product?.InwardDtlId === editedProduct?.InwardDtlId &&
product?.OfferId ===
(sameBookingTypeFreeProduct?.OfferMessage?.[0]?.OfferId ||
otherBookingTypeFreeProduct?.OfferMessage?.[0]
?.OfferId) &&
(sameBookingTypeFreeProduct?.OfferMessage?.[0]?.OfferId ||
otherBookingTypeFreeProduct?.OfferMessage?.[0]
?.OfferId) &&
product?.OfferMode ===
(sameBookingTypeFreeProduct?.OfferMode ||
otherBookingTypeFreeProduct?.OfferMode)
(sameBookingTypeFreeProduct?.OfferMode ||
otherBookingTypeFreeProduct?.OfferMode)
) {
return {
...product,
@ -2368,13 +2400,13 @@ const BSBillingEditQuantity = (props) => {
// Also check main offer conditions
const isMatchingOffer =
offerProduct?.OfferId ===
(sameBookingTypeFreeProduct?.OfferMessage?.[0]
?.OfferId ||
otherBookingTypeFreeProduct?.OfferMessage?.[0]
?.OfferId) &&
(sameBookingTypeFreeProduct?.OfferMessage?.[0]
?.OfferId ||
otherBookingTypeFreeProduct?.OfferMessage?.[0]
?.OfferId) &&
offerProduct?.OfferMode ===
(sameBookingTypeFreeProduct?.OfferMode ||
otherBookingTypeFreeProduct?.OfferMode);
(sameBookingTypeFreeProduct?.OfferMode ||
otherBookingTypeFreeProduct?.OfferMode);
if (hasMatchingFreeProduct && isMatchingOffer) {
// Get loyalty points from the matching free product
@ -2456,11 +2488,11 @@ const BSBillingEditQuantity = (props) => {
if (
cartItem.ProdId === sameBookingTypeProduct.ProdId &&
cartItem.InwardDtlId ===
sameBookingTypeProduct.InwardDtlId &&
sameBookingTypeProduct.InwardDtlId &&
cartItem.BookingTypeName ===
sameBookingTypeProduct.BookingTypeName &&
sameBookingTypeProduct.BookingTypeName &&
cartItem.OrderRate ===
sameBookingTypeProduct.OrderRate &&
sameBookingTypeProduct.OrderRate &&
cartItem.OfferMode &&
cartItem.Offer > 0
) {
@ -2513,11 +2545,11 @@ const BSBillingEditQuantity = (props) => {
if (
cartItem.ProdId === sameBookingTypeProduct.ProdId &&
cartItem.InwardDtlId ===
sameBookingTypeProduct.InwardDtlId &&
sameBookingTypeProduct.InwardDtlId &&
cartItem.BookingTypeName ===
sameBookingTypeProduct.BookingTypeName &&
sameBookingTypeProduct.BookingTypeName &&
cartItem.OrderRate ===
sameBookingTypeProduct.OrderRate &&
sameBookingTypeProduct.OrderRate &&
cartItem.OfferMode &&
cartItem.Offer > 0
) {
@ -2606,11 +2638,11 @@ const BSBillingEditQuantity = (props) => {
if (
cartItem.ProdId === otherBookingTypeProduct.ProdId &&
cartItem?.InwardDtlId ===
otherBookingTypeProduct.InwardDtlId &&
otherBookingTypeProduct.InwardDtlId &&
cartItem?.BookingTypeName ===
otherBookingTypeProduct.BookingTypeName &&
otherBookingTypeProduct.BookingTypeName &&
cartItem?.OrderRate ===
otherBookingTypeProduct.OrderRate &&
otherBookingTypeProduct.OrderRate &&
cartItem?.OfferMode &&
cartItem?.Offer > 0
) {
@ -2639,11 +2671,11 @@ const BSBillingEditQuantity = (props) => {
if (
cartItem.ProdId === otherBookingTypeProduct.ProdId &&
cartItem.InwardDtlId ===
otherBookingTypeProduct.InwardDtlId &&
otherBookingTypeProduct.InwardDtlId &&
cartItem.BookingTypeName ===
otherBookingTypeProduct.BookingTypeName &&
otherBookingTypeProduct.BookingTypeName &&
cartItem.OrderRate ===
otherBookingTypeProduct.OrderRate &&
otherBookingTypeProduct.OrderRate &&
cartItem.OfferMode &&
cartItem.Offer > 0
) {
@ -2673,11 +2705,11 @@ const BSBillingEditQuantity = (props) => {
if (
cartItem.ProdId === otherBookingTypeProduct.ProdId &&
cartItem.InwardDtlId ===
otherBookingTypeProduct.InwardDtlId &&
otherBookingTypeProduct.InwardDtlId &&
cartItem.BookingTypeName ===
otherBookingTypeProduct.BookingTypeName &&
otherBookingTypeProduct.BookingTypeName &&
cartItem.OrderRate ===
otherBookingTypeProduct.OrderRate &&
otherBookingTypeProduct.OrderRate &&
cartItem.OfferMode &&
cartItem.Offer > 0
) {
@ -2776,12 +2808,12 @@ const BSBillingEditQuantity = (props) => {
product?.ProdId === editedProduct?.ProdId &&
product?.InwardDtlId === editedProduct?.InwardDtlId &&
product?.OfferId ===
(sameBookingTypeFreeProduct?.OfferMessage?.[0]?.OfferId ||
otherBookingTypeFreeProduct?.OfferMessage?.[0]
?.OfferId) &&
(sameBookingTypeFreeProduct?.OfferMessage?.[0]?.OfferId ||
otherBookingTypeFreeProduct?.OfferMessage?.[0]
?.OfferId) &&
product?.OfferMode ===
(sameBookingTypeFreeProduct?.OfferMode ||
otherBookingTypeFreeProduct?.OfferMode)
(sameBookingTypeFreeProduct?.OfferMode ||
otherBookingTypeFreeProduct?.OfferMode)
) {
return {
...product,
@ -2815,12 +2847,12 @@ const BSBillingEditQuantity = (props) => {
// Also check main offer conditions
const isMatchingOffer =
offerProduct?.OfferId ===
(sameBookingTypeProduct?.OfferMessage?.[0]?.OfferId ||
otherBookingTypeProduct?.OfferMessage?.[0]
?.OfferId) &&
(sameBookingTypeProduct?.OfferMessage?.[0]?.OfferId ||
otherBookingTypeProduct?.OfferMessage?.[0]
?.OfferId) &&
offerProduct?.OfferMode ===
(sameBookingTypeProduct?.OfferMode ||
otherBookingTypeProduct?.OfferMode);
(sameBookingTypeProduct?.OfferMode ||
otherBookingTypeProduct?.OfferMode);
if (hasMatchingFreeProduct && isMatchingOffer) {
// Get loyalty points from the matching free product
@ -2899,11 +2931,11 @@ const BSBillingEditQuantity = (props) => {
if (
cartItem.ProdId === sameBookingTypeProduct.ProdId &&
cartItem.InwardDtlId ===
sameBookingTypeProduct.InwardDtlId &&
sameBookingTypeProduct.InwardDtlId &&
cartItem.BookingTypeName ===
sameBookingTypeProduct.BookingTypeName &&
sameBookingTypeProduct.BookingTypeName &&
cartItem.OrderRate ===
sameBookingTypeProduct.OrderRate &&
sameBookingTypeProduct.OrderRate &&
cartItem.OfferMode &&
cartItem.Offer > 0
) {
@ -2962,11 +2994,11 @@ const BSBillingEditQuantity = (props) => {
if (
cartItem.ProdId === otherBookingTypeProduct.ProdId &&
cartItem.InwardDtlId ===
otherBookingTypeProduct.InwardDtlId &&
otherBookingTypeProduct.InwardDtlId &&
cartItem.BookingTypeName ===
otherBookingTypeProduct.BookingTypeName &&
otherBookingTypeProduct.BookingTypeName &&
cartItem.OrderRate ===
otherBookingTypeProduct.OrderRate &&
otherBookingTypeProduct.OrderRate &&
cartItem.OfferMode &&
cartItem.Offer > 0
) {
@ -3038,12 +3070,12 @@ const BSBillingEditQuantity = (props) => {
product?.ProdId === editedProduct?.ProdId &&
product?.InwardDtlId === editedProduct?.InwardDtlId &&
product?.OfferId ===
(sameBookingTypeFreeProduct?.OfferMessage?.[0]?.OfferId ||
otherBookingTypeFreeProduct?.OfferMessage?.[0]
?.OfferId) &&
(sameBookingTypeFreeProduct?.OfferMessage?.[0]?.OfferId ||
otherBookingTypeFreeProduct?.OfferMessage?.[0]
?.OfferId) &&
product?.OfferMode ===
(sameBookingTypeFreeProduct?.OfferMode ||
otherBookingTypeFreeProduct?.OfferMode)
(sameBookingTypeFreeProduct?.OfferMode ||
otherBookingTypeFreeProduct?.OfferMode)
) {
return {
...product,
@ -3077,12 +3109,12 @@ const BSBillingEditQuantity = (props) => {
// Also check main offer conditions
const isMatchingOffer =
offerProduct?.OfferId ===
(sameBookingTypeProduct?.OfferMessage?.[0]?.OfferId ||
otherBookingTypeProduct?.OfferMessage?.[0]
?.OfferId) &&
(sameBookingTypeProduct?.OfferMessage?.[0]?.OfferId ||
otherBookingTypeProduct?.OfferMessage?.[0]
?.OfferId) &&
offerProduct?.OfferMode ===
(sameBookingTypeProduct?.OfferMode ||
otherBookingTypeProduct?.OfferMode);
(sameBookingTypeProduct?.OfferMode ||
otherBookingTypeProduct?.OfferMode);
if (hasMatchingFreeProduct && isMatchingOffer) {
// Get loyalty points from the matching free product
@ -3217,21 +3249,21 @@ const BSBillingEditQuantity = (props) => {
}),
...(!offerApply && itemDiscountPrice > 0
? {
DiscountAmt: safeRound(itemDiscountPrice * fixedQty),
DiscountType:
itemDiscountPercentageSelection === 'Fixed' ? 'F' : 'P',
DiscountValue:
itemDiscountPercentageSelection === 'Fixed'
? itemDiscountPrice * fixedQty
: ((itemDiscountPrice * fixedQty) /
(newPrice > 0 ? newPrice : editedProduct?.OrderRate)) *
100,
}
DiscountAmt: safeRound(itemDiscountPrice * fixedQty),
DiscountType:
itemDiscountPercentageSelection === 'Fixed' ? 'F' : 'P',
DiscountValue:
itemDiscountPercentageSelection === 'Fixed'
? itemDiscountPrice * fixedQty
: ((itemDiscountPrice * fixedQty) /
(newPrice > 0 ? newPrice : editedProduct?.OrderRate)) *
100,
}
: {
DiscountAmt: null,
DiscountType: null,
DiscountValue: null,
}),
DiscountAmt: null,
DiscountType: null,
DiscountValue: null,
}),
};
if (hasOffer) {
@ -3256,17 +3288,17 @@ const BSBillingEditQuantity = (props) => {
changeOrderCardDetails(
CartOrderDetails?.map((i) =>
i?.InwardDtlId == updatedProduct?.InwardDtlId &&
i?.BookingTypeName == updatedProduct?.BookingTypeName &&
i?.localId === updatedProduct?.localId
i?.BookingTypeName == updatedProduct?.BookingTypeName &&
i?.localId === updatedProduct?.localId
? {
...updatedProduct,
Offer: 0,
OfferType:
updatedProduct?.Type === 'C'
? updatedProduct?.OfferType
: null,
OfferMessage: null,
}
...updatedProduct,
Offer: 0,
OfferType:
updatedProduct?.Type === 'C'
? updatedProduct?.OfferType
: null,
OfferMessage: null,
}
: i
)
)
@ -3302,10 +3334,10 @@ const BSBillingEditQuantity = (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);
@ -4040,14 +4072,14 @@ const BSBillingEditQuantity = (props) => {
<div style={{ display: 'flex', justifyContent: 'flex-end' }}>
{((RadioBtnSelection == 'Price' && disableSubmitButton) ||
RadioBtnSelection == 'Quantity') && (
<Buttons
buttonText="Submit"
color="901D77"
htmlType
// handleSubmit={AddProductQuantity}
icon={<ArrowRightOutlined />}
></Buttons>
)}
<Buttons
buttonText="Submit"
color="901D77"
htmlType
// handleSubmit={AddProductQuantity}
icon={<ArrowRightOutlined />}
></Buttons>
)}
</div>
</Form>
</div>

View File

@ -217,16 +217,16 @@ const BSBillingTable3 = (Props) => {
OrderType === 'Hold'
? tableData?.filter((a, b) => a.BookingTypeName === 'TakeAway')
: tableData?.filter(
(a, b) => a.BookingTypeName === 'TakeAway' && !a?.SalesId
);
(a, b) => a.BookingTypeName === 'TakeAway' && !a?.SalesId
);
const OldtableDataDinein = tableData?.filter(
(a, b) => a.BookingTypeName === 'Dine In' && a?.SalesId
);
const OldtableDataTakeAway =
OrderType != 'Hold'
? tableData?.filter(
(a, b) => a.BookingTypeName === 'TakeAway' && a?.SalesId
)
(a, b) => a.BookingTypeName === 'TakeAway' && a?.SalesId
)
: [];
const [EditQuantity, setEditQuantity] = useState(false);
const [Modaldata, setModaldata] = useState([]);
@ -473,27 +473,27 @@ const BSBillingTable3 = (Props) => {
) {
if (BillOrderPre === 'Y') {
const UpdatedCartItem =
// if the item is already in the cart, increase the quantity of the item
{
...isItemInCart,
OrderQty: isItemInCart?.OrderQty - 1,
TotalAmt:
(isItemInCart?.OrderQty - 1) * isItemInCart?.OrderRate,
TaxAmt: (
// if the item is already in the cart, increase the quantity of the item
{
...isItemInCart,
OrderQty: isItemInCart?.OrderQty - 1,
TotalAmt:
(isItemInCart?.OrderQty - 1) * isItemInCart?.OrderRate,
TaxAmt: (
((isItemInCart?.OrderQty - 1) *
isItemInCart?.OrderRate *
isItemInCart?.TaxPercentage) /
(100 + isItemInCart?.TaxPercentage)
).toFixed(2),
WithoutTaxRate:
(isItemInCart?.OrderQty - 1) * isItemInCart?.OrderRate -
(
((isItemInCart?.OrderQty - 1) *
isItemInCart?.OrderRate *
isItemInCart?.TaxPercentage) /
(100 + isItemInCart?.TaxPercentage)
).toFixed(2),
WithoutTaxRate:
(isItemInCart?.OrderQty - 1) * isItemInCart?.OrderRate -
(
((isItemInCart?.OrderQty - 1) *
isItemInCart?.OrderRate *
isItemInCart?.TaxPercentage) /
(100 + isItemInCart?.TaxPercentage)
).toFixed(2),
};
};
const UpdatedData = [UpdatedCartItem, ...OtherorderDataforNormal];
@ -504,27 +504,27 @@ const BSBillingTable3 = (Props) => {
// }
} else {
const UpdatedCartItem =
// if the item is already in the cart, increase the quantity of the item
{
...isItemInCart,
OrderQty: isItemInCart?.OrderQty - 1,
TotalAmt:
(isItemInCart?.OrderQty - 1) * isItemInCart?.OrderRate,
TaxAmt: (
// if the item is already in the cart, increase the quantity of the item
{
...isItemInCart,
OrderQty: isItemInCart?.OrderQty - 1,
TotalAmt:
(isItemInCart?.OrderQty - 1) * isItemInCart?.OrderRate,
TaxAmt: (
((isItemInCart?.OrderQty - 1) *
isItemInCart?.OrderRate *
isItemInCart?.TaxPercentage) /
(100 + isItemInCart?.TaxPercentage)
).toFixed(2),
WithoutTaxRate:
(isItemInCart?.OrderQty - 1) * isItemInCart?.OrderRate -
(
((isItemInCart?.OrderQty - 1) *
isItemInCart?.OrderRate *
isItemInCart?.TaxPercentage) /
(100 + isItemInCart?.TaxPercentage)
).toFixed(2),
WithoutTaxRate:
(isItemInCart?.OrderQty - 1) * isItemInCart?.OrderRate -
(
((isItemInCart?.OrderQty - 1) *
isItemInCart?.OrderRate *
isItemInCart?.TaxPercentage) /
(100 + isItemInCart?.TaxPercentage)
).toFixed(2),
};
};
const UpdatedData = [...OtherorderDataforNormal, UpdatedCartItem];
@ -543,27 +543,27 @@ const BSBillingTable3 = (Props) => {
) {
if (BillOrderPre === 'Y') {
const UpdatedCartItem =
// if the item is already in the cart, increase the quantity of the item
{
...isItemInCart,
OrderQty: isItemInCart?.OrderQty - 1,
TotalAmt:
(isItemInCart?.OrderQty - 1) * isItemInCart?.OrderRate,
TaxAmt: (
// if the item is already in the cart, increase the quantity of the item
{
...isItemInCart,
OrderQty: isItemInCart?.OrderQty - 1,
TotalAmt:
(isItemInCart?.OrderQty - 1) * isItemInCart?.OrderRate,
TaxAmt: (
((isItemInCart?.OrderQty - 1) *
isItemInCart?.OrderRate *
isItemInCart?.TaxPercentage) /
(100 + isItemInCart?.TaxPercentage)
).toFixed(2),
WithoutTaxRate:
(isItemInCart?.OrderQty - 1) * isItemInCart?.OrderRate -
(
((isItemInCart?.OrderQty - 1) *
isItemInCart?.OrderRate *
isItemInCart?.TaxPercentage) /
(100 + isItemInCart?.TaxPercentage)
).toFixed(2),
WithoutTaxRate:
(isItemInCart?.OrderQty - 1) * isItemInCart?.OrderRate -
(
((isItemInCart?.OrderQty - 1) *
isItemInCart?.OrderRate *
isItemInCart?.TaxPercentage) /
(100 + isItemInCart?.TaxPercentage)
).toFixed(2),
};
};
const UpdatedData = [UpdatedCartItem, ...OtherorderDataforNormal];
// if (OfferCheckedInSetup && preferenceOffer) {
@ -573,27 +573,27 @@ const BSBillingTable3 = (Props) => {
// }
} else {
const UpdatedCartItem =
// if the item is already in the cart, increase the quantity of the item
{
...isItemInCart,
OrderQty: isItemInCart?.OrderQty - 1,
TotalAmt:
(isItemInCart?.OrderQty - 1) * isItemInCart?.OrderRate,
TaxAmt: (
// if the item is already in the cart, increase the quantity of the item
{
...isItemInCart,
OrderQty: isItemInCart?.OrderQty - 1,
TotalAmt:
(isItemInCart?.OrderQty - 1) * isItemInCart?.OrderRate,
TaxAmt: (
((isItemInCart?.OrderQty - 1) *
isItemInCart?.OrderRate *
isItemInCart?.TaxPercentage) /
(100 + isItemInCart?.TaxPercentage)
).toFixed(2),
WithoutTaxRate:
(isItemInCart?.OrderQty - 1) * isItemInCart?.OrderRate -
(
((isItemInCart?.OrderQty - 1) *
isItemInCart?.OrderRate *
isItemInCart?.TaxPercentage) /
(100 + isItemInCart?.TaxPercentage)
).toFixed(2),
WithoutTaxRate:
(isItemInCart?.OrderQty - 1) * isItemInCart?.OrderRate -
(
((isItemInCart?.OrderQty - 1) *
isItemInCart?.OrderRate *
isItemInCart?.TaxPercentage) /
(100 + isItemInCart?.TaxPercentage)
).toFixed(2),
};
};
const UpdatedData = [...OtherorderDataforNormal, UpdatedCartItem];
@ -606,29 +606,29 @@ const BSBillingTable3 = (Props) => {
} else if (isItemInCartHold && OrderType === 'Hold') {
if (BillOrderPre === 'Y') {
const UpdatedCartItem =
// if the item is already in the cart, increase the quantity of the item
{
...isItemInCartHold,
OrderQty: isItemInCartHold?.OrderQty - 1,
TotalAmt:
(isItemInCartHold?.OrderQty - 1) *
isItemInCartHold?.OrderRate,
TaxAmt: (
// if the item is already in the cart, increase the quantity of the item
{
...isItemInCartHold,
OrderQty: isItemInCartHold?.OrderQty - 1,
TotalAmt:
(isItemInCartHold?.OrderQty - 1) *
isItemInCartHold?.OrderRate,
TaxAmt: (
((isItemInCartHold?.OrderQty - 1) *
isItemInCartHold?.OrderRate *
isItemInCartHold?.TaxPercentage) /
(100 + isItemInCartHold?.TaxPercentage)
).toFixed(2),
WithoutTaxRate:
(isItemInCartHold?.OrderQty - 1) *
isItemInCartHold?.OrderRate -
(
((isItemInCartHold?.OrderQty - 1) *
isItemInCartHold?.OrderRate *
isItemInCartHold?.TaxPercentage) /
(100 + isItemInCartHold?.TaxPercentage)
).toFixed(2),
WithoutTaxRate:
(isItemInCartHold?.OrderQty - 1) *
isItemInCartHold?.OrderRate -
(
((isItemInCartHold?.OrderQty - 1) *
isItemInCartHold?.OrderRate *
isItemInCartHold?.TaxPercentage) /
(100 + isItemInCartHold?.TaxPercentage)
).toFixed(2),
};
};
const UpdatedData = [
UpdatedCartItem,
@ -642,29 +642,29 @@ const BSBillingTable3 = (Props) => {
// }
} else {
const UpdatedCartItem =
// if the item is already in the cart, increase the quantity of the item
{
...isItemInCartHold,
OrderQty: isItemInCartHold?.OrderQty - 1,
TotalAmt:
(isItemInCartHold?.OrderQty - 1) *
isItemInCartHold?.OrderRate,
TaxAmt: (
// if the item is already in the cart, increase the quantity of the item
{
...isItemInCartHold,
OrderQty: isItemInCartHold?.OrderQty - 1,
TotalAmt:
(isItemInCartHold?.OrderQty - 1) *
isItemInCartHold?.OrderRate,
TaxAmt: (
((isItemInCartHold?.OrderQty - 1) *
isItemInCartHold?.OrderRate *
isItemInCartHold?.TaxPercentage) /
(100 + isItemInCartHold?.TaxPercentage)
).toFixed(2),
WithoutTaxRate:
(isItemInCartHold?.OrderQty - 1) *
isItemInCartHold?.OrderRate -
(
((isItemInCartHold?.OrderQty - 1) *
isItemInCartHold?.OrderRate *
isItemInCartHold?.TaxPercentage) /
(100 + isItemInCartHold?.TaxPercentage)
).toFixed(2),
WithoutTaxRate:
(isItemInCartHold?.OrderQty - 1) *
isItemInCartHold?.OrderRate -
(
((isItemInCartHold?.OrderQty - 1) *
isItemInCartHold?.OrderRate *
isItemInCartHold?.TaxPercentage) /
(100 + isItemInCartHold?.TaxPercentage)
).toFixed(2),
};
};
const UpdatedData = [
...OtherorderDataforNormalWithoutSalesId,
@ -968,26 +968,26 @@ const BSBillingTable3 = (Props) => {
if (isItemInCart && BookingTypeProd != 'Dine In' && OrderType != 'Hold') {
if (BillOrderPre === 'Y') {
const UpdatedCartItem =
// if the item is already in the cart, increase the quantity of the item
{
...isItemInCart,
OrderQty: isItemInCart?.OrderQty + 1,
TotalAmt: (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate,
TaxAmt: (
// if the item is already in the cart, increase the quantity of the item
{
...isItemInCart,
OrderQty: isItemInCart?.OrderQty + 1,
TotalAmt: (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate,
TaxAmt: (
((isItemInCart?.OrderQty + 1) *
isItemInCart?.OrderRate *
isItemInCart?.TaxPercentage) /
(100 + isItemInCart?.TaxPercentage)
).toFixed(2),
WithoutTaxRate:
(isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate -
(
((isItemInCart?.OrderQty + 1) *
isItemInCart?.OrderRate *
isItemInCart?.TaxPercentage) /
(100 + isItemInCart?.TaxPercentage)
).toFixed(2),
WithoutTaxRate:
(isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate -
(
((isItemInCart?.OrderQty + 1) *
isItemInCart?.OrderRate *
isItemInCart?.TaxPercentage) /
(100 + isItemInCart?.TaxPercentage)
).toFixed(2),
};
};
const UpdatedData = [UpdatedCartItem, ...OtherorderDataforNormal];
@ -998,26 +998,26 @@ const BSBillingTable3 = (Props) => {
// }
} else {
const UpdatedCartItem =
// if the item is already in the cart, increase the quantity of the item
{
...isItemInCart,
OrderQty: isItemInCart?.OrderQty + 1,
TotalAmt: (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate,
TaxAmt: (
// if the item is already in the cart, increase the quantity of the item
{
...isItemInCart,
OrderQty: isItemInCart?.OrderQty + 1,
TotalAmt: (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate,
TaxAmt: (
((isItemInCart?.OrderQty + 1) *
isItemInCart?.OrderRate *
isItemInCart?.TaxPercentage) /
(100 + isItemInCart?.TaxPercentage)
).toFixed(2),
WithoutTaxRate:
(isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate -
(
((isItemInCart?.OrderQty + 1) *
isItemInCart?.OrderRate *
isItemInCart?.TaxPercentage) /
(100 + isItemInCart?.TaxPercentage)
).toFixed(2),
WithoutTaxRate:
(isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate -
(
((isItemInCart?.OrderQty + 1) *
isItemInCart?.OrderRate *
isItemInCart?.TaxPercentage) /
(100 + isItemInCart?.TaxPercentage)
).toFixed(2),
};
};
const UpdatedData = [...OtherorderDataforNormal, UpdatedCartItem];
@ -1036,26 +1036,26 @@ const BSBillingTable3 = (Props) => {
) {
if (BillOrderPre === 'Y') {
const UpdatedCartItem =
// if the item is already in the cart, increase the quantity of the item
{
...isItemInCart,
OrderQty: isItemInCart?.OrderQty + 1,
TotalAmt: (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate,
TaxAmt: (
// if the item is already in the cart, increase the quantity of the item
{
...isItemInCart,
OrderQty: isItemInCart?.OrderQty + 1,
TotalAmt: (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate,
TaxAmt: (
((isItemInCart?.OrderQty + 1) *
isItemInCart?.OrderRate *
isItemInCart?.TaxPercentage) /
(100 + isItemInCart?.TaxPercentage)
).toFixed(2),
WithoutTaxRate:
(isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate -
(
((isItemInCart?.OrderQty + 1) *
isItemInCart?.OrderRate *
isItemInCart?.TaxPercentage) /
(100 + isItemInCart?.TaxPercentage)
).toFixed(2),
WithoutTaxRate:
(isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate -
(
((isItemInCart?.OrderQty + 1) *
isItemInCart?.OrderRate *
isItemInCart?.TaxPercentage) /
(100 + isItemInCart?.TaxPercentage)
).toFixed(2),
};
};
const UpdatedData = [UpdatedCartItem, ...OtherorderDataforNormal];
@ -1066,26 +1066,26 @@ const BSBillingTable3 = (Props) => {
// }
} else {
const UpdatedCartItem =
// if the item is already in the cart, increase the quantity of the item
{
...isItemInCart,
OrderQty: isItemInCart?.OrderQty + 1,
TotalAmt: (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate,
TaxAmt: (
// if the item is already in the cart, increase the quantity of the item
{
...isItemInCart,
OrderQty: isItemInCart?.OrderQty + 1,
TotalAmt: (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate,
TaxAmt: (
((isItemInCart?.OrderQty + 1) *
isItemInCart?.OrderRate *
isItemInCart?.TaxPercentage) /
(100 + isItemInCart?.TaxPercentage)
).toFixed(2),
WithoutTaxRate:
(isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate -
(
((isItemInCart?.OrderQty + 1) *
isItemInCart?.OrderRate *
isItemInCart?.TaxPercentage) /
(100 + isItemInCart?.TaxPercentage)
).toFixed(2),
WithoutTaxRate:
(isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate -
(
((isItemInCart?.OrderQty + 1) *
isItemInCart?.OrderRate *
isItemInCart?.TaxPercentage) /
(100 + isItemInCart?.TaxPercentage)
).toFixed(2),
};
};
const UpdatedData = [...OtherorderDataforNormal, UpdatedCartItem];
@ -1098,27 +1098,27 @@ const BSBillingTable3 = (Props) => {
} else if (isItemInCartHold && OrderType === 'Hold') {
if (BillOrderPre === 'Y') {
const UpdatedCartItem =
// if the item is already in the cart, increase the quantity of the item
{
...isItemInCartHold,
OrderQty: isItemInCartHold?.OrderQty + 1,
TotalAmt:
(isItemInCartHold?.OrderQty + 1) * isItemInCartHold?.OrderRate,
TaxAmt: (
// if the item is already in the cart, increase the quantity of the item
{
...isItemInCartHold,
OrderQty: isItemInCartHold?.OrderQty + 1,
TotalAmt:
(isItemInCartHold?.OrderQty + 1) * isItemInCartHold?.OrderRate,
TaxAmt: (
((isItemInCartHold?.OrderQty + 1) *
isItemInCartHold?.OrderRate *
isItemInCartHold?.TaxPercentage) /
(100 + isItemInCartHold?.TaxPercentage)
).toFixed(2),
WithoutTaxRate:
(isItemInCartHold?.OrderQty + 1) * isItemInCartHold?.OrderRate -
(
((isItemInCartHold?.OrderQty + 1) *
isItemInCartHold?.OrderRate *
isItemInCartHold?.TaxPercentage) /
(100 + isItemInCartHold?.TaxPercentage)
).toFixed(2),
WithoutTaxRate:
(isItemInCartHold?.OrderQty + 1) * isItemInCartHold?.OrderRate -
(
((isItemInCartHold?.OrderQty + 1) *
isItemInCartHold?.OrderRate *
isItemInCartHold?.TaxPercentage) /
(100 + isItemInCartHold?.TaxPercentage)
).toFixed(2),
};
};
const UpdatedData = [
UpdatedCartItem,
@ -1132,27 +1132,27 @@ const BSBillingTable3 = (Props) => {
// }
} else {
const UpdatedCartItem =
// if the item is already in the cart, increase the quantity of the item
{
...isItemInCartHold,
OrderQty: isItemInCartHold?.OrderQty + 1,
TotalAmt:
(isItemInCartHold?.OrderQty + 1) * isItemInCartHold?.OrderRate,
TaxAmt: (
// if the item is already in the cart, increase the quantity of the item
{
...isItemInCartHold,
OrderQty: isItemInCartHold?.OrderQty + 1,
TotalAmt:
(isItemInCartHold?.OrderQty + 1) * isItemInCartHold?.OrderRate,
TaxAmt: (
((isItemInCartHold?.OrderQty + 1) *
isItemInCartHold?.OrderRate *
isItemInCartHold?.TaxPercentage) /
(100 + isItemInCartHold?.TaxPercentage)
).toFixed(2),
WithoutTaxRate:
(isItemInCartHold?.OrderQty + 1) * isItemInCartHold?.OrderRate -
(
((isItemInCartHold?.OrderQty + 1) *
isItemInCartHold?.OrderRate *
isItemInCartHold?.TaxPercentage) /
(100 + isItemInCartHold?.TaxPercentage)
).toFixed(2),
WithoutTaxRate:
(isItemInCartHold?.OrderQty + 1) * isItemInCartHold?.OrderRate -
(
((isItemInCartHold?.OrderQty + 1) *
isItemInCartHold?.OrderRate *
isItemInCartHold?.TaxPercentage) /
(100 + isItemInCartHold?.TaxPercentage)
).toFixed(2),
};
};
const UpdatedData = [
...OtherorderDataforNormalWithoutSalesId,
@ -1990,9 +1990,9 @@ const BSBillingTable3 = (Props) => {
)?.map((item, idx) =>
idx === 0
? {
...item,
FreeQty,
}
...item,
FreeQty,
}
: item
),
};
@ -3155,7 +3155,7 @@ const BSBillingTable3 = (Props) => {
} = section;
if (!data?.length) return null;
console.log(data, "OrderCart")
// Disabled check
const isDisabled = (item) => {
if (isOld) {
@ -3395,8 +3395,8 @@ const BSBillingTable3 = (Props) => {
style={{ fontFamily: 'Poppins' }}
onClick={() =>
item.FullProductIdentifierDtls?.length > 0 ||
item.ProductIdentifierDtls?.length > 0 ||
imeiModal
item.ProductIdentifierDtls?.length > 0 ||
imeiModal
? handleImeiDetails(item)
: editField && handleEditQuantity(item, index)
}
@ -3427,7 +3427,7 @@ const BSBillingTable3 = (Props) => {
<p
className={`offermessageTag ${!isMobile ? 'desktop' : ''}`}
>
{item.OfferMessage?.split('>')?.[0] +
{item?.OfferModeType === true ? item.OfferMessage : item.OfferMessage?.split('>')?.[0] +
`> ${item?.OrderQty} Eligible Free`}
</p>
)}
@ -3448,21 +3448,21 @@ const BSBillingTable3 = (Props) => {
{productBasedExtraCharges?.find(
(f) => f.ProdId === item.ProdId
) !== undefined && (
<div
style={{
fontSize: '10px',
fontWeight: '500',
whiteSpace: 'nowrap',
}}
>
Extra Charges :{' '}
{
productBasedExtraCharges.find(
(f) => f.ProdId === item.ProdId
)?.TotalAmt
}
</div>
)}
<div
style={{
fontSize: '10px',
fontWeight: '500',
whiteSpace: 'nowrap',
}}
>
Extra Charges :{' '}
{
productBasedExtraCharges.find(
(f) => f.ProdId === item.ProdId
)?.TotalAmt
}
</div>
)}
</td>
)}

View File

@ -2672,6 +2672,7 @@ const BSItemCard = (props) => {
let OfferNeedToApply = true;
let updatedFreeProductList = [];
let sameProduct = false;
let TotalDiscount = 0;
for (const offer of offers) {
if (offer.OfferMode === 'B') {
const {
@ -2680,6 +2681,7 @@ const BSItemCard = (props) => {
OfferApply,
updatedFreeProdList,
ProductOfferType,
otherTotalDiscount
} = applyBuyNGetFreeOffer(cartData, offer, item);
offer.OfferAmount = OfferAmount;
@ -2687,6 +2689,7 @@ const BSItemCard = (props) => {
OfferNeedToApply = OfferApply;
updatedFreeProductList = updatedFreeProdList;
sameProduct = ProductOfferType;
TotalDiscount = otherTotalDiscount;
}
if (!bestOffer || offer.OfferAmount > bestOffer.OfferAmount) {
bestOffer = offer;
@ -2702,9 +2705,9 @@ const BSItemCard = (props) => {
? bestOffer?.OfferAmount || item.Offer
: item.Offer || bestOffer?.OfferAmount,
OfferType: item?.OfferType || bestOffer?.OfferType,
OfferMessage: item?.OfferMessage || bestOffer?.OfferMessage,
OfferMessage: sameProduct ? (bestOffer?.OfferMessage || item?.OfferMessage) : (item?.OfferMessage || bestOffer?.OfferMessage),
OfferMode: item?.OfferMode || bestOffer?.OfferMode,
OfferModeType: sameProduct,
OfferModeType: sameProduct
};
const shouldRemove = (c) =>
@ -2729,6 +2732,12 @@ const BSItemCard = (props) => {
: [...filteredCart, UpdatedCartItemWithOffer];
if (bestOffer && OfferNeedToApply) {
if (TotalDiscount > 0) {
bestOffer = {
...bestOffer,
OfferAmount: TotalDiscount
}
}
dispatch(ChangeOfferAppliedProducts(bestOffer));
}
@ -3118,6 +3127,7 @@ const BSItemCard = (props) => {
function applyBuyNGetFreeOffer(cartItem, offer, item) {
const freeList = offer.FreeProductsList || [];
let otherTotalDiscount = 0;
let totalDiscount = 0;
let offerMessage = '';
let OfferApply = true;
@ -3171,20 +3181,45 @@ const BSItemCard = (props) => {
0.5;
sameProductOffer = true;
} else if (isSameProduct) {
// 🔥 Buy N Get M (same product)
const buyQty = offer.BuyQty || 1;
// 🔥 Buy N Get N (same product)
const totalQty = freeCartItem?.reduce(
(acc, fc) => acc + (fc?.OrderQty || 0),
0
);
const buyQty = offer.MinQty || 1;
const getQty = freeProd.FreeQty || 0;
const cycleSize = buyQty + getQty;
const fullCycles = Math.floor(
freeCartItem?.reduce((acc, fc) => acc + (fc?.OrderQty || 0), 0) /
cycleSize
);
const totalFreeQty = fullCycles * getQty;
const groupSize = buyQty + getQty;
// Discount logic (your existing correct logic)
const paidQty = Math.ceil(totalQty / groupSize);
const totalFreeQty = totalQty - paidQty;
totalDiscount += totalFreeQty * freeCartItem?.[0].OrderRate;
// check the offer applied for same product in different booking type
const differentBookTypeProd = freeCartItem?.filter((prod) => prod?.BookingTypeName !== item?.BookingTypeName && (prod?.Offer || 0) > 0 && prod?.OfferMode === offer?.OfferMode);
if (differentBookTypeProd?.length > 0) {
const diffBookTypeDis = differentBookTypeProd?.reduce(
(acc, fc) => acc + (fc?.Offer || 0),
0
);
otherTotalDiscount = totalDiscount;
totalDiscount = totalDiscount - diffBookTypeDis;
}
sameProductOffer = true;
// offerMessage = `${freeProd.FreeProdName} -> ${Math.ceil(totalFreeQty / 2)} qty Free Eligible`;
// Message logic (NEW)
const messageGroups = Math.ceil(totalQty / groupSize);
const eligibleFreeQty = messageGroups * getQty;
offerMessage = `${freeProd.FreeProdName} -> ${eligibleFreeQty} Eligible Free`;
// offerMessage = `${freeProd.FreeProdName} ->
// ( ${paidQty} Paid + ${eligibleFreeQty} Free Eligible ). \n
// saved ${otherTotalDiscount > 0 ? otherTotalDiscount : totalDiscount}`;
} else {
// 🔥 Different product free
const buyQty = offer.BuyQty || 1;
@ -3284,6 +3319,7 @@ const BSItemCard = (props) => {
OfferApply: OfferApply,
updatedFreeProdList: updatedFreeProdList,
ProductOfferType: sameProductOffer ? true : false,
otherTotalDiscount: otherTotalDiscount,
};
}