1426 lines
50 KiB
JavaScript
1426 lines
50 KiB
JavaScript
import '../../../../Styles/BookingScreen/Components/UtillComponents/BSNavBarComponents.scss';
|
||
import { useRef, useState, useEffect, useCallback } from 'react';
|
||
import { useDispatch, useSelector } from 'react-redux';
|
||
import { IoSearchOutline } from 'react-icons/io5';
|
||
import { Form, AutoComplete, Modal } from 'antd';
|
||
import { SearchOutlined } from '@ant-design/icons';
|
||
import {
|
||
changeHoldOrderDtl,
|
||
ChangeNewQrProduct,
|
||
changeOrderCardDetails,
|
||
changeothersdata,
|
||
changePreviousOrderLength,
|
||
Comboget,
|
||
getConfigType,
|
||
GlobalBookingType,
|
||
GlobalOrderCardDetails,
|
||
GlobalOrderType,
|
||
GlobalReorderHoldDetails,
|
||
GlobalReorderProductDetails,
|
||
} from '../../../../Features/BookingScreen/BookingData/BookingData.js';
|
||
import {
|
||
changepreOrderList,
|
||
GlobalPreOrderList,
|
||
GlobalpreOrderOpen,
|
||
} from '../../../../Features/BookingScreen/PreOrder/PreOrder.js';
|
||
import { Messages } from '../../../../Components/Notifications/Messages.jsx';
|
||
import { DefaultModal } from '../../../../Components/Modal/DefaultModal';
|
||
import FormHeader from '../../../PageComponents/FormHeader';
|
||
import { Tables } from '../../../../Components/Tables/Table';
|
||
import { ExclamationCircleOutlined } from '@ant-design/icons';
|
||
import BarcodeScanner from './BarcodeScanner';
|
||
import { isMobile } from 'react-device-detect';
|
||
import { BiBarcodeReader } from 'react-icons/bi';
|
||
import TooltipWrapper from '../../../../Components/Tooltip/Tooltip';
|
||
import BarCodeScan from '../../../../Services/BarCodeScan.jsx';
|
||
|
||
const BSNavBarComboSearch = (props) => {
|
||
|
||
const dispatch = useDispatch();
|
||
const propsData = props?.SessionData;
|
||
const [form] = Form.useForm();
|
||
const searchInputRef = useRef(null);
|
||
|
||
const BookingType = useSelector(GlobalBookingType);
|
||
const CartOrderDetails = useSelector(GlobalOrderCardDetails);
|
||
const ReorderProductData = useSelector(GlobalReorderProductDetails);
|
||
const ReportholdData = useSelector(GlobalReorderHoldDetails);
|
||
const OrderType = useSelector(GlobalOrderType);
|
||
const GPreOrderList = useSelector(GlobalPreOrderList);
|
||
const preOrder = useSelector(GlobalpreOrderOpen);
|
||
|
||
const [DropDown, setDropDown] = useState();
|
||
const [selectedprod, setselectedprod] = useState('');
|
||
const [BillOrderPre, setBillOrderPre] = useState();
|
||
const [messageType, setMessageType] = useState(null);
|
||
const [messageData, setMessageData] = useState(null);
|
||
const [modelstock, setModelstock] = useState(false);
|
||
const [qtydata, setQtydata] = useState();
|
||
const [expModel, setexpModel] = useState(false);
|
||
const [prodexpir, setProdexpir] = useState(false);
|
||
const [ExpProd, setExpProd] = useState();
|
||
const [Expdata, setExpdata] = useState();
|
||
const [PreOrderSelectedProdNames, setPreOrderSelectedProdNames] = useState(
|
||
[]
|
||
);
|
||
const [screenWidth, setScreenWidth] = useState(window.innerWidth);
|
||
const [openScanner, setOpenScanner] = useState(false);
|
||
const scannerRef = useRef();
|
||
|
||
const onComplete = useCallback(() => {
|
||
setMessageData(null);
|
||
setMessageType(null);
|
||
}, []);
|
||
|
||
const updateScreenSize = () => {
|
||
setScreenWidth(window.innerWidth);
|
||
};
|
||
|
||
useEffect(() => {
|
||
// Set initial screen size
|
||
updateScreenSize();
|
||
|
||
// Add event listener to track changes in screen size
|
||
window.addEventListener('resize', updateScreenSize);
|
||
|
||
// Clean up the event listener on component unmount
|
||
return () => {
|
||
window.removeEventListener('resize', updateScreenSize);
|
||
};
|
||
}, []);
|
||
|
||
//dhana
|
||
useEffect(() => {
|
||
const handleKeyPress = (event) => {
|
||
if (event.shiftKey && event.code === 'KeyS') {
|
||
if (
|
||
document.activeElement.tagName !== 'INPUT' &&
|
||
document.activeElement.tagName !== 'TEXTAREA'
|
||
) {
|
||
event.preventDefault(); // Stops "S" from being typed
|
||
searchInputRef?.current?.focus();
|
||
}
|
||
}
|
||
};
|
||
|
||
const handleClickOutside = (event) => {
|
||
searchInputRef?.current?.blur();
|
||
};
|
||
|
||
window.addEventListener('keydown', handleKeyPress);
|
||
window.addEventListener('mousedown', handleClickOutside);
|
||
|
||
return () => {
|
||
window.removeEventListener('keydown', handleKeyPress);
|
||
window.removeEventListener('mousedown', handleClickOutside);
|
||
};
|
||
}, []);
|
||
//dhana
|
||
|
||
const stockcolumns = [
|
||
{
|
||
title: 'Batch No',
|
||
dataIndex: 'ComboInwardDtlId',
|
||
key: 'ComboInwardDtlId',
|
||
align: 'center',
|
||
render: (text, record, index) => (
|
||
<span
|
||
style={
|
||
record.StockCount > 0
|
||
? { color: '#000', cursor: 'pointer' }
|
||
: { color: '#f49898', cursor: 'not-allowed' }
|
||
}
|
||
>
|
||
{record?.['ComboInwardDtlId']}
|
||
</span>
|
||
),
|
||
onCell: (record) => {
|
||
return {
|
||
onClick: () => {
|
||
if (record.StockCount > 0) {
|
||
StockSelected(record);
|
||
}
|
||
},
|
||
};
|
||
},
|
||
},
|
||
{
|
||
title: 'Stock Count',
|
||
dataIndex: 'StockCount',
|
||
key: 'StockCount',
|
||
align: 'center',
|
||
render: (_, record, index) => (
|
||
<span
|
||
style={
|
||
record.StockCount > 0
|
||
? { color: '#000', cursor: 'pointer' }
|
||
: { color: '#f49898', cursor: 'not-allowed' }
|
||
}
|
||
>
|
||
{record.StockCount}
|
||
</span>
|
||
),
|
||
onCell: (record) => {
|
||
return {
|
||
onClick: () => {
|
||
if (record.StockCount > 0) {
|
||
StockSelected(record);
|
||
}
|
||
},
|
||
};
|
||
},
|
||
},
|
||
{
|
||
title: 'Price',
|
||
dataIndex: 'Price',
|
||
key: 'Price',
|
||
align: 'center',
|
||
render: (_, record, index) => (
|
||
<span
|
||
style={
|
||
record.StockCount > 0
|
||
? { color: '#000', cursor: 'pointer' }
|
||
: { color: '#f49898', cursor: 'not-allowed' }
|
||
}
|
||
>
|
||
{record.Price}
|
||
</span>
|
||
),
|
||
onCell: (record) => {
|
||
return {
|
||
onClick: () => {
|
||
if (record.StockCount > 0) {
|
||
StockSelected(record);
|
||
}
|
||
},
|
||
};
|
||
},
|
||
},
|
||
];
|
||
|
||
const Prodcolumns = [
|
||
{
|
||
title: 'Product Name',
|
||
dataIndex: 'ProdName',
|
||
key: 'ProdName',
|
||
align: 'center',
|
||
render: (text) => <a style={{ color: 'black' }}>{text}</a>,
|
||
},
|
||
{
|
||
title: 'Size',
|
||
dataIndex: 'Size',
|
||
key: 'Size',
|
||
align: 'center',
|
||
render: (text) => <a style={{ color: 'black' }}>{text}</a>,
|
||
},
|
||
{
|
||
title: 'UomName',
|
||
dataIndex: 'UomName',
|
||
key: 'UomName',
|
||
align: 'center',
|
||
render: (text) => <a style={{ color: 'black' }}>{text}</a>,
|
||
},
|
||
{
|
||
title: 'ExpDate',
|
||
dataIndex: 'ExpDate',
|
||
key: 'ExpDate',
|
||
align: 'center',
|
||
render: (text) => <a style={{ color: 'black' }}>{text}</a>,
|
||
},
|
||
];
|
||
|
||
const onChangeprodFunction = async (e) => {
|
||
setselectedprod(e);
|
||
|
||
let data = {
|
||
AppId: propsData?.AppId,
|
||
CompId: propsData?.CompId,
|
||
BranchId: propsData?.BranchId,
|
||
comboName: e,
|
||
ActiveStatus: 'A',
|
||
};
|
||
|
||
let Response = await dispatch(Comboget(data)).unwrap();
|
||
if (Response?.data?.statusCode == 1) {
|
||
setDropDown(Response?.data?.data);
|
||
} else {
|
||
setDropDown();
|
||
}
|
||
const comboData = Response?.data?.data?.[0];
|
||
const inwardDetails = comboData?.ComboInwardDetails?.[0]?.QRCode === e;
|
||
|
||
if (inwardDetails) {
|
||
// Set the ComboId or perform any other actions needed when there’s a match
|
||
const selectedOption = Response?.data?.data;
|
||
|
||
onSelectCombo(selectedOption);
|
||
}
|
||
};
|
||
useEffect(() => {
|
||
setPreOrderSelectedProdNames(GPreOrderList);
|
||
}, [GPreOrderList]);
|
||
|
||
useEffect(() => {
|
||
setPreOrderSelectedProdNames([]);
|
||
// dispatch(changePreOrderAdditem(null));
|
||
}, [preOrder]);
|
||
|
||
const onSelectCombo = async (selectedOption) => {
|
||
let count = selectedOption?.[0]?.ComboInwardDetails?.length;
|
||
setQtydata(selectedOption);
|
||
let alreadyOrdercount = await returnCount(
|
||
selectedOption?.[0]?.ComboName,
|
||
selectedOption?.[0]?.OverallQuantity,
|
||
CartOrderDetails
|
||
);
|
||
if (alreadyOrdercount <= 0) {
|
||
setMessageType('error');
|
||
setMessageData('Stock Not Available');
|
||
} else if (count > 1) {
|
||
setModelstock(true);
|
||
form.resetFields(['ProdName']);
|
||
setselectedprod('');
|
||
} else {
|
||
onAutocompleteChange(selectedOption);
|
||
form.resetFields(['ProdName']);
|
||
setselectedprod('');
|
||
}
|
||
};
|
||
|
||
const returnCount = (ProdName, currentQty, orderDetails) => {
|
||
let SelectedProduct = ReorderProductData?.filter(
|
||
(a) => a?.ProdName === ProdName
|
||
);
|
||
let totalSelectedProductQty = SelectedProduct?.reduce(
|
||
(accumulator, card) => {
|
||
return (
|
||
accumulator +
|
||
parseInt(
|
||
card?.StockAvailable === 'Y'
|
||
? card.SinglePc !== 'Y'
|
||
? card.OrderQty
|
||
: card.OverAllPcs % card.NoOfPcs >= card.OrderQty
|
||
? 0
|
||
: card.OrderQty % card.NoOfPcs === 0
|
||
? Math.floor(card.OrderQty / card.NoOfPcs)
|
||
: Math.floor(card.OrderQty / card.NoOfPcs) + 1
|
||
: 0
|
||
)
|
||
);
|
||
},
|
||
0
|
||
);
|
||
let getCurrentProdDtl = orderDetails?.filter(
|
||
(a) => a?.ProdName === ProdName
|
||
);
|
||
let totalOrderQty = getCurrentProdDtl?.reduce((accumulator, card) => {
|
||
return (
|
||
accumulator +
|
||
parseInt(
|
||
card?.StockAvailable === 'Y'
|
||
? card.SinglePc !== 'Y'
|
||
? card.OrderQty
|
||
: card.OverAllPcs % card.NoOfPcs >= card.OrderQty
|
||
? 0
|
||
: card.OrderQty % card.NoOfPcs === 0
|
||
? Math.floor(card.OrderQty / card.NoOfPcs)
|
||
: Math.floor(card.OrderQty / card.NoOfPcs) + 1
|
||
: 0
|
||
)
|
||
);
|
||
}, 0);
|
||
let OverallProdQty = totalOrderQty - totalSelectedProductQty;
|
||
if (
|
||
parseInt(currentQty) >
|
||
parseInt(
|
||
Object.keys(ReportholdData)?.length > 0 && totalOrderQty
|
||
? OverallProdQty
|
||
: getCurrentProdDtl
|
||
? totalOrderQty
|
||
: 0
|
||
)
|
||
) {
|
||
let count =
|
||
parseInt(currentQty) -
|
||
parseInt(
|
||
Object.keys(ReportholdData)?.length > 0 && totalOrderQty
|
||
? OverallProdQty
|
||
: getCurrentProdDtl
|
||
? totalOrderQty
|
||
: 0
|
||
);
|
||
|
||
return parseInt(count);
|
||
} else {
|
||
let count = 0;
|
||
return count;
|
||
}
|
||
};
|
||
|
||
const onAutocompleteChange = async (selectedOption) => {
|
||
let OrderRate =
|
||
selectedOption?.[0]?.ComboInwardDetails?.[0]?.TotalSellPrice;
|
||
|
||
let data = {
|
||
Type: 'C',
|
||
OverallQuantity: selectedOption?.[0]?.OverallQuantity,
|
||
ActiveStatus: selectedOption?.[0]?.ActiveStatus,
|
||
AvailableFrom: selectedOption?.[0]?.ValidFrom,
|
||
AvailableTo: selectedOption?.[0]?.ValidTo,
|
||
ProdId: selectedOption?.[0]?.ComboId,
|
||
ProdDetail: selectedOption?.[0]?.ComboInwardDetails?.[0]?.ComboDetails,
|
||
ProdName: selectedOption?.[0]?.ComboName,
|
||
QRCode: selectedOption?.[0]?.ComboInwardDetails?.[0]?.QRCode,
|
||
StockAvailable: 'Y',
|
||
BalanceQty: selectedOption?.[0]?.ComboInwardDetails?.[0]?.BalanceQty,
|
||
InwardDtlId:
|
||
selectedOption?.[0]?.ComboInwardDetails?.[0]?.ComboInwardDtlId,
|
||
MRP: selectedOption?.[0]?.ComboInwardDetails?.[0]?.TotalSellPrice,
|
||
OrderRate: selectedOption?.[0]?.ComboInwardDetails?.[0]?.TotalSellPrice,
|
||
SellingPrice:
|
||
selectedOption?.[0]?.ComboInwardDetails?.[0]?.TotalSellPrice,
|
||
BookingTypeName: BookingType,
|
||
TaxPercentage: 0,
|
||
Size: 1,
|
||
UomName: 'PCS',
|
||
OfferType: selectedOption?.[0]?.ComboInwardDetails?.[0]?.OfferType,
|
||
OfferPrice: selectedOption?.[0]?.ComboInwardDetails?.[0]?.OfferPrice,
|
||
OfferValue:
|
||
selectedOption?.[0]?.ComboInwardDetails?.[0]?.OfferType === 'F'
|
||
? selectedOption?.[0]?.ComboInwardDetails?.[0]?.OfferPrice
|
||
: (OrderRate *
|
||
selectedOption?.[0]?.ComboInwardDetails?.[0]?.OfferPrice) /
|
||
100,
|
||
SinglePc: 'N',
|
||
};
|
||
|
||
await AddOrderDetails(data);
|
||
};
|
||
|
||
const AddOrderDetails = async (item) => {
|
||
if (preOrder) {
|
||
let Response = await dispatch(
|
||
getConfigType({ TypeName: 'Booking Type' })
|
||
).unwrap();
|
||
let BookingTypeID;
|
||
if (Response?.data?.statusCode == 1) {
|
||
BookingTypeID = Response?.data?.data?.find(
|
||
(item) => item?.ConfigName === 'Dine In'
|
||
)?.ConfigId;
|
||
}
|
||
let Condition = PreOrderSelectedProdNames?.some(
|
||
(obj) =>
|
||
obj?.InwardDtlId === item?.InwardDtlId &&
|
||
obj?.SinglePc === item?.SinglePc
|
||
);
|
||
|
||
if (Condition !== undefined && Condition === true) {
|
||
setMessageData('Dublicate Data');
|
||
setMessageType('error');
|
||
} else {
|
||
let OfferPri =
|
||
item?.OfferType === 'F'
|
||
? item?.OfferPrice
|
||
: (item?.OrderRate * item?.OfferPrice) / 100;
|
||
const SelectedProduct = {
|
||
ProdId: item?.ProdId,
|
||
InwardDtlId: item?.InwardDtlId,
|
||
ProdNameQty:
|
||
item?.Type != 'C'
|
||
? item?.ProdName + ' ' + item?.Size + ' ' + item?.UomName
|
||
: `${item?.ProdName} (1 Combo)`,
|
||
ProdName: item?.ProdName,
|
||
ProdDetail: item.ProdDetail,
|
||
OrderQty: 1,
|
||
OrderRate: item?.OrderRate,
|
||
SellingPrice: item?.SellingPrice,
|
||
TotalAmt: item?.OrderRate - OfferPri,
|
||
Image: null,
|
||
Description: null,
|
||
Type: item?.Type,
|
||
TaxAmt: 0,
|
||
RefundQty: 0,
|
||
TaxId: item?.TaxId,
|
||
OrderStatus: 'O',
|
||
OrderType: 'PRE',
|
||
SinglePc: item?.SinglePc,
|
||
BookingType: BookingTypeID,
|
||
TaxPercentage: 0,
|
||
Size: 1,
|
||
UomName: 'Combo',
|
||
OfferType: item?.OfferType,
|
||
OfferValue: item?.OfferPrice,
|
||
OfferAmt: OfferPri,
|
||
WithoutTaxRate:
|
||
1 * item?.OrderRate -
|
||
(
|
||
(1 * item?.OrderRate * item?.TaxPercentage) /
|
||
(100 + item?.TaxPercentage)
|
||
).toFixed(2),
|
||
};
|
||
|
||
let Data = [SelectedProduct];
|
||
|
||
if (PreOrderSelectedProdNames?.length > 0) {
|
||
for (let i = 0; i < PreOrderSelectedProdNames?.length; i++) {
|
||
Data.push(PreOrderSelectedProdNames[i]);
|
||
}
|
||
}
|
||
if (GPreOrderList) {
|
||
let updatedGPreOrderList = [...GPreOrderList];
|
||
Data?.forEach((product) => {
|
||
const exists = updatedGPreOrderList.some(
|
||
(gProduct) => gProduct.InwardDtlId === product.InwardDtlId
|
||
); // && gProduct.SinglePc === product.SinglePc
|
||
if (!exists) {
|
||
updatedGPreOrderList.push(product);
|
||
}
|
||
});
|
||
setPreOrderSelectedProdNames(Data);
|
||
dispatch(changepreOrderList(updatedGPreOrderList));
|
||
} else {
|
||
setPreOrderSelectedProdNames(Data);
|
||
dispatch(changepreOrderList(Data));
|
||
}
|
||
}
|
||
} else {
|
||
dispatch(changeHoldOrderDtl(false));
|
||
dispatch(changePreviousOrderLength(CartOrderDetails?.length));
|
||
const OtherOrderDatas = CartOrderDetails?.filter(
|
||
(cartItem) =>
|
||
!(
|
||
cartItem?.ProdId === item?.ProdId &&
|
||
cartItem?.InwardDtlId === item?.InwardDtlId &&
|
||
cartItem?.OrderRate === item?.OrderRate &&
|
||
cartItem?.BookingTypeName === item?.BookingTypeName
|
||
) && !cartItem?.SalesId
|
||
);
|
||
const OtherOrderDatawithsales = CartOrderDetails?.filter(
|
||
(cartItem) => cartItem?.SalesId
|
||
);
|
||
const OtherorderDataforNormal = CartOrderDetails?.filter(
|
||
(cartItem) =>
|
||
!(
|
||
cartItem?.ProdId === item?.ProdId &&
|
||
cartItem?.InwardDtlId === item?.InwardDtlId &&
|
||
cartItem?.OrderRate === item?.OrderRate &&
|
||
cartItem?.BookingTypeName === item?.BookingTypeName &&
|
||
!cartItem?.SalesId
|
||
)
|
||
);
|
||
const isItemInCart = CartOrderDetails?.find(
|
||
(cartItem) =>
|
||
cartItem?.ProdId === item?.ProdId &&
|
||
cartItem?.InwardDtlId === item?.InwardDtlId &&
|
||
cartItem?.OrderRate === item?.OrderRate &&
|
||
cartItem?.BookingTypeName === item?.BookingTypeName &&
|
||
!cartItem?.SalesId
|
||
); // check if the item is already in the cart
|
||
const isItemNotInDine = CartOrderDetails?.find(
|
||
(cartItem) =>
|
||
cartItem?.ProdId === item?.ProdId &&
|
||
cartItem?.InwardDtlId === item?.InwardDtlId &&
|
||
cartItem?.OrderRate === item?.OrderRate &&
|
||
cartItem?.BookingTypeName === item?.BookingTypeName &&
|
||
!cartItem?.SalesId
|
||
); // check if the item is already in the cart
|
||
const isItemInCartSalesId = CartOrderDetails?.find(
|
||
(cartItem) =>
|
||
cartItem?.ProdId === item?.ProdId &&
|
||
cartItem?.InwardDtlId === item?.InwardDtlId &&
|
||
cartItem?.OrderRate === item?.OrderRate &&
|
||
cartItem?.BookingTypeName === item?.BookingTypeName &&
|
||
cartItem?.SalesId
|
||
); // check if the item is already in the cart
|
||
const isItemInCartHold = CartOrderDetails?.find(
|
||
(cartItem) =>
|
||
cartItem?.ProdId === item?.ProdId &&
|
||
cartItem?.InwardDtlId === item?.InwardDtlId &&
|
||
cartItem?.OrderRate === item?.OrderRate &&
|
||
cartItem?.BookingTypeName === item?.BookingTypeName
|
||
); // check if the item is already in the cart
|
||
const OtherorderDataforNormalWithoutSalesId = CartOrderDetails?.filter(
|
||
(cartItem) =>
|
||
!(
|
||
cartItem?.ProdId === item?.ProdId &&
|
||
cartItem?.InwardDtlId === item?.InwardDtlId &&
|
||
cartItem?.OrderRate === item?.OrderRate &&
|
||
cartItem?.BookingTypeName === item?.BookingTypeName
|
||
)
|
||
);
|
||
|
||
const BookingTypeProd = item?.BookingTypeName;
|
||
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?.OfferPrice > 0
|
||
? (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate -
|
||
(isItemInCart?.OfferType === 'F'
|
||
? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice
|
||
: ((isItemInCart?.OrderQty + 1) *
|
||
isItemInCart?.OrderRate *
|
||
isItemInCart?.OfferPrice) /
|
||
100)
|
||
: (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate,
|
||
// TotalAmt: ((isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate),
|
||
OfferValue:
|
||
item?.OfferType === 'F'
|
||
? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice
|
||
: isItemInCart?.OfferPrice,
|
||
|
||
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),
|
||
};
|
||
|
||
dispatch(
|
||
changeOrderCardDetails([
|
||
UpdatedCartItem,
|
||
...OtherorderDataforNormal,
|
||
])
|
||
);
|
||
} else {
|
||
const UpdatedCartItem =
|
||
// if the item is already in the cart, increase the quantity of the item
|
||
{
|
||
...isItemInCart,
|
||
OrderQty: isItemInCart?.OrderQty + 1,
|
||
TotalAmt:
|
||
isItemInCart?.OfferPrice > 0
|
||
? (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate -
|
||
(isItemInCart?.OfferType === 'F'
|
||
? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice
|
||
: ((isItemInCart?.OrderQty + 1) *
|
||
isItemInCart?.OrderRate *
|
||
isItemInCart?.OfferPrice) /
|
||
100)
|
||
: (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate,
|
||
OfferValue:
|
||
item?.OfferType === 'F'
|
||
? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice
|
||
: ((isItemInCart?.OrderQty + 1) *
|
||
isItemInCart?.OrderRate *
|
||
isItemInCart?.OfferPrice) /
|
||
100,
|
||
// 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),
|
||
};
|
||
|
||
dispatch(
|
||
changeOrderCardDetails([
|
||
...OtherorderDataforNormal,
|
||
UpdatedCartItem,
|
||
])
|
||
);
|
||
}
|
||
}
|
||
//mohan for both
|
||
else 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?.OfferPrice > 0
|
||
? (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate -
|
||
(isItemInCart?.OfferType === 'F'
|
||
? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice
|
||
: ((isItemInCart?.OrderQty + 1) *
|
||
isItemInCart?.OrderRate *
|
||
isItemInCart?.OfferPrice) /
|
||
100)
|
||
: (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate,
|
||
OfferValue:
|
||
item?.OfferType === 'F'
|
||
? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice
|
||
: isItemInCart?.OfferPrice,
|
||
|
||
// 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),
|
||
};
|
||
|
||
dispatch(
|
||
changeOrderCardDetails([
|
||
UpdatedCartItem,
|
||
...OtherorderDataforNormal,
|
||
])
|
||
);
|
||
} else {
|
||
const UpdatedCartItem =
|
||
// if the item is already in the cart, increase the quantity of the item
|
||
{
|
||
...isItemInCart,
|
||
OrderQty: isItemInCart?.OrderQty + 1,
|
||
TotalAmt:
|
||
isItemInCart?.OfferPrice > 0
|
||
? (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate -
|
||
(isItemInCart?.OfferType === 'F'
|
||
? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice
|
||
: ((isItemInCart?.OrderQty + 1) *
|
||
isItemInCart?.OrderRate *
|
||
isItemInCart?.OfferPrice) /
|
||
100)
|
||
: (isItemInCart?.OrderQty + 1) * isItemInCart?.OrderRate,
|
||
OfferValue:
|
||
item?.OfferType === 'F'
|
||
? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice
|
||
: isItemInCart?.OfferPrice,
|
||
|
||
// 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),
|
||
};
|
||
|
||
dispatch(
|
||
changeOrderCardDetails([
|
||
...OtherorderDataforNormal,
|
||
UpdatedCartItem,
|
||
])
|
||
);
|
||
}
|
||
} 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?.OfferPrice > 0
|
||
? (isItemInCartHold?.OrderQty + 1) *
|
||
isItemInCartHold?.OrderRate -
|
||
(isItemInCartHold?.OfferType === 'F'
|
||
? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice
|
||
: ((isItemInCartHold?.OrderQty + 1) *
|
||
isItemInCartHold?.OrderRate *
|
||
isItemInCartHold?.OfferPrice) /
|
||
100)
|
||
: (isItemInCartHold?.OrderQty + 1) *
|
||
isItemInCartHold?.OrderRate,
|
||
OfferValue:
|
||
item?.OfferType === 'F'
|
||
? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice
|
||
: isItemInCart?.OfferPrice,
|
||
|
||
// 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),
|
||
};
|
||
|
||
dispatch(
|
||
changeOrderCardDetails([
|
||
UpdatedCartItem,
|
||
...OtherorderDataforNormalWithoutSalesId,
|
||
])
|
||
);
|
||
} else {
|
||
const UpdatedCartItem =
|
||
// if the item is already in the cart, increase the quantity of the item
|
||
{
|
||
...isItemInCartHold,
|
||
OrderQty: isItemInCartHold?.OrderQty + 1,
|
||
TotalAmt:
|
||
isItemInCartHold?.OfferPrice > 0
|
||
? (isItemInCartHold?.OrderQty + 1) *
|
||
isItemInCartHold?.OrderRate -
|
||
(isItemInCartHold?.OfferType === 'F'
|
||
? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice
|
||
: ((isItemInCartHold?.OrderQty + 1) *
|
||
isItemInCartHold?.OrderRate *
|
||
isItemInCartHold?.OfferPrice) /
|
||
100)
|
||
: (isItemInCartHold?.OrderQty + 1) *
|
||
isItemInCartHold?.OrderRate,
|
||
OfferValue:
|
||
item?.OfferType === 'F'
|
||
? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice
|
||
: isItemInCart?.OfferPrice,
|
||
|
||
// 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),
|
||
};
|
||
|
||
dispatch(
|
||
changeOrderCardDetails([
|
||
...OtherorderDataforNormalWithoutSalesId,
|
||
UpdatedCartItem,
|
||
])
|
||
);
|
||
}
|
||
} else if (
|
||
isItemNotInDine &&
|
||
BookingTypeProd == 'Dine In' &&
|
||
OrderType != 'Hold'
|
||
) {
|
||
if (BillOrderPre === 'Y') {
|
||
const UpdatedCartItem = {
|
||
...isItemNotInDine,
|
||
OrderQty: isItemNotInDine?.OrderQty + 1,
|
||
TotalAmt:
|
||
isItemNotInDine?.OfferPrice > 0
|
||
? (isItemNotInDine?.OrderQty + 1) * isItemNotInDine?.OrderRate -
|
||
(isItemNotInDine?.OfferType === 'F'
|
||
? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice
|
||
: ((isItemNotInDine?.OrderQty + 1) *
|
||
isItemNotInDine?.OrderRate *
|
||
isItemNotInDine?.OfferPrice) /
|
||
100)
|
||
: (isItemNotInDine?.OrderQty + 1) * isItemNotInDine?.OrderRate,
|
||
OfferValue:
|
||
item?.OfferType === 'F'
|
||
? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice
|
||
: isItemInCart?.OfferPrice,
|
||
|
||
// TotalAmt: ((isItemNotInDine?.OrderQty + 1) * isItemNotInDine?.OrderRate),
|
||
TaxAmt: (
|
||
((isItemNotInDine?.OrderQty + 1) *
|
||
isItemNotInDine?.OrderRate *
|
||
isItemNotInDine?.TaxPercentage) /
|
||
(100 + isItemNotInDine?.TaxPercentage)
|
||
).toFixed(2),
|
||
WithoutTaxRate:
|
||
(isItemNotInDine?.OrderQty + 1) * isItemNotInDine?.OrderRate -
|
||
(
|
||
((isItemNotInDine?.OrderQty + 1) *
|
||
isItemNotInDine?.OrderRate *
|
||
isItemNotInDine?.TaxPercentage) /
|
||
(100 + isItemNotInDine?.TaxPercentage)
|
||
).toFixed(2),
|
||
};
|
||
// otherwise, return the cart item
|
||
dispatch(
|
||
changeOrderCardDetails([
|
||
UpdatedCartItem,
|
||
...OtherOrderDatas,
|
||
...OtherOrderDatawithsales,
|
||
])
|
||
);
|
||
} else {
|
||
const UpdatedCartItem = {
|
||
...isItemNotInDine,
|
||
OrderQty: isItemNotInDine?.OrderQty + 1,
|
||
TotalAmt:
|
||
isItemNotInDine?.OfferPrice > 0
|
||
? (isItemNotInDine?.OrderQty + 1) * isItemNotInDine?.OrderRate -
|
||
(isItemNotInDine?.OfferType === 'F'
|
||
? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice
|
||
: ((isItemNotInDine?.OrderQty + 1) *
|
||
isItemNotInDine?.OrderRate *
|
||
isItemNotInDine?.OfferPrice) /
|
||
100)
|
||
: (isItemNotInDine?.OrderQty + 1) * isItemNotInDine?.OrderRate,
|
||
OfferValue:
|
||
item?.OfferType === 'F'
|
||
? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice
|
||
: isItemInCart?.OfferPrice,
|
||
|
||
// TotalAmt: ((isItemNotInDine?.OrderQty + 1) * isItemNotInDine?.OrderRate),
|
||
TaxAmt: (
|
||
((isItemNotInDine?.OrderQty + 1) *
|
||
isItemNotInDine?.OrderRate *
|
||
isItemNotInDine?.TaxPercentage) /
|
||
(100 + isItemNotInDine?.TaxPercentage)
|
||
).toFixed(2),
|
||
WithoutTaxRate:
|
||
(isItemNotInDine?.OrderQty + 1) * isItemNotInDine?.OrderRate -
|
||
(
|
||
((isItemNotInDine?.OrderQty + 1) *
|
||
isItemNotInDine?.OrderRate *
|
||
isItemNotInDine?.TaxPercentage) /
|
||
(100 + isItemNotInDine?.TaxPercentage)
|
||
).toFixed(2),
|
||
};
|
||
// otherwise, return the cart item
|
||
dispatch(
|
||
changeOrderCardDetails([
|
||
...OtherOrderDatawithsales,
|
||
...OtherOrderDatas,
|
||
UpdatedCartItem,
|
||
])
|
||
);
|
||
}
|
||
} else {
|
||
if (item?.OtherProduct === 'Others') {
|
||
BillOrderPre === 'Y'
|
||
? dispatch(
|
||
changeOrderCardDetails([
|
||
{
|
||
...item,
|
||
// TotalAmt: (((item?.OrderQty + 1) * item?.OrderRate)- (item?.OfferType === "F" ?item?.OfferPrice :(((item?.OrderQty + 1) * item?.OrderRate) * item?.OfferPrice)/100)),
|
||
|
||
TotalAmt: item?.OrderQty * item?.OrderRate,
|
||
TaxAmt: (
|
||
(item?.OrderQty * item?.OrderRate * item?.TaxPercentage) /
|
||
(100 + item?.TaxPercentage)
|
||
).toFixed(2),
|
||
WithoutTaxRate: (
|
||
item?.OrderQty * item?.OrderRate -
|
||
(item?.OrderQty * item?.OrderRate * item?.TaxPercentage) /
|
||
(100 + item?.TaxPercentage)
|
||
).toFixed(2),
|
||
},
|
||
...CartOrderDetails,
|
||
])
|
||
) // if the item is not in the cart, add the item to the cart
|
||
: dispatch(
|
||
changeOrderCardDetails([
|
||
...CartOrderDetails,
|
||
{
|
||
...item,
|
||
TotalAmt: item?.OrderQty * item?.OrderRate,
|
||
|
||
// TotalAmt: (((item?.OrderQty + 1) * item?.OrderRate)- (item?.OfferType === "F" ?item?.OfferPrice :(((item?.OrderQty + 1) * item?.OrderRate) * item?.OfferPrice)/100)),
|
||
TaxAmt: (
|
||
(item?.OrderQty * item?.OrderRate * item?.TaxPercentage) /
|
||
(100 + item?.TaxPercentage)
|
||
).toFixed(2),
|
||
WithoutTaxRate: (
|
||
item?.OrderQty * item?.OrderRate -
|
||
(item?.OrderQty * item?.OrderRate * item?.TaxPercentage) /
|
||
(100 + item?.TaxPercentage)
|
||
).toFixed(2),
|
||
},
|
||
])
|
||
);
|
||
} else {
|
||
BillOrderPre === 'Y'
|
||
? dispatch(
|
||
changeOrderCardDetails([
|
||
{
|
||
...item,
|
||
OrderQty: 1,
|
||
// TotalAmt: (((item?.OrderQty + 1) * item?.OrderRate)- (item?.OfferType === "F" ?item?.OfferPrice :(((item?.OrderQty + 1) * item?.OrderRate) * item?.OfferPrice)/100)),
|
||
OfferPrice: item?.OfferPrice,
|
||
TotalAmt:
|
||
item?.OfferPrice > 0
|
||
? item?.OrderRate -
|
||
(item?.OfferType === 'F'
|
||
? item?.OfferPrice
|
||
: (item?.OrderRate * item?.OfferPrice) / 100)
|
||
: item?.OrderRate,
|
||
TaxAmt: (
|
||
(item?.OrderRate * item?.TaxPercentage) /
|
||
(100 + item?.TaxPercentage)
|
||
).toFixed(2),
|
||
WithoutTaxRate: (
|
||
item?.OrderRate -
|
||
(item?.OrderRate * item?.TaxPercentage) /
|
||
(100 + item?.TaxPercentage)
|
||
).toFixed(2),
|
||
},
|
||
...CartOrderDetails,
|
||
])
|
||
) // if the item is not in the cart, add the item to the cart
|
||
: dispatch(
|
||
changeOrderCardDetails([
|
||
...CartOrderDetails,
|
||
{
|
||
...item,
|
||
OrderQty: 1,
|
||
// TotalAmt: (((item?.OrderQty + 1) * item?.OrderRate)- (item?.OfferType === "F" ?item?.OfferPrice :(((item?.OrderQty + 1) * item?.OrderRate) * item?.OfferPrice)/100)),
|
||
OfferPrice: item?.OfferPrice,
|
||
TotalAmt:
|
||
item?.OfferPrice > 0
|
||
? item?.OrderRate -
|
||
(item?.OfferType === 'F'
|
||
? item?.OfferPrice
|
||
: (item?.OrderRate * item?.OfferPrice) / 100)
|
||
: item?.OrderRate,
|
||
TaxAmt: (
|
||
(item?.OrderRate * item?.TaxPercentage) /
|
||
(100 + item?.TaxPercentage)
|
||
).toFixed(2),
|
||
WithoutTaxRate: (
|
||
item?.OrderRate -
|
||
(item?.OrderRate * item?.TaxPercentage) /
|
||
(100 + item?.TaxPercentage)
|
||
).toFixed(2),
|
||
},
|
||
])
|
||
);
|
||
}
|
||
}
|
||
dispatch(changeothersdata({}));
|
||
dispatch(ChangeNewQrProduct({}));
|
||
}
|
||
};
|
||
|
||
const CloseModal1 = () => {
|
||
setModelstock(false);
|
||
};
|
||
|
||
const returnCountStock = (ProdId, currentQty, orderDetails, InwardDtlId) => {
|
||
let SelectedProduct = ReorderProductData?.filter(
|
||
(a) => a?.ProdId === ProdId && a?.InwardDtlId === InwardDtlId
|
||
);
|
||
let totalSelectedProductQty = SelectedProduct?.reduce(
|
||
(accumulator, card) => {
|
||
return accumulator + parseInt(card.OrderQty || 0);
|
||
},
|
||
0
|
||
);
|
||
let getCurrentProdDtl = orderDetails?.filter(
|
||
(a) => a?.ProdId === ProdId && a?.InwardDtlId === InwardDtlId
|
||
);
|
||
|
||
let totalOrderQty = getCurrentProdDtl?.reduce((accumulator, card) => {
|
||
return accumulator + parseInt(card.OrderQty || 0);
|
||
}, 0);
|
||
|
||
let OverallProdQty = totalOrderQty - totalSelectedProductQty;
|
||
if (
|
||
parseInt(currentQty) >
|
||
parseInt(
|
||
Object.keys(ReportholdData)?.length > 0 && totalOrderQty
|
||
? OverallProdQty
|
||
: getCurrentProdDtl
|
||
? totalOrderQty
|
||
: 0
|
||
)
|
||
) {
|
||
let count =
|
||
parseInt(currentQty) -
|
||
parseInt(
|
||
Object.keys(ReportholdData)?.length > 0 && totalOrderQty
|
||
? OverallProdQty
|
||
: getCurrentProdDtl
|
||
? totalOrderQty
|
||
: 0
|
||
);
|
||
return parseInt(count);
|
||
} else {
|
||
let count = 0;
|
||
return count;
|
||
}
|
||
};
|
||
|
||
const stockdataSource = [];
|
||
let ProdId = qtydata?.[0]?.ComboId;
|
||
|
||
qtydata?.[0]?.ComboInwardDetails?.map((item, index) => {
|
||
stockdataSource.push({
|
||
key: index,
|
||
ComboInwardDtlId: item.ComboInwardDtlId,
|
||
StockCount: returnCountStock(
|
||
ProdId,
|
||
item.BalanceQty,
|
||
CartOrderDetails,
|
||
item?.ComboInwardDtlId
|
||
),
|
||
Price: item.TotalSellPrice,
|
||
});
|
||
});
|
||
|
||
const StockSelected = (item) => {
|
||
let Expdates = qtydata?.[0]?.ComboInwardDetails?.filter(
|
||
(a) => a.ComboInwardDtlId === item.ComboInwardDtlId
|
||
)?.[0]?.ComboDetails.map((detail) => detail.ExpDate);
|
||
|
||
let Combodata = qtydata?.[0]?.ComboInwardDetails?.filter(
|
||
(a) => a.ComboInwardDtlId === item.ComboInwardDtlId
|
||
)?.[0]?.ComboDetails;
|
||
|
||
let Cartdata = qtydata?.[0]?.ComboInwardDetails?.filter(
|
||
(a) => a.ComboInwardDtlId === item.ComboInwardDtlId
|
||
);
|
||
|
||
const today = new Date();
|
||
|
||
const matchingProducts = Combodata?.filter((detail) => {
|
||
if (detail.ExpDate != null) {
|
||
const expDate = new Date(detail.ExpDate);
|
||
return Expdates.includes(detail.ExpDate) && expDate < today;
|
||
} else {
|
||
return false;
|
||
}
|
||
})?.map((detail) => ({
|
||
ProdName: detail?.ProdName,
|
||
Size: detail?.Size,
|
||
UomName: detail?.UomName,
|
||
ExpDate: detail?.ExpDate,
|
||
}));
|
||
|
||
let data = {
|
||
Type: 'C',
|
||
OverallQuantity: qtydata?.[0]?.OverallQuantity,
|
||
ActiveStatus: qtydata?.[0]?.ActiveStatus,
|
||
AvailableFrom: qtydata?.[0]?.ValidFrom,
|
||
AvailableTo: qtydata?.[0]?.ValidTo,
|
||
ProdId: qtydata?.[0]?.ComboId,
|
||
ProdDetail: Combodata,
|
||
ProdName: qtydata?.[0]?.ComboName,
|
||
QRCode: qtydata?.[0]?.ComboInwardDetails?.[0]?.QRCode,
|
||
StockAvailable: 'Y',
|
||
BalanceQty: qtydata?.[0]?.ComboInwardDetails?.[0]?.BalanceQty,
|
||
InwardDtlId: Cartdata?.[0]?.ComboInwardDtlId,
|
||
MRP: qtydata?.[0]?.ComboInwardDetails?.[0]?.TotalSellPrice,
|
||
OrderRate: qtydata?.[0]?.ComboInwardDetails?.[0]?.TotalSellPrice,
|
||
SellingPrice: qtydata?.[0]?.ComboInwardDetails?.[0]?.TotalSellPrice,
|
||
BookingTypeName: BookingType,
|
||
TaxPercentage: 0,
|
||
Size: 1,
|
||
UomName: 'Combo',
|
||
OfferType: Cartdata?.[0]?.OfferType,
|
||
OfferValue:
|
||
Cartdata?.[0]?.OfferType === 'F'
|
||
? Cartdata?.[0]?.OfferPrice
|
||
: (qtydata?.[0]?.ComboInwardDetails?.[0]?.TotalSellPrice *
|
||
Cartdata?.[0]?.OfferPrice) /
|
||
100,
|
||
OfferPrice: Cartdata?.[0]?.OfferPrice,
|
||
SinglePc: 'N',
|
||
};
|
||
|
||
setExpdata(data);
|
||
|
||
setExpProd(matchingProducts);
|
||
if (matchingProducts?.length > 0) {
|
||
setexpModel(true);
|
||
} else if (expModel === false) {
|
||
AddOrderDetails(data);
|
||
} else {
|
||
onAutocompleteChange(Combodata);
|
||
}
|
||
|
||
setModelstock(false);
|
||
};
|
||
|
||
const expFun = (item) => {
|
||
AddOrderDetails(Expdata);
|
||
setexpModel(false);
|
||
setModelstock(false);
|
||
};
|
||
const handleSearch = async (value) => {
|
||
if (value === '') {
|
||
setDropDown();
|
||
}
|
||
|
||
// Call onChangeprodFunction if the value is not empty and doesn't include '@'
|
||
if (value && !value.includes('@')) {
|
||
await onChangeprodFunction(value);
|
||
}
|
||
|
||
// setOptions(() => {
|
||
// if (!value || value.includes('@')) {
|
||
// return [];
|
||
// }
|
||
|
||
return DropDown && Array.isArray(DropDown)
|
||
? DropDown.map((item) => ({
|
||
label: `${item.ComboName}`, // Display the combo name
|
||
value: `${item.ComboId}`, // Use combo ID as the value
|
||
}))
|
||
: [];
|
||
// });
|
||
};
|
||
// const stopScannerFromParent = () => {
|
||
// if (scannerRef.current) {
|
||
// scannerRef.current.stopScanner(); // Call stopScanner from the child component
|
||
// }
|
||
// };
|
||
|
||
// const handleQrcode = () => {
|
||
// setOpenScanner((prev) => !prev);
|
||
// if (!openScanner && scannerRef.current) {
|
||
// scannerRef.current.reinitializeCamera(); // Call the function to reinitialize the camera
|
||
// }
|
||
// };
|
||
|
||
// const handleQrData = (decodedText, err) => {
|
||
// onChangeprodFunction(decodedText);
|
||
// setOpenScanner(false); // Close the modal after scanning
|
||
// stopScannerFromParent();
|
||
// if (err && err?.error) {
|
||
// setMessageData(err?.error);
|
||
// setMessageType('error');
|
||
// }
|
||
// };
|
||
return (
|
||
<div className="L">
|
||
<Messages
|
||
messageType={messageType}
|
||
messageData={messageData}
|
||
onComplete={onComplete}
|
||
/>
|
||
|
||
<div>
|
||
<Form form={form}>
|
||
<div
|
||
className={props.nosearch == true ? 'search-input' : 'search-input'}
|
||
style={
|
||
props.nosearch == true
|
||
? {
|
||
border:
|
||
background == 'white' &&
|
||
'#fff' &&
|
||
'#ffff' &&
|
||
'rgb(1, 1, 1)'
|
||
? '1px solid #000'
|
||
: '1px solid #fff',
|
||
}
|
||
: {}
|
||
}
|
||
>
|
||
<Form.Item
|
||
name="ProdName"
|
||
// style={{ margin: '-17px 8px 0px -7px' }}
|
||
// rules={
|
||
// [{ required: true, message: 'Please enter Item Name' }]
|
||
// }
|
||
className="custom-search"
|
||
>
|
||
<div className="Combosearch" style={{ height: '3rem' }}>
|
||
<AutoComplete
|
||
className={
|
||
props.nosearch == true ? 'custom-input' : 'custom-input'
|
||
}
|
||
ref={searchInputRef}
|
||
onSearch={handleSearch}
|
||
placeholder="Search Combo Product (SHIFT + S)"
|
||
// filterOption={(inputValue, option) =>
|
||
// option.label.toLowerCase().includes(inputValue.toLowerCase()) ||
|
||
// option.value.toString().toLowerCase().includes(inputValue.toLowerCase())
|
||
// }
|
||
options={DropDown?.map((option) => ({
|
||
value: option.ComboName,
|
||
label: option.ComboName,
|
||
data: option.ComboId,
|
||
}))}
|
||
value={selectedprod}
|
||
onSelect={(value, option) =>
|
||
onSelectCombo(
|
||
DropDown?.filter((a, b) => a.ComboId == option.data)
|
||
)
|
||
}
|
||
onPressEnter={(e) => onChangeprodFunction(e?.target?.value)}
|
||
onChange={(value) => setselectedprod(value)}
|
||
suffix={
|
||
<TooltipWrapper
|
||
title="Search Combo Name"
|
||
isMobile={isMobile}
|
||
>
|
||
<SearchOutlined style={{ color: 'rgba(0,0,0,.45)' }} />
|
||
</TooltipWrapper>
|
||
}
|
||
/>
|
||
</div>
|
||
{isMobile && screenWidth <= 768 ? (
|
||
// <BiBarcodeReader
|
||
// className="search-icon"
|
||
// onClick={() => handleQrcode()}
|
||
// />
|
||
<BarCodeScan
|
||
onScan={(value) => {
|
||
onChangeprodFunction(value);
|
||
}} />
|
||
) : (
|
||
<IoSearchOutline className="search-icon" />
|
||
)}
|
||
</Form.Item>
|
||
</div>
|
||
</Form>
|
||
</div>
|
||
|
||
{modelstock && (
|
||
<DefaultModal
|
||
title={
|
||
<div className="EditQuantity-title">
|
||
<FormHeader title={'Item Stock'} />
|
||
</div>
|
||
}
|
||
open={modelstock}
|
||
// width={500}
|
||
footer={null}
|
||
top={0}
|
||
handleCancel={CloseModal1}
|
||
maskTransitionName=""
|
||
transitionName=""
|
||
children={
|
||
<div>
|
||
<div
|
||
className="EditQuantity-heading"
|
||
style={{
|
||
display: 'flex',
|
||
flexDirection: 'column',
|
||
marginBottom: '3rem',
|
||
alignItems: 'start',
|
||
}}
|
||
>
|
||
<div style={{ display: 'flex' }}>
|
||
<div className="EditQuantity-headingname">
|
||
<p className="EditQuantity-itemname">Item Name:</p>
|
||
</div>
|
||
<div
|
||
className="EditQuantity-headingproductname"
|
||
style={{ marginLeft: '1rem' }}
|
||
>
|
||
<p className="EditQuantity-productname">
|
||
{qtydata?.[0]?.ComboName}
|
||
{/* {!qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.ProdVariantName?.toLowerCase()?.includes('variant') && <span>({qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.ProdVariantName}) </span>} */}
|
||
</p>
|
||
</div>
|
||
</div>
|
||
<div style={{ display: 'flex' }}>
|
||
<div className="EditQuantity-headingname">
|
||
<p className="EditQuantity-itemname">Item Quantity:</p>
|
||
</div>
|
||
<div
|
||
className="EditQuantity-headingproductname"
|
||
style={{ marginLeft: '1rem' }}
|
||
>
|
||
<p className="EditQuantity-productname">
|
||
{qtydata?.[0]?.ComboInwardDetails?.[0]?.ComboDetails?.map(
|
||
(item, index) => (
|
||
<div key={index} style={{}}>
|
||
<p>
|
||
{' '}
|
||
{index + 1}. {item.ProdName} ({item.Size}{' '}
|
||
{item.UomName}){' '}
|
||
</p>
|
||
</div>
|
||
)
|
||
)}
|
||
</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div className="Re-Print-table">
|
||
<Tables columns={stockcolumns} data={stockdataSource} />
|
||
</div>
|
||
</div>
|
||
}
|
||
/>
|
||
)}
|
||
|
||
{expModel && (
|
||
<Modal
|
||
title={
|
||
<div style={{ display: 'flex', flexDirection: 'row', gap: '1rem' }}>
|
||
<ExclamationCircleOutlined
|
||
style={{ color: 'rgb(231 176 12)', fontSize: '30px' }}
|
||
/>
|
||
<h4>Product Expires</h4>
|
||
</div>
|
||
}
|
||
open={expModel}
|
||
onOk={(Item) => expFun(Item)}
|
||
onCancel={() => setexpModel(false)}
|
||
okText="Submit"
|
||
cancelText="Don't Submit"
|
||
maskTransitionName="" // Remove animation for the mask
|
||
transitionName=""
|
||
>
|
||
<div className="Re-Print-table">
|
||
<Tables columns={Prodcolumns} data={ExpProd} />
|
||
</div>
|
||
</Modal>
|
||
)}
|
||
{/* {isMobile && screenWidth <= 768 && (
|
||
<DefaultModal
|
||
title="Barcode Reader"
|
||
width={800}
|
||
open={openScanner}
|
||
footer={false}
|
||
handleCancel={handleQrData} // Close modal on cancel
|
||
>
|
||
{openScanner && (
|
||
<BarcodeScanner
|
||
ref={scannerRef}
|
||
openScanner={openScanner}
|
||
setOpenScanner={setOpenScanner}
|
||
handleQrData={handleQrData}
|
||
type="ComboSearch"
|
||
/>
|
||
)}
|
||
</DefaultModal>
|
||
)} */}
|
||
</div>
|
||
);
|
||
};
|
||
export default BSNavBarComboSearch;
|