5099 lines
191 KiB
JavaScript
5099 lines
191 KiB
JavaScript
import React, { useCallback, useEffect, useState } from 'react';
|
|
import { shallowEqual, useDispatch, useSelector } from 'react-redux';
|
|
import moment from 'moment';
|
|
import { Badge, Modal, Tooltip } from 'antd';
|
|
import { GoTriangleRight } from 'react-icons/go';
|
|
import { ExclamationCircleOutlined } from '@ant-design/icons';
|
|
import defaultimage from '../../../../Images/defaultItemImg.png';
|
|
import FormHeader from '../../../PageComponents/FormHeader';
|
|
import {
|
|
SelectedGlobalCardColorDetail,
|
|
SelectedGlobalCardFont,
|
|
StoredSessionData,
|
|
getTemplateData,
|
|
} from '../../../../Features/ThemeChange/ThemeChange';
|
|
import { Tables } from '../../../../Components/Tables/Table';
|
|
import {
|
|
GlobalProductSubCategorie,
|
|
GlobalItemCard,
|
|
getLayoutproductCard,
|
|
GlobalOrderCardDetails,
|
|
changeOrderCardDetails,
|
|
changeSearchedData,
|
|
ChangeAllItemData,
|
|
GlobalAllItemData,
|
|
GlobalCardAccess,
|
|
getSelectedFavItems,
|
|
GlobalSelectedDatas,
|
|
GlobalEditfavItems,
|
|
getEditFavItems,
|
|
GlobalAccessForOthers,
|
|
GlobalAlldat,
|
|
Globalothersdata,
|
|
GlobalProductCategorie,
|
|
getCardDataWithoutSub,
|
|
changeothersdata,
|
|
ChangeNewQrProduct,
|
|
GlobalWSProduct,
|
|
GlobalNewQrProduct,
|
|
GlobalBookingType,
|
|
GlobalSearchData,
|
|
getCardDataWithoutSubmodule,
|
|
getPreferenceData,
|
|
changePreviousOrderLength,
|
|
changeHoldOrderDtl,
|
|
GlobalReorderHoldDetails,
|
|
GlobalUnpaidData,
|
|
GlobalWeightScalePort,
|
|
GlobalWeightScaleWeight,
|
|
changeWeightScaleWeight,
|
|
GlobalExpDateforHeight,
|
|
GlobalBookingTypeBoth,
|
|
GlobalOrderType,
|
|
GlobalReorderProductDetails,
|
|
getConfigType,
|
|
GlobalPayementloader,
|
|
GlobalPaymentTransactionNumber,
|
|
GlobalSelOption,
|
|
PreferenceData,
|
|
changeCardData,
|
|
GlobaldraggingComponent,
|
|
GlobalCombocarddata,
|
|
GlobalGetmultipleSearchDatas,
|
|
getmultipleSearch,
|
|
} from '../../../../Features/BookingScreen/BookingData/BookingData';
|
|
import {
|
|
GlobalPreOrderAdditem,
|
|
GlobalPreOrderList,
|
|
GlobalpreOrderOpen,
|
|
changepreOrderList,
|
|
} from '../../../../Features/BookingScreen/PreOrder/PreOrder';
|
|
import { DefaultModal } from '../../../../Components/Modal/DefaultModal';
|
|
import { Messages } from '../../../../Components/Notifications/Messages';
|
|
import '../../../../Styles/BookingScreen/Components/BSItemCards/BSItemCard.scss';
|
|
import WebFont from 'webfontloader';
|
|
import FeaturesFunctionalities from '../BookingFunctionality/FeaturesFunctionalities';
|
|
import { isMobile } from 'react-device-detect';
|
|
import { Global_OfferStatus } from '../../../../Features/Offer/Offer';
|
|
import {
|
|
useApplyOfferto_CardDetail,
|
|
} from '../UtillComponents/BSNavBarOffer/BSNavBarOffer_CustomHooks.jsx';
|
|
import { GlobalAddCustomerDetails } from '../../../../Features/BookingScreen/Customer/addCustomer.js';
|
|
import {
|
|
DndContext,
|
|
useSensor,
|
|
useSensors,
|
|
PointerSensor,
|
|
closestCenter,
|
|
} from '@dnd-kit/core';
|
|
import {
|
|
SortableContext,
|
|
arrayMove,
|
|
rectSortingStrategy,
|
|
} from '@dnd-kit/sortable';
|
|
import { useSortable } from '@dnd-kit/sortable';
|
|
import { v4 as uuidv4 } from "uuid";
|
|
|
|
import { CSS } from '@dnd-kit/utilities';
|
|
import { getCombolist } from '../../../../Features/ComboMaster/ComboMaster.js';
|
|
|
|
// const BSComboItemCard = () => {
|
|
|
|
// const dispatch = useDispatch();
|
|
// const SessionData = useSelector(StoredSessionData, shallowEqual);
|
|
|
|
// const AppId = SessionData?.AppId;
|
|
// const CompId = SessionData?.CompId;
|
|
// const BranchId = SessionData?.BranchId;
|
|
|
|
// const [ComboCardata,setCombocardata] = useState([]);
|
|
|
|
// useEffect(()=>{
|
|
// Combocarddata();
|
|
// },[])
|
|
|
|
// const Combocarddata = async () => {
|
|
|
|
// let data = {
|
|
// CompId: CompId,
|
|
// BranchId: BranchId,
|
|
// AppId : AppId,
|
|
// ActiveStatus: 'A',
|
|
// };
|
|
|
|
// let response = await dispatch(getCombolist(data)).unwrap();
|
|
|
|
// if (response?.data?.statusCode == 1) {
|
|
// setCombocardata(response?.data?.data);
|
|
// }
|
|
|
|
// };
|
|
|
|
// return (
|
|
|
|
// <div>BSComboItemCard</div>
|
|
// )
|
|
// }
|
|
|
|
// export default BSComboItemCard
|
|
|
|
export function SortableCard({ id, children, item }) {
|
|
const {
|
|
attributes,
|
|
listeners,
|
|
setNodeRef,
|
|
transform,
|
|
transition,
|
|
isDragging,
|
|
} = useSortable({ id });
|
|
const style = {
|
|
transform: CSS.Transform.toString(transform),
|
|
transition,
|
|
opacity: isDragging ? 0.5 : 1,
|
|
};
|
|
const draggingComponent = useSelector(GlobaldraggingComponent);
|
|
const allowDrag = draggingComponent === 'card';
|
|
return (
|
|
<div
|
|
ref={setNodeRef}
|
|
style={style}
|
|
{...(allowDrag ? attributes : {})}
|
|
{...(allowDrag ? listeners : {})}
|
|
>
|
|
{children}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
const BSComboItemCard = (props) => {
|
|
const cardFunction = props.cardFunctionality;
|
|
|
|
const applyOffer = useApplyOfferto_CardDetail();
|
|
const preferenceDatas = useSelector(PreferenceData, shallowEqual);
|
|
const preferenceOffer =
|
|
preferenceDatas?.[0]?.['SettingDtlDetails']?.find(
|
|
(item) => item.SettingIdName === 'Offer'
|
|
)?.SettingValue === 'Y';
|
|
const AddCustomerDetails = useSelector(
|
|
GlobalAddCustomerDetails,
|
|
shallowEqual
|
|
);
|
|
const SelectedCust = useSelector(GlobalSelOption, shallowEqual);
|
|
const CustDetails = SelectedCust ? SelectedCust : AddCustomerDetails?.[0];
|
|
const GPreOrderList = useSelector(GlobalPreOrderList, shallowEqual);
|
|
const [modelQty, setModelQty] = useState(false);
|
|
const [modelstock, setModelstock] = useState(false);
|
|
const [ModalVarient, setModalVarient] = useState(false);
|
|
const [QtyIndex, setQtyIndex] = useState(0);
|
|
const [VarientIndex, setVarientIndex] = useState(0);
|
|
const [expModel, setexpModel] = useState(false);
|
|
const [prodexpir, setProdexpir] = useState(false);
|
|
const [expVarModel, setexpVarModel] = useState(false);
|
|
const [expStockModel, setexpStockModel] = useState(false);
|
|
const [initialRun, setInitialRun] = useState(false);
|
|
const [Item, setItem] = useState();
|
|
const [VarItem, setVarItem] = useState(0);
|
|
const [StockItem, setStockItem] = useState();
|
|
const [noSubcatCardData, setNoSubcatCardData] = useState();
|
|
const [qtydata, setQtydata] = useState();
|
|
const PreOrderAdditem = useSelector(GlobalPreOrderAdditem, shallowEqual);
|
|
const OrderType = useSelector(GlobalOrderType, shallowEqual);
|
|
const ProdSubCat = useSelector(GlobalProductSubCategorie);
|
|
const ItemCard = useSelector(GlobalItemCard, shallowEqual);
|
|
const globaldata = useSelector(GlobalAlldat, shallowEqual);
|
|
const preOrder = useSelector(GlobalpreOrderOpen, shallowEqual);
|
|
const templateData = useSelector(getTemplateData, shallowEqual);
|
|
const temp5 = templateData?.BookingLayout?.[0] === 'Layout5';
|
|
const OfferCheckedInSetup = templateData?.BookingNavbar?.[1].some(
|
|
(item) => item?.OptionName == 'Offer'
|
|
);
|
|
const globalAllItemdata = useSelector(GlobalAllItemData);
|
|
const EditfavItems = useSelector(GlobalEditfavItems);
|
|
const BookingType = useSelector(GlobalBookingType);
|
|
const ProductSearch = useSelector(GlobalSearchData);
|
|
const [SelectedProdNames, setSelectedProdNames] = useState(EditfavItems);
|
|
const [PreOrderSelectedProdNames, setPreOrderSelectedProdNames] = useState(
|
|
[]
|
|
);
|
|
const OrderOfferStatus = useSelector(Global_OfferStatus);
|
|
const CardAccess = useSelector(GlobalCardAccess, shallowEqual);
|
|
const globalAccessForOthers = useSelector(
|
|
GlobalAccessForOthers,
|
|
shallowEqual
|
|
);
|
|
const SelectedCardColor = useSelector(
|
|
SelectedGlobalCardColorDetail,
|
|
shallowEqual
|
|
);
|
|
const GetmultipleSearchDatas = useSelector(GlobalGetmultipleSearchDatas, shallowEqual)
|
|
const SelectedCardFont = useSelector(SelectedGlobalCardFont, shallowEqual);
|
|
const CartOrderDetails = useSelector(GlobalOrderCardDetails, shallowEqual);
|
|
const SelectedDatas = useSelector(GlobalSelectedDatas, shallowEqual);
|
|
const otherscarddata = useSelector(Globalothersdata, shallowEqual);
|
|
const WSProductdata = useSelector(GlobalWSProduct, shallowEqual);
|
|
const NewQrProductData = useSelector(GlobalNewQrProduct, shallowEqual);
|
|
const ReportholdData = useSelector(GlobalReorderHoldDetails, shallowEqual);
|
|
const ReorderProductData = useSelector(
|
|
GlobalReorderProductDetails,
|
|
shallowEqual
|
|
);
|
|
const WeightScalePort = useSelector(GlobalWeightScalePort, shallowEqual);
|
|
const WeightScaleWeight = useSelector(GlobalWeightScaleWeight, shallowEqual);
|
|
const PaymentTransactionNumber = useSelector(
|
|
GlobalPaymentTransactionNumber,
|
|
shallowEqual
|
|
);
|
|
const ProdCat = useSelector(GlobalProductCategorie, shallowEqual);
|
|
const paymentloader = useSelector(GlobalPayementloader, shallowEqual);
|
|
const SessionData = useSelector(StoredSessionData, shallowEqual);
|
|
const GlobalCombocarddatas = useSelector(GlobalCombocarddata);
|
|
console.log(GlobalCombocarddatas, 'GlobalCombocarddatas combo card');
|
|
const [messageType, setMessageType] = useState(null);
|
|
const [messageData, setMessageData] = useState(null);
|
|
const [repeatedModel, setRepeatedModel] = useState(false);
|
|
const [StockPreferenceDetail, setStockPreferenceDetail] = useState();
|
|
const [QuickAdd, setQuickAdd] = useState(true);
|
|
const [onePeiceFlow, setOnePeiceFlow] = useState(false);
|
|
const [BillOrderPre, setBillOrderPre] = useState();
|
|
const [expQtyModel, setExpQtyModel] = useState(false);
|
|
const [qtyExpData, setQtyExpData] = useState();
|
|
const [screenWidth, setScreenWidth] = useState(window.innerWidth);
|
|
const [screenHeight, setScreenHeight] = useState(window.innerHeight);
|
|
// const [ComboCardata, setCombocardata] = useState([]);
|
|
const [ExpiredProduct, setExpiredProduct] = useState()
|
|
|
|
|
|
|
|
const AppId = SessionData?.AppId;
|
|
const CompId = SessionData?.CompId;
|
|
const BranchId = SessionData?.BranchId;
|
|
const dispatch = useDispatch();
|
|
|
|
useEffect(() => {
|
|
if (SelectedCardFont) {
|
|
WebFont.load({
|
|
google: {
|
|
families: [SelectedCardFont], // Load the selected font
|
|
},
|
|
});
|
|
}
|
|
}, [SelectedCardFont]);
|
|
|
|
//mohan 18-04-2025
|
|
const cardData = !globalAccessForOthers
|
|
? CardAccess
|
|
? SelectedDatas?.length > 1
|
|
? SelectedDatas
|
|
: SelectedDatas?.[0]?.AppId === 0 && SelectedDatas?.[0]?.CompId === 0
|
|
? []
|
|
: SelectedDatas
|
|
: GlobalCombocarddatas?.length == 0 ||
|
|
(GlobalCombocarddatas?.[0]?.AppId === 0 && GlobalCombocarddatas?.[0]?.CompId === 0)
|
|
? noSubcatCardData
|
|
: GlobalCombocarddatas
|
|
: '';
|
|
const cardDataForNewPrd = !globalAccessForOthers
|
|
? CardAccess
|
|
? SelectedDatas
|
|
: GlobalCombocarddatas?.length == 0
|
|
? noSubcatCardData
|
|
: GlobalCombocarddatas
|
|
: '';
|
|
//
|
|
console.log(cardData, 'cardData combo card');
|
|
useEffect(() => {
|
|
// fetchedit();
|
|
getPreferenceStock();
|
|
// dispatch(changepreOrder(false)); Commented to Add Normal Produts After Adding the Combo Pack !!!!!! Dont Touch Without Shifayath Permission
|
|
}, [preferenceDatas]);
|
|
|
|
useEffect(() => {
|
|
if (AppId && CompId && BranchId) {
|
|
fetchedit();
|
|
GetmultipleSearchData()
|
|
}
|
|
|
|
// dispatch(changepreOrder(false)); Commented to Add Normal Produts After Adding the Combo Pack !!!!!! Dont Touch Without Shifayath Permission
|
|
}, [AppId, CompId, BranchId]);
|
|
const GetmultipleSearchData = async () => {
|
|
const data = {
|
|
AppId,
|
|
CompId,
|
|
BranchId,
|
|
};
|
|
|
|
try {
|
|
const response = await dispatch(getmultipleSearch(data))
|
|
|
|
} catch (error) {
|
|
console.error("Get Search Terms Error:", error);
|
|
}
|
|
};
|
|
|
|
useEffect(() => {
|
|
setPreOrderSelectedProdNames([]);
|
|
// dispatch(changePreOrderAdditem(null));
|
|
}, [preOrder]);
|
|
|
|
// useEffect(() => {
|
|
// if (ProdCat && ProdSubCat !== NaN) {
|
|
// // if (ProdCat && !isNaN(ProdSubCat)) {
|
|
// productCardList();
|
|
// }
|
|
// }, [ProdSubCat]);
|
|
|
|
useEffect(() => {
|
|
if (noSubcatCardData) {
|
|
setNoSubcatCardData();
|
|
}
|
|
|
|
if (ProductSearch?.length > 5 && GetmultipleSearchDatas.some(
|
|
e => e.toLowerCase() === "qrcode"
|
|
)) {
|
|
setQuickAdd(true);
|
|
}
|
|
}, [ProductSearch,GetmultipleSearchDatas]);
|
|
|
|
// useEffect(() => {
|
|
// if (
|
|
// !initialRun &&
|
|
// (!ProdSubCat || ProdSubCat != NaN || ProdSubCat === 'NaN') &&
|
|
// ProdCat
|
|
// ) {
|
|
// // if (!initialRun && (!ProdSubCat || !isNaN(ProdSubCat)) && ProdCat) {
|
|
// setInitialRun(true);
|
|
// productCardList();
|
|
// }
|
|
// }, [ProdCat, initialRun]);
|
|
|
|
const productCardList = async () => {
|
|
//condition
|
|
if (
|
|
templateData?.BookingLayout?.[1]?.some(
|
|
(item) => item?.OptionName === 'SubCategory'
|
|
) &&
|
|
ProdSubCat &&
|
|
ProdCat
|
|
) {
|
|
let data = {
|
|
CompId: CompId,
|
|
BranchId: BranchId,
|
|
AppId: AppId,
|
|
ProdSubCat: ProdSubCat,
|
|
};
|
|
//mohan
|
|
let response = await dispatch(getLayoutproductCard(data)).unwrap();
|
|
if (response?.data?.statusCode == 1) {
|
|
setNoSubcatCardData(response?.data?.data);
|
|
}
|
|
} else if (
|
|
!templateData?.BookingLayout?.[1]?.some(
|
|
(item) => item?.OptionName === 'SubCategory'
|
|
) &&
|
|
ProdCat
|
|
) {
|
|
let data = {
|
|
compId: CompId,
|
|
branchId: BranchId,
|
|
appId: AppId,
|
|
prodCat: ProdCat,
|
|
};
|
|
let response = await dispatch(getCardDataWithoutSubmodule(data)).unwrap();
|
|
|
|
if (response?.data?.statusCode == 1) {
|
|
setNoSubcatCardData(response?.data?.data);
|
|
}
|
|
} else if (
|
|
templateData?.BookingLayout?.[1]?.some(
|
|
(item) => item?.OptionName === 'SubCategory'
|
|
) &&
|
|
!ProdSubCat &&
|
|
ProdCat &&
|
|
ProdSubCat != 'NaN'
|
|
) {
|
|
let data = {
|
|
compId: CompId,
|
|
branchId: BranchId,
|
|
appId: AppId,
|
|
prodCat: ProdCat,
|
|
};
|
|
|
|
let response = await dispatch(getCardDataWithoutSub(data)).unwrap();
|
|
|
|
if (response?.data?.statusCode == 1) {
|
|
setNoSubcatCardData(response?.data?.data);
|
|
}
|
|
}
|
|
};
|
|
|
|
const fetchedit = async () => {
|
|
let data = {
|
|
CompId: CompId,
|
|
BranchId: BranchId,
|
|
AppId: AppId,
|
|
};
|
|
let res = await dispatch(getEditFavItems(data)).unwrap();
|
|
if (res?.data?.statusCode == 1) {
|
|
setSelectedProdNames(res?.data?.data);
|
|
} else {
|
|
setSelectedProdNames([]);
|
|
}
|
|
};
|
|
|
|
useEffect(() => {
|
|
Combocarddata();
|
|
}, []);
|
|
|
|
const Combocarddata = async () => {
|
|
let data = {
|
|
CompId: CompId,
|
|
BranchId: BranchId,
|
|
AppId: AppId,
|
|
ActiveStatus: 'A',
|
|
};
|
|
|
|
let response = await dispatch(getCombolist(data)).unwrap();
|
|
|
|
// if (response?.data?.statusCode === 1) {
|
|
// let Data = response?.data?.data;
|
|
// let comboList = Data?.map((item, index) => ({
|
|
// ...item,
|
|
// id: `${item.ComboName || 'Combo'}-${index}`,
|
|
// ProdName: item?.ComboName,
|
|
// OverAllQty: item?.OverallQuantity,
|
|
// StockAvailable: 'Y',
|
|
// }));
|
|
|
|
// setCombocardata(comboList);
|
|
|
|
// if (!GlobalCombocarddatas || !Array.isArray(GlobalCombocarddatas)) return;
|
|
|
|
// const comboList = await GlobalCombocarddatas.map((item, index) => ({
|
|
// ...item,
|
|
// id: `${item.ComboName || 'Combo'}-${index}`,
|
|
// ProdName: item?.ComboName,
|
|
// OverAllQty: item?.OverallQuantity,
|
|
// }));
|
|
|
|
// setCombocardata(comboList);
|
|
// }
|
|
};
|
|
|
|
const processGlobalComboData = () => {
|
|
if (!GlobalCombocarddatas || !Array.isArray(GlobalCombocarddatas)) return;
|
|
|
|
let comboList = GlobalCombocarddatas.map((item, index) => ({
|
|
...item,
|
|
id: `${item.ComboName || 'Combo'}-${index}`,
|
|
ProdName: item?.ComboName,
|
|
OverAllQty: item?.OverallQuantity,
|
|
StockAvailable: 'Y',
|
|
}));
|
|
|
|
return comboList;
|
|
};
|
|
|
|
const comboList = processGlobalComboData() || [];
|
|
|
|
useEffect(() => {
|
|
DispatchData();
|
|
}, [SelectedProdNames]);
|
|
|
|
const DispatchData = async () => {
|
|
await dispatch(ChangeAllItemData(SelectedProdNames));
|
|
};
|
|
|
|
useEffect(() => {
|
|
if (Object.keys(WSProductdata)?.length > 0) {
|
|
AddOrderDetails(WSProductdata);
|
|
}
|
|
}, [WSProductdata]);
|
|
useEffect(() => {
|
|
|
|
if (ItemCard?.[0]?.QrBasedSearch === 'Y') {
|
|
if (ItemCard?.[0]?.OverAllExpStatus == 'Y' && ExpiredProduct) {
|
|
setexpModel(true);
|
|
setItem(ItemCard?.[0]);
|
|
} else {
|
|
setQtydata(ItemCard?.[0]);
|
|
SingleQuantity(ItemCard?.[0], false);
|
|
}
|
|
} else if (ItemCard?.[0]?.OnePcQRBased === 'Y') {
|
|
if (ItemCard?.[0]?.OverAllExpStatus == 'Y' && ExpiredProduct) {
|
|
setexpModel(true);
|
|
setItem(ItemCard?.[0]);
|
|
setOnePeiceFlow(true);
|
|
} else {
|
|
setQtydata(ItemCard?.[0]);
|
|
SingleQuantity(ItemCard?.[0], true);
|
|
}
|
|
}
|
|
}, [ItemCard]);
|
|
|
|
useEffect(() => {
|
|
if (Object.keys(otherscarddata)?.length > 0) {
|
|
let data = {
|
|
Type: otherscarddata?.Type ? otherscarddata?.Type : 'P',
|
|
OverallQuantity: otherscarddata?.OverAllQty,
|
|
ActiveStatus: otherscarddata?.ActiveStatus,
|
|
AvailableFrom: otherscarddata?.AvailableFrom,
|
|
AvailableTo: otherscarddata?.AvailableTo,
|
|
Cess: otherscarddata?.Cess,
|
|
ExpDate: otherscarddata?.ExpDate,
|
|
HSNCode: otherscarddata?.HSNCode,
|
|
ManufDate: otherscarddata?.ManufDate,
|
|
OpeningQty: otherscarddata?.OpeningQty,
|
|
ProdType: otherscarddata?.ProdType,
|
|
PartNumber: otherscarddata?.PartNumber,
|
|
ProdId: otherscarddata?.ProdId,
|
|
ProdLogo: otherscarddata?.ProdLogo,
|
|
ProdName: otherscarddata?.ProdName,
|
|
QRCode: otherscarddata?.QRCode,
|
|
QtyBasedPrice: otherscarddata?.QtyBasedPrice,
|
|
Rack: otherscarddata?.Rack,
|
|
Size: otherscarddata?.Size,
|
|
StockAvailable: otherscarddata?.StockAvailable,
|
|
TaxId: otherscarddata?.TaxId,
|
|
TaxPercentage: otherscarddata?.TaxPercentage,
|
|
TaxName: otherscarddata?.TaxIdName,
|
|
UniqueId: otherscarddata?.UniqueId,
|
|
UomName: otherscarddata?.UomName,
|
|
ProdVariantName: otherscarddata?.ProdVariantName, //sri
|
|
BalanceQty: otherscarddata?.BalanceQty,
|
|
BatchRef: otherscarddata?.BatchRef,
|
|
ModelNumber: otherscarddata?.ModelNumber, //sri
|
|
FullProductIdentifierDtls: otherscarddata?.FullProductIdentifierDtls, //sri
|
|
InwardDate: otherscarddata?.InwardDate,
|
|
InwardDtlId: otherscarddata?.InwardDtlId,
|
|
InwardId: otherscarddata?.InwardId,
|
|
MRP: otherscarddata?.MRP,
|
|
Offer: otherscarddata?.OfferPrice,
|
|
OrderRate: otherscarddata?.SellPrice,
|
|
SellingPrice: otherscarddata?.SellPrice, // edit srii
|
|
SuppId: otherscarddata?.SuppId,
|
|
SuppName: otherscarddata?.SuppName,
|
|
OrderQty: otherscarddata?.Quantity,
|
|
OtherProduct: otherscarddata?.OtherProduct,
|
|
// 'ProdVariantName': otherscarddata?.ProdVariantName,
|
|
BookingTypeName: BookingType,
|
|
CounterName: '', //sri
|
|
};
|
|
AddOrderDetails(data);
|
|
}
|
|
// data["OrderRate"] = otherscarddata?.SellPrice
|
|
}, [otherscarddata]);
|
|
|
|
useEffect(() => {
|
|
if (Object.keys(NewQrProductData)?.length > 0) {
|
|
let addQrProductData = { ...NewQrProductData };
|
|
addQrProductData['OrderRate'] = addQrProductData['SellPrice'];
|
|
addQrProductData['OrderQty'] = addQrProductData['Quantity'];
|
|
addQrProductData['SellingPrice'] = addQrProductData['SellPrice'];
|
|
addQrProductData['BookingTypeName'] = BookingType;
|
|
AddOrderDetails(addQrProductData);
|
|
}
|
|
}, [NewQrProductData]);
|
|
|
|
const getPreferenceStock = async () => {
|
|
const PreferenceStckDtl = preferenceDatas?.[0]?.SettingDtlDetails;
|
|
const StockPreference = PreferenceStckDtl?.find(
|
|
(item) => item.SettingIdName === 'StockSelection'
|
|
);
|
|
setStockPreferenceDetail(StockPreference);
|
|
const BillOrder = PreferenceStckDtl?.find(
|
|
(item) => item.SettingIdName === 'BillItemsOrder'
|
|
);
|
|
setBillOrderPre(BillOrder?.SettingValue);
|
|
|
|
const expiredDate = PreferenceStckDtl?.find(
|
|
(item) => item.SettingIdName === 'ExpiredSelection'
|
|
)?.SettingValue === 'Y';
|
|
setExpiredProduct(expiredDate)
|
|
};
|
|
|
|
const CloseModal = () => {
|
|
setModelQty(false);
|
|
setRepeatedModel(false);
|
|
setProdexpir(false);
|
|
setOnePeiceFlow(false);
|
|
};
|
|
|
|
const CloseVarientModal = () => {
|
|
setModalVarient(false);
|
|
setRepeatedModel(false);
|
|
setProdexpir(false);
|
|
setOnePeiceFlow(false);
|
|
};
|
|
|
|
const Quantity = () => {
|
|
setModelQty(true);
|
|
};
|
|
|
|
const SingleQuantity = (item, onePcs) => {
|
|
let count = item?.ProductDetail?.[0]?.ProdVariantDetails?.length;
|
|
if (count > 1) {
|
|
setModalVarient(true);
|
|
} else {
|
|
setVarientIndex(0);
|
|
SingleStockfun(item, onePcs);
|
|
}
|
|
};
|
|
|
|
const SingleStockfun = (item, onePcs) => {
|
|
let count =
|
|
item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.length;
|
|
if (
|
|
StockPreferenceDetail?.SettingValue === 'Y' &&
|
|
item?.ProductDetail?.[QtyIndex]?.StockAvailable == 'Y'
|
|
) {
|
|
if (count > 1) {
|
|
setModelstock(true);
|
|
} else {
|
|
let Isincart = CartOrderDetails?.find(
|
|
(cartItem) =>
|
|
cartItem?.ProdId === item?.ProductDetail?.[QtyIndex]?.ProdId &&
|
|
cartItem?.InwardDtlId ===
|
|
item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[
|
|
VarientIndex
|
|
]?.StockDetails?.[0]?.InwardDtlId &&
|
|
cartItem?.OrderRate ===
|
|
item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[
|
|
VarientIndex
|
|
]?.StockDetails?.[0]?.SellPrice &&
|
|
!cartItem?.SalesId
|
|
);
|
|
|
|
if (onePcs) {
|
|
let Isincartonepc = CartOrderDetails?.filter(
|
|
(cartItem) =>
|
|
cartItem?.ProdId === item?.ProductDetail?.[QtyIndex]?.ProdId &&
|
|
cartItem?.InwardDtlId ===
|
|
item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[
|
|
VarientIndex
|
|
]?.StockDetails?.[0]?.InwardDtlId &&
|
|
// (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice)
|
|
!cartItem?.SalesId
|
|
);
|
|
let totalOrderQty = Isincartonepc?.reduce((accumulator, card) => {
|
|
return (
|
|
accumulator +
|
|
parseInt(
|
|
card?.StockAvailable === 'Y'
|
|
? card.SinglePc !== 'Y'
|
|
? card.OrderQty * card.NoOfPcs
|
|
: card.OrderQty
|
|
: 0
|
|
)
|
|
);
|
|
}, 0);
|
|
if (Isincartonepc && Isincartonepc?.[0]?.StockAvailable === 'Y') {
|
|
if (Isincartonepc?.[0]?.OverAllPcs > totalOrderQty) {
|
|
dataTransfer(item, 0, 0, 0, onePcs);
|
|
} else {
|
|
dataTransfer(item, 0, 0, 1, onePcs);
|
|
}
|
|
} else {
|
|
dataTransfer(item, 0, 0, 0, onePcs);
|
|
}
|
|
} else {
|
|
if (Isincart && Isincart?.StockAvailable === 'Y') {
|
|
if (Isincart?.BalanceQty > Isincart?.OrderQty) {
|
|
dataTransfer(item, 0, 0, 0, onePcs);
|
|
} else {
|
|
dataTransfer(item, 0, 0, 1, onePcs);
|
|
}
|
|
} else {
|
|
dataTransfer(item, 0, 0, 0, onePcs);
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
let Isincart = CartOrderDetails?.find(
|
|
(cartItem) =>
|
|
cartItem?.ProdId === item?.ProductDetail?.[QtyIndex]?.ProdId &&
|
|
cartItem?.InwardDtlId ===
|
|
item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.[0]?.InwardDtlId &&
|
|
cartItem?.OrderRate ===
|
|
item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.[0]?.SellPrice &&
|
|
!cartItem?.SalesId
|
|
);
|
|
|
|
if (onePcs) {
|
|
let Isincartonepc = CartOrderDetails?.filter(
|
|
(cartItem) =>
|
|
cartItem?.ProdId === item?.ProductDetail?.[QtyIndex]?.ProdId &&
|
|
cartItem?.InwardDtlId ===
|
|
item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[
|
|
VarientIndex
|
|
]?.StockDetails?.[0]?.InwardDtlId &&
|
|
// (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice)
|
|
!cartItem?.SalesId
|
|
);
|
|
let totalOrderQty = Isincartonepc?.reduce((accumulator, card) => {
|
|
return (
|
|
accumulator +
|
|
parseInt(
|
|
card?.StockAvailable === 'Y'
|
|
? card.SinglePc !== 'Y'
|
|
? card.OrderQty * (card.NoOfPcs ? card.NoOfPcs : 1)
|
|
: card.OrderQty
|
|
: 0
|
|
)
|
|
);
|
|
}, 0);
|
|
if (Isincartonepc && Isincartonepc?.[0]?.StockAvailable === 'Y') {
|
|
if (Isincartonepc?.[0]?.OverAllPcs > totalOrderQty) {
|
|
dataTransfer(item, 0, 0, 0, onePcs);
|
|
} else {
|
|
dataTransfer(item, 0, 0, 1, onePcs);
|
|
}
|
|
} else {
|
|
dataTransfer(item, 0, 0, 0, onePcs);
|
|
}
|
|
} else {
|
|
if (Isincart && Isincart?.StockAvailable === 'Y') {
|
|
if (Isincart?.BalanceQty > Isincart?.OrderQty) {
|
|
dataTransfer(item, 0, 0, 0, onePcs);
|
|
} else {
|
|
dataTransfer(item, 0, 0, 1, onePcs);
|
|
}
|
|
} else {
|
|
dataTransfer(item, 0, 0, 0, onePcs);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
const Stockfun = (index) => {
|
|
setVarientIndex(index.key);
|
|
const variantDetails =
|
|
qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[index.key] || {};
|
|
const overallExpStatus = variantDetails.OverAllExpStatus;
|
|
const count = variantDetails.StockDetails?.length || 0;
|
|
if (
|
|
StockPreferenceDetail?.SettingValue === 'Y' &&
|
|
qtydata?.ProductDetail?.[QtyIndex]?.StockAvailable == 'Y'
|
|
) {
|
|
if (count > 1) {
|
|
if (
|
|
overallExpStatus === 'N' ||
|
|
// (overallExpStatus === 'Y' && prodexpir)
|
|
(overallExpStatus === 'Y')
|
|
) {
|
|
setModalVarient(false);
|
|
setModelstock(true);
|
|
setVarItem(index.key);
|
|
if (overallExpStatus === 'Y' && prodexpir) {
|
|
setRepeatedModel(true);
|
|
}
|
|
} else if (overallExpStatus === 'Y' && ExpiredProduct) {
|
|
setVarItem(index.key);
|
|
setexpVarModel(true);
|
|
}
|
|
} else {
|
|
if (
|
|
overallExpStatus === 'N' ||
|
|
(overallExpStatus === 'Y' && prodexpir)
|
|
) {
|
|
let Isincart = CartOrderDetails?.find(
|
|
(cartItem) =>
|
|
cartItem?.ProdId === qtydata?.ProductDetail?.[QtyIndex]?.ProdId &&
|
|
cartItem?.InwardDtlId ===
|
|
qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[
|
|
index.key
|
|
]?.StockDetails?.[0]?.InwardDtlId &&
|
|
cartItem?.OrderRate ===
|
|
qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[
|
|
index.key
|
|
]?.StockDetails?.[0]?.SellPrice &&
|
|
!cartItem?.SalesId
|
|
);
|
|
|
|
if (onePeiceFlow) {
|
|
let Isincartonepc = CartOrderDetails?.filter(
|
|
(cartItem) =>
|
|
cartItem?.ProdId ===
|
|
qtydata?.ProductDetail?.[QtyIndex]?.ProdId &&
|
|
cartItem?.InwardDtlId ===
|
|
qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[
|
|
index.key
|
|
]?.StockDetails?.[0]?.InwardDtlId &&
|
|
// (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice)
|
|
!cartItem?.SalesId
|
|
);
|
|
let totalOrderQty = Isincartonepc?.reduce((accumulator, card) => {
|
|
return (
|
|
accumulator +
|
|
parseInt(
|
|
card?.StockAvailable === 'Y'
|
|
? card.SinglePc !== 'Y'
|
|
? card.OrderQty * (card.NoOfPcs ? card.NoOfPcs : 1)
|
|
: card.OrderQty
|
|
: 0
|
|
)
|
|
);
|
|
}, 0);
|
|
if (Isincartonepc && Isincartonepc?.[0]?.StockAvailable === 'Y') {
|
|
if (Isincartonepc?.[0]?.OverAllPcs > totalOrderQty) {
|
|
dataTransfer(qtydata, QtyIndex, index.key, 0, onePeiceFlow);
|
|
} else {
|
|
dataTransfer(qtydata, QtyIndex, index.key, 1, onePeiceFlow);
|
|
}
|
|
} else {
|
|
dataTransfer(qtydata, QtyIndex, index.key, 0, onePeiceFlow);
|
|
}
|
|
} else {
|
|
if (Isincart && Isincart?.StockAvailable === 'Y') {
|
|
if (Isincart?.BalanceQty > Isincart?.OrderQty) {
|
|
dataTransfer(qtydata, QtyIndex, index.key, 0, onePeiceFlow);
|
|
} else {
|
|
dataTransfer(qtydata, QtyIndex, index.key, 1, onePeiceFlow);
|
|
}
|
|
} else {
|
|
dataTransfer(qtydata, QtyIndex, index.key, 0, onePeiceFlow);
|
|
}
|
|
}
|
|
|
|
setModelQty(false);
|
|
setVarItem(index.key);
|
|
if (overallExpStatus === 'Y' && prodexpir) {
|
|
setProdexpir(false);
|
|
setRepeatedModel(true);
|
|
}
|
|
} else if (overallExpStatus === 'Y' && ExpiredProduct) {
|
|
setVarItem(index.key);
|
|
setexpVarModel(true);
|
|
}
|
|
}
|
|
} else {
|
|
|
|
if (
|
|
overallExpStatus === 'N' ||
|
|
(overallExpStatus === 'Y' && prodexpir)
|
|
) {
|
|
setModalVarient(false);
|
|
setModelstock(true);
|
|
setVarItem(index.key);
|
|
if (overallExpStatus === 'Y' && prodexpir) {
|
|
setRepeatedModel(true);
|
|
}
|
|
return
|
|
} else if (overallExpStatus === 'Y' && ExpiredProduct) {
|
|
setVarItem(index.key);
|
|
setexpVarModel(true);
|
|
return
|
|
}
|
|
let Isincart = CartOrderDetails?.find(
|
|
(cartItem) =>
|
|
cartItem?.ProdId === qtydata?.ProductDetail?.[QtyIndex]?.ProdId &&
|
|
cartItem?.InwardDtlId ===
|
|
qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[index.key]
|
|
?.StockDetails?.[0]?.InwardDtlId &&
|
|
cartItem?.OrderRate ===
|
|
qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[index.key]
|
|
?.StockDetails?.[0]?.SellPrice &&
|
|
!cartItem?.SalesId
|
|
);
|
|
if (onePeiceFlow) {
|
|
let Isincartonepc = CartOrderDetails?.filter(
|
|
(cartItem) =>
|
|
cartItem?.ProdId === qtydata?.ProductDetail?.[QtyIndex]?.ProdId &&
|
|
cartItem?.InwardDtlId ===
|
|
qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[
|
|
index.key
|
|
]?.StockDetails?.[0]?.InwardDtlId &&
|
|
// (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice)
|
|
!cartItem?.SalesId
|
|
);
|
|
let totalOrderQty = Isincartonepc?.reduce((accumulator, card) => {
|
|
return (
|
|
accumulator +
|
|
parseInt(
|
|
card?.StockAvailable === 'Y'
|
|
? card.SinglePc !== 'Y'
|
|
? card.OrderQty * (card.NoOfPcs ? card.NoOfPcs : 1)
|
|
: card.OrderQty
|
|
: 0
|
|
)
|
|
);
|
|
}, 0);
|
|
if (Isincartonepc && Isincartonepc?.[0]?.StockAvailable === 'Y') {
|
|
if (Isincartonepc?.[0]?.OverAllPcs > totalOrderQty) {
|
|
dataTransfer(qtydata, QtyIndex, index.key, 0, onePeiceFlow);
|
|
} else {
|
|
dataTransfer(qtydata, QtyIndex, index.key, 1, onePeiceFlow);
|
|
}
|
|
} else {
|
|
dataTransfer(qtydata, QtyIndex, index.key, 0, onePeiceFlow);
|
|
}
|
|
} else {
|
|
if (Isincart && Isincart?.StockAvailable === 'Y') {
|
|
if (Isincart?.BalanceQty > Isincart?.OrderQty) {
|
|
dataTransfer(qtydata, QtyIndex, index.key, 0, onePeiceFlow);
|
|
} else {
|
|
dataTransfer(qtydata, QtyIndex, index.key, 1, onePeiceFlow);
|
|
}
|
|
} else {
|
|
dataTransfer(qtydata, QtyIndex, index.key, 0, onePeiceFlow);
|
|
}
|
|
}
|
|
setModelQty(false);
|
|
}
|
|
};
|
|
|
|
const VarientFun = (index) => {
|
|
const QtyExpire = index?.ProdVariantDetails.every(
|
|
(item) => item.OverAllExpStatus === 'Y'
|
|
);
|
|
if (QtyExpire && ExpiredProduct) {
|
|
setExpQtyModel(true);
|
|
setQtyExpData(index);
|
|
} else {
|
|
const selectedProIndex = qtydata?.ProductDetail?.findIndex(
|
|
(item) =>
|
|
item?.ProdId === index?.ProdId &&
|
|
item?.Size === index?.Size &&
|
|
item?.UomName === index?.UomName &&
|
|
item?.Brand === index?.Brand
|
|
);
|
|
|
|
if (selectedProIndex !== -1) {
|
|
const count =
|
|
qtydata?.ProductDetail[selectedProIndex]?.ProdVariantDetails
|
|
?.length || 0;
|
|
|
|
if (count > 1) {
|
|
setModelQty(false);
|
|
setModalVarient(true);
|
|
} else {
|
|
const item = { QtyIndex: selectedProIndex, VarientIndex: 0 };
|
|
singleVarient(item);
|
|
setModelQty(false);
|
|
}
|
|
}
|
|
|
|
setQtyIndex(selectedProIndex);
|
|
setVarientIndex(0);
|
|
setRepeatedModel(false);
|
|
}
|
|
};
|
|
|
|
const singleVarient = (item) => {
|
|
let count =
|
|
qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[
|
|
item?.VarientIndex
|
|
]?.StockDetails?.length;
|
|
|
|
if (
|
|
StockPreferenceDetail?.SettingValue === 'Y' &&
|
|
qtydata?.ProductDetail?.[item?.QtyIndex]?.StockAvailable == 'Y'
|
|
) {
|
|
if (count > 1) {
|
|
setModalVarient(false);
|
|
setModelstock(true);
|
|
// setVarientIndex(index.key)
|
|
} else {
|
|
let Isincart = CartOrderDetails?.find(
|
|
(cartItem) =>
|
|
cartItem?.ProdId ===
|
|
qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId &&
|
|
cartItem?.InwardDtlId ===
|
|
qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[
|
|
item?.VarientIndex
|
|
]?.StockDetails?.[0]?.InwardDtlId &&
|
|
cartItem?.OrderRate ===
|
|
qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[
|
|
item?.VarientIndex
|
|
]?.StockDetails?.[0]?.SellPrice &&
|
|
!cartItem?.SalesId
|
|
);
|
|
|
|
if (onePeiceFlow) {
|
|
let Isincartonepc = CartOrderDetails?.filter(
|
|
(cartItem) =>
|
|
cartItem?.ProdId ===
|
|
qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId &&
|
|
cartItem?.InwardDtlId ===
|
|
qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[
|
|
item?.VarientIndex
|
|
]?.StockDetails?.[0]?.InwardDtlId &&
|
|
// (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice)
|
|
!cartItem?.SalesId
|
|
);
|
|
let totalOrderQty = Isincartonepc?.reduce((accumulator, card) => {
|
|
return (
|
|
accumulator +
|
|
parseInt(
|
|
card?.StockAvailable === 'Y'
|
|
? card.SinglePc !== 'Y'
|
|
? card.OrderQty * card.NoOfPcs
|
|
: card.OrderQty
|
|
: 0
|
|
)
|
|
);
|
|
}, 0);
|
|
if (Isincartonepc && Isincartonepc?.[0]?.StockAvailable === 'Y') {
|
|
if (Isincartonepc?.[0]?.OverAllPcs > totalOrderQty) {
|
|
dataTransfer(
|
|
qtydata,
|
|
item?.QtyIndex,
|
|
item?.VarientIndex,
|
|
0,
|
|
onePeiceFlow
|
|
);
|
|
} else {
|
|
dataTransfer(
|
|
qtydata,
|
|
item?.QtyIndex,
|
|
item?.VarientIndex,
|
|
1,
|
|
onePeiceFlow
|
|
);
|
|
}
|
|
} else {
|
|
dataTransfer(
|
|
qtydata,
|
|
item?.QtyIndex,
|
|
item?.VarientIndex,
|
|
0,
|
|
onePeiceFlow
|
|
);
|
|
}
|
|
} else {
|
|
if (Isincart && Isincart?.StockAvailable === 'Y') {
|
|
if (Isincart?.BalanceQty > Isincart?.OrderQty) {
|
|
dataTransfer(
|
|
qtydata,
|
|
item?.QtyIndex,
|
|
item?.VarientIndex,
|
|
0,
|
|
onePeiceFlow
|
|
);
|
|
} else {
|
|
dataTransfer(
|
|
qtydata,
|
|
item?.QtyIndex,
|
|
item?.VarientIndex,
|
|
1,
|
|
onePeiceFlow
|
|
);
|
|
}
|
|
} else {
|
|
dataTransfer(
|
|
qtydata,
|
|
item?.QtyIndex,
|
|
item?.VarientIndex,
|
|
0,
|
|
onePeiceFlow
|
|
);
|
|
}
|
|
}
|
|
setModelQty(false);
|
|
}
|
|
} else {
|
|
let Isincart = CartOrderDetails?.find(
|
|
(cartItem) =>
|
|
cartItem?.ProdId ===
|
|
qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId &&
|
|
cartItem?.InwardDtlId ===
|
|
qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[
|
|
item?.VarientIndex
|
|
]?.StockDetails?.[0]?.InwardDtlId &&
|
|
cartItem?.OrderRate ===
|
|
qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[
|
|
item?.VarientIndex
|
|
]?.StockDetails?.[0]?.SellPrice &&
|
|
!cartItem?.SalesId
|
|
);
|
|
|
|
if (onePeiceFlow) {
|
|
let Isincartonepc = CartOrderDetails?.filter(
|
|
(cartItem) =>
|
|
cartItem?.ProdId ===
|
|
qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdId &&
|
|
cartItem?.InwardDtlId ===
|
|
qtydata?.ProductDetail?.[item?.QtyIndex]?.ProdVariantDetails?.[
|
|
item?.VarientIndex
|
|
]?.StockDetails?.[0]?.InwardDtlId &&
|
|
// (cartItem?.OrderRate === item?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]?.StockDetails?.[0]?.SellPrice)
|
|
!cartItem?.SalesId
|
|
);
|
|
let totalOrderQty = Isincartonepc?.reduce((accumulator, card) => {
|
|
return (
|
|
accumulator +
|
|
parseInt(
|
|
card?.StockAvailable === 'Y'
|
|
? card.SinglePc !== 'Y'
|
|
? card.OrderQty * card.NoOfPcs
|
|
: card.OrderQty
|
|
: 0
|
|
)
|
|
);
|
|
}, 0);
|
|
if (Isincartonepc && Isincartonepc?.[0]?.StockAvailable === 'Y') {
|
|
if (Isincartonepc?.[0]?.OverAllPcs > totalOrderQty) {
|
|
dataTransfer(
|
|
qtydata,
|
|
item?.QtyIndex,
|
|
item?.VarientIndex,
|
|
0,
|
|
onePeiceFlow
|
|
);
|
|
} else {
|
|
dataTransfer(
|
|
qtydata,
|
|
item?.QtyIndex,
|
|
item?.VarientIndex,
|
|
1,
|
|
onePeiceFlow
|
|
);
|
|
}
|
|
} else {
|
|
dataTransfer(
|
|
qtydata,
|
|
item?.QtyIndex,
|
|
item?.VarientIndex,
|
|
0,
|
|
onePeiceFlow
|
|
);
|
|
}
|
|
} else {
|
|
if (Isincart && Isincart?.StockAvailable === 'Y') {
|
|
if (Isincart?.BalanceQty > Isincart?.OrderQty) {
|
|
dataTransfer(
|
|
qtydata,
|
|
item?.QtyIndex,
|
|
item?.VarientIndex,
|
|
0,
|
|
onePeiceFlow
|
|
);
|
|
} else {
|
|
dataTransfer(
|
|
qtydata,
|
|
item?.QtyIndex,
|
|
item?.VarientIndex,
|
|
1,
|
|
onePeiceFlow
|
|
);
|
|
}
|
|
} else {
|
|
dataTransfer(
|
|
qtydata,
|
|
item?.QtyIndex,
|
|
item?.VarientIndex,
|
|
0,
|
|
onePeiceFlow
|
|
);
|
|
}
|
|
}
|
|
setModelQty(false);
|
|
}
|
|
};
|
|
|
|
const StockDate = (date) => {
|
|
let dateVal = moment(date, ['YYYY-MM-DDTHH:mm:ss']).format('DD-MM-YYYY');
|
|
return dateVal;
|
|
};
|
|
|
|
const returnOnepcCount = (ProdName, currentQty, orderDetails, overallpcs) => {
|
|
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.NoOfPcs
|
|
: card.OrderQty
|
|
: 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.NoOfPcs
|
|
: 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 returnQtyCount = (ProdId, item, orderDetails) => {
|
|
if (onePeiceFlow) {
|
|
let ItemQuantity = item?.ProdVariantDetails?.reduce(
|
|
(accumulator, card) => {
|
|
return accumulator + parseInt(card.OverAllPcs || 0);
|
|
},
|
|
0
|
|
);
|
|
let SelectedProduct = ReorderProductData?.filter(
|
|
(a) => a?.ProdId === ProdId
|
|
);
|
|
let totalSelectedProductQty = SelectedProduct?.reduce(
|
|
(accumulator, card) => {
|
|
return (
|
|
accumulator +
|
|
parseInt(
|
|
card?.StockAvailable === 'Y'
|
|
? card.SinglePc !== 'Y'
|
|
? card.OrderQty * card.NoOfPcs
|
|
: card.OrderQty
|
|
: 0
|
|
)
|
|
);
|
|
},
|
|
0
|
|
);
|
|
let getCurrentProdDtl = orderDetails?.filter((a) => a?.ProdId === ProdId);
|
|
let totalOrderQty = getCurrentProdDtl?.reduce((accumulator, card) => {
|
|
return (
|
|
accumulator +
|
|
parseInt(
|
|
card?.StockAvailable === 'Y'
|
|
? card.SinglePc !== 'Y'
|
|
? card.OrderQty * card.NoOfPcs
|
|
: card.OrderQty
|
|
: 0
|
|
)
|
|
);
|
|
}, 0);
|
|
let OverallProdQty = totalOrderQty - totalSelectedProductQty;
|
|
if (
|
|
parseInt(ItemQuantity) >
|
|
parseInt(
|
|
Object.keys(ReportholdData)?.length > 0 && totalOrderQty
|
|
? OverallProdQty
|
|
: getCurrentProdDtl
|
|
? totalOrderQty
|
|
: 0
|
|
)
|
|
) {
|
|
let count =
|
|
parseInt(ItemQuantity) -
|
|
parseInt(
|
|
Object.keys(ReportholdData)?.length > 0 && totalOrderQty
|
|
? OverallProdQty
|
|
: getCurrentProdDtl
|
|
? totalOrderQty
|
|
: 0
|
|
);
|
|
|
|
return parseInt(count);
|
|
} else {
|
|
let count = 0;
|
|
return count;
|
|
}
|
|
} else {
|
|
let ItemQuantity = item?.ProdVariantDetails?.reduce(
|
|
(accumulator, card) => {
|
|
return accumulator + parseInt(card.OverAllQty || 0);
|
|
},
|
|
0
|
|
);
|
|
let SelectedProduct = ReorderProductData?.filter(
|
|
(a) => a?.ProdId === ProdId
|
|
);
|
|
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?.ProdId === ProdId);
|
|
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(ItemQuantity) >
|
|
parseInt(
|
|
Object.keys(ReportholdData)?.length > 0 && totalOrderQty
|
|
? OverallProdQty
|
|
: getCurrentProdDtl
|
|
? totalOrderQty
|
|
: 0
|
|
)
|
|
) {
|
|
let count =
|
|
parseInt(ItemQuantity) -
|
|
parseInt(
|
|
Object.keys(ReportholdData)?.length > 0 && totalOrderQty
|
|
? OverallProdQty
|
|
: getCurrentProdDtl
|
|
? totalOrderQty
|
|
: 0
|
|
);
|
|
|
|
return parseInt(count);
|
|
} else {
|
|
let count = 0;
|
|
return count;
|
|
}
|
|
}
|
|
};
|
|
|
|
const returnVariantStock = (
|
|
ProdId,
|
|
currentQty,
|
|
orderDetails,
|
|
ProdVariantName
|
|
) => {
|
|
// let ReorderProdetails = BookingType === "Dine In" && !UnpaidData ? ReportholdData?.OrderDtlDetails
|
|
// : BookingType === "Dine In" && UnpaidData ? ReportholdData?.productDetails
|
|
// : ReportholdData?.productDetails
|
|
if (onePeiceFlow) {
|
|
let SelectedProduct = ReorderProductData?.filter(
|
|
(a) => a?.ProdId === ProdId && a?.ProdVariantName === ProdVariantName
|
|
);
|
|
let totalSelectedProductQty = SelectedProduct?.reduce(
|
|
(accumulator, card) => {
|
|
return (
|
|
accumulator +
|
|
parseInt(
|
|
card?.StockAvailable === 'Y'
|
|
? card.SinglePc !== 'Y'
|
|
? card.OrderQty * card.NoOfPcs
|
|
: card.OrderQty
|
|
: 0
|
|
)
|
|
);
|
|
},
|
|
0
|
|
);
|
|
let getCurrentProdDtl = orderDetails?.filter(
|
|
(a) => a?.ProdId === ProdId && a?.ProdVariantName === ProdVariantName
|
|
);
|
|
let totalOrderQty = getCurrentProdDtl?.reduce((accumulator, card) => {
|
|
return (
|
|
accumulator +
|
|
parseInt(
|
|
card?.StockAvailable === 'Y'
|
|
? card.SinglePc !== 'Y'
|
|
? card.OrderQty * card.NoOfPcs
|
|
: card.OrderQty
|
|
: 0
|
|
)
|
|
);
|
|
}, 0);
|
|
|
|
if (
|
|
parseInt(currentQty) >
|
|
parseInt(
|
|
Object.keys(ReportholdData)?.length > 0 && totalOrderQty
|
|
? totalOrderQty - totalSelectedProductQty
|
|
: getCurrentProdDtl
|
|
? totalOrderQty
|
|
: 0
|
|
)
|
|
) {
|
|
let count =
|
|
parseInt(currentQty) -
|
|
parseInt(
|
|
Object.keys(ReportholdData)?.length > 0 && totalOrderQty
|
|
? totalOrderQty - totalSelectedProductQty
|
|
: getCurrentProdDtl
|
|
? totalOrderQty
|
|
: 0
|
|
);
|
|
return parseInt(count);
|
|
} else {
|
|
let count = 0;
|
|
return count;
|
|
}
|
|
} else {
|
|
let SelectedProduct = ReorderProductData?.filter(
|
|
(a) => a?.ProdId === ProdId && a?.ProdVariantName === ProdVariantName
|
|
);
|
|
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?.ProdId === ProdId && a?.ProdVariantName === ProdVariantName
|
|
);
|
|
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);
|
|
|
|
if (
|
|
parseInt(currentQty) >
|
|
parseInt(
|
|
Object.keys(ReportholdData)?.length > 0 && totalOrderQty
|
|
? totalOrderQty - totalSelectedProductQty
|
|
: getCurrentProdDtl
|
|
? totalOrderQty
|
|
: 0
|
|
)
|
|
) {
|
|
let count =
|
|
parseInt(currentQty) -
|
|
parseInt(
|
|
Object.keys(ReportholdData)?.length > 0 && totalOrderQty
|
|
? totalOrderQty - totalSelectedProductQty
|
|
: getCurrentProdDtl
|
|
? totalOrderQty
|
|
: 0
|
|
);
|
|
return parseInt(count);
|
|
} else {
|
|
let count = 0;
|
|
return count;
|
|
}
|
|
}
|
|
};
|
|
|
|
const varientcolumns = [
|
|
{
|
|
title: 'Variant Name',
|
|
dataIndex: 'VarientName',
|
|
key: 'VarientName',
|
|
align: 'left',
|
|
render: (_, record, index) => (
|
|
<span
|
|
style={
|
|
record.StockCount > 0 ||
|
|
record.StockCount === 'Stock Not Maintained'
|
|
? { color: '#000', cursor: 'pointer' }
|
|
: { color: '#f49898', cursor: 'not-allowed' }
|
|
}
|
|
>
|
|
{record.VarientName}
|
|
</span>
|
|
),
|
|
onCell: (record) => {
|
|
return {
|
|
onClick: () => {
|
|
if (
|
|
record.StockCount > 0 ||
|
|
record.StockCount === 'Stock Not Maintained'
|
|
) {
|
|
Stockfun(record);
|
|
}
|
|
},
|
|
};
|
|
},
|
|
},
|
|
{
|
|
title: 'Stock Count',
|
|
dataIndex: 'StockCount',
|
|
key: 'StockCount',
|
|
align: 'Right',
|
|
render: (_, record, index) => (
|
|
<span
|
|
style={
|
|
record.StockCount > 0 ||
|
|
record.StockCount === 'Stock Not Maintained'
|
|
? { color: '#000', cursor: 'pointer' }
|
|
: { color: '#f49898', cursor: 'not-allowed' }
|
|
}
|
|
>
|
|
{record.StockCount}
|
|
</span>
|
|
),
|
|
onCell: (record) => {
|
|
return {
|
|
onClick: () => {
|
|
if (
|
|
record.StockCount > 0 ||
|
|
record.StockCount === 'Stock Not Maintained'
|
|
) {
|
|
Stockfun(record);
|
|
}
|
|
},
|
|
};
|
|
},
|
|
},
|
|
{
|
|
title: 'Amount',
|
|
dataIndex: 'Amount',
|
|
key: 'Amount',
|
|
align: 'right',
|
|
render: (_, record, index) => (
|
|
<span
|
|
style={
|
|
record.StockCount > 0 ||
|
|
record.StockCount === 'Stock Not Maintained'
|
|
? { color: '#000', cursor: 'pointer' }
|
|
: { color: '#f49898', cursor: 'not-allowed' }
|
|
}
|
|
>
|
|
{record.Amount}
|
|
</span>
|
|
),
|
|
onCell: (record) => {
|
|
return {
|
|
onClick: () => {
|
|
if (
|
|
record.StockCount > 0 ||
|
|
record.StockCount === 'Stock Not Maintained'
|
|
) {
|
|
Stockfun(record);
|
|
}
|
|
},
|
|
};
|
|
},
|
|
},
|
|
];
|
|
|
|
const qtydataSource = [];
|
|
qtydata?.ProductDetail?.map((item, index) => {
|
|
qtydataSource.push({
|
|
key: index,
|
|
Quantity: item?.Size + ' ' + item?.UomName,
|
|
Amount: item?.ProdVariantDetails?.[0]?.StockDetails?.[0]?.SellPrice,
|
|
});
|
|
});
|
|
|
|
const varientdataSource = [];
|
|
qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.map((item, index) => {
|
|
varientdataSource.push({
|
|
key: index,
|
|
VarientName: item?.ProdVariantName,
|
|
Amount: onePeiceFlow
|
|
? item?.StockDetails?.[0]?.OnePcsPrice
|
|
: item?.StockDetails?.[0]?.SellPrice,
|
|
StockCount:
|
|
qtydata?.ProductDetail?.[QtyIndex]?.StockAvailable === 'Y'
|
|
? onePeiceFlow
|
|
? returnVariantStock(
|
|
qtydata?.ProductDetail?.[QtyIndex]?.ProdId,
|
|
item?.OverAllPcs,
|
|
CartOrderDetails,
|
|
item?.ProdVariantName
|
|
)
|
|
: returnVariantStock(
|
|
qtydata?.ProductDetail?.[QtyIndex]?.ProdId,
|
|
item?.OverAllQty,
|
|
CartOrderDetails,
|
|
item?.ProdVariantName
|
|
)
|
|
: 'Stock Not Maintained',
|
|
});
|
|
});
|
|
|
|
const dataTransfer = (a, QtyIndex, VarientIndex, stockIndex, onePcs) => {
|
|
if (WeightScalePort === true) {
|
|
if (
|
|
(a?.ProductDetail?.[QtyIndex]?.UomName?.toLowerCase() ===
|
|
'KGS'?.toLowerCase() || a?.ProductDetail?.[QtyIndex]?.UomName?.toLowerCase() ===
|
|
'KG'?.toLowerCase()) &&
|
|
a?.ProductDetail?.[QtyIndex]?.Size == '1'
|
|
) {
|
|
if (WeightScaleWeight > 0 && WeightScaleWeight !== null) {
|
|
let TotalOrderRate =
|
|
parseFloat(
|
|
onePcs
|
|
? (a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[
|
|
VarientIndex
|
|
]?.StockDetails?.[stockIndex]?.OnePcsPrice /
|
|
1000) *
|
|
(parseFloat(WeightScaleWeight) * 1000)
|
|
: a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[
|
|
VarientIndex
|
|
]?.StockDetails?.[stockIndex]?.SellPrice / 1000
|
|
) *
|
|
(parseFloat(WeightScaleWeight) * 1000);
|
|
let data = {
|
|
ProdCat: a?.ProdCat,
|
|
Type: a?.Type,
|
|
OverallQuantity: a?.OverAllQty,
|
|
ActiveStatus: a?.ProductDetail?.[QtyIndex]?.ActiveStatus,
|
|
AvailableFrom: a?.ProductDetail?.[QtyIndex]?.AvailableFrom,
|
|
AvailableTo: a?.ProductDetail?.[QtyIndex]?.AvailableTo,
|
|
Cess: a?.ProductDetail?.[QtyIndex]?.Cess,
|
|
HSNCode: a?.ProductDetail?.[QtyIndex]?.HSNCode,
|
|
BrandName: a?.ProductDetail?.[QtyIndex]?.BrandName,
|
|
// 'ManufDate': a?.ProductDetail?.[QtyIndex]?.ManufDate,
|
|
OpeningQty: a?.ProductDetail?.[QtyIndex]?.OpeningQty,
|
|
PartNumber: a?.ProductDetail?.[QtyIndex]?.PartNumber,
|
|
ProdId: a?.ProductDetail?.[QtyIndex]?.ProdId,
|
|
ProdLogo: a?.ProductDetail?.[QtyIndex]?.ProdLogo,
|
|
ProdName: a?.ProductDetail?.[QtyIndex]?.ProdName,
|
|
QRCode: a?.ProductDetail?.[QtyIndex]?.QRCode,
|
|
QtyBasedPrice: a?.ProductDetail?.[QtyIndex]?.QtyBasedPrice,
|
|
Rack: a?.ProductDetail?.[QtyIndex]?.Rack,
|
|
Size: parseFloat(WeightScaleWeight),
|
|
StockAvailable: a?.ProductDetail?.[QtyIndex]?.StockAvailable,
|
|
TokenAvailable: a?.ProductDetail?.[QtyIndex]?.TokenAvailable,
|
|
TaxId: a?.ProductDetail?.[QtyIndex]?.TaxId,
|
|
TaxPercentage: a?.ProductDetail?.[QtyIndex]?.TaxPercentage,
|
|
TaxName: a?.ProductDetail?.[QtyIndex]?.TaxIdName,
|
|
UniqueId: a?.ProductDetail?.[QtyIndex]?.UniqueId,
|
|
UomName: onePcs ? 'PCS' : a?.ProductDetail?.[QtyIndex]?.UomName,
|
|
SinglePc: onePcs ? 'Y' : 'N',
|
|
FullProductIdentifierDtls:
|
|
a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.[stockIndex]?.ProductIdentifierDtls,
|
|
NoOfPcs:
|
|
a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.[stockIndex]?.NoOfPcs,
|
|
ProdVariantName:
|
|
a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.ProdVariantName,
|
|
BalanceQty:
|
|
a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.[stockIndex]?.BalanceQty,
|
|
BatchRef:
|
|
a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.[stockIndex]?.BatchRef,
|
|
ModelNumber:
|
|
a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.[stockIndex]?.ModelNumber,
|
|
InwardDate:
|
|
a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.[stockIndex]?.InwardDate,
|
|
InwardDtlId:
|
|
a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.[stockIndex]?.InwardDtlId,
|
|
ExpDate:
|
|
a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.[stockIndex]?.ExpDate,
|
|
InwardId:
|
|
a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.[stockIndex]?.InwardId,
|
|
MRP: onePcs
|
|
? a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.[stockIndex]?.OnePcsPrice
|
|
: a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.[stockIndex]?.MRP,
|
|
OrderRate: parseFloat(TotalOrderRate).toFixed(2),
|
|
SellingPrice: parseFloat(TotalOrderRate).toFixed(2),
|
|
SuppId:
|
|
a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.[stockIndex]?.SuppId,
|
|
SuppName:
|
|
a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.[stockIndex]?.SuppName,
|
|
OverAllPcs:
|
|
a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.[stockIndex]?.OverAllPcs,
|
|
Offer:
|
|
a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.[stockIndex]?.OfferPrice,
|
|
BookingTypeName: BookingType,
|
|
CounterName: a?.CounterName,
|
|
};
|
|
setModelQty(false);
|
|
setModalVarient(false);
|
|
setModelstock(false);
|
|
setQtyIndex(0);
|
|
setVarientIndex(0);
|
|
setVarItem(0);
|
|
setItem(), setStockItem();
|
|
dispatch(changeSearchedData(''));
|
|
AddOrderDetails(data);
|
|
dispatch(changeWeightScaleWeight(null));
|
|
setRepeatedModel(false);
|
|
setProdexpir(false);
|
|
setOnePeiceFlow(false);
|
|
} else {
|
|
setMessageType('error');
|
|
setMessageData('Please Connect WeightScale');
|
|
}
|
|
} else {
|
|
setMessageType('error');
|
|
setMessageData('Please Select 1Kg Product');
|
|
}
|
|
} else {
|
|
if (
|
|
(onePcs &&
|
|
a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.[stockIndex]?.NoOfPcs > 0 &&
|
|
a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.[stockIndex]?.OnePcsPrice > 0) ||
|
|
!onePcs ||
|
|
(a?.ProductDetail?.[QtyIndex]?.StockAvailable !== 'Y' &&
|
|
onePcs &&
|
|
a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.[stockIndex]?.OnePcsPrice > 0)
|
|
) {
|
|
let data = {
|
|
ProdCat: a?.ProdCat,
|
|
Type: a?.Type,
|
|
OverallQuantity: a?.OverAllQty,
|
|
ActiveStatus: a?.ProductDetail?.[QtyIndex]?.ActiveStatus,
|
|
AvailableFrom: a?.ProductDetail?.[QtyIndex]?.AvailableFrom,
|
|
AvailableTo: a?.ProductDetail?.[QtyIndex]?.AvailableTo,
|
|
Cess: a?.ProductDetail?.[QtyIndex]?.Cess,
|
|
HSNCode: a?.ProductDetail?.[QtyIndex]?.HSNCode,
|
|
BrandName: a?.ProductDetail?.[QtyIndex]?.BrandName,
|
|
// 'ManufDate': a?.ProductDetail?.[QtyIndex]?.ManufDate,
|
|
OpeningQty: a?.ProductDetail?.[QtyIndex]?.OpeningQty,
|
|
PartNumber: a?.ProductDetail?.[QtyIndex]?.PartNumber,
|
|
ProdId: a?.ProductDetail?.[QtyIndex]?.ProdId,
|
|
ProdLogo: a?.ProductDetail?.[QtyIndex]?.ProdLogo,
|
|
ProdName: a?.ProductDetail?.[QtyIndex]?.ProdName,
|
|
QRCode: a?.ProductDetail?.[QtyIndex]?.QRCode,
|
|
QtyBasedPrice: a?.ProductDetail?.[QtyIndex]?.QtyBasedPrice,
|
|
Rack: a?.ProductDetail?.[QtyIndex]?.Rack,
|
|
Size: onePcs ? '1' : a?.ProductDetail?.[QtyIndex]?.Size,
|
|
StockAvailable: a?.ProductDetail?.[QtyIndex]?.StockAvailable,
|
|
TokenAvailable: a?.ProductDetail?.[QtyIndex]?.TokenAvailable,
|
|
TaxId: a?.ProductDetail?.[QtyIndex]?.TaxId,
|
|
TaxPercentage: a?.ProductDetail?.[QtyIndex]?.TaxPercentage,
|
|
TaxName: a?.ProductDetail?.[QtyIndex]?.TaxIdName,
|
|
UniqueId: a?.ProductDetail?.[QtyIndex]?.UniqueId,
|
|
UomName: a?.ProductDetail?.[QtyIndex]?.UomName,
|
|
SinglePc: onePcs ? 'Y' : 'N',
|
|
NoOfPcs:
|
|
a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.[stockIndex]?.NoOfPcs,
|
|
ProdVariantName:
|
|
a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.ProdVariantName,
|
|
BalanceQty:
|
|
a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.[stockIndex]?.BalanceQty,
|
|
BatchRef:
|
|
a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.[stockIndex]?.BatchRef,
|
|
ModelNumber:
|
|
a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.[stockIndex]?.ModelNumber,
|
|
FullProductIdentifierDtls:
|
|
a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.[stockIndex]?.ProductIdentifierDtls,
|
|
InwardDate:
|
|
a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.[stockIndex]?.InwardDate,
|
|
InwardDtlId:
|
|
a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.[stockIndex]?.InwardDtlId,
|
|
ExpDate:
|
|
a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.[stockIndex]?.ExpDate,
|
|
InwardId:
|
|
a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.[stockIndex]?.InwardId,
|
|
MRP: onePcs
|
|
? a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.[stockIndex]?.OnePcsPrice
|
|
: a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.[stockIndex]?.MRP,
|
|
OrderRate: onePcs
|
|
? a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.[stockIndex]?.OnePcsPrice
|
|
: a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.[stockIndex]?.SellPrice,
|
|
SellingPrice: onePcs
|
|
? a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.[stockIndex]?.OnePcsPrice
|
|
: a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.[stockIndex]?.SellPrice,
|
|
SuppId:
|
|
a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.[stockIndex]?.SuppId,
|
|
OverAllPcs:
|
|
a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.[stockIndex]?.OverAllPcs,
|
|
SuppName:
|
|
a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.[stockIndex]?.SuppName,
|
|
Offer:
|
|
a?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[VarientIndex]
|
|
?.StockDetails?.[stockIndex]?.OfferPrice,
|
|
BookingTypeName: BookingType,
|
|
CounterName: a?.CounterName,
|
|
};
|
|
setModelQty(false);
|
|
setModalVarient(false);
|
|
setModelstock(false);
|
|
setQtyIndex(0);
|
|
setVarientIndex(0);
|
|
setVarItem(0);
|
|
setItem(), setStockItem();
|
|
dispatch(changeSearchedData(''));
|
|
AddOrderDetails(data);
|
|
setOnePeiceFlow(false);
|
|
} else {
|
|
setMessageType('error');
|
|
setMessageData(
|
|
'Please add No.of pieces Inside the box in Product master'
|
|
);
|
|
setModelQty(false);
|
|
setModalVarient(false);
|
|
setModelstock(false);
|
|
setQtyIndex(0);
|
|
setVarientIndex(0);
|
|
setVarItem(0);
|
|
setItem(), setStockItem();
|
|
dispatch(changeSearchedData(''));
|
|
setOnePeiceFlow(false);
|
|
}
|
|
}
|
|
};
|
|
|
|
useEffect(() => {
|
|
setPreOrderSelectedProdNames(GPreOrderList);
|
|
}, [GPreOrderList]);
|
|
|
|
const pickData = (e, item) => {
|
|
if (e.target.checked === true) {
|
|
setSelectedProdNames([
|
|
...globalAllItemdata,
|
|
{
|
|
ProdName: item.ProdName,
|
|
ProdId: item.ProductDetail?.[0]?.ProdId,
|
|
ProdCat: item.ProdCat,
|
|
ProdCatName: item.ProdCatName,
|
|
},
|
|
]);
|
|
} else {
|
|
setSelectedProdNames(
|
|
SelectedProdNames?.filter(
|
|
(data) =>
|
|
!(data?.ProdName == item.ProdName && data?.ProdCat == item.ProdCat)
|
|
)
|
|
);
|
|
}
|
|
};
|
|
|
|
const handleQuickCancel = async () => {
|
|
setQuickAdd(false);
|
|
dispatch(changeSearchedData(''));
|
|
let data = {
|
|
CompId: CompId,
|
|
BranchId: BranchId,
|
|
AppId: AppId,
|
|
};
|
|
await dispatch(getSelectedFavItems(data)).unwrap();
|
|
let data1 = {
|
|
CompId: CompId,
|
|
BranchId: BranchId,
|
|
AppId: AppId,
|
|
ProdSubCat: ProdSubCat,
|
|
};
|
|
|
|
let data2 = {
|
|
compId: CompId,
|
|
branchId: BranchId,
|
|
appId: AppId,
|
|
prodCat: ProdCat,
|
|
};
|
|
|
|
if (
|
|
templateData?.BookingLayout?.[1]?.some(
|
|
(item) => item?.OptionName === 'SubCategory'
|
|
) &&
|
|
ProdSubCat
|
|
) {
|
|
await dispatch(getLayoutproductCard(data1)).unwrap();
|
|
} else if (
|
|
!templateData?.BookingLayout?.[1]?.some(
|
|
(item) => item?.OptionName === 'SubCategory'
|
|
)
|
|
) {
|
|
await dispatch(getCardDataWithoutSubmodule(data2)).unwrap();
|
|
} else {
|
|
await dispatch(getCardDataWithoutSub(data2)).unwrap();
|
|
}
|
|
};
|
|
|
|
let brandMapping = {};
|
|
// Group product details by Brand ID
|
|
qtydata?.ProductDetail?.forEach((item) => {
|
|
const brandId = item?.BrandName;
|
|
if (!brandMapping[brandId]) {
|
|
brandMapping[brandId] = [];
|
|
}
|
|
brandMapping[brandId].push(item);
|
|
});
|
|
|
|
const ItemSellingPrice = (item) => {
|
|
// const variantWithDetails = item?.ProductDetail?.find((variant) => variant?.ProdVariantDetails?.length > 0);
|
|
const variantWithDetails = item?.ComboInwardDetails?.find(
|
|
(variant) => variant?.TotalSellPrice
|
|
);
|
|
if (variantWithDetails) {
|
|
// Access the details of the first variant with ProdVariantDetails
|
|
const firstVariantDetails =
|
|
variantWithDetails?.ProdVariantDetails?.[0]?.StockDetails?.[0]
|
|
?.TotalSellPrice;
|
|
return firstVariantDetails;
|
|
} else {
|
|
// Handle the case where no variant satisfies the condition
|
|
return null; // or any other value you want to return
|
|
}
|
|
};
|
|
|
|
const ItemSize = (item) => {
|
|
const variantWithDetails = item?.ProductDetail?.find(
|
|
(variant) => variant?.ProdVariantDetails?.length > 0
|
|
);
|
|
|
|
if (variantWithDetails) {
|
|
// Access the details of the first variant with ProdVariantDetails
|
|
const firstVariantDetails = variantWithDetails?.Size;
|
|
return firstVariantDetails;
|
|
} else {
|
|
// Handle the case where no variant satisfies the condition
|
|
return null; // or any other value you want to return
|
|
}
|
|
};
|
|
|
|
const ItemUomName = (item) => {
|
|
const variantWithDetails = item?.ProductDetail?.find(
|
|
(variant) => variant?.ProdVariantDetails?.length > 0
|
|
);
|
|
|
|
if (variantWithDetails) {
|
|
// Access the details of the first variant with ProdVariantDetails
|
|
const firstVariantDetails = variantWithDetails?.UomName;
|
|
return firstVariantDetails;
|
|
} else {
|
|
// Handle the case where no variant satisfies the condition
|
|
return null; // or any other value you want to return
|
|
}
|
|
};
|
|
|
|
const expQtyFun = (index) => {
|
|
const selectedProIndex = qtydata?.ProductDetail?.findIndex(
|
|
(item) =>
|
|
item?.ProdId === index?.ProdId &&
|
|
item?.Size === index?.Size &&
|
|
item?.UomName === index?.UomName &&
|
|
item?.Brand === index?.Brand
|
|
);
|
|
|
|
if (selectedProIndex !== -1) {
|
|
const count =
|
|
qtydata?.ProductDetail[selectedProIndex]?.ProdVariantDetails?.length ||
|
|
0;
|
|
|
|
if (count > 1) {
|
|
setModelQty(false);
|
|
setModalVarient(true);
|
|
} else {
|
|
const item = { QtyIndex: selectedProIndex, VarientIndex: 0 };
|
|
singleVarient(item);
|
|
setModelQty(false);
|
|
}
|
|
}
|
|
|
|
setQtyIndex(selectedProIndex);
|
|
setRepeatedModel(true);
|
|
setExpQtyModel(false);
|
|
};
|
|
|
|
const expVerFun = (item) => {
|
|
let count =
|
|
qtydata?.ProductDetail?.[QtyIndex]?.ProdVariantDetails?.[item]
|
|
?.StockDetails?.length;
|
|
if (count > 1) {
|
|
setRepeatedModel(true);
|
|
setModalVarient(false);
|
|
setModelstock(true);
|
|
} else {
|
|
setRepeatedModel(true);
|
|
dataTransfer(qtydata, QtyIndex, item, 0, onePeiceFlow);
|
|
setModelQty(false);
|
|
}
|
|
setexpVarModel(false);
|
|
};
|
|
|
|
const expStockFun = (item) => {
|
|
dataTransfer(qtydata, QtyIndex, VarientIndex, item, onePeiceFlow);
|
|
setexpStockModel(false);
|
|
};
|
|
|
|
const getMaxBrandWidth = () => {
|
|
let maxBrandDataLength = 0;
|
|
|
|
// Iterate through each brand and find the maximum length of the specified key
|
|
Object.values(brandMapping).forEach((brand) => {
|
|
const keyDataLength = brand.length;
|
|
if (keyDataLength > maxBrandDataLength) {
|
|
maxBrandDataLength = keyDataLength;
|
|
}
|
|
});
|
|
|
|
// Set your width logic here based on the maxBrandDataLength
|
|
const maxWidth = maxBrandDataLength >= 5 ? 750 : 'max-content';
|
|
|
|
return maxWidth;
|
|
};
|
|
|
|
useEffect(() => {
|
|
function handleResize() {
|
|
setScreenWidth(window.innerWidth);
|
|
}
|
|
|
|
window.addEventListener('resize', handleResize);
|
|
|
|
return () => {
|
|
window.removeEventListener('resize', handleResize);
|
|
};
|
|
}, []);
|
|
|
|
useEffect(() => {
|
|
function handleResize() {
|
|
setScreenHeight(window.innerHeight);
|
|
}
|
|
|
|
window.addEventListener('resize', handleResize);
|
|
|
|
return () => {
|
|
window.removeEventListener('resize', handleResize);
|
|
};
|
|
}, []);
|
|
|
|
// Example usage for checking the length of 'ProdVariantDetails'
|
|
const widthBasedOnProdVariantDetails = getMaxBrandWidth();
|
|
const ExpDate = useSelector(GlobalExpDateforHeight);
|
|
let containerHeight = '';
|
|
|
|
if (templateData?.BookingLayout?.[0] === 'Layout1') {
|
|
if (templateData?.BookingBilling?.[0] == 'Billing1') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 310}px`
|
|
: '61vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 320}px`
|
|
: '60vh'
|
|
: '76vh';
|
|
} else if (templateData?.BookingBilling?.[0] == 'Billing2') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 300}px`
|
|
: '61vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 310}px`
|
|
: '60vh'
|
|
: '76vh';
|
|
} else if (templateData?.BookingBilling?.[0] == 'Billing3') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 340}px`
|
|
: '63vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 350}px`
|
|
: '62vh'
|
|
: '76vh';
|
|
} else if (templateData?.BookingBilling?.[0] == 'Billing4') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 300}px`
|
|
: '63vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 310}px`
|
|
: '62vh'
|
|
: '76vh';
|
|
} else if (templateData?.BookingBilling?.[0] == 'Billing5') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 300}px`
|
|
: '60vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 310}px`
|
|
: '59vh'
|
|
: '76vh';
|
|
} else if (templateData?.BookingBilling?.[0] == 'Billing6') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 300}px`
|
|
: '60vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 310}px`
|
|
: '59vh'
|
|
: '76vh';
|
|
} else if (templateData?.BookingBilling?.[0] == 'Billing7') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 300}px`
|
|
: '60vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 310}px`
|
|
: '59vh'
|
|
: '76vh';
|
|
}
|
|
} else if (templateData?.BookingLayout?.[0] === 'Layout2') {
|
|
if (templateData?.BookingBilling?.[0] == 'Billing1') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 310}px`
|
|
: '61vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 320}px`
|
|
: '60vh'
|
|
: '74vh';
|
|
} else if (templateData?.BookingBilling?.[0] == 'Billing2') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 320}px`
|
|
: '61vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 330}px`
|
|
: '60vh'
|
|
: '74vh';
|
|
} else if (templateData?.BookingBilling?.[0] == 'Billing3') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 320}px`
|
|
: '63vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 330}px`
|
|
: '62vh'
|
|
: '74vh';
|
|
} else if (templateData?.BookingBilling?.[0] == 'Billing4') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 320}px`
|
|
: '63vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 330}px`
|
|
: '62vh'
|
|
: '74vh';
|
|
} else if (templateData?.BookingBilling?.[0] == 'Billing5') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 320}px`
|
|
: '60vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 330}px`
|
|
: '61vh'
|
|
: '74vh';
|
|
} else if (templateData?.BookingBilling?.[0] == 'Billing6') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 320}px`
|
|
: '60vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 330}px`
|
|
: '59vh'
|
|
: '74vh';
|
|
} else if (templateData?.BookingBilling?.[0] == 'Billing7') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 310}px`
|
|
: '61vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 320}px`
|
|
: '60vh'
|
|
: '75vh';
|
|
}
|
|
} else if (templateData?.BookingLayout?.[0] === 'Layout3') {
|
|
if (templateData?.BookingBilling?.[0] == 'Billing1') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 390}px`
|
|
: '58vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 400}px`
|
|
: '57vh'
|
|
: '73vh';
|
|
} else if (templateData?.BookingBilling?.[0] == 'Billing2') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 390}px`
|
|
: '57vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 400}px`
|
|
: '56vh'
|
|
: '73vh';
|
|
} else if (templateData?.BookingBilling?.[0] == 'Billing3') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 395}px`
|
|
: '57vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 400}px`
|
|
: '56vh'
|
|
: '73vh';
|
|
} else if (templateData?.BookingBilling?.[0] == 'Billing4') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 390}px`
|
|
: '57vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 400}px`
|
|
: '56vh'
|
|
: '75vh';
|
|
} else if (templateData?.BookingBilling?.[0] == 'Billing5') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 385}px`
|
|
: '57vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 395}px`
|
|
: '56vh'
|
|
: '72vh';
|
|
} else if (templateData?.BookingBilling?.[0] == 'Billing6') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 385}px`
|
|
: '57vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 395}px`
|
|
: '56vh'
|
|
: '72vh';
|
|
} else if (templateData?.BookingBilling?.[0] == 'Billing7') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 390}px`
|
|
: '57vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 400}px`
|
|
: '56vh'
|
|
: '72vh';
|
|
}
|
|
} else if (templateData?.BookingLayout?.[0] === 'Layout4') {
|
|
if (templateData?.BookingBilling?.[0] == 'Billing1') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 260}px`
|
|
: '73vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 270}px`
|
|
: '72vh'
|
|
: '88vh';
|
|
} else if (templateData?.BookingBilling?.[0] == 'Billing2') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 220}px`
|
|
: '73vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 230}px`
|
|
: '72vh'
|
|
: '88vh';
|
|
} else if (templateData?.BookingBilling?.[0] == 'Billing3') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 260}px`
|
|
: '73vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 270}px`
|
|
: '72vh'
|
|
: '88vh';
|
|
} else if (templateData?.BookingBilling?.[0] == 'Billing4') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 230}px`
|
|
: '73vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 240}px`
|
|
: '72vh'
|
|
: '88vh';
|
|
} else if (templateData?.BookingBilling?.[0] == 'Billing5') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 230}px`
|
|
: '73vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 240}px`
|
|
: '72vh'
|
|
: '88vh';
|
|
} else if (templateData?.BookingBilling?.[0] == 'Billing6') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 260}px`
|
|
: '73vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 270}px`
|
|
: '72vh'
|
|
: '88vh';
|
|
} else if (templateData?.BookingBilling?.[0] == 'Billing7') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 260}px`
|
|
: '73vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 270}px`
|
|
: '72vh'
|
|
: '88vh';
|
|
}
|
|
} else if (templateData?.BookingLayout?.[0] === 'Layout5') {
|
|
if (templateData?.BookingBilling?.[0] == 'Billing1') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 280}px`
|
|
: '72vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 290}px`
|
|
: '70vh'
|
|
: '88vh';
|
|
} else if (templateData?.BookingBilling?.[0] == 'Billing2') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 260}px`
|
|
: '72vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 270}px`
|
|
: '70vh'
|
|
: '88vh';
|
|
} else if (templateData?.BookingBilling?.[0] == 'Billing3') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 270}px`
|
|
: '72vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 280}px`
|
|
: '70vh'
|
|
: '88vh';
|
|
} else if (templateData?.BookingBilling?.[0] == 'Billing4') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 270}px`
|
|
: '72vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 280}px`
|
|
: '70vh'
|
|
: '88vh';
|
|
} else if (templateData?.BookingBilling?.[0] == 'Billing5') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 260}px`
|
|
: '72vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 270}px`
|
|
: '70vh'
|
|
: '88vh';
|
|
} else if (templateData?.BookingBilling?.[0] == 'Billing6') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 260}px`
|
|
: '72vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 270}px`
|
|
: '70vh'
|
|
: '88vh';
|
|
} else if (templateData?.BookingBilling?.[0] == 'Billing7') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 270}px`
|
|
: '72vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 280}px`
|
|
: '70vh'
|
|
: '88vh';
|
|
}
|
|
} else if (templateData?.BookingLayout?.[0] === 'Layout6') {
|
|
if (templateData?.BookingBilling?.[0] == 'Billing1') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 330}px`
|
|
: '61vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 340}px`
|
|
: '60vh'
|
|
: '76vh';
|
|
} else if (templateData?.BookingBilling?.[0] == 'Billing2') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 260}px`
|
|
: '61vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 370}px`
|
|
: '60vh'
|
|
: '76vh';
|
|
} else if (templateData?.BookingBilling?.[0] == 'Billing3') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 320}px`
|
|
: '61vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 330}px`
|
|
: '60vh'
|
|
: '76vh';
|
|
} else if (templateData?.BookingBilling?.[0] == 'Billing4') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 320}px`
|
|
: '61vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 320}px`
|
|
: '60vh'
|
|
: '76vh';
|
|
} else if (templateData?.BookingBilling?.[0] == 'Billing5') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 290}px`
|
|
: '61vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 300}px`
|
|
: '60vh'
|
|
: '76vh';
|
|
} else if (templateData?.BookingBilling?.[0] == 'Billing6') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 320}px`
|
|
: '61vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 330}px`
|
|
: '60vh'
|
|
: '76vh';
|
|
} else if (templateData?.BookingBilling?.[0] == 'Billing7') {
|
|
containerHeight = isMobile
|
|
? ExpDate >= 7
|
|
? screenWidth < 600
|
|
? `${props?.screenHeight - 280}px`
|
|
: '61vh'
|
|
: screenWidth < 600
|
|
? `${props?.screenHeight - 290}px`
|
|
: '60vh'
|
|
: '76vh';
|
|
}
|
|
}
|
|
const [draggableCardData, setDraggableCardData] = useState([]);
|
|
|
|
useEffect(() => {
|
|
if (Array.isArray(cardData)) {
|
|
const withIds = cardData.map((item, idx) => ({
|
|
...item,
|
|
id: item?.ProductDetail?.[0]?.ProdName + '-' + idx,
|
|
}));
|
|
setDraggableCardData(withIds);
|
|
}
|
|
}, [cardData]);
|
|
|
|
const sensors = useSensors(
|
|
useSensor(PointerSensor, {
|
|
activationConstraint: {
|
|
distance: 8, // <- number of pixels the pointer must move before activating drag
|
|
},
|
|
})
|
|
);
|
|
|
|
const handleDragEnd = (event) => {
|
|
const { active, over } = event;
|
|
|
|
// Ensure `over` is not null
|
|
if (!over) return;
|
|
|
|
if (active.id !== over.id) {
|
|
const oldIndex = draggableCardData.findIndex((i) => i.id === active.id);
|
|
const newIndex = draggableCardData.findIndex((i) => i.id === over.id);
|
|
|
|
const updatedData = arrayMove(draggableCardData, oldIndex, newIndex);
|
|
setDraggableCardData(updatedData);
|
|
|
|
dispatch(changeCardData(updatedData));
|
|
}
|
|
};
|
|
|
|
// ---------------------------------------------------BS COMBO ITEM CARD---------------------------------------------------------------------------------------------------------
|
|
|
|
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>,
|
|
},
|
|
];
|
|
|
|
useEffect(() => {
|
|
setPreOrderSelectedProdNames(GPreOrderList);
|
|
}, [GPreOrderList]);
|
|
|
|
useEffect(() => {
|
|
setPreOrderSelectedProdNames([]);
|
|
// dispatch(changePreOrderAdditem(null));
|
|
}, [preOrder]);
|
|
|
|
const CardOnclick = async (selectedOption, item) => {
|
|
let count = selectedOption?.[0]?.ComboInwardDetails?.length;
|
|
setQtydata(selectedOption);
|
|
let alreadyOrdercount = await returnCount(
|
|
selectedOption?.ComboName,
|
|
selectedOption?.OverallQuantity,
|
|
CartOrderDetails
|
|
);
|
|
if (alreadyOrdercount <= 0 && selectedOption?.SetCount > 0) {
|
|
setMessageType('error');
|
|
setMessageData('Stock Not Available');
|
|
} else if (count > 1) {
|
|
setModelstock(true);
|
|
// form.resetFields(['ProdName']);
|
|
} else {
|
|
onAutocompleteChange(selectedOption);
|
|
// form.resetFields(['ProdName']);
|
|
}
|
|
};
|
|
|
|
const returnCount = (
|
|
ProdName,
|
|
currentQty,
|
|
orderDetails,
|
|
comboItem // pass the full combo item object here if available
|
|
) => {
|
|
// --- Combo SetCount==0 logic ---
|
|
if (
|
|
comboItem &&
|
|
comboItem.SetCount === 0 &&
|
|
(
|
|
Array.isArray(comboItem.ComboInwardDetails?.[0]?.ComboDetails) ||
|
|
Array.isArray(comboItem.ProdDetail)
|
|
)
|
|
) {
|
|
const insideProducts =
|
|
comboItem.ComboInwardDetails?.[0]?.ComboDetails || comboItem.ProdDetail;
|
|
const comboOrderQty = parseInt(currentQty) || 1;
|
|
const combosInCart = orderDetails?.filter(
|
|
(a) => a?.ProdId === comboItem.ComboId || a?.ProdId === comboItem.ProdId
|
|
) || [];
|
|
const combosInCartQty = combosInCart.reduce(
|
|
(sum, c) => sum + (parseInt(c.OrderQty) || 0),
|
|
0
|
|
);
|
|
|
|
// Include reorder combos (SetCount == 0) for the same combo id
|
|
const reorderCombos = (ReorderProductData || []).filter(
|
|
(a) => a?.Type === 'C' && (a?.ProdId === comboItem.ComboId || a?.ProdId === comboItem.ProdId)
|
|
);
|
|
const reorderCombosQty = reorderCombos.reduce((sum, c) => {
|
|
const setZero = c?.SetCount === 0 || c?.SetCount === '0';
|
|
return setZero ? sum + (parseInt(c?.OrderQty) || 0) : sum;
|
|
}, 0);
|
|
// Ignore reorder combos when validating availability
|
|
const combosInCartQtyNet = Math.max(0, (parseInt(combosInCartQty) || 0) - (parseInt(reorderCombosQty) || 0));
|
|
|
|
// Collect out-of-stock product names
|
|
const outOfStockProducts = insideProducts
|
|
.filter((prod) => {
|
|
if (prod.StockAvailable === 'Y') {
|
|
// Find all cart items for this inside product
|
|
const cartQty = orderDetails
|
|
?.filter((cartItem) => cartItem.ProdId === prod.ProdId)
|
|
?.reduce((sum, cartItem) => sum + (parseInt(cartItem.OrderQty) || 0), 0) || 0;
|
|
|
|
// How many combos are being added now
|
|
const comboOrderQty = parseInt(currentQty) || 1;
|
|
const combosInCart = orderDetails?.filter(
|
|
(a) => a?.ProdId === comboItem.ComboId || a?.ProdId === comboItem.ProdId
|
|
) || [];
|
|
const combosInCartQty = combosInCart.reduce(
|
|
(sum, c) => sum + (parseInt(c.OrderQty) || 0),
|
|
0
|
|
);
|
|
|
|
// Include reorder combos (SetCount == 0) for the same combo id
|
|
const reorderCombos = (ReorderProductData || []).filter(
|
|
(a) => a?.Type === 'C' && (a?.ProdId === comboItem.ComboId || a?.ProdId === comboItem.ProdId)
|
|
);
|
|
const reorderCombosQty = reorderCombos.reduce((sum, c) => {
|
|
const setZero = c?.SetCount === 0 || c?.SetCount === '0';
|
|
return setZero ? sum + (parseInt(c?.OrderQty) || 0) : sum;
|
|
}, 0);
|
|
const combosInCartQtyNet = Math.max(0, (parseInt(combosInCartQty) || 0) - (parseInt(reorderCombosQty) || 0));
|
|
|
|
// Total required for this inside product: (combos in cart (excluding reorder) + this add) * ProductQty + single product in cart
|
|
const requiredQtyFromCombos = (comboOrderQty + combosInCartQtyNet) * (parseInt(prod.ProductQty) || 1);
|
|
const totalRequiredQty = requiredQtyFromCombos + cartQty;
|
|
|
|
const availableQty = (prod.StockDetails || []).reduce(
|
|
(sum, stock) => sum + (parseInt(stock.BalanceQty) || 0),
|
|
0
|
|
);
|
|
return totalRequiredQty > availableQty;
|
|
}
|
|
return false;
|
|
})
|
|
.map((prod) => prod.ProdName);
|
|
|
|
if (outOfStockProducts.length > 0) {
|
|
return { count: 0, outOfStockProducts };
|
|
}
|
|
return { count: 1, outOfStockProducts: [] };
|
|
}
|
|
|
|
// --- Original logic for normal products ---
|
|
// (keep your original logic, but return {count, outOfStockProducts: []})
|
|
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 { count: parseInt(count), outOfStockProducts: [] };
|
|
} else {
|
|
return { count: 0, outOfStockProducts: [] };
|
|
}
|
|
};
|
|
|
|
const onAutocompleteChange = async (selectedOption) => {
|
|
let OrderRate = selectedOption?.ComboInwardDetails?.[0]?.TotalSellPrice;
|
|
|
|
let data = {
|
|
Type: 'C',
|
|
OverallQuantity: selectedOption?.OverallQuantity,
|
|
ActiveStatus: selectedOption?.ActiveStatus,
|
|
AvailableFrom: selectedOption?.ValidFrom,
|
|
AvailableTo: selectedOption?.ValidTo,
|
|
ProdId: selectedOption?.ComboId,
|
|
ProdDetail: selectedOption?.ComboInwardDetails?.[0]?.ComboDetails,
|
|
ProdName: selectedOption?.ComboName,
|
|
QRCode: selectedOption?.ComboInwardDetails?.[0]?.QRCode,
|
|
StockAvailable: 'Y',
|
|
BalanceQty: selectedOption?.ComboInwardDetails?.[0]?.BalanceQty,
|
|
InwardDtlId: selectedOption?.ComboInwardDetails?.[0]?.ComboInwardDtlId,
|
|
MRP: selectedOption?.ComboInwardDetails?.[0]?.TotalSellPrice,
|
|
OrderRate: selectedOption?.ComboInwardDetails?.[0]?.TotalSellPrice,
|
|
SellingPrice: selectedOption?.ComboInwardDetails?.[0]?.TotalSellPrice,
|
|
BookingTypeName: BookingType,
|
|
TaxPercentage: 0,
|
|
Size: 1,
|
|
UomName: 'PCS',
|
|
OfferType: selectedOption?.ComboInwardDetails?.[0]?.OfferType,
|
|
OfferPrice: selectedOption?.ComboInwardDetails?.[0]?.OfferPrice,
|
|
OfferValue:
|
|
selectedOption?.ComboInwardDetails?.[0]?.OfferType === 'F'
|
|
? selectedOption?.ComboInwardDetails?.[0]?.OfferPrice
|
|
: (OrderRate * selectedOption?.ComboInwardDetails?.[0]?.OfferPrice) /
|
|
100,
|
|
SinglePc: 'N',
|
|
SetCount: selectedOption?.SetCount,
|
|
|
|
};
|
|
|
|
await AddOrderDetails(data);
|
|
};
|
|
const calculateTaxAmounts = (item) => {
|
|
// Calculate TotalAmt considering OfferPrice and OfferType
|
|
const offerValue =
|
|
item?.OfferPrice > 0
|
|
? item?.OrderRate -
|
|
(item?.OfferType === 'F'
|
|
? item?.OfferPrice
|
|
: (item?.OrderRate * item?.OfferPrice) / 100)
|
|
: item?.OrderRate;
|
|
|
|
const taxAmount = ((item?.OrderRate * item?.TaxPercentage) / (100 + item?.TaxPercentage)).toFixed(2);
|
|
const withoutTaxRate = (
|
|
item?.OrderRate -
|
|
(item?.OrderRate * item?.TaxPercentage) / (100 + item?.TaxPercentage)
|
|
).toFixed(2);
|
|
|
|
return {
|
|
TotalAmt: offerValue,
|
|
TaxAmt: parseFloat(taxAmount),
|
|
WithoutTaxRate: parseFloat(withoutTaxRate),
|
|
};
|
|
};
|
|
|
|
const createNewCartItem = (item) => {
|
|
const taxAmounts = calculateTaxAmounts(item);
|
|
|
|
return {
|
|
...item,
|
|
OrderQty: 1,
|
|
OfferPrice: item?.OfferPrice,
|
|
...taxAmounts,
|
|
localId: uuidv4(),
|
|
};
|
|
};
|
|
|
|
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?.OrderQty + 1) *
|
|
isItemInCart?.OrderRate *
|
|
isItemInCart?.OfferPrice) /
|
|
100)?.toFixed(2),
|
|
|
|
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)?.toFixed(2),
|
|
// 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?.OrderQty + 1) *
|
|
isItemInCart?.OrderRate *
|
|
isItemInCart?.OfferPrice) /
|
|
100)?.toFixed(2),
|
|
|
|
// 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?.OrderQty + 1) *
|
|
isItemInCart?.OrderRate *
|
|
isItemInCart?.OfferPrice) /
|
|
100)?.toFixed(2),
|
|
|
|
// 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
|
|
: (((isItemInCartHold?.OrderQty + 1) *
|
|
isItemInCartHold?.OrderRate *
|
|
isItemInCartHold?.OfferPrice) /
|
|
100)?.toFixed(2),
|
|
|
|
// 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'
|
|
? (isItemInCartHold?.OrderQty + 1) * isItemInCart?.OfferPrice
|
|
: (((isItemInCartHold?.OrderQty + 1) *
|
|
isItemInCartHold?.OrderRate *
|
|
isItemInCartHold?.OfferPrice) /
|
|
100)?.toFixed(2),
|
|
|
|
// 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'
|
|
? (isItemNotInDine?.OrderQty + 1) * isItemNotInDine?.OfferPrice
|
|
: ((isItemNotInDine?.OrderQty + 1) *
|
|
isItemNotInDine?.OrderRate *
|
|
isItemNotInDine?.OfferPrice) /
|
|
100)
|
|
: (isItemNotInDine?.OrderQty + 1) * isItemNotInDine?.OrderRate,
|
|
OfferValue:
|
|
item?.OfferType === 'F'
|
|
? (isItemNotInDine?.OrderQty + 1) * isItemNotInDine?.OfferPrice
|
|
: (((isItemNotInDine?.OrderQty + 1) *
|
|
isItemNotInDine?.OrderRate *
|
|
isItemNotInDine?.OfferPrice) /
|
|
100)?.toFixed(2),
|
|
|
|
// 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'
|
|
? (isItemNotInDine?.OrderQty + 1) * isItemNotInDine?.OfferPrice
|
|
: ((isItemNotInDine?.OrderQty + 1) *
|
|
isItemNotInDine?.OrderRate *
|
|
isItemNotInDine?.OfferPrice) /
|
|
100)
|
|
: (isItemNotInDine?.OrderQty + 1) * isItemNotInDine?.OrderRate,
|
|
OfferValue:
|
|
item?.OfferType === 'F'
|
|
? (isItemInCart?.OrderQty + 1) * isItemInCart?.OfferPrice
|
|
: (((isItemNotInDine?.OrderQty + 1) *
|
|
isItemNotInDine?.OrderRate *
|
|
isItemNotInDine?.OfferPrice) /
|
|
100)?.toFixed(2),
|
|
|
|
// 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'
|
|
// ?
|
|
const newCartItem = createNewCartItem(item, item.OrderQty);
|
|
const updatedData = BillOrderPre === 'Y'
|
|
? [newCartItem, ...CartOrderDetails]
|
|
: [...CartOrderDetails, newCartItem];
|
|
dispatch(changeOrderCardDetails(updatedData));
|
|
// 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 {
|
|
const newCartItem = createNewCartItem(item, 1);
|
|
const updatedData = (BillOrderPre === 'Y')
|
|
? [newCartItem, ...CartOrderDetails]
|
|
: [...CartOrderDetails, newCartItem];
|
|
dispatch(changeOrderCardDetails(updatedData));
|
|
// 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) => {
|
|
onChangeprodFunction(decodedText);
|
|
setOpenScanner(false); // Close the modal after scanning
|
|
stopScannerFromParent();
|
|
};
|
|
|
|
function encrypt(code, key) {
|
|
let encrypted = (
|
|
<>
|
|
<div
|
|
className="bs-item-card-masterdiv"
|
|
style={{
|
|
display: 'flex',
|
|
flexDirection: 'column',
|
|
overflowY: 'scroll',
|
|
height: containerHeight,
|
|
}}
|
|
>
|
|
{messageType && messageData && (
|
|
<Messages
|
|
messageType={messageType}
|
|
messageData={messageData}
|
|
onComplete={onComplete}
|
|
/>
|
|
)}
|
|
<div style={{
|
|
display: 'flex',
|
|
// justifyContent: 'center'
|
|
}}>
|
|
<div
|
|
className="BSItemCard-master-container"
|
|
style={{
|
|
rowGap: cardFunction?.BigImage ? '15px' : '15px',
|
|
pointerEvents: OrderType === 'Failed' ? 'none' : 'auto',
|
|
}}
|
|
>
|
|
{/* <div className="BSItemCard-master-container" > */}
|
|
{cardData?.length > 0 ? (
|
|
<>
|
|
<DndContext
|
|
sensors={sensors}
|
|
collisionDetection={closestCenter}
|
|
onDragEnd={handleDragEnd}
|
|
>
|
|
<SortableContext
|
|
items={comboList.map((item) => item.id)}
|
|
strategy={rectSortingStrategy}
|
|
>
|
|
<div
|
|
style={{
|
|
display: 'flex',
|
|
flexWrap: 'wrap',
|
|
|
|
gap: templateData?.BookingCard?.[0] != 'Card4' ? '8px' : '1.7rem',
|
|
}}
|
|
>
|
|
{comboList?.map((item) => {
|
|
const stockResult = returnCount(
|
|
item?.ComboName,
|
|
item?.OverallQuantity,
|
|
CartOrderDetails,
|
|
item
|
|
);
|
|
return (
|
|
<SortableCard
|
|
key={item.id || index}
|
|
id={item.id || index}
|
|
item={item}
|
|
>
|
|
{templateData?.BookingCard?.[0] != 'Card4' ?
|
|
<div
|
|
style={{ position: 'relative' }}
|
|
className={
|
|
(item?.OverallQuantity !== undefined &&
|
|
stockResult.count > 0) ||
|
|
item?.StockAvailable !== 'Y'
|
|
? 'BkPrdCardActive'
|
|
: 'BkPrdCardDeActive'
|
|
}
|
|
>
|
|
{!isMobile ? (
|
|
<Tooltip title={item?.ComboName}>
|
|
|
|
<div
|
|
style={{
|
|
alignItems: 'center',
|
|
backgroundColor:
|
|
cardFunction?.SmallImage &&
|
|
cardFunction?.Background &&
|
|
(SelectedCardColor
|
|
? SelectedCardColor?.[
|
|
'BackgroundColor'
|
|
]
|
|
: ''),
|
|
padding:
|
|
!cardFunction?.ImageUp &&
|
|
!cardFunction?.ImageDown
|
|
? cardFunction?.SmallImage &&
|
|
'5px 9px'
|
|
: '8px 2px',
|
|
flexDirection:
|
|
cardFunction?.ImageRight &&
|
|
'row-reverse'
|
|
? cardFunction?.ImageRight &&
|
|
'row-reverse'
|
|
: cardFunction?.ImageUp && 'column'
|
|
? cardFunction?.ImageUp && 'column'
|
|
: cardFunction?.ImageDown &&
|
|
'column-reverse'
|
|
? cardFunction?.ImageDown &&
|
|
'column-reverse'
|
|
: cardFunction?.ImageLeft &&
|
|
'row',
|
|
borderRadius:
|
|
cardFunction?.EdgeCurve && '6px',
|
|
width:
|
|
!cardFunction?.ImageUp &&
|
|
!cardFunction?.ImageDown &&
|
|
!cardFunction?.BigImage &&
|
|
!cardFunction?.ImageRight &&
|
|
cardFunction?.SmallImage &&
|
|
(cardFunction?.ImageUp ||
|
|
cardFunction?.ImageDown)
|
|
? '6rem'
|
|
: cardFunction?.BigImage && '9rem',
|
|
height:
|
|
!cardFunction?.ImageUp &&
|
|
!cardFunction?.BigImage &&
|
|
'',
|
|
pointerEvents: globaldata && 'none',
|
|
}}
|
|
className={
|
|
cardFunction?.SmallImage
|
|
? 'BSItemCard-container-smallimage'
|
|
: 'BSItemCard-container'
|
|
}
|
|
onClick={(e) => {
|
|
if (
|
|
!(
|
|
item?.OverallQuantity !== undefined &&
|
|
stockResult.count > 0
|
|
)
|
|
) {
|
|
setMessageType && setMessageType('error');
|
|
setMessageData && setMessageData('Stock Not Available');
|
|
e.stopPropagation();
|
|
} else {
|
|
CardOnclick(item);
|
|
}
|
|
}}
|
|
data-aos="zoom-in"
|
|
data-aos-duration="600"
|
|
>
|
|
{(cardFunction?.BigImage ||
|
|
cardFunction?.SmallImage) && (
|
|
<img
|
|
style={{
|
|
objectFit:
|
|
cardFunction?.BigImage && '',
|
|
height: !cardFunction?.BigImage
|
|
? (!cardFunction?.BigImage &&
|
|
cardFunction?.SmallImage) ||
|
|
cardFunction?.ImageLeft ||
|
|
cardFunction?.ImageUp ||
|
|
cardFunction?.ImageDown
|
|
? '3rem'
|
|
: cardFunction?.BigImage && '7rem'
|
|
: '5rem',
|
|
}}
|
|
className={
|
|
cardFunction?.SmallImage
|
|
? 'BSItemCard-image-smallimage'
|
|
: 'BSItemCard-image'
|
|
}
|
|
src={
|
|
item?.ComboImage ===
|
|
''
|
|
? defaultimage
|
|
: item?.ComboImage
|
|
? item?.ComboImage
|
|
: defaultimage
|
|
}
|
|
alt=""
|
|
/>
|
|
)}
|
|
|
|
<div
|
|
className={
|
|
cardFunction?.SmallImage
|
|
? 'BSItemCard-content-smallimage'
|
|
: 'BSItemCard-content'
|
|
}
|
|
style={{
|
|
backgroundColor:
|
|
cardFunction?.Background &&
|
|
(SelectedCardColor
|
|
? SelectedCardColor?.[
|
|
'BackgroundColor'
|
|
]
|
|
: ''),
|
|
|
|
position: !cardFunction?.BigImage
|
|
? 'relative'
|
|
: 'absolute',
|
|
flexDirection:
|
|
!cardFunction?.BigImage && 'column',
|
|
borderRadius:
|
|
!cardFunction?.BigImage &&
|
|
cardFunction?.EdgeCurve &&
|
|
'6px',
|
|
bottom: cardFunction?.BigImage && '',
|
|
cardFunction,
|
|
width:
|
|
!cardFunction?.BigImage &&
|
|
!cardFunction?.SmallImage &&
|
|
'',
|
|
height: cardFunction?.SmallImage
|
|
? '5.5rem'
|
|
: !cardFunction?.BigImage && '5.5rem',
|
|
alignItems:
|
|
!cardFunction?.BigImage &&
|
|
!cardFunction?.SmallImage &&
|
|
'center',
|
|
textAlign:
|
|
!cardFunction?.BigImage &&
|
|
!cardFunction?.SmallImage &&
|
|
'center',
|
|
flexWrap:
|
|
cardFunction?.BigImage && 'wrap',
|
|
// flexDirection:
|
|
// cardFunction?.SmallImage ||
|
|
// (cardFunction?.BigImage && "column"),
|
|
}}
|
|
>
|
|
<p
|
|
style={{
|
|
textTransform:
|
|
cardFunction?.TextCapitalize &&
|
|
'uppercase',
|
|
width: !cardFunction?.SmallImage
|
|
? cardFunction?.BigImage && '120px'
|
|
: cardFunction?.SmallImage &&
|
|
!cardFunction?.ImageUp &&
|
|
!cardFunction?.ImageDown &&
|
|
'85px',
|
|
// Width: cardFunction?.BigImage && "70px",
|
|
fontSize:
|
|
!cardFunction?.BigImage &&
|
|
!cardFunction?.SmallImage &&
|
|
'12px', //naresh27
|
|
whiteSpace:
|
|
!cardFunction?.BigImage &&
|
|
'pre-wrap',
|
|
margin: 'auto',
|
|
fontFamily: SelectedCardFont
|
|
? SelectedCardFont
|
|
: '',
|
|
color: SelectedCardColor
|
|
? SelectedCardColor?.['FontColor']
|
|
: '',
|
|
textOverflow: 'ellipsis',
|
|
}}
|
|
className="BSItemCard-itemName"
|
|
>
|
|
{/* {item?.ComboName} {(item?.OverallQuantity !== undefined &&
|
|
returnCount(item?.ComboName, item?.OverallQuantity, CartOrderDetails) > 0)
|
|
|| item?.OverallQuantity > 0 ? '' : <p style={{ color: 'red', marginTop: '5px', fontSize: '15px' }}>No Stock</p>} */}
|
|
{item?.ProdName}{' '}
|
|
|
|
{(item?.OverallQuantity !== undefined && stockResult.count > 0)
|
|
? (
|
|
''
|
|
) : (
|
|
<p
|
|
style={{
|
|
color: 'red',
|
|
marginTop: '5px',
|
|
fontSize: '9px',
|
|
textAlign: 'left',
|
|
}}
|
|
>
|
|
No Stock
|
|
{stockResult.outOfStockProducts &&
|
|
stockResult.outOfStockProducts.length > 0 && (
|
|
<>: {stockResult.outOfStockProducts.join(', ')}</>
|
|
)}
|
|
</p>
|
|
)}
|
|
</p>
|
|
{cardFunction?.Price &&
|
|
(((item?.OverallQuantity !== undefined &&
|
|
item?.OverallQuantity !== 0 &&
|
|
item?.OverallQuantity !== null) ||
|
|
item?.ProductDetail?.some(
|
|
(item) =>
|
|
item?.StockAvailable !== 'Y'
|
|
)) || stockResult.count > 0) && (
|
|
<p
|
|
className="BSItemCard-itemPrice"
|
|
style={{
|
|
fontSize:
|
|
!cardFunction?.SmallImage
|
|
? cardFunction?.BigImage &&
|
|
'12px'
|
|
: '12px',
|
|
textAlign: 'center',
|
|
lineHeight: '2',
|
|
fontFamily: SelectedCardFont
|
|
? SelectedCardFont
|
|
: '',
|
|
color: SelectedCardColor
|
|
? SelectedCardColor?.[
|
|
'FontColor'
|
|
]
|
|
: '',
|
|
}}
|
|
>
|
|
₹{' '}
|
|
{
|
|
item?.ComboInwardDetails?.[0]
|
|
?.TotalSellPrice
|
|
}
|
|
|
|
{/* {item?.ProductDetail?.[0]?.ProdVariantDetails?.[0]?.StockDetails?.[0]?.SellPrice} */}
|
|
{/* {ItemSellingPrice(item)} */}
|
|
<span className="BSItemCard-itemCount">
|
|
{'(1 Combo Pack)'}
|
|
</span>
|
|
</p>
|
|
)}
|
|
</div>
|
|
|
|
{cardFunction?.StockCount &&
|
|
item?.OverallQuantity !== undefined &&
|
|
item?.OverallQuantity !== 0 && (
|
|
<div
|
|
style={{
|
|
top: !cardFunction?.BigImage && '0',
|
|
right:
|
|
!cardFunction?.BigImage &&
|
|
!cardFunction?.SmallImage &&
|
|
'0px',
|
|
position: 'absolute',
|
|
}}
|
|
className={
|
|
cardFunction?.BigImage
|
|
? 'BSItemCard-badge'
|
|
: 'BSItemCard-badge-withoutimage'
|
|
}
|
|
>
|
|
{item?.OverallQuantity !== null && (
|
|
<Badge
|
|
count={stockResult.count}
|
|
overflowCount={10000}
|
|
></Badge>
|
|
)}
|
|
</div>
|
|
)}
|
|
</div>
|
|
</Tooltip>
|
|
) : (
|
|
<>
|
|
{globaldata && (
|
|
<input
|
|
type="checkbox"
|
|
value={item.ProductDetail?.[0]?.ProdId}
|
|
name={item.ProdName}
|
|
onChange={(e) => pickData(e, item)}
|
|
style={{
|
|
position: 'absolute',
|
|
zIndex: 1,
|
|
transform: 'scale(1.5)',
|
|
cursor: 'pointer',
|
|
}}
|
|
checked={(
|
|
globalAllItemdata || EditfavItems
|
|
)?.some(
|
|
// (a) => a?.ProdName === item?.ProdName
|
|
(a) =>
|
|
a?.ProdName === item?.ProdName &&
|
|
a?.ProdCat === item?.ProdCat
|
|
)}
|
|
/>
|
|
)}
|
|
|
|
<div
|
|
style={{
|
|
alignItems: 'center',
|
|
backgroundColor:
|
|
cardFunction?.SmallImage &&
|
|
cardFunction?.Background &&
|
|
(SelectedCardColor
|
|
? SelectedCardColor?.[
|
|
'BackgroundColor'
|
|
]
|
|
: ''),
|
|
padding:
|
|
!cardFunction?.ImageUp &&
|
|
!cardFunction?.ImageDown
|
|
? cardFunction?.SmallImage &&
|
|
'5px 9px'
|
|
: '8px 2px',
|
|
flexDirection:
|
|
cardFunction?.ImageRight &&
|
|
'row-reverse'
|
|
? cardFunction?.ImageRight &&
|
|
'row-reverse'
|
|
: cardFunction?.ImageUp && 'column'
|
|
? cardFunction?.ImageUp && 'column'
|
|
: cardFunction?.ImageDown &&
|
|
'column-reverse'
|
|
? cardFunction?.ImageDown &&
|
|
'column-reverse'
|
|
: cardFunction?.ImageLeft &&
|
|
'row',
|
|
borderRadius:
|
|
cardFunction?.EdgeCurve && '6px',
|
|
width:
|
|
!cardFunction?.ImageUp &&
|
|
!cardFunction?.ImageDown &&
|
|
!cardFunction?.BigImage &&
|
|
!cardFunction?.ImageRight &&
|
|
cardFunction?.SmallImage &&
|
|
(cardFunction?.ImageUp ||
|
|
cardFunction?.ImageDown)
|
|
? '6rem'
|
|
: cardFunction?.BigImage && '9rem',
|
|
height:
|
|
!cardFunction?.ImageUp &&
|
|
!cardFunction?.BigImage &&
|
|
'',
|
|
pointerEvents: globaldata && 'none',
|
|
}}
|
|
className={
|
|
cardFunction?.SmallImage
|
|
? 'BSItemCard-containers-smallimage-mobile'
|
|
: 'BSItemCard-containers-mobile'
|
|
}
|
|
onClick={(e) => {
|
|
if (
|
|
!(
|
|
item?.OverallQuantity !== undefined &&
|
|
stockResult.count > 0
|
|
)
|
|
) {
|
|
e.stopPropagation();
|
|
} else {
|
|
CardOnclick(item);
|
|
}
|
|
}}
|
|
// data-aos="zoom-in" data-aos-duration="600"
|
|
>
|
|
{(cardFunction?.BigImage ||
|
|
cardFunction?.SmallImage) && (
|
|
<img
|
|
style={{
|
|
objectFit:
|
|
cardFunction?.BigImage && '',
|
|
height: !cardFunction?.BigImage
|
|
? (!cardFunction?.BigImage &&
|
|
cardFunction?.SmallImage) ||
|
|
cardFunction?.ImageLeft ||
|
|
cardFunction?.ImageUp ||
|
|
cardFunction?.ImageDown
|
|
? '3rem'
|
|
: cardFunction?.BigImage && '7rem'
|
|
: '4rem',
|
|
}}
|
|
className={
|
|
cardFunction?.SmallImage
|
|
? 'BSItemCard-image-smallimage'
|
|
: 'BSItemCard-image'
|
|
}
|
|
src={
|
|
item?.ComboImage ===
|
|
''
|
|
? defaultimage
|
|
: item?.ComboImage
|
|
? item?.ComboImage
|
|
: defaultimage
|
|
}
|
|
alt=""
|
|
/>
|
|
)}
|
|
<div
|
|
className={
|
|
cardFunction?.SmallImage
|
|
? 'BSItemCard-content-smallimage'
|
|
: 'BSItemCard-content'
|
|
}
|
|
style={{
|
|
backgroundColor:
|
|
cardFunction?.Background &&
|
|
(SelectedCardColor
|
|
? SelectedCardColor?.[
|
|
'BackgroundColor'
|
|
]
|
|
: ''),
|
|
position: !cardFunction?.BigImage
|
|
? 'relative'
|
|
: 'absolute',
|
|
flexDirection:
|
|
!cardFunction?.BigImage && 'column',
|
|
borderRadius:
|
|
!cardFunction?.BigImage &&
|
|
cardFunction?.EdgeCurve &&
|
|
'6px',
|
|
bottom: cardFunction?.BigImage && '',
|
|
cardFunction,
|
|
width:
|
|
!cardFunction?.BigImage &&
|
|
!cardFunction?.SmallImage &&
|
|
'',
|
|
height: cardFunction?.SmallImage
|
|
? '5.5rem'
|
|
: !cardFunction?.BigImage && '4.5rem',
|
|
alignItems:
|
|
!cardFunction?.BigImage &&
|
|
!cardFunction?.SmallImage &&
|
|
'center',
|
|
textAlign:
|
|
!cardFunction?.BigImage &&
|
|
!cardFunction?.SmallImage &&
|
|
'center',
|
|
flexWrap:
|
|
cardFunction?.BigImage && 'wrap',
|
|
}}
|
|
>
|
|
<p
|
|
style={{
|
|
textTransform:
|
|
cardFunction?.TextCapitalize &&
|
|
'uppercase',
|
|
width: !cardFunction?.SmallImage
|
|
? cardFunction?.BigImage && '120px'
|
|
: cardFunction?.SmallImage &&
|
|
!cardFunction?.ImageUp &&
|
|
!cardFunction?.ImageDown &&
|
|
'85px',
|
|
// Width: cardFunction?.BigImage && "70px",
|
|
fontSize:
|
|
!cardFunction?.BigImage &&
|
|
!cardFunction?.SmallImage &&
|
|
'12px', //naresh27
|
|
whiteSpace:
|
|
!cardFunction?.BigImage &&
|
|
'pre-wrap',
|
|
margin: 'auto',
|
|
fontFamily: SelectedCardFont
|
|
? SelectedCardFont
|
|
: '',
|
|
color: SelectedCardColor
|
|
? SelectedCardColor?.['FontColor']
|
|
: '',
|
|
textOverflow: 'ellipsis',
|
|
}}
|
|
className="BSItemCard-itemName"
|
|
>
|
|
{item?.ProdName}{' '}
|
|
{(item?.OverallQuantity !== undefined &&
|
|
stockResult.count > 0) ||
|
|
item?.OverallQuantity > 0 || item?.SetCount == 0 ? (
|
|
''
|
|
) : (
|
|
<p
|
|
style={{
|
|
color: 'red',
|
|
marginTop: '5px',
|
|
fontSize: '11px',
|
|
}}
|
|
>
|
|
No Stock
|
|
</p>
|
|
)}
|
|
</p>
|
|
{cardFunction?.Price &&
|
|
((item?.OverallQuantity !== undefined &&
|
|
item?.OverallQuantity !== 0 &&
|
|
item?.OverallQuantity !== null) ||
|
|
item?.ProductDetail?.some(
|
|
(item) =>
|
|
item?.StockAvailable !== 'Y'
|
|
|
|
)) || item?.SetCount == 0 && (
|
|
<p
|
|
className="BSItemCard-itemPrice"
|
|
style={{
|
|
fontSize:
|
|
!cardFunction?.SmallImage
|
|
? cardFunction?.BigImage &&
|
|
'12px'
|
|
: '12px',
|
|
textAlign: 'center',
|
|
lineHeight: '2',
|
|
fontFamily: SelectedCardFont
|
|
? SelectedCardFont
|
|
: '',
|
|
color: SelectedCardColor
|
|
? SelectedCardColor?.[
|
|
'FontColor'
|
|
]
|
|
: '',
|
|
}}
|
|
>
|
|
₹ {
|
|
item?.ComboInwardDetails?.[0]
|
|
?.TotalSellPrice
|
|
}
|
|
{/* {item?.ProductDetail?.[0]?.ProdVariantDetails?.[0]?.StockDetails?.[0]?.SellPrice} */}
|
|
{/* {ItemSellingPrice(item)} */}
|
|
<span className="BSItemCard-itemCount">
|
|
{'(1 Combo Pack)'}
|
|
</span>
|
|
</p>
|
|
)}
|
|
</div>
|
|
|
|
{cardFunction?.StockCount &&
|
|
item?.OverallQuantity !== undefined &&
|
|
item?.OverallQuantity !== 0 && (
|
|
<div
|
|
style={{
|
|
top: !cardFunction?.BigImage && '0',
|
|
right:
|
|
!cardFunction?.BigImage &&
|
|
!cardFunction?.SmallImage &&
|
|
'0px',
|
|
position: 'absolute',
|
|
}}
|
|
className={
|
|
cardFunction?.BigImage
|
|
? 'BSItemCard-badge'
|
|
: 'BSItemCard-badge-withoutimage'
|
|
}
|
|
>
|
|
{item?.OverallQuantity !== null && (
|
|
<Badge
|
|
count={stockResult.count}
|
|
overflowCount={10000}
|
|
></Badge>
|
|
)}
|
|
</div>
|
|
)}
|
|
</div>
|
|
</>
|
|
)}
|
|
</div>
|
|
:
|
|
<div
|
|
className={
|
|
(item?.OverAllQty !== undefined &&
|
|
stockResult.count > 0) ||
|
|
item?.StockAvailable !== 'Y'
|
|
? 'card4Main card4Main-active'
|
|
: 'card4Main card4Main-deactive'
|
|
}
|
|
onClick={(e) => {
|
|
if (
|
|
!(
|
|
(item?.OverAllQty !== undefined &&
|
|
stockResult.count > 0)
|
|
)
|
|
) {
|
|
e.stopPropagation(); // Prevent event bubbling if no stock or condition isn't met
|
|
} else {
|
|
// Ensure this only runs if the "One Piece" condition isn't triggered
|
|
if (!e.target.closest('.card4Main-onepiece')) {
|
|
CardOnclick(item); // This will trigger if you're clicking outside the "One Piece" button
|
|
}
|
|
}
|
|
}}
|
|
>
|
|
{/* Global Data Checkbox */}
|
|
{globaldata && (
|
|
<input
|
|
type="checkbox"
|
|
value={item.ProductDetail?.[0]?.ProdId}
|
|
name={item.ProdName}
|
|
onChange={(e) => pickData(e, item)}
|
|
style={{
|
|
position: 'absolute',
|
|
zIndex: 1,
|
|
transform: 'scale(1.5)',
|
|
cursor: 'pointer',
|
|
}}
|
|
checked={(
|
|
globalAllItemdata || EditfavItems
|
|
)?.some(
|
|
(a) =>
|
|
a?.ProdName === item?.ProdName &&
|
|
a?.ProdCat === item?.ProdCat
|
|
)}
|
|
/>
|
|
)}
|
|
|
|
{/* Tooltip for Product Name */}
|
|
<Tooltip title={item.ProdName}>
|
|
<div className='card4Img'>
|
|
<img
|
|
width={50}
|
|
height={60}
|
|
src={
|
|
item?.ProductDetail?.[0]?.ProdLogo === ''
|
|
? defaultimage
|
|
: item?.ProductDetail?.[0]?.ProdLogo
|
|
? item?.ProductDetail?.[0]?.ProdLogo
|
|
: defaultimage
|
|
}
|
|
alt=""
|
|
/>
|
|
</div>
|
|
</Tooltip>
|
|
|
|
<div className="Card4datas">
|
|
<div className="card4ProductName">
|
|
{item?.ProdName}
|
|
{(item?.OverallQuantity !== undefined && stockResult.count > 0) ? (
|
|
''
|
|
) : (
|
|
<p style={{ color: 'red', marginTop: '5px', fontSize: '15px' }}>
|
|
No Stock
|
|
</p>
|
|
)}
|
|
</div>
|
|
<div className="card4PriceUom">
|
|
|
|
<div className='card4Price'>₹ {
|
|
item?.ComboInwardDetails?.[0]
|
|
?.TotalSellPrice
|
|
} </div>
|
|
<div className='card4Uom'> {'(1 Combo Pack)'}</div>
|
|
</div>
|
|
</div>
|
|
|
|
{/* Stock Count Badge */}
|
|
|
|
{cardFunction?.StockCount &&
|
|
item?.OverallQuantity !== undefined &&
|
|
item?.OverallQuantity !== 0 && (
|
|
<div
|
|
style={{
|
|
top: '0',
|
|
right: '0px',
|
|
position: 'absolute',
|
|
}}
|
|
className='card4Main-badge'
|
|
>
|
|
{item?.OverallQuantity !== null && (
|
|
<Badge
|
|
count={stockResult.count}
|
|
overflowCount={10000}
|
|
></Badge>
|
|
)}
|
|
</div>
|
|
)}
|
|
|
|
</div>
|
|
|
|
}
|
|
</SortableCard>
|
|
)
|
|
})}
|
|
</div>
|
|
</SortableContext>
|
|
</DndContext>
|
|
</>
|
|
) : ProductSearch?.length > 5 && GetmultipleSearchDatas.some(
|
|
e => e.toLowerCase() === "qrcode"
|
|
) &&
|
|
(cardData?.length == 0 || cardData == undefined) ? (
|
|
<div>
|
|
{/* cardData mohan 18-04-2025 */}
|
|
<FeaturesFunctionalities
|
|
handleQuickAddCancel={handleQuickCancel}
|
|
QuickAdd={QuickAdd}
|
|
ProductSearch={true}
|
|
ProductSearchType={'I'}
|
|
cardData={cardDataForNewPrd}
|
|
/>
|
|
</div>
|
|
) : (
|
|
<>
|
|
<div
|
|
className={!temp5 ? 'NodataFound' : 'NodataFound5'}
|
|
style={{
|
|
display: globalAccessForOthers && 'none',
|
|
}}
|
|
>
|
|
<div align="center" class="fond">
|
|
<div class="contener_general">
|
|
<div class="contener_mixte">
|
|
<div class="ballcolor ball_1"> </div>
|
|
</div>
|
|
<div class="contener_mixte">
|
|
<div class="ballcolor ball_2"> </div>
|
|
</div>
|
|
<div class="contener_mixte">
|
|
<div class="ballcolor ball_3"> </div>
|
|
</div>
|
|
<div class="contener_mixte">
|
|
<div class="ballcolor ball_4"> </div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</>
|
|
)}
|
|
{paymentloader === true && (
|
|
<div class="Payment-loader1">
|
|
<div class="Payment-loader">
|
|
<div class="contener_mixte">
|
|
<div class="ballcolor ball_1"> </div>
|
|
</div>
|
|
<div class="contener_mixte">
|
|
<div class="ballcolor ball_2"> </div>
|
|
</div>
|
|
<div class="contener_mixte">
|
|
<div class="ballcolor ball_3"> </div>
|
|
</div>
|
|
<div class="contener_mixte">
|
|
<div class="ballcolor ball_4"> </div>
|
|
</div>
|
|
<p style={{ marginTop: '2rem' }}>
|
|
{' '}
|
|
Please wait while we process your payment
|
|
</p>
|
|
{PaymentTransactionNumber != null && (
|
|
<p style={{ fontSize: '16px', fontWeight: '600' }}>
|
|
Transaction Number : {PaymentTransactionNumber}
|
|
</p>
|
|
)}
|
|
</div>
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{expModel && (
|
|
<Modal
|
|
title={
|
|
<div
|
|
style={{ display: 'flex', gap: '1rem', flexDirection: 'row' }}
|
|
>
|
|
<div>
|
|
<ExclamationCircleOutlined
|
|
style={{ color: 'rgb(231 176 12)', fontSize: '30px' }}
|
|
/>
|
|
</div>
|
|
<div>
|
|
<h4>Product Expires</h4>
|
|
</div>
|
|
</div>
|
|
}
|
|
open={expModel}
|
|
onOk={() => expFun(Item)}
|
|
onCancel={() => setexpModel(false)}
|
|
okText="Submit"
|
|
cancelText="Don't Submit"
|
|
maskTransitionName="" // Remove animation for the mask
|
|
transitionName=""
|
|
></Modal>
|
|
)}
|
|
|
|
{expQtyModel && (
|
|
<Modal
|
|
title={
|
|
<div
|
|
style={{ display: 'flex', gap: '1rem', flexDirection: 'row' }}
|
|
>
|
|
<ExclamationCircleOutlined
|
|
style={{ color: 'rgb(231 176 12)', fontSize: '30px' }}
|
|
/>
|
|
<h3>Quantity Expires</h3>
|
|
</div>
|
|
}
|
|
open={expQtyModel}
|
|
onOk={() => expQtyFun(qtyExpData)}
|
|
onCancel={() => {
|
|
setRepeatedModel(false),
|
|
setProdexpir(false),
|
|
setExpQtyModel(false);
|
|
}}
|
|
okText="Submit"
|
|
cancelText="Don't Submit"
|
|
maskTransitionName=""
|
|
transitionName=""
|
|
></Modal>
|
|
)}
|
|
|
|
{expVarModel && (
|
|
<Modal
|
|
title={
|
|
<div
|
|
style={{ display: 'flex', gap: '1rem', flexDirection: 'row' }}
|
|
>
|
|
<ExclamationCircleOutlined
|
|
style={{ color: 'rgb(231 176 12)', fontSize: '30px' }}
|
|
/>
|
|
<h3>Variant Expires</h3>
|
|
</div>
|
|
}
|
|
open={expVarModel}
|
|
onOk={() => expVerFun(VarItem)}
|
|
onCancel={() => {
|
|
setexpVarModel(false),
|
|
setRepeatedModel(false),
|
|
setProdexpir(false);
|
|
}}
|
|
okText="Submit"
|
|
cancelText="Don't Submit"
|
|
maskTransitionName=""
|
|
transitionName=""
|
|
></Modal>
|
|
)}
|
|
|
|
{expStockModel && (
|
|
<Modal
|
|
title={
|
|
<div
|
|
style={{ display: 'flex', gap: '1rem', flexDirection: 'row' }}
|
|
>
|
|
<ExclamationCircleOutlined
|
|
style={{ color: 'rgb(231 176 12)', fontSize: '30px' }}
|
|
/>
|
|
<h3>Stock Expires</h3>
|
|
</div>
|
|
}
|
|
open={expStockModel}
|
|
onOk={() => expStockFun(StockItem)}
|
|
onCancel={() => {
|
|
setexpStockModel(false),
|
|
setRepeatedModel(false),
|
|
setProdexpir(false);
|
|
}}
|
|
okText="Submit"
|
|
cancelText="Don't Submit"
|
|
maskTransitionName=""
|
|
transitionName=""
|
|
></Modal>
|
|
)}
|
|
|
|
{modelQty && (
|
|
<DefaultModal
|
|
title={
|
|
<div className="EditQuantity-title">
|
|
<FormHeader title={'Item Quantity'} />
|
|
</div>
|
|
}
|
|
open={modelQty}
|
|
width={widthBasedOnProdVariantDetails}
|
|
handleCancel={CloseModal}
|
|
footer={null}
|
|
maskTransitionName=""
|
|
transitionName=""
|
|
children={
|
|
<div>
|
|
<div className="EditQuantity-heading">
|
|
<div className="EditQuantity-headingname">
|
|
<p className="EditQuantity-itemname">Item Name:</p>
|
|
</div>
|
|
<div
|
|
className="EditQuantity-headingproductname"
|
|
style={{ marginLeft: '1rem' }}
|
|
>
|
|
<p className="EditQuantity-productname">
|
|
{qtydata?.ProdName}
|
|
</p>
|
|
</div>
|
|
</div>
|
|
<div
|
|
className={
|
|
BrandCheckresult
|
|
? 'Card-modal-table'
|
|
: 'Brand-Card-modal-table'
|
|
}
|
|
>
|
|
{Object.keys(brandMapping).map((brandId) => {
|
|
const brandName =
|
|
brandId !== 'null' && brandId !== 'undefined'
|
|
? brandId
|
|
: '';
|
|
const brandItems = brandMapping[brandId] || [];
|
|
return (
|
|
<div key={brandId} className="Brand-Card">
|
|
{brandName && (
|
|
<div className="Brandname">
|
|
<h4>{brandName}</h4>
|
|
</div>
|
|
)}
|
|
<div className="BrandDetail">
|
|
{brandItems.map((item, index) => {
|
|
const qtyCount = returnQtyCount(
|
|
item?.ProdId,
|
|
item,
|
|
CartOrderDetails
|
|
);
|
|
const isAvailable = item?.StockAvailable !== 'Y';
|
|
const isDisabled = qtyCount > 0 || isAvailable;
|
|
return (
|
|
<div key={`${brandId}-${index}`}>
|
|
<div
|
|
className={
|
|
isDisabled
|
|
? 'ItemQtyCard'
|
|
: 'ItemQtyCard-disabled'
|
|
}
|
|
onClick={() => VarientFun(item)}
|
|
>
|
|
<div className="ItemQtyImgCard">
|
|
<img
|
|
src={item?.ProdLogo || defaultimage}
|
|
width={'80px'}
|
|
height={'70px'}
|
|
alt={`Product ${index}`}
|
|
/>
|
|
</div>
|
|
<div className="qtyDetail">
|
|
<p className="qtyUomName-itemCard">
|
|
{item?.Size + ' ' + item?.UomName}
|
|
</p>
|
|
{isDisabled && (
|
|
<p className="qtyprice">
|
|
<sup style={{ fontFamily: 'Gilroy' }}>
|
|
₹
|
|
</sup>
|
|
|
|
{
|
|
item?.ProdVariantDetails?.[0]
|
|
?.StockDetails?.[0]?.SellPrice
|
|
}
|
|
</p>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
})}
|
|
</div>
|
|
</div>
|
|
);
|
|
})}
|
|
{Object.keys(brandMapping).length === 0 && (
|
|
<p>No product details available</p>
|
|
)}
|
|
</div>
|
|
</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?.ProdName}{' '}
|
|
{!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?.ProductDetail?.[QtyIndex]?.Size}{' '}
|
|
{onePeiceFlow
|
|
? 'PCS'
|
|
: qtydata?.ProductDetail?.[QtyIndex]?.UomName}
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div className="Re-Print-table">
|
|
<Tables columns={stockcolumns} data={stockdataSource} />
|
|
</div>
|
|
</div>
|
|
}
|
|
/>
|
|
)}
|
|
{ModalVarient && (
|
|
<DefaultModal
|
|
title={
|
|
<div className="EditQuantity-title">
|
|
<FormHeader title={'Item Variant'} />
|
|
</div>
|
|
}
|
|
open={ModalVarient}
|
|
width={500}
|
|
top={0}
|
|
footer={null}
|
|
handleCancel={CloseVarientModal}
|
|
maskTransitionName=""
|
|
transitionName=""
|
|
children={
|
|
<div className="EditQuantity-Master">
|
|
<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?.ProdName}
|
|
</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?.ProductDetail?.[QtyIndex]?.Size}{' '}
|
|
{onePeiceFlow
|
|
? 'PCS'
|
|
: qtydata?.ProductDetail?.[QtyIndex]?.UomName}
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div className="Re-Print-table">
|
|
<Tables columns={varientcolumns} data={varientdataSource} />
|
|
</div>
|
|
</div>
|
|
}
|
|
/>
|
|
)}
|
|
</>
|
|
);
|
|
|
|
for (let i = 0; i < code?.length; i++) {
|
|
encrypted += String.fromCharCode(
|
|
code.charCodeAt(i) ^ key.charCodeAt(i % key.length)
|
|
);
|
|
}
|
|
|
|
return encrypted;
|
|
}
|
|
|
|
function decrypt(encrypted, key) {
|
|
// Implement decryption logic
|
|
let decrypted = encrypt();
|
|
for (let i = 0; i < encrypted?.length; i++) {
|
|
decrypted += String.fromCharCode(
|
|
encrypted.charCodeAt(i) ^ key.charCodeAt(i % key.length)
|
|
);
|
|
}
|
|
return decrypted;
|
|
}
|
|
|
|
const encryptedCode = encrypt(); // Encrypted React component code
|
|
const decryptionKey = decrypt(); // Decryption key (keep it secure)
|
|
const decryptedCode = decrypt(encryptedCode, decryptionKey);
|
|
|
|
return <>{encrypt()}</>;
|
|
};
|
|
|
|
export default React.memo(BSComboItemCard); |