kisok quantity constrain
This commit is contained in:
parent
70444d3028
commit
608aa917b3
|
|
@ -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 (
|
||||
<div className="BSBilling-EditQuantity-Modal">
|
||||
|
|
@ -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}
|
||||
/>
|
||||
</Form.Item>
|
||||
)}
|
||||
|
|
@ -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}
|
||||
/>
|
||||
</Form.Item>
|
||||
{/* <input type="text"
|
||||
|
|
@ -3796,14 +3818,14 @@ const [RadioBtnSelection, setRadioBtnSelection] = useState(() => {
|
|||
<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>
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,5 @@
|
|||
export const calculateOverAllQtyLimit = (orders) => {
|
||||
return orders?.reduce((acc, cartItem) => {
|
||||
return acc + (cartItem?.OrderQty || 0);
|
||||
}, 0)
|
||||
}
|
||||
Loading…
Reference in New Issue