2026-02-06 13:54:33 +05:30
|
|
|
import React, { useEffect, useRef, useState } from 'react';
|
2026-01-27 18:27:29 +05:30
|
|
|
import './ComboSalesBillTable.scss';
|
|
|
|
|
import { shallowEqual, useDispatch, useSelector } from 'react-redux';
|
|
|
|
|
import { Popconfirm, Tooltip } from 'antd';
|
|
|
|
|
import WebFont from 'webfontloader';
|
|
|
|
|
import { isMobile } from 'react-device-detect';
|
|
|
|
|
import { AiOutlineClose, AiFillDelete } from 'react-icons/ai';
|
|
|
|
|
import {
|
|
|
|
|
ChangeTotalAmount,
|
|
|
|
|
globalExtraTotalAmount,
|
|
|
|
|
} from '../../../../../Features/ExteraCharges/ExtraCharges.js';
|
|
|
|
|
import BSBillingEditQuantity from '../BSBillingEditQuantity/BSBillingEditQuantity';
|
|
|
|
|
import {
|
|
|
|
|
changeholddata,
|
|
|
|
|
gettinghold,
|
|
|
|
|
puttinghold,
|
|
|
|
|
} from '../../../../../Features/BookingScreen/HoldOption/HoldOption.js';
|
|
|
|
|
import { getCustomerDisplayWindow } from '../../../../../Features/customerDisplayWindow/customerDisplayWindow.js';
|
|
|
|
|
import BSEditTotalAmt from '../BSEditTotalAmount/BSEditTotalAmt.jsx';
|
|
|
|
|
import { useApplyOfferto_CardDetail } from '../../UtillComponents/BSNavBarOffer/BSNavBarOffer_CustomHooks.jsx';
|
|
|
|
|
import BSImeiDetails from '../BSImeiDetails/BSImeiDetails.jsx';
|
|
|
|
|
import {
|
|
|
|
|
getTemplateData,
|
|
|
|
|
SelectedGlobalBillingColorDetail,
|
|
|
|
|
SelectedGlobalBillingFont,
|
|
|
|
|
StoredSessionData,
|
|
|
|
|
} from '../../../../../Features/ThemeChange/ThemeChange';
|
|
|
|
|
import {
|
|
|
|
|
GlobalOrderCardDetails,
|
|
|
|
|
changeOrderCardDetails,
|
|
|
|
|
GlobalBookingType,
|
|
|
|
|
GlobalPreviousOrderLength,
|
|
|
|
|
GlobalHoldOrderDtl,
|
|
|
|
|
GlobalUnpaidData,
|
|
|
|
|
ChangeSelectedCustDisable,
|
|
|
|
|
changeSelectedOption,
|
|
|
|
|
changeReorderHoldDetails,
|
|
|
|
|
changeUnpaidData,
|
|
|
|
|
changeBookingType,
|
|
|
|
|
GlobalSelProdWiseEst,
|
|
|
|
|
GlobalBookingTypeBoth,
|
|
|
|
|
GlobalOrderType,
|
|
|
|
|
changeReorderProductDetails,
|
|
|
|
|
GlobalReorderHoldDetails,
|
|
|
|
|
getSelectedFavItems,
|
|
|
|
|
getLayoutproductCard,
|
|
|
|
|
getCardDataWithoutSubmodule,
|
|
|
|
|
getCardDataWithoutSub,
|
|
|
|
|
changeOrderType,
|
|
|
|
|
GlobalProductCategorie,
|
|
|
|
|
GlobalProductSubCategorie,
|
|
|
|
|
changeAllProductTokenAvailable,
|
|
|
|
|
changeTokenOnly,
|
|
|
|
|
PreferenceData,
|
|
|
|
|
GlobalEstimateBooking,
|
|
|
|
|
ChangeOverAllDiscSales,
|
|
|
|
|
ChangeOverAllDiscEstimate,
|
|
|
|
|
changeSelProdWiseEst,
|
|
|
|
|
GlobalOtherSevices,
|
|
|
|
|
GlobalDefaultBookingType,
|
2026-02-05 15:53:37 +05:30
|
|
|
GlobalCustId,
|
|
|
|
|
GlobalSelOption,
|
2026-01-27 18:27:29 +05:30
|
|
|
} from '../../../../../Features/BookingScreen/BookingData/BookingData';
|
|
|
|
|
import {
|
|
|
|
|
ChangeOfferAppliedProducts,
|
|
|
|
|
ChangeFreeProductList,
|
|
|
|
|
ChangeFullFreeProductList,
|
|
|
|
|
GlobalFreeProdList,
|
|
|
|
|
GlobalOfferAppliedProducts,
|
|
|
|
|
changeFullOfferAppliedProducts,
|
|
|
|
|
changeLoyaltyConsumedQuantities,
|
|
|
|
|
ClearOfferAppliedProducts,
|
|
|
|
|
} from '../../../../../Features/Offer/Offernew/BookingOffernew.js';
|
|
|
|
|
import { useRemoveProducts } from '../BSBillingTable3/RemoveCartWithOffer.jsx';
|
|
|
|
|
import { useUtilsComponent } from '../../../../../Services/utils.js';
|
2026-02-06 13:54:33 +05:30
|
|
|
import ComboEditRate from '../ComboBillTableEdit/ComboEditRate.jsx';
|
2026-02-05 15:53:37 +05:30
|
|
|
import CustomerPriceHistory from '../../UtillComponents/CustomerPriceHistory.jsx';
|
2026-02-10 19:55:47 +05:30
|
|
|
import ComboEditQtyAndRate from '../ComboBillTableEdit/ComboEditQtyAndRate.jsx';
|
2026-01-27 18:27:29 +05:30
|
|
|
|
|
|
|
|
const ComboSalesBillTable = () => {
|
|
|
|
|
const { removeExtraCharge } = useUtilsComponent();
|
|
|
|
|
const dispatch = useDispatch();
|
|
|
|
|
const removeProducts = useRemoveProducts();
|
|
|
|
|
const applyOffer = useApplyOfferto_CardDetail();
|
|
|
|
|
const preferenceDatas = useSelector(PreferenceData);
|
|
|
|
|
const preferenceDetails = preferenceDatas?.[0]?.SettingDtlDetails;
|
|
|
|
|
const preferenceOffer =
|
|
|
|
|
preferenceDetails?.find((item) => item.SettingIdName === 'Offer')
|
|
|
|
|
?.SettingValue === 'Y';
|
|
|
|
|
const BillOrderPre = preferenceDatas?.[0]?.SettingDtlDetails?.find(
|
|
|
|
|
(item) => item.SettingIdName === 'BillItemsOrder'
|
|
|
|
|
)?.SettingValue;
|
|
|
|
|
const allowDecimal = preferenceDatas?.[0]?.SettingDtlDetails?.find(
|
|
|
|
|
(setting) =>
|
|
|
|
|
setting?.SettingIdName?.toLowerCase() === 'decimal' &&
|
|
|
|
|
setting?.SettingValue === 'Y'
|
|
|
|
|
);
|
|
|
|
|
const SessionData = useSelector(StoredSessionData);
|
|
|
|
|
const BranchId = SessionData?.BranchId;
|
|
|
|
|
const AppId = SessionData?.AppId;
|
|
|
|
|
const CompId = SessionData?.CompId;
|
|
|
|
|
const templateData = useSelector(getTemplateData);
|
|
|
|
|
const tableOptions = templateData?.BookingBilling?.[1];
|
|
|
|
|
console.log(tableOptions, 'tableOptions');
|
|
|
|
|
|
|
|
|
|
const OfferCheckedInSetup = templateData?.BookingNavbar?.[1].some(
|
|
|
|
|
(item) => item?.OptionName == 'Offer'
|
|
|
|
|
);
|
|
|
|
|
const SelectedBillColor = useSelector(SelectedGlobalBillingColorDetail);
|
|
|
|
|
const SelectedFont = useSelector(SelectedGlobalBillingFont);
|
|
|
|
|
const GlobalOfferAppliedProductsData = useSelector(
|
|
|
|
|
GlobalOfferAppliedProducts
|
|
|
|
|
);
|
|
|
|
|
const [Index, setIndex] = useState(null);
|
|
|
|
|
const BookingType = useSelector(GlobalBookingType);
|
|
|
|
|
const defaultBookingType = useSelector(GlobalDefaultBookingType);
|
|
|
|
|
const tableData = useSelector(GlobalOrderCardDetails, shallowEqual);
|
|
|
|
|
const PreviousOrderLength = useSelector(GlobalPreviousOrderLength);
|
|
|
|
|
const HoldOrderDtl = useSelector(GlobalHoldOrderDtl);
|
|
|
|
|
const UnpaidData = useSelector(GlobalUnpaidData);
|
|
|
|
|
const GlobProdwisedata = useSelector(GlobalSelProdWiseEst);
|
|
|
|
|
const ReportholdData = useSelector(GlobalReorderHoldDetails);
|
|
|
|
|
const prodCat = useSelector(GlobalProductCategorie);
|
|
|
|
|
const ProdSubCat = useSelector(GlobalProductSubCategorie);
|
|
|
|
|
const [PreviousdataLength, setPreviousdataLength] = useState();
|
|
|
|
|
const BookingTypeBoth = useSelector(GlobalBookingTypeBoth);
|
|
|
|
|
const OrderType = useSelector(GlobalOrderType);
|
|
|
|
|
console.log(PreviousOrderLength, 'PreviousOrderLength');
|
|
|
|
|
const GlobEstBooking = useSelector(GlobalEstimateBooking);
|
|
|
|
|
const GlobalExtraCharge = useSelector(globalExtraTotalAmount);
|
|
|
|
|
const OfferFreeProduct = useSelector(GlobalFreeProdList, shallowEqual);
|
|
|
|
|
const OtherServicesglobal = useSelector(GlobalOtherSevices);
|
2026-02-05 15:53:37 +05:30
|
|
|
const GetCustId = useSelector(GlobalCustId);
|
|
|
|
|
const selectedCustomer = useSelector(GlobalSelOption);
|
|
|
|
|
|
2026-02-06 13:54:33 +05:30
|
|
|
const [customerPriceHistoryOpen, setCustomerPriceHistoryOpen] =
|
|
|
|
|
useState(false);
|
2026-02-05 15:53:37 +05:30
|
|
|
const [customerProduct, setCustomerProduct] = useState(null);
|
2026-01-27 18:27:29 +05:30
|
|
|
|
|
|
|
|
const tableDataDinein = tableData?.filter(
|
|
|
|
|
(a, b) => a.BookingTypeName === 'Dine In' && !a?.SalesId
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const OldtableDataDinein = tableData?.filter(
|
|
|
|
|
(a, b) => a.BookingTypeName === 'Dine In' && a?.SalesId
|
|
|
|
|
);
|
|
|
|
|
const tableDataTakeAway =
|
|
|
|
|
OrderType === 'Hold'
|
|
|
|
|
? tableData?.filter((a, b) => a.BookingTypeName === 'TakeAway')
|
|
|
|
|
: tableData?.filter(
|
2026-02-09 14:16:08 +05:30
|
|
|
(a, b) => a.BookingTypeName === 'TakeAway' && !a?.SalesId
|
|
|
|
|
);
|
2026-01-27 18:27:29 +05:30
|
|
|
const OldtableDataTakeAway =
|
|
|
|
|
OrderType != 'Hold'
|
|
|
|
|
? tableData?.filter(
|
2026-02-09 14:16:08 +05:30
|
|
|
(a, b) => a.BookingTypeName === 'TakeAway' && a?.SalesId
|
|
|
|
|
)
|
2026-01-27 18:27:29 +05:30
|
|
|
: [];
|
|
|
|
|
|
|
|
|
|
const [EditQuantity, setEditQuantity] = useState(false);
|
2026-02-06 13:54:33 +05:30
|
|
|
const [EditQtyCombo, setEditQtyCombo] = useState(false);
|
|
|
|
|
const [EditRateCombo, setEditRateCombo] = useState(false);
|
2026-01-27 18:27:29 +05:30
|
|
|
const [Modaldata, setModaldata] = useState([]);
|
|
|
|
|
const [triggerAnimation, setTriggerAnimation] = useState(true);
|
|
|
|
|
// const editField =
|
|
|
|
|
// tableOptions?.some((item) => item.OptionName === 'Edit') ?? false;
|
|
|
|
|
|
|
|
|
|
const [OpenEditTotalAmt, setOpenEditTotalAmt] = useState(false);
|
|
|
|
|
const [OpenImeiDetail, setOpenImeiDetail] = useState(false);
|
|
|
|
|
const [editField, setEditField] = useState(false);
|
|
|
|
|
const productBasedExtraCharges = GlobalExtraCharge.filter(
|
|
|
|
|
(obj) => 'ProdName' in obj
|
|
|
|
|
);
|
|
|
|
|
// const [BillOrderPre, setBillOrderPre] = useState();
|
|
|
|
|
// console.log(BillOrderPre,'BillOrderPre');
|
|
|
|
|
|
2026-02-06 13:54:33 +05:30
|
|
|
const [qtyEdit, setQtyEdit] = useState(false);
|
|
|
|
|
const qtyTdRef = useRef(null);
|
|
|
|
|
const qtyInputRef = useRef(null);
|
2026-02-10 19:55:47 +05:30
|
|
|
const [shortKeyMethod, setshortKeyMethod] = useState(null);
|
|
|
|
|
const [activeRowIndex, setActiveRowIndex] = useState(null);
|
|
|
|
|
const [activeColIndex, setActiveColIndex] = useState(null);
|
|
|
|
|
const tableRef = useRef(null);
|
2026-02-06 13:54:33 +05:30
|
|
|
|
|
|
|
|
const handleEditQTYcombo = () => {
|
|
|
|
|
if (!qtyEdit) {
|
|
|
|
|
setQtyEdit(true);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Outside click handler for quantity edit
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const handleOutsideClick = (e) => {
|
|
|
|
|
if (qtyEdit && qtyTdRef.current && !qtyTdRef.current.contains(e.target)) {
|
|
|
|
|
setQtyEdit(false); // 👈 outside click → close edit
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
document.addEventListener('mousedown', handleOutsideClick);
|
|
|
|
|
return () => {
|
|
|
|
|
document.removeEventListener('mousedown', handleOutsideClick);
|
|
|
|
|
};
|
|
|
|
|
}, [qtyEdit]);
|
|
|
|
|
// Outside click handler for quantity edit End
|
|
|
|
|
|
2026-01-27 18:27:29 +05:30
|
|
|
useEffect(() => {
|
|
|
|
|
if (tableOptions?.length > 0) {
|
|
|
|
|
let editFieldValue = tableOptions?.filter(
|
|
|
|
|
(item) => item.OptionName == 'Edit'
|
|
|
|
|
);
|
|
|
|
|
if (editFieldValue?.length > 0) {
|
|
|
|
|
setEditField(true);
|
|
|
|
|
} else {
|
|
|
|
|
setEditField(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, [tableOptions]);
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (SelectedFont) {
|
|
|
|
|
WebFont.load({
|
|
|
|
|
google: {
|
|
|
|
|
families: [SelectedFont],
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}, [SelectedFont]);
|
|
|
|
|
|
2026-02-05 15:53:37 +05:30
|
|
|
useEffect(() => {
|
|
|
|
|
const handleKeyDown = (e) => {
|
|
|
|
|
if (e.ctrlKey && e.key.toLowerCase() === 'i') {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
|
|
const prodId = tableData?.[0]?.ProdId;
|
|
|
|
|
|
|
|
|
|
if (GetCustId && prodId) {
|
|
|
|
|
setCustomerPriceHistoryOpen(true);
|
|
|
|
|
setCustomerProduct(prodId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
window.addEventListener('keydown', handleKeyDown);
|
|
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
|
window.removeEventListener('keydown', handleKeyDown);
|
|
|
|
|
};
|
|
|
|
|
}, [GetCustId, tableData]);
|
|
|
|
|
|
2026-01-27 18:27:29 +05:30
|
|
|
// useEffect(() => {
|
|
|
|
|
// const BillOrder = preferenceDatas?.[0]?.SettingDtlDetails?.find(
|
|
|
|
|
// (item) => item.SettingIdName === 'BillItemsOrder'
|
|
|
|
|
// );
|
|
|
|
|
// setBillOrderPre(BillOrder?.SettingValue);
|
|
|
|
|
// }, [preferenceDatas]);
|
|
|
|
|
useEffect(() => {
|
2026-02-09 14:16:08 +05:30
|
|
|
const getSelectedItem = () => {
|
|
|
|
|
const getItem = (data = []) => {
|
|
|
|
|
if (!data.length) return null;
|
|
|
|
|
return BillOrderPre === 'Y' ? data[0] : data[data.length - 1];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (tableDataTakeAway?.length > 0) {
|
|
|
|
|
return getItem(tableDataTakeAway);
|
|
|
|
|
} else if (tableDataDinein?.length > 0) {
|
|
|
|
|
return getItem(tableDataDinein);
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleShortcut = (method) => {
|
|
|
|
|
const item = getSelectedItem();
|
|
|
|
|
if (!item) return;
|
|
|
|
|
|
2026-02-10 19:55:47 +05:30
|
|
|
handleEditQuantityCombo(item);
|
2026-02-09 14:16:08 +05:30
|
|
|
setshortKeyMethod(method);
|
|
|
|
|
};
|
|
|
|
|
|
2026-01-27 18:27:29 +05:30
|
|
|
const handleKeyDown = (event) => {
|
2026-02-09 14:16:08 +05:30
|
|
|
const key = event.key.toLowerCase();
|
|
|
|
|
// 👉 ALT + P → Open Edit Total Amount
|
|
|
|
|
if (event.altKey && key === 'p') {
|
2026-01-27 18:27:29 +05:30
|
|
|
event.preventDefault();
|
2026-02-09 14:16:08 +05:30
|
|
|
if (tableData?.length > 0) {
|
|
|
|
|
OpenEditTotalAmount();
|
2026-01-27 18:27:29 +05:30
|
|
|
}
|
2026-02-09 14:16:08 +05:30
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// 👉 CTRL shortcuts
|
|
|
|
|
if (!event.ctrlKey) return;
|
|
|
|
|
|
2026-02-10 19:55:47 +05:30
|
|
|
if (key === 'q') {
|
2026-02-09 14:16:08 +05:30
|
|
|
event.preventDefault();
|
|
|
|
|
handleShortcut('qty');
|
2026-02-09 17:37:35 +05:30
|
|
|
} else if (key === 'e') {
|
2026-02-09 14:16:08 +05:30
|
|
|
event.preventDefault();
|
|
|
|
|
handleShortcut('price');
|
2026-02-09 17:37:35 +05:30
|
|
|
} else if (key === 'y') {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
handleShortcut('Parcel');
|
|
|
|
|
} else if (key === 'b') {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
handleShortcut('weightAmount');
|
2026-01-27 18:27:29 +05:30
|
|
|
}
|
2026-02-10 19:55:47 +05:30
|
|
|
|
2026-01-27 18:27:29 +05:30
|
|
|
};
|
|
|
|
|
window.addEventListener('keydown', handleKeyDown);
|
2026-02-09 14:16:08 +05:30
|
|
|
|
2026-01-27 18:27:29 +05:30
|
|
|
return () => {
|
|
|
|
|
window.removeEventListener('keydown', handleKeyDown);
|
|
|
|
|
};
|
|
|
|
|
}, [tableDataTakeAway, tableDataDinein, BillOrderPre]);
|
|
|
|
|
|
|
|
|
|
function safeRound(amountStr) {
|
|
|
|
|
if (amountStr == null) return allowDecimal ? '0.00' : '0';
|
|
|
|
|
const cleaned = String(amountStr).replace(/[^0-9.-]+/g, '');
|
|
|
|
|
const num = Number(cleaned);
|
|
|
|
|
if (isNaN(num)) return allowDecimal ? '0.00' : '0';
|
|
|
|
|
return allowDecimal ? num.toFixed(2) : Math.round(num).toString();
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-05 15:53:37 +05:30
|
|
|
const handleCustomerProductPriceHistory = (item) => {
|
|
|
|
|
setCustomerPriceHistoryOpen(true);
|
|
|
|
|
setCustomerProduct(item?.ProdId);
|
2026-02-06 13:54:33 +05:30
|
|
|
};
|
2026-02-05 15:53:37 +05:30
|
|
|
|
2026-01-27 18:27:29 +05:30
|
|
|
const handleEditQuantity = (value) => {
|
|
|
|
|
if (OtherServicesglobal && value.Type == 'OS' && value.ServiceType == 'I') {
|
|
|
|
|
setEditQuantity(false);
|
|
|
|
|
} else {
|
|
|
|
|
if (value?.SalesId) {
|
|
|
|
|
setEditQuantity(false);
|
|
|
|
|
} else {
|
|
|
|
|
setEditQuantity(true);
|
|
|
|
|
setModaldata(value);
|
|
|
|
|
setIndex(value?.localId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
2026-02-06 13:54:33 +05:30
|
|
|
const handleEditQuantityCombo = (value) => {
|
|
|
|
|
if (OtherServicesglobal && value.Type == 'OS' && value.ServiceType == 'I') {
|
|
|
|
|
setEditQtyCombo(false);
|
|
|
|
|
} else {
|
|
|
|
|
if (value?.SalesId) {
|
|
|
|
|
setEditQtyCombo(false);
|
|
|
|
|
} else {
|
|
|
|
|
setEditQtyCombo(true);
|
|
|
|
|
setEditRateCombo(false);
|
|
|
|
|
setModaldata(value);
|
|
|
|
|
setIndex(value?.localId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
const handleEditRateCombo = (value) => {
|
|
|
|
|
if (OtherServicesglobal && value.Type == 'OS' && value.ServiceType == 'I') {
|
|
|
|
|
setEditRateCombo(false);
|
|
|
|
|
} else {
|
|
|
|
|
if (value?.SalesId) {
|
|
|
|
|
setEditRateCombo(false);
|
|
|
|
|
} else {
|
|
|
|
|
setEditRateCombo(true);
|
|
|
|
|
setModaldata(value);
|
|
|
|
|
setIndex(value?.localId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
2026-01-27 18:27:29 +05:30
|
|
|
|
|
|
|
|
const handleEditQuantityCancel = () => {
|
|
|
|
|
setEditQuantity(false);
|
|
|
|
|
};
|
2026-02-06 13:54:33 +05:30
|
|
|
const handleEditQuantityComboCancel = () => {
|
|
|
|
|
setEditQtyCombo(false);
|
|
|
|
|
};
|
|
|
|
|
const handleEditRateComboCancel = () => {
|
|
|
|
|
setEditRateCombo(false);
|
|
|
|
|
};
|
2026-01-27 18:27:29 +05:30
|
|
|
|
|
|
|
|
const OpenEditTotalAmount = () => {
|
|
|
|
|
setOpenEditTotalAmt(true);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleEditTotalAmountCancel = () => {
|
|
|
|
|
setOpenEditTotalAmt(false);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleImeiDetails = (value) => {
|
|
|
|
|
setOpenImeiDetail(true);
|
|
|
|
|
setModaldata(value);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleImeiDetailClose = () => {
|
|
|
|
|
setOpenImeiDetail(false);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const getstockbadge = async () => {
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const ClearOfferDetails = () => {
|
|
|
|
|
dispatch(changeFullOfferAppliedProducts([]));
|
|
|
|
|
dispatch(ChangeFullFreeProductList([]));
|
|
|
|
|
dispatch(changeLoyaltyConsumedQuantities({}));
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const Clearall = async () => {
|
|
|
|
|
if (OrderType === 'Hold') {
|
|
|
|
|
if (OfferCheckedInSetup && preferenceOffer) {
|
|
|
|
|
await ClearOfferDetails();
|
|
|
|
|
}
|
|
|
|
|
dispatch(changeOrderCardDetails([]));
|
|
|
|
|
|
|
|
|
|
let putData = { OrderId: [ReportholdData?.OrderId] };
|
|
|
|
|
let response = await dispatch(puttinghold(putData)).unwrap();
|
|
|
|
|
if (response?.data?.statusCode == 1) {
|
|
|
|
|
getstockbadge();
|
|
|
|
|
let holdingData = await dispatch(
|
|
|
|
|
gettinghold({ CompId: CompId, BranchId: BranchId, AppId: AppId })
|
|
|
|
|
).unwrap();
|
|
|
|
|
if (holdingData?.data?.statusCode === 1) {
|
|
|
|
|
dispatch(changeholddata(holdingData?.data?.data));
|
|
|
|
|
} else {
|
|
|
|
|
dispatch(changeholddata([]));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
await dispatch(ChangeTotalAmount([]));
|
|
|
|
|
await dispatch(changeOrderType(null));
|
|
|
|
|
await dispatch(changeReorderHoldDetails({}));
|
|
|
|
|
} else if (OrderType === 'Reorder') {
|
|
|
|
|
const UpdatedData = tableData?.filter((cartItem) => cartItem?.SalesId);
|
|
|
|
|
|
|
|
|
|
if (OfferCheckedInSetup && preferenceOffer) {
|
|
|
|
|
await ClearOfferDetails();
|
|
|
|
|
}
|
|
|
|
|
dispatch(changeOrderCardDetails(UpdatedData));
|
|
|
|
|
|
|
|
|
|
await dispatch(changeBookingType('Dine In'));
|
|
|
|
|
} else {
|
|
|
|
|
if (OfferCheckedInSetup && preferenceOffer) {
|
|
|
|
|
await ClearOfferDetails();
|
|
|
|
|
}
|
|
|
|
|
dispatch(changeOrderCardDetails([]));
|
|
|
|
|
await dispatch(ChangeTotalAmount([]));
|
|
|
|
|
await dispatch(changeUnpaidData(false));
|
|
|
|
|
await dispatch(changeReorderHoldDetails({}));
|
|
|
|
|
await dispatch(changeReorderProductDetails([]));
|
|
|
|
|
await dispatch(ChangeSelectedCustDisable(false));
|
|
|
|
|
await dispatch(changeSelectedOption(false));
|
|
|
|
|
await dispatch(changeBookingType(defaultBookingType || 'TakeAway'));
|
|
|
|
|
await dispatch(changeOrderType());
|
|
|
|
|
}
|
|
|
|
|
await dispatch(ChangeOverAllDiscSales(null));
|
|
|
|
|
await dispatch(ChangeOverAllDiscEstimate(null));
|
|
|
|
|
await dispatch(changeTokenOnly(false));
|
|
|
|
|
await dispatch(changeAllProductTokenAvailable(false));
|
|
|
|
|
await dispatch(changeSelProdWiseEst([]));
|
|
|
|
|
const customerDisplayWindow = getCustomerDisplayWindow();
|
|
|
|
|
if (customerDisplayWindow && !customerDisplayWindow.closed) {
|
|
|
|
|
const updatedData = {
|
|
|
|
|
type: 'remove',
|
|
|
|
|
keyValue: 'customer',
|
|
|
|
|
};
|
|
|
|
|
customerDisplayWindow.postMessage(updatedData, '*');
|
|
|
|
|
} else {
|
|
|
|
|
console.error(
|
|
|
|
|
'Customer display window is not available or has been closed.'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const calculateAmounts = (
|
|
|
|
|
OrderQty,
|
|
|
|
|
OrderRate,
|
|
|
|
|
TaxPercentage,
|
|
|
|
|
IsPaid = true
|
|
|
|
|
) => {
|
|
|
|
|
const total = OrderQty * OrderRate;
|
|
|
|
|
|
|
|
|
|
const withoutTax = total - (total * TaxPercentage) / (100 + TaxPercentage);
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
TotalAmt: total,
|
|
|
|
|
...(IsPaid && { Offer: total }),
|
|
|
|
|
WithoutTaxRate: +withoutTax.toFixed(2),
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const ChangeOrderCardDetailsFn = async ({
|
|
|
|
|
OrderQty,
|
|
|
|
|
InwardDtlId,
|
|
|
|
|
Offer,
|
|
|
|
|
CompleteRemove = false,
|
|
|
|
|
RemoveAndUpdate = false,
|
|
|
|
|
BuyInwardDtlId,
|
|
|
|
|
BuyProdQty,
|
|
|
|
|
UpdateBuyAndFree = false,
|
|
|
|
|
CompleteRemoveBuyAndAddWithPaid = false,
|
|
|
|
|
CompleteRemoveconvertFreetoPaid = false,
|
|
|
|
|
CompleteRemoveconvertFreetoPaidTwoTypes = false,
|
|
|
|
|
CompleteRemoveconvertFreetoPaidNotCompletely = false,
|
|
|
|
|
CompleteRemoveAndPaidToFreeOtherType = false,
|
|
|
|
|
CompleteRemoveAndPaidToFreeOtherTypeWithoutMerge = false,
|
|
|
|
|
RemoveAndUpdateOtherBookingType = false,
|
|
|
|
|
BookingTypeName,
|
|
|
|
|
OrderRate,
|
|
|
|
|
}) => {
|
|
|
|
|
let ModifiedOrderCardDetail = JSON.parse(JSON.stringify(tableData));
|
|
|
|
|
|
|
|
|
|
if (RemoveAndUpdate) {
|
|
|
|
|
const data = ModifiedOrderCardDetail?.filter(
|
|
|
|
|
(e) =>
|
|
|
|
|
!(
|
|
|
|
|
e?.InwardDtlId === InwardDtlId &&
|
|
|
|
|
e?.Offer === Offer &&
|
|
|
|
|
e?.BookingTypeName === BookingTypeName &&
|
|
|
|
|
(!e?.SalesId || OrderType == 'Hold')
|
|
|
|
|
)
|
|
|
|
|
)?.map((e) => {
|
|
|
|
|
if (
|
|
|
|
|
e?.InwardDtlId == InwardDtlId &&
|
|
|
|
|
e?.Offer > 0 &&
|
|
|
|
|
e?.BookingTypeName === BookingTypeName
|
|
|
|
|
) {
|
|
|
|
|
const newQty = OrderQty;
|
|
|
|
|
return {
|
|
|
|
|
...e,
|
|
|
|
|
OrderQty: newQty,
|
|
|
|
|
...calculateAmounts(newQty, e.OrderRate, e.TaxPercentage),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (e?.InwardDtlId == BuyInwardDtlId) {
|
|
|
|
|
return {
|
|
|
|
|
...e,
|
|
|
|
|
OrderQty: BuyProdQty,
|
|
|
|
|
...calculateAmounts(
|
|
|
|
|
BuyProdQty,
|
|
|
|
|
e.OrderRate,
|
|
|
|
|
e.TaxPercentage,
|
|
|
|
|
false
|
|
|
|
|
),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return e;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return dispatch(changeOrderCardDetails(data));
|
|
|
|
|
}
|
|
|
|
|
if (RemoveAndUpdateOtherBookingType) {
|
|
|
|
|
const data = ModifiedOrderCardDetail?.filter(
|
|
|
|
|
(e) =>
|
|
|
|
|
!(
|
|
|
|
|
e?.InwardDtlId === InwardDtlId &&
|
|
|
|
|
e?.Offer === Offer &&
|
|
|
|
|
e?.BookingTypeName === BookingTypeName &&
|
|
|
|
|
(!e?.SalesId || OrderType == 'Hold')
|
|
|
|
|
)
|
|
|
|
|
)?.flatMap((e) => {
|
|
|
|
|
if (
|
|
|
|
|
e?.InwardDtlId == InwardDtlId &&
|
|
|
|
|
e?.Offer > 0 &&
|
|
|
|
|
e?.BookingTypeName === BookingTypeName
|
|
|
|
|
) {
|
|
|
|
|
const newQty = e?.OrderQty - BuyProdQty;
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
...e,
|
|
|
|
|
OrderQty: newQty,
|
|
|
|
|
...calculateAmounts(newQty, e.OrderRate, e.TaxPercentage),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
if (
|
|
|
|
|
e?.InwardDtlId == InwardDtlId &&
|
|
|
|
|
e?.Offer == 0 &&
|
|
|
|
|
e?.BookingTypeName !== BookingTypeName
|
|
|
|
|
) {
|
|
|
|
|
const newQty = e?.OrderQty - BuyProdQty;
|
|
|
|
|
|
|
|
|
|
let first = {
|
|
|
|
|
...e,
|
|
|
|
|
OrderQty: BuyProdQty,
|
|
|
|
|
...calculateAmounts(BuyProdQty, e.OrderRate, e.TaxPercentage),
|
|
|
|
|
};
|
|
|
|
|
if (newQty > 0) {
|
|
|
|
|
let second = {
|
|
|
|
|
...e,
|
|
|
|
|
Offer: 0,
|
|
|
|
|
OrderQty: newQty,
|
|
|
|
|
...calculateAmounts(newQty, e.OrderRate, e.TaxPercentage, false),
|
|
|
|
|
};
|
|
|
|
|
return [first, second];
|
|
|
|
|
}
|
|
|
|
|
return [first];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (e?.InwardDtlId == BuyInwardDtlId) {
|
|
|
|
|
return {
|
|
|
|
|
...e,
|
|
|
|
|
OrderQty: BuyProdQty,
|
|
|
|
|
...calculateAmounts(
|
|
|
|
|
BuyProdQty,
|
|
|
|
|
e.OrderRate,
|
|
|
|
|
e.TaxPercentage,
|
|
|
|
|
false
|
|
|
|
|
),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return e;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return dispatch(changeOrderCardDetails(data));
|
|
|
|
|
}
|
|
|
|
|
if (CompleteRemove) {
|
|
|
|
|
const data = ModifiedOrderCardDetail?.filter(
|
|
|
|
|
(e) =>
|
|
|
|
|
!(
|
|
|
|
|
e?.InwardDtlId === InwardDtlId &&
|
|
|
|
|
e?.Offer === Offer &&
|
|
|
|
|
e?.BookingTypeName === BookingTypeName &&
|
|
|
|
|
(!e?.SalesId || OrderType == 'Hold') &&
|
|
|
|
|
e?.SinglePc == 'N' &&
|
|
|
|
|
e?.OrderRate == OrderRate
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
return dispatch(changeOrderCardDetails(data));
|
|
|
|
|
}
|
|
|
|
|
if (CompleteRemoveAndPaidToFreeOtherType) {
|
|
|
|
|
let data = ModifiedOrderCardDetail?.filter(
|
|
|
|
|
(e) =>
|
|
|
|
|
!(
|
|
|
|
|
e?.InwardDtlId === InwardDtlId &&
|
|
|
|
|
e?.Offer === Offer &&
|
|
|
|
|
e?.BookingTypeName === BookingTypeName &&
|
|
|
|
|
(!e?.SalesId || OrderType == 'Hold')
|
|
|
|
|
)
|
|
|
|
|
)?.flatMap((exp) => {
|
|
|
|
|
// Same product but different booking type and not an offer
|
|
|
|
|
if (
|
|
|
|
|
exp?.InwardDtlId == InwardDtlId &&
|
|
|
|
|
exp?.Offer == 0 &&
|
|
|
|
|
exp?.BookingTypeName !== BookingTypeName
|
|
|
|
|
) {
|
|
|
|
|
const remainingQty = exp.OrderQty - OrderQty;
|
|
|
|
|
|
|
|
|
|
if (remainingQty === 0) {
|
|
|
|
|
return {
|
|
|
|
|
...exp,
|
|
|
|
|
OfferMode: 'B',
|
|
|
|
|
...calculateAmounts(
|
|
|
|
|
exp.OrderQty,
|
|
|
|
|
exp.OrderRate,
|
|
|
|
|
exp.TaxPercentage,
|
|
|
|
|
true
|
|
|
|
|
),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (remainingQty > 0) {
|
|
|
|
|
return [
|
|
|
|
|
{
|
|
|
|
|
...exp,
|
|
|
|
|
OrderQty: remainingQty,
|
|
|
|
|
...calculateAmounts(
|
|
|
|
|
remainingQty,
|
|
|
|
|
exp.OrderRate,
|
|
|
|
|
exp.TaxPercentage,
|
|
|
|
|
false
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
...exp,
|
|
|
|
|
OrderQty: OrderQty,
|
|
|
|
|
Offer: 0,
|
|
|
|
|
OfferMode: 'B',
|
|
|
|
|
...calculateAmounts(
|
|
|
|
|
OrderQty,
|
|
|
|
|
exp.OrderRate,
|
|
|
|
|
exp.TaxPercentage,
|
|
|
|
|
true
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return exp;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// ===== Merge duplicates for free offers =====
|
|
|
|
|
const mergedData = [];
|
|
|
|
|
data?.forEach((item) => {
|
|
|
|
|
if (item?.OfferMode === 'B') {
|
|
|
|
|
// Check if a free item already exists for this product + booking type
|
|
|
|
|
const existingIndex = mergedData.findIndex(
|
|
|
|
|
(e) =>
|
|
|
|
|
e.InwardDtlId === item.InwardDtlId &&
|
|
|
|
|
e.BookingTypeName === item.BookingTypeName &&
|
|
|
|
|
e.OfferMode === 'B'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (existingIndex > -1) {
|
|
|
|
|
// Merge quantities
|
|
|
|
|
const existing = mergedData[existingIndex];
|
|
|
|
|
const newQty = existing.OrderQty + item.OrderQty;
|
|
|
|
|
mergedData[existingIndex] = {
|
|
|
|
|
...existing,
|
|
|
|
|
OrderQty: newQty,
|
|
|
|
|
...calculateAmounts(
|
|
|
|
|
newQty,
|
|
|
|
|
item.OrderRate,
|
|
|
|
|
item.TaxPercentage,
|
|
|
|
|
true
|
|
|
|
|
),
|
|
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
mergedData.push(item);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
mergedData.push(item);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return dispatch(changeOrderCardDetails(mergedData));
|
|
|
|
|
}
|
|
|
|
|
if (CompleteRemoveAndPaidToFreeOtherTypeWithoutMerge) {
|
|
|
|
|
let data = ModifiedOrderCardDetail?.filter(
|
|
|
|
|
(e) =>
|
|
|
|
|
!(
|
|
|
|
|
e?.InwardDtlId === InwardDtlId &&
|
|
|
|
|
e?.Offer === Offer &&
|
|
|
|
|
e?.BookingTypeName === BookingTypeName &&
|
|
|
|
|
(!e?.SalesId || OrderType == 'Hold')
|
|
|
|
|
)
|
|
|
|
|
)?.flatMap((exp) => {
|
|
|
|
|
// Same product but different booking type and not an offer
|
|
|
|
|
if (
|
|
|
|
|
exp?.InwardDtlId == InwardDtlId &&
|
|
|
|
|
exp?.Offer == 0 &&
|
|
|
|
|
exp?.BookingTypeName !== BookingTypeName
|
|
|
|
|
) {
|
|
|
|
|
const remainingQty = exp.OrderQty - OrderQty;
|
|
|
|
|
|
|
|
|
|
if (remainingQty === 0) {
|
|
|
|
|
return {
|
|
|
|
|
...exp,
|
|
|
|
|
OfferMode: 'B',
|
|
|
|
|
...calculateAmounts(
|
|
|
|
|
exp.OrderQty,
|
|
|
|
|
exp.OrderRate,
|
|
|
|
|
exp.TaxPercentage,
|
|
|
|
|
true
|
|
|
|
|
),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (remainingQty < 0) {
|
|
|
|
|
return [
|
|
|
|
|
{
|
|
|
|
|
...exp,
|
|
|
|
|
OrderQty: exp.OrderQty,
|
|
|
|
|
OfferMode: 'B',
|
|
|
|
|
...calculateAmounts(
|
|
|
|
|
exp.OrderQty,
|
|
|
|
|
exp.OrderRate,
|
|
|
|
|
exp.TaxPercentage,
|
|
|
|
|
true
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return exp;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return dispatch(changeOrderCardDetails(data));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (CompleteRemoveconvertFreetoPaid) {
|
|
|
|
|
const data = ModifiedOrderCardDetail?.filter(
|
|
|
|
|
(e) =>
|
|
|
|
|
!(
|
|
|
|
|
e?.InwardDtlId === BuyInwardDtlId &&
|
|
|
|
|
e?.BookingTypeName === BookingTypeName &&
|
|
|
|
|
(!e?.SalesId || OrderType == 'Hold')
|
|
|
|
|
)
|
|
|
|
|
)?.map((exp) => {
|
|
|
|
|
if (
|
|
|
|
|
exp?.InwardDtlId == InwardDtlId &&
|
|
|
|
|
exp?.Offer > 0 &&
|
|
|
|
|
exp?.BookingTypeName === BookingTypeName
|
|
|
|
|
) {
|
|
|
|
|
const { OfferType, OfferMessage, ...exp1 } = exp;
|
|
|
|
|
return {
|
|
|
|
|
...exp1,
|
|
|
|
|
Offer: 0,
|
|
|
|
|
OrderQty: OrderQty,
|
|
|
|
|
...calculateAmounts(
|
|
|
|
|
OrderQty,
|
|
|
|
|
exp.OrderRate,
|
|
|
|
|
exp.TaxPercentage,
|
|
|
|
|
false
|
|
|
|
|
),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
return exp; // keep unchanged item
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return dispatch(changeOrderCardDetails(data));
|
|
|
|
|
}
|
|
|
|
|
if (CompleteRemoveconvertFreetoPaidNotCompletely) {
|
|
|
|
|
const data = ModifiedOrderCardDetail?.filter(
|
|
|
|
|
(e) =>
|
|
|
|
|
!(
|
|
|
|
|
e?.InwardDtlId === BuyInwardDtlId &&
|
|
|
|
|
e?.BookingTypeName === BookingTypeName &&
|
|
|
|
|
(!e?.SalesId || OrderType == 'Hold')
|
|
|
|
|
)
|
|
|
|
|
)?.flatMap((exp) => {
|
|
|
|
|
if (
|
|
|
|
|
exp?.InwardDtlId == InwardDtlId &&
|
|
|
|
|
exp?.Offer > 0 &&
|
|
|
|
|
exp?.BookingTypeName === BookingTypeName
|
|
|
|
|
) {
|
|
|
|
|
const { OfferType, OfferMessage, ...exp1 } = exp;
|
|
|
|
|
let first = {
|
|
|
|
|
...exp1,
|
|
|
|
|
Offer: 0,
|
|
|
|
|
OrderQty: BuyProdQty,
|
|
|
|
|
...calculateAmounts(
|
|
|
|
|
OrderQty,
|
|
|
|
|
exp.OrderRate,
|
|
|
|
|
exp.TaxPercentage,
|
|
|
|
|
false
|
|
|
|
|
),
|
|
|
|
|
};
|
|
|
|
|
if (BuyProdQty < OrderQty) {
|
|
|
|
|
let second = {
|
|
|
|
|
...exp1,
|
|
|
|
|
Offer: 0,
|
|
|
|
|
OrderQty: exp1?.OrderQty - BuyProdQty,
|
|
|
|
|
...calculateAmounts(
|
|
|
|
|
exp1?.OrderQty - BuyProdQty,
|
|
|
|
|
exp.OrderRate,
|
|
|
|
|
exp.TaxPercentage,
|
|
|
|
|
true
|
|
|
|
|
),
|
|
|
|
|
};
|
|
|
|
|
return [first, second];
|
|
|
|
|
}
|
|
|
|
|
return [first];
|
|
|
|
|
}
|
|
|
|
|
return exp; // keep unchanged item
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return dispatch(changeOrderCardDetails(data));
|
|
|
|
|
}
|
|
|
|
|
if (CompleteRemoveBuyAndAddWithPaid) {
|
|
|
|
|
const data = ModifiedOrderCardDetail?.filter(
|
|
|
|
|
(e) =>
|
|
|
|
|
!(
|
|
|
|
|
(e?.InwardDtlId === BuyInwardDtlId &&
|
|
|
|
|
e?.BookingTypeName === BookingTypeName &&
|
|
|
|
|
(!e?.SalesId || OrderType == 'Hold')) ||
|
|
|
|
|
(e?.InwardDtlId == InwardDtlId &&
|
|
|
|
|
e?.Offer > 0 &&
|
|
|
|
|
e?.BookingTypeName === BookingTypeName &&
|
|
|
|
|
(!e?.SalesId || OrderType == 'Hold'))
|
|
|
|
|
)
|
|
|
|
|
)?.map((exp) => {
|
|
|
|
|
if (
|
|
|
|
|
exp?.InwardDtlId == InwardDtlId &&
|
|
|
|
|
exp?.Offer == 0 &&
|
|
|
|
|
exp?.BookingTypeName === BookingTypeName
|
|
|
|
|
) {
|
|
|
|
|
return {
|
|
|
|
|
...exp, // keep existing fields
|
|
|
|
|
OrderQty: OrderQty,
|
|
|
|
|
...calculateAmounts(
|
|
|
|
|
OrderQty,
|
|
|
|
|
exp.OrderRate,
|
|
|
|
|
exp.TaxPercentage,
|
|
|
|
|
false
|
|
|
|
|
),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
return exp; // keep unchanged item
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return dispatch(changeOrderCardDetails(data));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (UpdateBuyAndFree) {
|
|
|
|
|
const data = ModifiedOrderCardDetail?.map((e) => {
|
|
|
|
|
if (
|
|
|
|
|
e?.InwardDtlId == InwardDtlId &&
|
|
|
|
|
e?.Offer > 0 &&
|
|
|
|
|
e?.BookingTypeName === BookingTypeName
|
|
|
|
|
) {
|
|
|
|
|
const newQty = e?.OrderQty + OrderQty;
|
|
|
|
|
return {
|
|
|
|
|
...e,
|
|
|
|
|
OrderQty: newQty,
|
|
|
|
|
...calculateAmounts(newQty, e.OrderRate, e.TaxPercentage),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
if (e?.InwardDtlId == InwardDtlId && e?.Offer == Offer) {
|
|
|
|
|
const newQty = e?.OrderQty - OrderQty;
|
|
|
|
|
return {
|
|
|
|
|
...e,
|
|
|
|
|
OrderQty: newQty,
|
|
|
|
|
|
|
|
|
|
...calculateAmounts(newQty, e.OrderRate, e.TaxPercentage, false),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
e?.InwardDtlId == BuyInwardDtlId &&
|
|
|
|
|
e?.BookingTypeName === BookingTypeName
|
|
|
|
|
) {
|
|
|
|
|
return {
|
|
|
|
|
...e,
|
|
|
|
|
OrderQty: BuyProdQty,
|
|
|
|
|
...calculateAmounts(
|
|
|
|
|
BuyProdQty,
|
|
|
|
|
e.OrderRate,
|
|
|
|
|
e.TaxPercentage,
|
|
|
|
|
false
|
|
|
|
|
),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return e;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return dispatch(changeOrderCardDetails(data));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (CompleteRemoveconvertFreetoPaidTwoTypes) {
|
|
|
|
|
const data = ModifiedOrderCardDetail?.filter(
|
|
|
|
|
(e) =>
|
|
|
|
|
!(
|
|
|
|
|
e?.InwardDtlId === BuyInwardDtlId &&
|
|
|
|
|
e?.BookingTypeName === BookingTypeName &&
|
|
|
|
|
(!e?.SalesId || OrderType == 'Hold')
|
|
|
|
|
)
|
|
|
|
|
)?.flatMap((exp) => {
|
|
|
|
|
if (
|
|
|
|
|
exp?.InwardDtlId == InwardDtlId &&
|
|
|
|
|
exp?.Offer > 0 &&
|
|
|
|
|
exp?.BookingTypeName === BookingTypeName
|
|
|
|
|
) {
|
|
|
|
|
const { OfferType, OfferMessage, ...exp1 } = exp;
|
|
|
|
|
return {
|
|
|
|
|
...exp1,
|
|
|
|
|
Offer: 0,
|
|
|
|
|
OrderQty: OrderQty,
|
|
|
|
|
...calculateAmounts(
|
|
|
|
|
OrderQty,
|
|
|
|
|
exp.OrderRate,
|
|
|
|
|
exp.TaxPercentage,
|
|
|
|
|
false
|
|
|
|
|
),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
if (
|
|
|
|
|
exp?.InwardDtlId == InwardDtlId &&
|
|
|
|
|
exp?.Offer > 0 &&
|
|
|
|
|
exp?.BookingTypeName !== BookingTypeName
|
|
|
|
|
) {
|
|
|
|
|
const { ...exp1 } = exp;
|
|
|
|
|
let first = {
|
|
|
|
|
...exp1,
|
|
|
|
|
// Offer: 0,
|
|
|
|
|
OrderQty: exp1?.OrderQty - BuyProdQty,
|
|
|
|
|
...calculateAmounts(
|
|
|
|
|
exp1?.OrderQty - BuyProdQty,
|
|
|
|
|
exp.OrderRate,
|
|
|
|
|
exp.TaxPercentage,
|
|
|
|
|
true
|
|
|
|
|
),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let second = {
|
|
|
|
|
...exp1,
|
|
|
|
|
Offer: 0,
|
|
|
|
|
OrderQty: BuyProdQty,
|
|
|
|
|
...calculateAmounts(
|
|
|
|
|
BuyProdQty,
|
|
|
|
|
exp.OrderRate,
|
|
|
|
|
exp.TaxPercentage,
|
|
|
|
|
false
|
|
|
|
|
),
|
|
|
|
|
};
|
|
|
|
|
delete second?.OfferMessage;
|
|
|
|
|
delete second?.OfferType;
|
|
|
|
|
return [first, second];
|
|
|
|
|
}
|
|
|
|
|
return exp; // keep unchanged item
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return dispatch(changeOrderCardDetails(data));
|
|
|
|
|
}
|
|
|
|
|
// Update qty for normal case
|
|
|
|
|
|
|
|
|
|
const data = ModifiedOrderCardDetail?.map((e) => {
|
|
|
|
|
if (
|
|
|
|
|
e?.InwardDtlId == InwardDtlId &&
|
|
|
|
|
e?.Offer == Offer &&
|
|
|
|
|
e?.BookingTypeName === BookingTypeName
|
|
|
|
|
) {
|
|
|
|
|
return {
|
|
|
|
|
...e,
|
|
|
|
|
OrderQty,
|
|
|
|
|
...calculateAmounts(OrderQty, e.OrderRate, e.TaxPercentage, false),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
return e;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
dispatch(changeOrderCardDetails(data));
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const ChangeFreeprodlistFn = async ({
|
|
|
|
|
FreeProdId,
|
|
|
|
|
OfferId,
|
|
|
|
|
OverAllFreeQty,
|
|
|
|
|
RemainingQty,
|
|
|
|
|
FreeQty,
|
|
|
|
|
CompleteRemove = false,
|
|
|
|
|
}) => {
|
|
|
|
|
const deepCopy = JSON.parse(JSON.stringify(OfferFreeProduct));
|
|
|
|
|
|
|
|
|
|
let ModifyedData;
|
|
|
|
|
|
|
|
|
|
if (CompleteRemove) {
|
|
|
|
|
// 🔹 Remove the matching FreeProd completely
|
|
|
|
|
ModifyedData = deepCopy?.filter(
|
|
|
|
|
(exp) => !(exp?.OfferId == OfferId && exp?.FreeProdId == FreeProdId)
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
// 🔹 Update the matching FreeProd
|
|
|
|
|
ModifyedData = deepCopy?.map((exp) => {
|
|
|
|
|
if (exp?.OfferId == OfferId && FreeProdId == exp?.FreeProdId) {
|
|
|
|
|
return {
|
|
|
|
|
...exp,
|
|
|
|
|
OverAllFreeQty,
|
|
|
|
|
RemainingQty,
|
|
|
|
|
FreeQty,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
return { ...exp };
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dispatch(ChangeFullFreeProductList(ModifyedData));
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const ChangeOfferAppliedProdsFn = async ({
|
|
|
|
|
inwardDtlId,
|
|
|
|
|
OfferAmount,
|
|
|
|
|
FreeQty,
|
|
|
|
|
CompleteRemove = false,
|
|
|
|
|
insideinwardDtlId = false,
|
|
|
|
|
}) => {
|
|
|
|
|
const deepCopy = JSON.parse(JSON.stringify(GlobalOfferAppliedProductsData));
|
|
|
|
|
|
|
|
|
|
let ModifyedData;
|
|
|
|
|
|
|
|
|
|
if (CompleteRemove) {
|
|
|
|
|
// 🔹 Remove case
|
|
|
|
|
if (!insideinwardDtlId) {
|
|
|
|
|
ModifyedData = deepCopy?.filter(
|
|
|
|
|
(exp) => exp?.InwardDtlId !== inwardDtlId
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
ModifyedData = deepCopy?.filter(
|
|
|
|
|
(exp) =>
|
|
|
|
|
!(
|
|
|
|
|
Array?.isArray(exp?.FreeProductsList)
|
|
|
|
|
? exp?.FreeProductsList
|
|
|
|
|
: [exp?.FreeProductsList]
|
|
|
|
|
)?.some((freeProd) =>
|
|
|
|
|
freeProd?.ProdVariantDetails?.some((variant) =>
|
|
|
|
|
variant?.StockDetails?.some(
|
|
|
|
|
(stock) => stock?.FreeInwardDtlId === inwardDtlId
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 🔹 Update case
|
|
|
|
|
ModifyedData = deepCopy?.map((exp) => {
|
|
|
|
|
let shouldUpdate = false;
|
|
|
|
|
|
|
|
|
|
if (!insideinwardDtlId) {
|
|
|
|
|
shouldUpdate = exp?.InwardDtlId == inwardDtlId;
|
|
|
|
|
} else {
|
|
|
|
|
shouldUpdate = (
|
|
|
|
|
Array?.isArray(exp?.FreeProductsList)
|
|
|
|
|
? exp?.FreeProductsList
|
|
|
|
|
: [exp?.FreeProductsList]
|
|
|
|
|
)?.some((freeProd) =>
|
|
|
|
|
freeProd?.ProdVariantDetails?.some((variant) =>
|
|
|
|
|
variant?.StockDetails?.some(
|
|
|
|
|
(stock) => stock?.FreeInwardDtlId === inwardDtlId
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (shouldUpdate) {
|
|
|
|
|
return {
|
|
|
|
|
...exp,
|
|
|
|
|
OfferAmount,
|
|
|
|
|
ActualFreeQty: FreeQty,
|
|
|
|
|
FreeProductsList: (Array?.isArray(exp?.FreeProductsList)
|
|
|
|
|
? exp?.FreeProductsList
|
|
|
|
|
: [exp?.FreeProductsList]
|
|
|
|
|
)?.map((item, idx) =>
|
|
|
|
|
idx === 0
|
|
|
|
|
? {
|
2026-02-09 14:16:08 +05:30
|
|
|
...item,
|
|
|
|
|
FreeQty,
|
|
|
|
|
}
|
2026-01-27 18:27:29 +05:30
|
|
|
: item
|
|
|
|
|
),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return { ...exp };
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dispatch(changeFullOfferAppliedProducts(ModifyedData));
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const removeFromCart = async (item) => {
|
|
|
|
|
removeExtraCharge(item);
|
|
|
|
|
setPreviousdataLength(tableData?.length);
|
|
|
|
|
|
|
|
|
|
if (item?.SinglePc == 'Y') {
|
|
|
|
|
let ModifiedOrderCardDetail = JSON.parse(JSON.stringify(tableData));
|
|
|
|
|
const data = ModifiedOrderCardDetail?.filter(
|
|
|
|
|
(e) =>
|
|
|
|
|
!(
|
|
|
|
|
e?.InwardDtlId === item?.InwardDtlId &&
|
|
|
|
|
e?.Offer === item?.Offer &&
|
|
|
|
|
e?.BookingTypeName === item?.BookingTypeName &&
|
|
|
|
|
(!e?.SalesId || OrderType == 'Hold') &&
|
|
|
|
|
e?.SinglePc == 'Y'
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
return dispatch(changeOrderCardDetails(data));
|
|
|
|
|
}
|
|
|
|
|
let ischeckBothBookingType = tableData?.find(
|
|
|
|
|
(e) =>
|
|
|
|
|
e?.InwardDtlId == item?.InwardDtlId &&
|
|
|
|
|
e?.Offer > 0 &&
|
|
|
|
|
e?.BookingTypeName != item?.BookingTypeName
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (item?.Offer > 0) {
|
|
|
|
|
//check is Buyxgetx Or something
|
|
|
|
|
// let ischeck= GlobalOfferAppliedProductsData?.some((e)=>e?.FreeProductsList?.[0]??.
|
|
|
|
|
const isBuyAndGetX =
|
|
|
|
|
GlobalOfferAppliedProductsData?.find((data) =>
|
|
|
|
|
(Array?.isArray(data?.FreeProductsList)
|
|
|
|
|
? data?.FreeProductsList
|
|
|
|
|
: [data?.FreeProductsList]
|
|
|
|
|
)?.some((freeProd) =>
|
|
|
|
|
freeProd?.ProdVariantDetails?.some((variant) =>
|
|
|
|
|
variant?.StockDetails?.some(
|
|
|
|
|
(stock) => stock?.FreeInwardDtlId === item?.InwardDtlId
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
)?.OfferMode == 'B';
|
|
|
|
|
|
|
|
|
|
const isItemWiseOrQuantityProduct = GlobalOfferAppliedProductsData?.find(
|
|
|
|
|
(data) =>
|
|
|
|
|
data?.ProdId === item?.ProdId &&
|
|
|
|
|
data?.InwardDtlId === item?.InwardDtlId &&
|
|
|
|
|
(data?.OfferMode === 'I' || data?.OfferMode === 'Q') &&
|
|
|
|
|
data?.OfferAmount === item?.Offer
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const isCheckFreeProduct = GlobalOfferAppliedProductsData?.find((off) =>
|
|
|
|
|
(Array.isArray(off?.FreeProductsList)
|
|
|
|
|
? off?.FreeProductsList
|
|
|
|
|
: [off?.FreeProductsList]
|
|
|
|
|
)?.some((prod) =>
|
|
|
|
|
prod?.ProdVariantDetails?.some((variant) =>
|
|
|
|
|
variant?.StockDetails?.some(
|
|
|
|
|
(stock) => stock.FreeInwardDtlId === item?.InwardDtlId
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (isBuyAndGetX) {
|
|
|
|
|
let isPaidproduct = tableData?.find(
|
|
|
|
|
(e) =>
|
|
|
|
|
e?.InwardDtlId == item?.InwardDtlId &&
|
|
|
|
|
e?.Offer == 0 &&
|
|
|
|
|
item?.BookingTypeName == e?.BookingTypeName
|
|
|
|
|
);
|
|
|
|
|
const isCheckFreeProduct = OfferFreeProduct?.find((exp) =>
|
|
|
|
|
exp?.ProdVariantDetails?.some((variant) =>
|
|
|
|
|
variant?.StockDetails?.some(
|
|
|
|
|
(stock) => stock?.FreeInwardDtlId === item?.InwardDtlId
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
if (isPaidproduct) {
|
|
|
|
|
if (isPaidproduct?.OrderQty == item?.OrderQty) {
|
|
|
|
|
//just remove Paid Qty
|
|
|
|
|
await ChangeOrderCardDetailsFn({
|
|
|
|
|
BookingTypeName: item?.BookingTypeName,
|
|
|
|
|
BuyProdQty: null,
|
|
|
|
|
OrderQty: isPaidproduct?.OrderQty,
|
|
|
|
|
CompleteRemove: true,
|
|
|
|
|
InwardDtlId: isPaidproduct?.InwardDtlId,
|
|
|
|
|
BuyInwardDtlId: null,
|
|
|
|
|
Offer: 0,
|
|
|
|
|
});
|
|
|
|
|
} else if (isPaidproduct?.OrderQty > item?.OrderQty) {
|
|
|
|
|
// Just Decrease Paid Qty
|
|
|
|
|
await ChangeOrderCardDetailsFn({
|
|
|
|
|
BookingTypeName: item?.BookingTypeName,
|
|
|
|
|
BuyProdQty: null,
|
|
|
|
|
OrderQty: isPaidproduct?.OrderQty - item?.OrderQty,
|
|
|
|
|
CompleteRemove: false,
|
|
|
|
|
InwardDtlId: isPaidproduct?.InwardDtlId,
|
|
|
|
|
BuyInwardDtlId: null,
|
|
|
|
|
Offer: 0,
|
|
|
|
|
});
|
|
|
|
|
} else if (isPaidproduct?.OrderQty < item?.OrderQty) {
|
|
|
|
|
//just remove Paid Qty
|
|
|
|
|
//decrease FreeQty
|
|
|
|
|
|
|
|
|
|
if (ischeckBothBookingType) {
|
|
|
|
|
await ChangeOrderCardDetailsFn({
|
|
|
|
|
BookingTypeName: item?.BookingTypeName,
|
|
|
|
|
BuyProdQty: null,
|
|
|
|
|
OrderQty: -isPaidproduct?.OrderQty,
|
|
|
|
|
RemoveAndUpdate: true,
|
|
|
|
|
InwardDtlId: isPaidproduct?.InwardDtlId,
|
|
|
|
|
BuyInwardDtlId: null,
|
|
|
|
|
Offer: 0,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await ChangeFreeprodlistFn({
|
|
|
|
|
OverAllFreeQty: isCheckFreeProduct?.OverAllFreeQty,
|
|
|
|
|
RemainingQty:
|
|
|
|
|
isCheckFreeProduct?.OverAllFreeQty -
|
|
|
|
|
(ischeckBothBookingType?.OrderQty + isPaidproduct?.OrderQty),
|
|
|
|
|
FreeQty:
|
|
|
|
|
ischeckBothBookingType?.OrderQty + isPaidproduct?.OrderQty,
|
|
|
|
|
FreeProdId: isPaidproduct?.ProdId,
|
|
|
|
|
OfferId: isCheckFreeProduct?.OfferId,
|
|
|
|
|
});
|
|
|
|
|
// await ChangeOfferAppliedProdsFn(isPaidproduct?.InwardDtlId, (isPaidproduct?.OrderRate * isPaidproduct?.OrderQty), isPaidproduct?.OrderQty, true, insideinwardDtlId true)
|
|
|
|
|
await ChangeOfferAppliedProdsFn({
|
|
|
|
|
inwardDtlId: isPaidproduct?.InwardDtlId,
|
|
|
|
|
OfferAmount: isPaidproduct?.OrderRate * isPaidproduct?.OrderQty,
|
|
|
|
|
FreeQty: isPaidproduct?.OrderQty,
|
|
|
|
|
CompleteRemove: false,
|
|
|
|
|
insideinwardDtlId: true,
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
let FreeProdcutinPaidModeOtherBookingType = tableData?.find(
|
|
|
|
|
(e) =>
|
|
|
|
|
e?.InwardDtlId == item?.InwardDtlId &&
|
|
|
|
|
e?.Offer == 0 &&
|
|
|
|
|
item?.BookingTypeName != e?.BookingTypeName
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (FreeProdcutinPaidModeOtherBookingType) {
|
|
|
|
|
await ChangeOrderCardDetailsFn({
|
|
|
|
|
BookingTypeName: item?.BookingTypeName,
|
|
|
|
|
BuyProdQty: item?.OrderQty - isPaidproduct?.OrderQty,
|
|
|
|
|
OrderQty: item.OrderQty,
|
|
|
|
|
RemoveAndUpdateOtherBookingType: true,
|
|
|
|
|
InwardDtlId: isPaidproduct?.InwardDtlId,
|
|
|
|
|
BuyInwardDtlId: null,
|
|
|
|
|
Offer: 0,
|
|
|
|
|
});
|
|
|
|
|
await ChangeFreeprodlistFn({
|
|
|
|
|
OverAllFreeQty: item?.OrderQty,
|
|
|
|
|
RemainingQty:
|
|
|
|
|
item?.OrderQty -
|
|
|
|
|
(isPaidproduct?.OrderQty +
|
|
|
|
|
(FreeProdcutinPaidModeOtherBookingType?.OrderQty -
|
|
|
|
|
(item?.OrderQty - isPaidproduct?.OrderQty) ||
|
|
|
|
|
FreeProdcutinPaidModeOtherBookingType?.OrderQty)),
|
|
|
|
|
FreeQty:
|
|
|
|
|
isPaidproduct?.OrderQty +
|
|
|
|
|
(FreeProdcutinPaidModeOtherBookingType?.OrderQty -
|
|
|
|
|
(item?.OrderQty - isPaidproduct?.OrderQty) ||
|
|
|
|
|
FreeProdcutinPaidModeOtherBookingType?.OrderQty),
|
|
|
|
|
FreeProdId: isPaidproduct?.ProdId,
|
|
|
|
|
OfferId: isCheckFreeProduct?.OfferId,
|
|
|
|
|
});
|
|
|
|
|
// await ChangeOfferAppliedProdsFn(isPaidproduct?.InwardDtlId, (isPaidproduct?.OrderRate * isPaidproduct?.OrderQty), isPaidproduct?.OrderQty, true, insideinwardDtlId true)
|
|
|
|
|
|
|
|
|
|
await ChangeOfferAppliedProdsFn({
|
|
|
|
|
inwardDtlId: isPaidproduct?.InwardDtlId,
|
|
|
|
|
OfferAmount:
|
|
|
|
|
isPaidproduct?.OrderRate *
|
|
|
|
|
(isPaidproduct?.OrderQty +
|
|
|
|
|
(FreeProdcutinPaidModeOtherBookingType?.OrderQty -
|
|
|
|
|
(item?.OrderQty - isPaidproduct?.OrderQty) ||
|
|
|
|
|
FreeProdcutinPaidModeOtherBookingType?.OrderQty)),
|
|
|
|
|
FreeQty:
|
|
|
|
|
isPaidproduct?.OrderQty +
|
|
|
|
|
(FreeProdcutinPaidModeOtherBookingType?.OrderQty -
|
|
|
|
|
(item?.OrderQty - isPaidproduct?.OrderQty) ||
|
|
|
|
|
FreeProdcutinPaidModeOtherBookingType?.OrderQty),
|
|
|
|
|
insideinwardDtlId: true,
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
await ChangeOrderCardDetailsFn({
|
|
|
|
|
BookingTypeName: item?.BookingTypeName,
|
|
|
|
|
BuyProdQty: null,
|
|
|
|
|
OrderQty: isPaidproduct?.OrderQty,
|
|
|
|
|
RemoveAndUpdate: true,
|
|
|
|
|
InwardDtlId: isPaidproduct?.InwardDtlId,
|
|
|
|
|
BuyInwardDtlId: null,
|
|
|
|
|
Offer: 0,
|
|
|
|
|
});
|
|
|
|
|
await ChangeFreeprodlistFn({
|
|
|
|
|
OverAllFreeQty: item?.OrderQty,
|
|
|
|
|
RemainingQty: item?.OrderQty - isPaidproduct?.OrderQty,
|
|
|
|
|
FreeQty: isPaidproduct?.OrderQty,
|
|
|
|
|
FreeProdId: isPaidproduct?.ProdId,
|
|
|
|
|
OfferId: isCheckFreeProduct?.OfferId,
|
|
|
|
|
});
|
|
|
|
|
// await ChangeOfferAppliedProdsFn(isPaidproduct?.InwardDtlId, (isPaidproduct?.OrderRate * isPaidproduct?.OrderQty), isPaidproduct?.OrderQty, true, insideinwardDtlId true)
|
|
|
|
|
|
|
|
|
|
await ChangeOfferAppliedProdsFn({
|
|
|
|
|
inwardDtlId: isPaidproduct?.InwardDtlId,
|
|
|
|
|
OfferAmount:
|
|
|
|
|
isPaidproduct?.OrderRate * isPaidproduct?.OrderQty,
|
|
|
|
|
FreeQty: isPaidproduct?.OrderQty,
|
|
|
|
|
CompleteRemove: false,
|
|
|
|
|
insideinwardDtlId: true,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (ischeckBothBookingType) {
|
|
|
|
|
// //Free Product in Paid Mode
|
|
|
|
|
let FreeProdcutinPaidModeOtherBookingType = tableData?.find(
|
|
|
|
|
(e) =>
|
|
|
|
|
e?.InwardDtlId == item?.InwardDtlId &&
|
|
|
|
|
e?.Offer == 0 &&
|
|
|
|
|
item?.BookingTypeName != e?.BookingTypeName
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
//if free product is available in paid mode in other booking type then just decrease the free qty from that product
|
|
|
|
|
if (FreeProdcutinPaidModeOtherBookingType) {
|
|
|
|
|
await ChangeOrderCardDetailsFn({
|
|
|
|
|
BookingTypeName: item?.BookingTypeName,
|
|
|
|
|
BuyProdQty: null,
|
|
|
|
|
OrderQty: item?.OrderQty,
|
|
|
|
|
CompleteRemoveAndPaidToFreeOtherType: true,
|
|
|
|
|
InwardDtlId: item?.InwardDtlId,
|
|
|
|
|
BuyInwardDtlId: null,
|
|
|
|
|
Offer: item?.Offer,
|
|
|
|
|
});
|
|
|
|
|
await ChangeFreeprodlistFn({
|
|
|
|
|
OverAllFreeQty: isCheckFreeProduct?.OverAllFreeQty,
|
|
|
|
|
RemainingQty: isCheckFreeProduct?.OverAllFreeQty,
|
|
|
|
|
FreeQty: isCheckFreeProduct?.FreeQty,
|
|
|
|
|
FreeProdId: isCheckFreeProduct?.FreeProdId,
|
|
|
|
|
OfferId: isCheckFreeProduct?.OfferId,
|
|
|
|
|
});
|
|
|
|
|
// await ChangeOfferAppliedProdsFn(isPaidproduct?.InwardDtlId, (isPaidproduct?.OrderRate * Quantity), Quantity, true,)
|
|
|
|
|
await ChangeOfferAppliedProdsFn({
|
|
|
|
|
inwardDtlId: item?.InwardDtlId,
|
|
|
|
|
OfferAmount: isCheckFreeProduct?.FreeQty * item?.OrderRate,
|
|
|
|
|
FreeQty: item?.OrderQty,
|
|
|
|
|
CompleteRemove: false,
|
|
|
|
|
insideinwardDtlId: true,
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
await ChangeOrderCardDetailsFn({
|
|
|
|
|
BookingTypeName: item?.BookingTypeName,
|
|
|
|
|
BuyProdQty: null,
|
|
|
|
|
OrderQty: isPaidproduct?.OrderQty,
|
|
|
|
|
CompleteRemove: true,
|
|
|
|
|
InwardDtlId: item?.InwardDtlId,
|
|
|
|
|
BuyInwardDtlId: null,
|
|
|
|
|
Offer: item?.Offer,
|
|
|
|
|
});
|
|
|
|
|
await ChangeFreeprodlistFn({
|
|
|
|
|
OverAllFreeQty: isCheckFreeProduct?.OverAllFreeQty,
|
|
|
|
|
RemainingQty:
|
|
|
|
|
isCheckFreeProduct?.OverAllFreeQty - item?.OrderQty,
|
|
|
|
|
FreeQty: isCheckFreeProduct?.FreeQty - item?.OrderQty,
|
|
|
|
|
FreeProdId: isCheckFreeProduct?.FreeProdId,
|
|
|
|
|
OfferId: isCheckFreeProduct?.OfferId,
|
|
|
|
|
});
|
|
|
|
|
// await ChangeOfferAppliedProdsFn(isPaidproduct?.InwardDtlId, (isPaidproduct?.OrderRate * Quantity), Quantity, true,)
|
|
|
|
|
await ChangeOfferAppliedProdsFn({
|
|
|
|
|
inwardDtlId: item?.InwardDtlId,
|
|
|
|
|
OfferAmount:
|
|
|
|
|
(isCheckFreeProduct?.FreeQty - item?.OrderQty) *
|
|
|
|
|
item?.OrderRate,
|
|
|
|
|
FreeQty: item?.OrderQty,
|
|
|
|
|
CompleteRemove: false,
|
|
|
|
|
insideinwardDtlId: true,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// }
|
|
|
|
|
else {
|
|
|
|
|
let isPaidProductAvailableInCartOtherType = tableData?.find(
|
|
|
|
|
(e) =>
|
|
|
|
|
e?.InwardDtlId == item?.InwardDtlId &&
|
|
|
|
|
e?.Offer == 0 &&
|
|
|
|
|
item?.BookingTypeName != e?.BookingTypeName
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (isPaidProductAvailableInCartOtherType) {
|
|
|
|
|
await ChangeOrderCardDetailsFn({
|
|
|
|
|
BookingTypeName: item?.BookingTypeName,
|
|
|
|
|
BuyProdQty: null,
|
|
|
|
|
OrderQty: item?.OrderQty,
|
|
|
|
|
CompleteRemoveAndPaidToFreeOtherTypeWithoutMerge: true,
|
|
|
|
|
InwardDtlId: item?.InwardDtlId,
|
|
|
|
|
BuyInwardDtlId: null,
|
|
|
|
|
Offer: item?.Offer,
|
|
|
|
|
});
|
|
|
|
|
await ChangeFreeprodlistFn({
|
|
|
|
|
OverAllFreeQty: isCheckFreeProduct?.OverAllFreeQty,
|
|
|
|
|
RemainingQty:
|
|
|
|
|
isCheckFreeProduct?.OverAllFreeQty -
|
|
|
|
|
(isCheckFreeProduct?.FreeQty -
|
|
|
|
|
(item?.OrderQty -
|
|
|
|
|
isPaidProductAvailableInCartOtherType?.OrderQty)),
|
|
|
|
|
FreeQty:
|
|
|
|
|
isCheckFreeProduct?.FreeQty -
|
|
|
|
|
(item?.OrderQty -
|
|
|
|
|
isPaidProductAvailableInCartOtherType?.OrderQty),
|
|
|
|
|
FreeProdId: isCheckFreeProduct?.FreeProdId,
|
|
|
|
|
OfferId: isCheckFreeProduct?.OfferId,
|
|
|
|
|
});
|
|
|
|
|
// await ChangeOfferAppliedProdsFn(isPaidproduct?.InwardDtlId, (isPaidproduct?.OrderRate * Quantity), Quantity, true,)
|
|
|
|
|
await ChangeOfferAppliedProdsFn({
|
|
|
|
|
inwardDtlId: item?.InwardDtlId,
|
|
|
|
|
OfferAmount:
|
|
|
|
|
item?.OrderRate *
|
|
|
|
|
(isCheckFreeProduct?.FreeQty -
|
|
|
|
|
(item?.OrderQty -
|
|
|
|
|
isPaidProductAvailableInCartOtherType?.OrderQty)),
|
|
|
|
|
FreeQty:
|
|
|
|
|
isCheckFreeProduct?.FreeQty -
|
|
|
|
|
(item?.OrderQty -
|
|
|
|
|
isPaidProductAvailableInCartOtherType?.OrderQty),
|
|
|
|
|
CompleteRemove: false,
|
|
|
|
|
insideinwardDtlId: true,
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
await ChangeOrderCardDetailsFn({
|
|
|
|
|
BookingTypeName: item?.BookingTypeName,
|
|
|
|
|
BuyProdQty: null,
|
|
|
|
|
OrderQty: isPaidproduct?.OrderQty,
|
|
|
|
|
CompleteRemove: true,
|
|
|
|
|
InwardDtlId: item?.InwardDtlId,
|
|
|
|
|
BuyInwardDtlId: null,
|
|
|
|
|
Offer: item?.Offer,
|
|
|
|
|
});
|
|
|
|
|
await ChangeFreeprodlistFn({
|
|
|
|
|
OverAllFreeQty: isCheckFreeProduct?.OverAllFreeQty,
|
|
|
|
|
RemainingQty: isCheckFreeProduct?.OverAllFreeQty,
|
|
|
|
|
FreeQty: 0,
|
|
|
|
|
FreeProdId: isCheckFreeProduct?.FreeProdId,
|
|
|
|
|
OfferId: isCheckFreeProduct?.OfferId,
|
|
|
|
|
});
|
|
|
|
|
// await ChangeOfferAppliedProdsFn(isPaidproduct?.InwardDtlId, (isPaidproduct?.OrderRate * Quantity), Quantity, true,)
|
|
|
|
|
await ChangeOfferAppliedProdsFn({
|
|
|
|
|
inwardDtlId: item?.InwardDtlId,
|
|
|
|
|
OfferAmount: item?.OrderRate * item?.OrderQty,
|
|
|
|
|
FreeQty: item?.OrderQty,
|
|
|
|
|
CompleteRemove: true,
|
|
|
|
|
insideinwardDtlId: true,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//Change Remove OrderCartDetail
|
|
|
|
|
//Remove FreeprodList
|
|
|
|
|
//ChangeOfferApplied Products
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
///remove item wise offer
|
|
|
|
|
if (isItemWiseOrQuantityProduct) {
|
|
|
|
|
await ChangeOrderCardDetailsFn({
|
|
|
|
|
BookingTypeName: item?.BookingTypeName,
|
|
|
|
|
BuyProdQty: null,
|
|
|
|
|
OrderQty: item?.OrderQty,
|
|
|
|
|
CompleteRemove: true,
|
|
|
|
|
InwardDtlId: item?.InwardDtlId,
|
|
|
|
|
BuyInwardDtlId: null,
|
|
|
|
|
Offer: item?.Offer,
|
|
|
|
|
});
|
|
|
|
|
await ChangeOfferAppliedProdsFn({
|
|
|
|
|
inwardDtlId: item?.InwardDtlId,
|
|
|
|
|
OfferAmount: item?.OrderRate * item?.OrderQty,
|
|
|
|
|
FreeQty: item?.OrderQty,
|
|
|
|
|
CompleteRemove: true,
|
|
|
|
|
});
|
|
|
|
|
} else if (isCheckFreeProduct) {
|
|
|
|
|
// remove or update loyalty/code based free product which is added in cart
|
|
|
|
|
const freeProdList = Array?.isArray(
|
|
|
|
|
isCheckFreeProduct?.FreeProductsList
|
|
|
|
|
)
|
|
|
|
|
? isCheckFreeProduct?.FreeProductsList?.[0]
|
|
|
|
|
: isCheckFreeProduct?.FreeProductsList;
|
|
|
|
|
let isPaidProductAvailableInCart = tableData?.find(
|
|
|
|
|
(e) =>
|
|
|
|
|
e?.InwardDtlId == item?.InwardDtlId &&
|
|
|
|
|
e?.Offer == 0 &&
|
|
|
|
|
item?.BookingTypeName == e?.BookingTypeName
|
|
|
|
|
);
|
|
|
|
|
if (isPaidProductAvailableInCart) {
|
|
|
|
|
if (isPaidProductAvailableInCart?.OrderQty === item?.OrderQty) {
|
|
|
|
|
//just remove Paid Qty
|
|
|
|
|
await ChangeOrderCardDetailsFn({
|
|
|
|
|
BookingTypeName: item?.BookingTypeName,
|
|
|
|
|
BuyProdQty: null,
|
|
|
|
|
OrderQty: isPaidProductAvailableInCart?.OrderQty,
|
|
|
|
|
CompleteRemove: true,
|
|
|
|
|
InwardDtlId: isPaidProductAvailableInCart?.InwardDtlId,
|
|
|
|
|
BuyInwardDtlId: null,
|
|
|
|
|
Offer: 0,
|
|
|
|
|
});
|
|
|
|
|
} else if (
|
|
|
|
|
isPaidProductAvailableInCart?.OrderQty > item?.OrderQty
|
|
|
|
|
) {
|
|
|
|
|
await ChangeOrderCardDetailsFn({
|
|
|
|
|
BookingTypeName: item?.BookingTypeName,
|
|
|
|
|
BuyProdQty: null,
|
|
|
|
|
OrderQty:
|
|
|
|
|
isPaidProductAvailableInCart?.OrderQty - item?.OrderQty,
|
|
|
|
|
CompleteRemove: false,
|
|
|
|
|
InwardDtlId: isPaidProductAvailableInCart?.InwardDtlId,
|
|
|
|
|
BuyInwardDtlId: null,
|
|
|
|
|
Offer: 0,
|
|
|
|
|
});
|
|
|
|
|
} else if (
|
|
|
|
|
isPaidProductAvailableInCart?.OrderQty < item?.OrderQty
|
|
|
|
|
) {
|
|
|
|
|
//just remove Paid Qty
|
|
|
|
|
//decrease FreeQty
|
|
|
|
|
await ChangeOrderCardDetailsFn({
|
|
|
|
|
BookingTypeName: item?.BookingTypeName,
|
|
|
|
|
BuyProdQty: null,
|
|
|
|
|
OrderQty: -isPaidProductAvailableInCart?.OrderQty,
|
|
|
|
|
RemoveAndUpdate: true,
|
|
|
|
|
InwardDtlId: isPaidProductAvailableInCart?.InwardDtlId,
|
|
|
|
|
BuyInwardDtlId: null,
|
|
|
|
|
Offer: 0,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (ischeckBothBookingType) {
|
|
|
|
|
await ChangeFreeprodlistFn({
|
|
|
|
|
OverAllFreeQty: freeProdList?.OverAllFreeQty,
|
|
|
|
|
RemainingQty:
|
|
|
|
|
freeProdList?.OverAllFreeQty -
|
|
|
|
|
(ischeckBothBookingType?.OrderQty +
|
|
|
|
|
isPaidProductAvailableInCart?.OrderQty),
|
|
|
|
|
FreeQty:
|
|
|
|
|
ischeckBothBookingType?.OrderQty +
|
|
|
|
|
isPaidProductAvailableInCart?.OrderQty,
|
|
|
|
|
FreeProdId: isPaidProductAvailableInCart?.ProdId,
|
|
|
|
|
OfferId: freeProdList?.OfferId,
|
|
|
|
|
});
|
|
|
|
|
// await ChangeOfferAppliedProdsFn(isPaidproduct?.InwardDtlId, (isPaidproduct?.OrderRate * isPaidproduct?.OrderQty), isPaidproduct?.OrderQty, true, insideinwardDtlId true)
|
|
|
|
|
await ChangeOfferAppliedProdsFn({
|
|
|
|
|
inwardDtlId: isPaidProductAvailableInCart?.InwardDtlId,
|
|
|
|
|
OfferAmount:
|
|
|
|
|
isPaidProductAvailableInCart?.OrderRate *
|
|
|
|
|
isPaidProductAvailableInCart?.OrderQty,
|
|
|
|
|
FreeQty: isPaidProductAvailableInCart?.OrderQty,
|
|
|
|
|
CompleteRemove: false,
|
|
|
|
|
insideinwardDtlId: true,
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
await ChangeFreeprodlistFn({
|
|
|
|
|
OverAllFreeQty: item?.OrderQty,
|
|
|
|
|
RemainingQty:
|
|
|
|
|
item?.OrderQty - isPaidProductAvailableInCart?.OrderQty,
|
|
|
|
|
FreeQty: isPaidProductAvailableInCart?.OrderQty,
|
|
|
|
|
FreeProdId: isPaidProductAvailableInCart?.ProdId,
|
|
|
|
|
OfferId: freeProdList?.OfferId,
|
|
|
|
|
});
|
|
|
|
|
// await ChangeOfferAppliedProdsFn(isPaidproduct?.InwardDtlId, (isPaidproduct?.OrderRate * isPaidproduct?.OrderQty), isPaidproduct?.OrderQty, true, insideinwardDtlId true)
|
|
|
|
|
await ChangeOfferAppliedProdsFn({
|
|
|
|
|
inwardDtlId: isPaidProductAvailableInCart?.InwardDtlId,
|
|
|
|
|
OfferAmount:
|
|
|
|
|
isPaidProductAvailableInCart?.OrderRate *
|
|
|
|
|
isPaidProductAvailableInCart?.OrderQty,
|
|
|
|
|
FreeQty: isPaidProductAvailableInCart?.OrderQty,
|
|
|
|
|
CompleteRemove: false,
|
|
|
|
|
insideinwardDtlId: true,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (ischeckBothBookingType) {
|
|
|
|
|
await ChangeOrderCardDetailsFn({
|
|
|
|
|
BookingTypeName: item?.BookingTypeName,
|
|
|
|
|
BuyProdQty: null,
|
|
|
|
|
OrderQty: isPaidProductAvailableInCart?.OrderQty,
|
|
|
|
|
CompleteRemove: true,
|
|
|
|
|
InwardDtlId: item?.InwardDtlId,
|
|
|
|
|
BuyInwardDtlId: null,
|
|
|
|
|
Offer: item?.Offer,
|
|
|
|
|
});
|
|
|
|
|
await ChangeFreeprodlistFn({
|
|
|
|
|
OverAllFreeQty: freeProdList?.OverAllFreeQty,
|
|
|
|
|
RemainingQty: freeProdList?.OverAllFreeQty - item?.OrderQty,
|
|
|
|
|
FreeQty: freeProdList?.FreeQty - item?.OrderQty,
|
|
|
|
|
FreeProdId: freeProdList?.FreeProdId,
|
|
|
|
|
OfferId: freeProdList?.OfferId,
|
|
|
|
|
});
|
|
|
|
|
// await ChangeOfferAppliedProdsFn(isPaidproduct?.InwardDtlId, (isPaidproduct?.OrderRate * Quantity), Quantity, true,)
|
|
|
|
|
await ChangeOfferAppliedProdsFn({
|
|
|
|
|
inwardDtlId: item?.InwardDtlId,
|
|
|
|
|
OfferAmount:
|
|
|
|
|
(freeProdList?.FreeQty - item?.OrderQty) * item?.OrderRate,
|
|
|
|
|
FreeQty: item?.OrderQty,
|
|
|
|
|
CompleteRemove: false,
|
|
|
|
|
insideinwardDtlId: true,
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
await ChangeOrderCardDetailsFn({
|
|
|
|
|
BookingTypeName: item?.BookingTypeName,
|
|
|
|
|
BuyProdQty: null,
|
|
|
|
|
OrderQty: isPaidProductAvailableInCart?.OrderQty,
|
|
|
|
|
CompleteRemove: true,
|
|
|
|
|
InwardDtlId: item?.InwardDtlId,
|
|
|
|
|
BuyInwardDtlId: null,
|
|
|
|
|
Offer: item?.Offer,
|
|
|
|
|
});
|
|
|
|
|
await ChangeFreeprodlistFn({
|
|
|
|
|
OverAllFreeQty: freeProdList?.OverAllFreeQty,
|
|
|
|
|
RemainingQty: freeProdList?.OverAllFreeQty,
|
|
|
|
|
FreeQty: 0,
|
|
|
|
|
FreeProdId: freeProdList?.FreeProdId,
|
|
|
|
|
OfferId: freeProdList?.OfferId,
|
|
|
|
|
});
|
|
|
|
|
// await ChangeOfferAppliedProdsFn(isPaidproduct?.InwardDtlId, (isPaidproduct?.OrderRate * Quantity), Quantity, true,)
|
|
|
|
|
await ChangeOfferAppliedProdsFn({
|
|
|
|
|
inwardDtlId: item?.InwardDtlId,
|
|
|
|
|
OfferAmount: item?.OrderRate * item?.OrderQty,
|
|
|
|
|
FreeQty: item?.OrderQty,
|
|
|
|
|
CompleteRemove: true,
|
|
|
|
|
insideinwardDtlId: true,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
let ModifiedOrderCardDetail = JSON.parse(JSON.stringify(tableData));
|
|
|
|
|
|
|
|
|
|
const data = ModifiedOrderCardDetail?.filter(
|
|
|
|
|
(e) =>
|
|
|
|
|
!(
|
|
|
|
|
e?.InwardDtlId === item?.InwardDtlId &&
|
|
|
|
|
e?.Offer === item?.Offer &&
|
|
|
|
|
e?.BookingTypeName === item?.BookingTypeName &&
|
|
|
|
|
(!e?.SalesId || OrderType == 'Hold')
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
return dispatch(changeOrderCardDetails(data));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
const isCheckFreeProductOutside = OfferFreeProduct?.find(
|
|
|
|
|
(exp) => exp?.InwardDtlId == item?.InwardDtlId
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (!isCheckFreeProductOutside) {
|
|
|
|
|
await ChangeOrderCardDetailsFn({
|
|
|
|
|
BookingTypeName: item?.BookingTypeName,
|
|
|
|
|
BuyProdQty: null,
|
|
|
|
|
OrderQty: item?.OrderQty,
|
|
|
|
|
CompleteRemove: true,
|
|
|
|
|
InwardDtlId: item?.InwardDtlId,
|
|
|
|
|
BuyInwardDtlId: null,
|
|
|
|
|
Offer: item?.Offer,
|
|
|
|
|
OrderRate: item?.OrderRate,
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
const isCheck = GlobalOfferAppliedProductsData?.find(
|
|
|
|
|
(exp) => exp?.InwardDtlId === item?.InwardDtlId
|
|
|
|
|
);
|
|
|
|
|
const FreeProd = OfferFreeProduct?.find(
|
|
|
|
|
(exp) => exp?.InwardDtlId === item?.InwardDtlId
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (isCheck) {
|
|
|
|
|
let inward =
|
|
|
|
|
isCheck?.FreeProductsList?.[0]?.ProdVariantDetails?.[0]
|
|
|
|
|
?.StockDetails?.[0]?.FreeInwardDtlId;
|
|
|
|
|
|
|
|
|
|
let isPaidproduct = tableData?.find(
|
|
|
|
|
(e) =>
|
|
|
|
|
e?.InwardDtlId == inward &&
|
|
|
|
|
e?.Offer == 0 &&
|
|
|
|
|
e?.BookingTypeName == item?.BookingTypeName
|
|
|
|
|
);
|
|
|
|
|
if (isPaidproduct) {
|
|
|
|
|
let ischeckBothBookingType = tableData?.find(
|
|
|
|
|
(e) =>
|
|
|
|
|
e?.InwardDtlId == inward &&
|
|
|
|
|
e?.Offer > 0 &&
|
|
|
|
|
e?.BookingTypeName != item?.BookingTypeName
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
//if any Paid Product is there, we have to Merge With That
|
|
|
|
|
if (ischeckBothBookingType) {
|
|
|
|
|
await ChangeOrderCardDetailsFn({
|
|
|
|
|
BookingTypeName: item?.BookingTypeName,
|
|
|
|
|
BuyProdQty: null,
|
|
|
|
|
OrderQty:
|
|
|
|
|
isPaidproduct?.OrderQty +
|
|
|
|
|
isCheck?.ActualFreeQty -
|
|
|
|
|
ischeckBothBookingType?.OrderQty,
|
|
|
|
|
CompleteRemoveBuyAndAddWithPaid: true,
|
|
|
|
|
InwardDtlId: isPaidproduct?.InwardDtlId,
|
|
|
|
|
BuyInwardDtlId: item?.InwardDtlId,
|
|
|
|
|
Offer: item?.Offer,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await ChangeFreeprodlistFn({
|
|
|
|
|
OverAllFreeQty: FreeProd?.OverAllFreeQty - item?.OrderQty,
|
|
|
|
|
RemainingQty:
|
|
|
|
|
FreeProd?.OverAllFreeQty -
|
|
|
|
|
item?.OrderQty -
|
|
|
|
|
(FreeProd?.FreeQty - item?.OrderQty),
|
|
|
|
|
FreeQty: FreeProd?.FreeQty - item?.OrderQty,
|
|
|
|
|
FreeProdId: FreeProd?.FreeProdId,
|
|
|
|
|
OfferId: FreeProd?.OfferId,
|
|
|
|
|
CompleteRemove: false,
|
|
|
|
|
});
|
|
|
|
|
// await ChangeOfferAppliedProdsFn(isPaidproduct?.InwardDtlId, (isPaidproduct?.OrderRate * isPaidproduct?.OrderQty), isPaidproduct?.OrderQty, true, insideinwardDtlId true)
|
|
|
|
|
await ChangeOfferAppliedProdsFn({
|
|
|
|
|
inwardDtlId: item?.InwardDtlId,
|
|
|
|
|
OfferAmount:
|
|
|
|
|
isPaidproduct?.OrderRate *
|
|
|
|
|
(FreeProd?.FreeQty - item?.OrderQty),
|
|
|
|
|
FreeQty: FreeProd?.FreeQty - item?.OrderQty,
|
|
|
|
|
CompleteRemove: false,
|
|
|
|
|
insideinwardDtlId: false,
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
await ChangeOrderCardDetailsFn({
|
|
|
|
|
BookingTypeName: item?.BookingTypeName,
|
|
|
|
|
BuyProdQty: null,
|
|
|
|
|
OrderQty: isPaidproduct?.OrderQty + isCheck?.ActualFreeQty,
|
|
|
|
|
CompleteRemoveBuyAndAddWithPaid: true,
|
|
|
|
|
InwardDtlId: isPaidproduct?.InwardDtlId,
|
|
|
|
|
BuyInwardDtlId: item?.InwardDtlId,
|
|
|
|
|
Offer: item?.Offer,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await ChangeFreeprodlistFn({
|
|
|
|
|
OverAllFreeQty: item?.OrderQty,
|
|
|
|
|
RemainingQty: item?.OrderQty - isPaidproduct?.OrderQty,
|
|
|
|
|
FreeQty: isPaidproduct?.OrderQty,
|
|
|
|
|
FreeProdId: FreeProd?.FreeProdId,
|
|
|
|
|
OfferId: FreeProd?.OfferId,
|
|
|
|
|
CompleteRemove: true,
|
|
|
|
|
});
|
|
|
|
|
// await ChangeOfferAppliedProdsFn(isPaidproduct?.InwardDtlId, (isPaidproduct?.OrderRate * isPaidproduct?.OrderQty), isPaidproduct?.OrderQty, true, insideinwardDtlId true)
|
|
|
|
|
await ChangeOfferAppliedProdsFn({
|
|
|
|
|
inwardDtlId: item?.InwardDtlId,
|
|
|
|
|
OfferAmount: isPaidproduct?.OrderRate * isPaidproduct?.OrderQty,
|
|
|
|
|
FreeQty: isPaidproduct?.OrderQty,
|
|
|
|
|
CompleteRemove: true,
|
|
|
|
|
insideinwardDtlId: false,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
//have to find if thereis two Booking Type is there
|
|
|
|
|
//Convert That Free Product To Paid Product
|
|
|
|
|
let ischeckBothBookingType = tableData?.find(
|
|
|
|
|
(e) =>
|
|
|
|
|
e?.InwardDtlId == inward &&
|
|
|
|
|
e?.Offer > 0 &&
|
|
|
|
|
e?.BookingTypeName != item?.BookingTypeName
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
let FreeProductSameBookingType = tableData?.find(
|
|
|
|
|
(e) =>
|
|
|
|
|
e?.InwardDtlId == inward &&
|
|
|
|
|
e?.Offer > 0 &&
|
|
|
|
|
e?.BookingTypeName == item?.BookingTypeName
|
|
|
|
|
);
|
|
|
|
|
if (ischeckBothBookingType) {
|
|
|
|
|
//Convert That Free Product To Paid Product
|
|
|
|
|
|
|
|
|
|
//merge that paid product with same booking type
|
|
|
|
|
//decrease free prod list qty
|
|
|
|
|
//change offer applied product qty
|
|
|
|
|
// await ChangeOrderCardDetailsFn(item?.BookingTypeName, null, ischeckBothBookingType?.OrderQty + FreeProductSameBookingType?.OrderQty, false, ischeckBothBookingType?.InwardDtlId, item?.InwardDtlId, item?.Offer, true)
|
|
|
|
|
if (FreeProductSameBookingType?.OrderQty >= item?.OrderQty) {
|
|
|
|
|
await ChangeFreeprodlistFn({
|
|
|
|
|
OverAllFreeQty: FreeProd?.OverAllFreeQty - item?.OrderQty,
|
|
|
|
|
RemainingQty:
|
|
|
|
|
FreeProd?.OverAllFreeQty -
|
|
|
|
|
item?.OrderQty -
|
|
|
|
|
(FreeProd?.FreeQty - item?.OrderQty),
|
|
|
|
|
FreeQty: FreeProd?.FreeQty - item?.OrderQty,
|
|
|
|
|
FreeProdId: FreeProd?.FreeProdId,
|
|
|
|
|
OfferId: FreeProd?.OfferId,
|
|
|
|
|
CompleteRemove: false,
|
|
|
|
|
});
|
|
|
|
|
await ChangeOrderCardDetailsFn({
|
|
|
|
|
BookingTypeName: item?.BookingTypeName,
|
|
|
|
|
BuyProdQty: item?.OrderQty,
|
|
|
|
|
OrderQty: FreeProductSameBookingType?.OrderQty,
|
|
|
|
|
CompleteRemoveconvertFreetoPaidNotCompletely: true,
|
|
|
|
|
InwardDtlId: inward,
|
|
|
|
|
BuyInwardDtlId: item?.InwardDtlId,
|
|
|
|
|
Offer: item?.Offer,
|
|
|
|
|
});
|
|
|
|
|
await ChangeOfferAppliedProdsFn({
|
|
|
|
|
inwardDtlId: item?.InwardDtlId,
|
|
|
|
|
OfferAmount:
|
|
|
|
|
(FreeProd?.FreeQty - item?.OrderQty) *
|
|
|
|
|
ischeckBothBookingType?.OrderRate,
|
|
|
|
|
FreeQty: FreeProd?.FreeQty - item?.OrderQty,
|
|
|
|
|
CompleteRemove: false,
|
|
|
|
|
insideinwardDtlId: false,
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
let data = isCheckFreeProductOutside?.FreeQty - item?.OrderQty;
|
|
|
|
|
//First i Calculate Another Booking Type Qty
|
|
|
|
|
let anotherBookingType = tableData?.find(
|
|
|
|
|
(e) =>
|
|
|
|
|
e?.InwardDtlId == item?.InwardDtlId &&
|
|
|
|
|
e?.Offer == 0 &&
|
|
|
|
|
e?.BookingTypeName != item?.BookingTypeName
|
|
|
|
|
);
|
|
|
|
|
let anotherBookingTypeOffer = tableData?.find(
|
|
|
|
|
(e) =>
|
|
|
|
|
e?.InwardDtlId == inward &&
|
|
|
|
|
e?.Offer > 0 &&
|
|
|
|
|
e?.BookingTypeName != item?.BookingTypeName
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
let diff =
|
|
|
|
|
item?.OrderQty - FreeProductSameBookingType?.OrderQty;
|
|
|
|
|
if (
|
|
|
|
|
(anotherBookingType?.OrderQty || 0) <
|
|
|
|
|
anotherBookingTypeOffer?.OrderQty
|
|
|
|
|
) {
|
|
|
|
|
//paidproduct ischeckBothBookingType?.OrderQty-anotherBookingType?.OrderQty
|
|
|
|
|
//PaidProdcut Current BookingType FreeProductSameBookingType?.OrderQty
|
|
|
|
|
let paidproductAnotherType =
|
|
|
|
|
ischeckBothBookingType?.OrderQty -
|
|
|
|
|
anotherBookingType?.OrderQty;
|
|
|
|
|
let paidproductCurrentType =
|
|
|
|
|
FreeProductSameBookingType?.OrderQty;
|
|
|
|
|
|
|
|
|
|
await ChangeOrderCardDetailsFn({
|
|
|
|
|
BookingTypeName: item?.BookingTypeName,
|
|
|
|
|
BuyProdQty: paidproductAnotherType,
|
|
|
|
|
OrderQty: paidproductCurrentType,
|
|
|
|
|
CompleteRemoveconvertFreetoPaidTwoTypes: true,
|
|
|
|
|
InwardDtlId: inward,
|
|
|
|
|
BuyInwardDtlId: item?.InwardDtlId,
|
|
|
|
|
Offer: item?.Offer,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await ChangeFreeprodlistFn({
|
|
|
|
|
OverAllFreeQty: FreeProd?.OverAllFreeQty - item?.OrderQty,
|
|
|
|
|
RemainingQty:
|
|
|
|
|
FreeProd?.OverAllFreeQty -
|
|
|
|
|
item?.OrderQty -
|
|
|
|
|
(FreeProd?.FreeQty -
|
|
|
|
|
(paidproductCurrentType + paidproductCurrentType)),
|
|
|
|
|
FreeQty:
|
|
|
|
|
FreeProd?.FreeQty -
|
|
|
|
|
(paidproductCurrentType + paidproductCurrentType),
|
|
|
|
|
FreeProdId: FreeProd?.FreeProdId,
|
|
|
|
|
OfferId: FreeProd?.OfferId,
|
|
|
|
|
CompleteRemove: false,
|
|
|
|
|
});
|
|
|
|
|
await ChangeOfferAppliedProdsFn({
|
|
|
|
|
inwardDtlId: item?.InwardDtlId,
|
|
|
|
|
OfferAmount:
|
|
|
|
|
(FreeProd?.FreeQty - item?.OrderQty) *
|
|
|
|
|
ischeckBothBookingType?.OrderRate,
|
|
|
|
|
FreeQty: FreeProd?.FreeQty - item?.OrderQty,
|
|
|
|
|
CompleteRemove: false,
|
|
|
|
|
insideinwardDtlId: false,
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
await ChangeFreeprodlistFn({
|
|
|
|
|
OverAllFreeQty: FreeProd?.OverAllFreeQty - item?.OrderQty,
|
|
|
|
|
RemainingQty:
|
|
|
|
|
FreeProd?.OverAllFreeQty -
|
|
|
|
|
item?.OrderQty -
|
|
|
|
|
(FreeProd?.FreeQty - item?.OrderQty),
|
|
|
|
|
FreeQty: FreeProd?.FreeQty - item?.OrderQty,
|
|
|
|
|
FreeProdId: FreeProd?.FreeProdId,
|
|
|
|
|
OfferId: FreeProd?.OfferId,
|
|
|
|
|
CompleteRemove: false,
|
|
|
|
|
});
|
|
|
|
|
await ChangeOrderCardDetailsFn({
|
|
|
|
|
BookingTypeName: item?.BookingTypeName,
|
|
|
|
|
BuyProdQty: null,
|
|
|
|
|
OrderQty: FreeProductSameBookingType?.OrderQty,
|
|
|
|
|
CompleteRemoveconvertFreetoPaid: true,
|
|
|
|
|
InwardDtlId: inward,
|
|
|
|
|
BuyInwardDtlId: item?.InwardDtlId,
|
|
|
|
|
Offer: item?.Offer,
|
|
|
|
|
});
|
|
|
|
|
await ChangeOfferAppliedProdsFn({
|
|
|
|
|
inwardDtlId: item?.InwardDtlId,
|
|
|
|
|
OfferAmount:
|
|
|
|
|
(FreeProd?.FreeQty - item?.OrderQty) *
|
|
|
|
|
ischeckBothBookingType?.OrderRate,
|
|
|
|
|
FreeQty: FreeProd?.FreeQty - item?.OrderQty,
|
|
|
|
|
CompleteRemove: false,
|
|
|
|
|
insideinwardDtlId: false,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
await ChangeFreeprodlistFn({
|
|
|
|
|
OverAllFreeQty: item?.OrderQty,
|
|
|
|
|
RemainingQty: item?.OrderQty - isPaidproduct?.OrderQty,
|
|
|
|
|
FreeQty: isPaidproduct?.OrderQty,
|
|
|
|
|
FreeProdId: FreeProd?.FreeProdId,
|
|
|
|
|
OfferId: FreeProd?.OfferId,
|
|
|
|
|
CompleteRemove: true,
|
|
|
|
|
});
|
|
|
|
|
await ChangeOrderCardDetailsFn({
|
|
|
|
|
BookingTypeName: item?.BookingTypeName,
|
|
|
|
|
BuyProdQty: null,
|
|
|
|
|
OrderQty: FreeProductSameBookingType?.OrderQty,
|
|
|
|
|
CompleteRemoveconvertFreetoPaid: true,
|
|
|
|
|
InwardDtlId: inward,
|
|
|
|
|
BuyInwardDtlId: item?.InwardDtlId,
|
|
|
|
|
Offer: item?.Offer,
|
|
|
|
|
});
|
|
|
|
|
await ChangeOfferAppliedProdsFn({
|
|
|
|
|
inwardDtlId: item?.InwardDtlId,
|
|
|
|
|
OfferAmount:
|
|
|
|
|
(isCheck?.ActualFreeQty -
|
|
|
|
|
FreeProductSameBookingType?.OrderQty) *
|
|
|
|
|
isPaidproduct?.OrderQty,
|
|
|
|
|
FreeQty:
|
|
|
|
|
isCheck?.ActualFreeQty - FreeProductSameBookingType?.OrderQty,
|
|
|
|
|
CompleteRemove: true,
|
|
|
|
|
insideinwardDtlId: false,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
let ischeckBothBookingType = tableData?.find(
|
|
|
|
|
(e) =>
|
|
|
|
|
e?.InwardDtlId == item?.InwardDtlId &&
|
|
|
|
|
e?.Offer == 0 &&
|
|
|
|
|
e?.BookingTypeName != item?.BookingTypeName
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (ischeckBothBookingType) {
|
|
|
|
|
await ChangeOrderCardDetailsFn({
|
|
|
|
|
BookingTypeName: item?.BookingTypeName,
|
|
|
|
|
BuyProdQty: null,
|
|
|
|
|
OrderQty: 0,
|
|
|
|
|
CompleteRemove: true,
|
|
|
|
|
InwardDtlId: item?.InwardDtlId,
|
|
|
|
|
BuyInwardDtlId: item?.InwardDtlId,
|
|
|
|
|
Offer: item?.Offer,
|
|
|
|
|
});
|
|
|
|
|
await ChangeFreeprodlistFn({
|
|
|
|
|
OverAllFreeQty: FreeProd?.OverAllFreeQty - item?.OrderQty,
|
|
|
|
|
RemainingQty: FreeProd?.OverAllFreeQty - item?.OrderQty,
|
|
|
|
|
FreeQty: 0,
|
|
|
|
|
FreeProdId: FreeProd?.FreeProdId,
|
|
|
|
|
OfferId: FreeProd?.OfferId,
|
|
|
|
|
CompleteRemove: false,
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
await ChangeOrderCardDetailsFn({
|
|
|
|
|
BookingTypeName: item?.BookingTypeName,
|
|
|
|
|
BuyProdQty: null,
|
|
|
|
|
OrderQty: 0,
|
|
|
|
|
CompleteRemove: true,
|
|
|
|
|
InwardDtlId: item?.InwardDtlId,
|
|
|
|
|
BuyInwardDtlId: item?.InwardDtlId,
|
|
|
|
|
Offer: item?.Offer,
|
|
|
|
|
});
|
|
|
|
|
await ChangeFreeprodlistFn({
|
|
|
|
|
OverAllFreeQty: item?.OrderQty,
|
|
|
|
|
RemainingQty: 0,
|
|
|
|
|
FreeQty: 0,
|
|
|
|
|
FreeProdId: FreeProd?.FreeProdId,
|
|
|
|
|
OfferId: FreeProd?.OfferId,
|
|
|
|
|
CompleteRemove: true,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
//Remove From Free ProdList That Entirely
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (tableData?.length === 0) {
|
|
|
|
|
dispatch(ClearOfferAppliedProducts());
|
|
|
|
|
}
|
|
|
|
|
if (!isMobile) {
|
|
|
|
|
const customerDisplayWindow = getCustomerDisplayWindow();
|
|
|
|
|
if (customerDisplayWindow && !customerDisplayWindow.closed) {
|
|
|
|
|
const updatedData = {
|
|
|
|
|
userData: tableData,
|
|
|
|
|
};
|
|
|
|
|
customerDisplayWindow.postMessage(updatedData, '*');
|
|
|
|
|
}
|
|
|
|
|
const timer = setTimeout(() => {
|
|
|
|
|
setTriggerAnimation(false);
|
|
|
|
|
}, 400);
|
|
|
|
|
return () => clearTimeout(timer);
|
|
|
|
|
}
|
|
|
|
|
}, [tableData]);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
setPreviousdataLength(PreviousOrderLength);
|
|
|
|
|
}, [PreviousOrderLength]);
|
|
|
|
|
|
|
|
|
|
const combinedTableData = [
|
|
|
|
|
...(OldtableDataTakeAway || []),
|
|
|
|
|
...(OldtableDataDinein || []),
|
|
|
|
|
...(tableDataTakeAway || []),
|
|
|
|
|
...(tableDataDinein || []),
|
|
|
|
|
];
|
|
|
|
|
|
2026-02-10 19:55:47 +05:30
|
|
|
// Set last row as active when data changes
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (combinedTableData?.length > 0 && activeRowIndex === null) {
|
|
|
|
|
setActiveRowIndex(combinedTableData.length - 1);
|
|
|
|
|
}
|
|
|
|
|
}, [combinedTableData?.length]);
|
|
|
|
|
|
|
|
|
|
// Table navigation
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const handleTableNav = (e) => {
|
|
|
|
|
if (EditQtyCombo || EditRateCombo) return;
|
|
|
|
|
if (!combinedTableData?.length || activeRowIndex === null) return;
|
|
|
|
|
|
|
|
|
|
const visibleCols =
|
|
|
|
|
tableOptions?.filter((opt) =>
|
|
|
|
|
['Item', 'Quantity', 'Rate', 'Total'].includes(opt.OptionName)
|
|
|
|
|
) || [];
|
|
|
|
|
|
|
|
|
|
// Arrow Up/Down - Row navigation
|
|
|
|
|
if (e.key === 'ArrowUp') {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
setActiveRowIndex((prev) => Math.max(0, prev - 1));
|
|
|
|
|
setActiveColIndex(null);
|
|
|
|
|
} else if (e.key === 'ArrowDown') {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
setActiveRowIndex((prev) =>
|
|
|
|
|
Math.min(combinedTableData.length - 1, prev + 1)
|
|
|
|
|
);
|
|
|
|
|
setActiveColIndex(null);
|
|
|
|
|
}
|
|
|
|
|
// Arrow Left/Right - Column navigation
|
|
|
|
|
else if (e.key === 'ArrowLeft') {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
if (activeColIndex === null) {
|
|
|
|
|
setActiveColIndex(visibleCols.length - 1);
|
|
|
|
|
} else {
|
|
|
|
|
setActiveColIndex((prev) => Math.max(0, prev - 1));
|
|
|
|
|
}
|
|
|
|
|
} else if (e.key === 'ArrowRight') {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
if (activeColIndex === null) {
|
|
|
|
|
setActiveColIndex(0);
|
|
|
|
|
} else {
|
|
|
|
|
setActiveColIndex((prev) =>
|
|
|
|
|
Math.min(visibleCols.length - 1, prev + 1)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Tab - Move to next column
|
|
|
|
|
else if (e.key === 'Tab') {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
if (activeColIndex === null) {
|
|
|
|
|
setActiveColIndex(0);
|
|
|
|
|
} else {
|
|
|
|
|
const nextCol = activeColIndex + 1;
|
|
|
|
|
if (nextCol >= visibleCols.length) {
|
|
|
|
|
setActiveColIndex(0);
|
|
|
|
|
if (activeRowIndex < combinedTableData.length - 1) {
|
|
|
|
|
setActiveRowIndex((prev) => prev + 1);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
setActiveColIndex(nextCol);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Enter - Trigger cell action
|
|
|
|
|
else if (e.key === 'Enter' && activeColIndex !== null) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
const row = combinedTableData[activeRowIndex];
|
|
|
|
|
const col = visibleCols[activeColIndex];
|
|
|
|
|
if (row && col && editField) {
|
|
|
|
|
if (col.OptionName === 'Quantity') handleEditQuantityCombo(row);
|
|
|
|
|
else if (col.OptionName === 'Rate') handleEditRateCombo(row);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
window.addEventListener('keydown', handleTableNav);
|
|
|
|
|
return () => window.removeEventListener('keydown', handleTableNav);
|
|
|
|
|
}, [
|
|
|
|
|
activeRowIndex,
|
|
|
|
|
activeColIndex,
|
|
|
|
|
combinedTableData,
|
|
|
|
|
EditQtyCombo,
|
|
|
|
|
EditRateCombo,
|
|
|
|
|
editField,
|
|
|
|
|
tableOptions,
|
|
|
|
|
]);
|
|
|
|
|
|
2026-01-27 18:27:29 +05:30
|
|
|
console.log(combinedTableData, 'combinedTableData', tableData);
|
|
|
|
|
const displayTableData =
|
|
|
|
|
BillOrderPre === 'N' ? [...combinedTableData].reverse() : combinedTableData;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="combo-sales-bill-table">
|
|
|
|
|
<table className="bill-table">
|
|
|
|
|
<thead>
|
|
|
|
|
<tr>
|
|
|
|
|
{tableOptions?.map((item) => (
|
|
|
|
|
<>
|
|
|
|
|
{/* Sl.No */}
|
|
|
|
|
{/* {item.OptionName === 'Sl.No' && BookingTypeBoth && (
|
|
|
|
|
<th className="BillingTable1-table-th" key={item.OptionId}>
|
|
|
|
|
{!isMobile ? <Tooltip title="Serial Number">{''}</Tooltip> : <div>{''}</div>}
|
|
|
|
|
</th>
|
|
|
|
|
)}
|
|
|
|
|
{item.OptionName === 'Sl.No' && !BookingTypeBoth && (
|
|
|
|
|
<th className="BillingTable1-table-th" key={item.OptionId}>
|
|
|
|
|
{!isMobile ? <Tooltip title="Serial Number">Sl.No</Tooltip> : <div>Sl.No</div>}
|
|
|
|
|
</th>
|
|
|
|
|
)} */}
|
|
|
|
|
|
|
|
|
|
{/* HSN Code */}
|
|
|
|
|
{item.OptionName === 'HSNCode' && (
|
|
|
|
|
<th className="hsnCodeTh" key={item.OptionId}>
|
|
|
|
|
HSN Code
|
|
|
|
|
</th>
|
|
|
|
|
)}
|
|
|
|
|
{item.OptionName === 'Item' && (
|
|
|
|
|
<th className="productNameTh" key={item.OptionId}>
|
|
|
|
|
Product Name
|
|
|
|
|
</th>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{/* Barcode */}
|
|
|
|
|
{item.OptionName === 'Barcode' && (
|
|
|
|
|
<th className="barcodeTh" key={item.OptionId}>
|
|
|
|
|
Barcode
|
|
|
|
|
</th>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{/* Quantity */}
|
|
|
|
|
{item.OptionName === 'Quantity' && (
|
|
|
|
|
<th
|
|
|
|
|
className="qtyTh"
|
|
|
|
|
key={item.OptionId}
|
|
|
|
|
onClick={() =>
|
|
|
|
|
tableData?.length > 0 && OpenEditTotalAmount()
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
{!isMobile ? (
|
|
|
|
|
<Tooltip title="Quantity">Qty</Tooltip>
|
|
|
|
|
) : (
|
|
|
|
|
<div>Qty</div>
|
|
|
|
|
)}
|
|
|
|
|
</th>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{/* Rate */}
|
|
|
|
|
{item.OptionName === 'Rate' && (
|
|
|
|
|
<th className="rateTh" key={item.OptionId}>
|
|
|
|
|
{!isMobile ? (
|
|
|
|
|
<Tooltip title="Rate">Rate</Tooltip>
|
|
|
|
|
) : (
|
|
|
|
|
<div>Rate</div>
|
|
|
|
|
)}
|
|
|
|
|
</th>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{/* Disc % */}
|
|
|
|
|
{item.OptionName === 'Discount' && (
|
|
|
|
|
<th className="discPerTh" key={item.OptionId}>
|
|
|
|
|
{!isMobile ? (
|
|
|
|
|
<Tooltip title="Disc %">Disc %</Tooltip>
|
|
|
|
|
) : (
|
|
|
|
|
<div>Disc %</div>
|
|
|
|
|
)}
|
|
|
|
|
</th>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{/* Disc Amt */}
|
|
|
|
|
{item.OptionName === 'Amount' && (
|
|
|
|
|
<th className="discAmtTh" key={item.OptionId}>
|
|
|
|
|
{!isMobile ? (
|
|
|
|
|
<Tooltip title="Disc Amt">Disc Amt</Tooltip>
|
|
|
|
|
) : (
|
|
|
|
|
<div>Disc Amt</div>
|
|
|
|
|
)}
|
|
|
|
|
</th>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{/* Total */}
|
|
|
|
|
{item.OptionName === 'Total' && (
|
|
|
|
|
<th className="totalTh" key={item.OptionId}>
|
|
|
|
|
{!isMobile ? (
|
|
|
|
|
<Tooltip title="Total">Total</Tooltip>
|
|
|
|
|
) : (
|
|
|
|
|
<div>Total</div>
|
|
|
|
|
)}
|
|
|
|
|
</th>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{/* Optional columns */}
|
|
|
|
|
{item.OptionName === 'SalesMan' && (
|
|
|
|
|
<th className="salesManTh" key={item.OptionId}>
|
|
|
|
|
SalesMan
|
|
|
|
|
</th>
|
|
|
|
|
)}
|
|
|
|
|
{item.OptionName === '%' && (
|
|
|
|
|
<th className="percentageTh" key={item.OptionId}>
|
|
|
|
|
%
|
|
|
|
|
</th>
|
|
|
|
|
)}
|
|
|
|
|
{item.OptionName === 'Commission' && (
|
|
|
|
|
<th className="commissionTh" key={item.OptionId}>
|
|
|
|
|
Commission
|
|
|
|
|
</th>
|
|
|
|
|
)}
|
|
|
|
|
{item.OptionName === 'StockId' && (
|
|
|
|
|
<th className="stockIdTh" key={item.OptionId}>
|
|
|
|
|
StockId
|
|
|
|
|
</th>
|
|
|
|
|
)}
|
|
|
|
|
{item.OptionName === 'Points' && (
|
|
|
|
|
<th className="pointsTh" key={item.OptionId}>
|
|
|
|
|
Points
|
|
|
|
|
</th>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{/* Delete */}
|
|
|
|
|
{item.OptionName === 'Delete' && (
|
2026-02-06 13:54:33 +05:30
|
|
|
<th
|
|
|
|
|
className="deleteTh"
|
2026-01-30 10:05:20 +05:30
|
|
|
style={{ textAlign: 'center', width: '80px' }}
|
2026-02-06 13:54:33 +05:30
|
|
|
key={item.OptionId}
|
|
|
|
|
>
|
2026-01-27 18:27:29 +05:30
|
|
|
{tableData?.length > 0 ? (
|
|
|
|
|
<Popconfirm
|
|
|
|
|
title="Delete the items"
|
|
|
|
|
description="Are you sure you want to clear these items?"
|
|
|
|
|
okText="Yes"
|
|
|
|
|
cancelText="No"
|
|
|
|
|
placement="leftTop"
|
2026-01-30 10:05:20 +05:30
|
|
|
onConfirm={() => {
|
|
|
|
|
Clearall();
|
|
|
|
|
}}
|
2026-01-27 18:27:29 +05:30
|
|
|
>
|
|
|
|
|
<div className="del-all-btn">
|
|
|
|
|
{!isMobile ? (
|
|
|
|
|
<Tooltip title="Delete All" placement="left">
|
2026-01-30 10:05:20 +05:30
|
|
|
<AiFillDelete color="#ef4444" size={18} />
|
2026-01-27 18:27:29 +05:30
|
|
|
</Tooltip>
|
|
|
|
|
) : (
|
|
|
|
|
<div>
|
2026-01-30 10:05:20 +05:30
|
|
|
<AiFillDelete color="#ef4444" size={18} />
|
2026-01-27 18:27:29 +05:30
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</Popconfirm>
|
|
|
|
|
) : (
|
|
|
|
|
<div className="del-all-btn">
|
|
|
|
|
{!isMobile ? (
|
|
|
|
|
<Tooltip title="Delete" placement="left">
|
|
|
|
|
<AiFillDelete />
|
|
|
|
|
</Tooltip>
|
|
|
|
|
) : (
|
|
|
|
|
<div>
|
|
|
|
|
<AiFillDelete />
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</th>
|
|
|
|
|
)}
|
|
|
|
|
</>
|
|
|
|
|
))}
|
|
|
|
|
</tr>
|
|
|
|
|
</thead>
|
|
|
|
|
|
|
|
|
|
<tbody>
|
|
|
|
|
{combinedTableData?.map((row, index) => {
|
|
|
|
|
// const rowIndex = index;
|
|
|
|
|
// const isOldOrder = row?.SalesId;
|
|
|
|
|
return (
|
|
|
|
|
<tr
|
|
|
|
|
key={`${row?.InwardDtlId || index}-${row?.BookingTypeName || ''}-${row?.SalesId || ''}-${index}`}
|
2026-02-10 19:55:47 +05:30
|
|
|
className={`${row.highlighted ? 'highlighted-row' : ''} ${activeRowIndex === index ? 'active-row' : ''}`}
|
2026-01-27 18:27:29 +05:30
|
|
|
style={{
|
|
|
|
|
fontFamily: SelectedFont,
|
|
|
|
|
backgroundColor:
|
|
|
|
|
BillOrderPre === 'Y'
|
|
|
|
|
? row?.SalesId &&
|
|
|
|
|
triggerAnimation &&
|
|
|
|
|
OldtableDataTakeAway?.length + index === 0 &&
|
|
|
|
|
!row?.SalesId &&
|
|
|
|
|
tableDataDinein?.length >= PreviousdataLength
|
|
|
|
|
? 'wheat'
|
|
|
|
|
: BookingType !== 'Dine In' &&
|
2026-02-09 14:16:08 +05:30
|
|
|
triggerAnimation &&
|
|
|
|
|
OldtableDataTakeAway?.length + index === 0 &&
|
|
|
|
|
tableDataDinein?.length >= PreviousdataLength &&
|
|
|
|
|
!HoldOrderDtl &&
|
|
|
|
|
!UnpaidData
|
2026-01-27 18:27:29 +05:30
|
|
|
? 'wheat'
|
|
|
|
|
: 'inherit'
|
|
|
|
|
: 'none',
|
|
|
|
|
background: row?.SalesId
|
|
|
|
|
? 'rgb(243, 248, 213)'
|
|
|
|
|
: GlobEstBooking === 'ParEst' &&
|
2026-02-09 14:16:08 +05:30
|
|
|
GlobProdwisedata?.includes(
|
|
|
|
|
row?.InwardDtlId + ' ' + row?.BookingTypeName
|
|
|
|
|
)
|
2026-01-27 18:27:29 +05:30
|
|
|
? '#b2d1f7'
|
|
|
|
|
: (OldtableDataTakeAway?.length + index) % 2 === 0
|
|
|
|
|
? 'white'
|
|
|
|
|
: SelectedBillColor?.['OverallBackgroundColor'],
|
|
|
|
|
|
|
|
|
|
animation:
|
|
|
|
|
BillOrderPre === 'Y' && !BookingTypeBoth
|
|
|
|
|
? triggerAnimation &&
|
|
|
|
|
OldtableDataTakeAway?.length + index === 0 &&
|
|
|
|
|
!row?.SalesId &&
|
|
|
|
|
tableDataDinein?.length >= PreviousdataLength &&
|
|
|
|
|
!HoldOrderDtl &&
|
|
|
|
|
!UnpaidData
|
|
|
|
|
? 'splashAnimation 0.5s ease-in-out'
|
|
|
|
|
: 'none'
|
|
|
|
|
: 'none',
|
|
|
|
|
}}
|
|
|
|
|
>
|
2026-02-10 19:55:47 +05:30
|
|
|
{tableOptions?.map((item, colIdx) => {
|
|
|
|
|
const isActiveCell =
|
|
|
|
|
activeRowIndex === index &&
|
|
|
|
|
activeColIndex !== null &&
|
|
|
|
|
['Item', 'Quantity', 'Rate', 'Total'].indexOf(
|
|
|
|
|
item.OptionName
|
|
|
|
|
) === activeColIndex;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
{/* HSN Code */}
|
|
|
|
|
{item.OptionName === 'HSNCode' && (
|
2026-02-09 14:16:08 +05:30
|
|
|
<td
|
2026-02-10 19:55:47 +05:30
|
|
|
key={`hsn-${index}`}
|
|
|
|
|
className="hsnCodeTd"
|
|
|
|
|
onClick={() => editField && handleEditQuantity(row)}
|
2026-02-09 14:16:08 +05:30
|
|
|
>
|
2026-02-10 19:55:47 +05:30
|
|
|
{row.HSNCode || '-'}
|
2026-02-09 14:16:08 +05:30
|
|
|
</td>
|
|
|
|
|
)}
|
2026-01-27 18:27:29 +05:30
|
|
|
|
2026-02-10 19:55:47 +05:30
|
|
|
{/* Product Name / Item */}
|
|
|
|
|
{(item.OptionName === 'Item' ||
|
|
|
|
|
item.OptionName === 'Product Name') && (
|
|
|
|
|
<td
|
|
|
|
|
key={`prod-${index}`}
|
|
|
|
|
className={`productNameTd ${isActiveCell ? 'active-cell' : ''}`}
|
|
|
|
|
onClick={() =>
|
|
|
|
|
row.FullProductIdentifierDtls?.length > 0 ||
|
|
|
|
|
row.ProductIdentifierDtls?.length > 0
|
|
|
|
|
? handleImeiDetails(row)
|
|
|
|
|
: editField && handleEditQuantity(row)
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
{row?.Type !== 'OS' ? row.ProdName : row.ServiceName}
|
|
|
|
|
{row?.BrandName ? ` ${row.BrandName}` : ''}
|
|
|
|
|
{row?.Type !== 'C' && (
|
|
|
|
|
<p className="Tbl3-Variant">
|
|
|
|
|
{/* {row?.ProdVariantName} {row?.Size} {row?.UomName} */}
|
|
|
|
|
(
|
|
|
|
|
{!row?.ProdVariantName?.toLowerCase()?.includes(
|
|
|
|
|
'variant'
|
|
|
|
|
) && <span>{row?.ProdVariantName} </span>}
|
|
|
|
|
{row?.Size}
|
|
|
|
|
{row?.SinglePc == 'Y' ? 'PCS' : row?.UomName})
|
|
|
|
|
</p>
|
|
|
|
|
)}
|
|
|
|
|
{row?.Type === 'C' &&
|
|
|
|
|
row.ProdDetail?.map((prod, idx) => (
|
|
|
|
|
<p key={idx}>
|
|
|
|
|
{prod.ProdName} - {prod.Size} {prod.UomName}
|
|
|
|
|
</p>
|
|
|
|
|
))}
|
|
|
|
|
</td>
|
|
|
|
|
)}
|
2026-01-27 18:27:29 +05:30
|
|
|
|
2026-02-10 19:55:47 +05:30
|
|
|
{/* Barcode */}
|
|
|
|
|
{item.OptionName === 'Barcode' && (
|
|
|
|
|
<td
|
|
|
|
|
key={`barcode-${index}`}
|
|
|
|
|
className="barcodeTd"
|
|
|
|
|
onClick={() => editField && handleEditQuantity(row)}
|
|
|
|
|
>
|
|
|
|
|
{row.QRCode || '-'}
|
|
|
|
|
</td>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{/* Quantity */}
|
|
|
|
|
{item.OptionName === 'Quantity' && (
|
|
|
|
|
<td
|
|
|
|
|
ref={(el) => {
|
|
|
|
|
if (
|
|
|
|
|
shortKeyMethod === 'qty' &&
|
|
|
|
|
row?.localId === Index
|
|
|
|
|
) {
|
|
|
|
|
el?.focus();
|
|
|
|
|
el?.click();
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
key={`qty-${index}`}
|
|
|
|
|
tabIndex={0}
|
|
|
|
|
className={`${EditQtyCombo && row?.localId === Index
|
2026-02-06 13:54:33 +05:30
|
|
|
? 'EditQTYcomboTD'
|
|
|
|
|
: 'qtyTd'
|
2026-02-10 19:55:47 +05:30
|
|
|
} ${isActiveCell ? 'active-cell' : ''}`}
|
2026-02-06 13:54:33 +05:30
|
|
|
onClick={() =>
|
|
|
|
|
editField && handleEditQuantityCombo(row)
|
|
|
|
|
}
|
2026-02-10 19:55:47 +05:30
|
|
|
>
|
|
|
|
|
{(!EditQtyCombo || row?.localId !== Index) && (
|
|
|
|
|
<>{row.OrderQty}</>
|
|
|
|
|
)}
|
|
|
|
|
{EditQtyCombo && row?.localId === Index && (
|
|
|
|
|
<ComboEditQtyAndRate
|
2026-02-06 13:54:33 +05:30
|
|
|
key={`edit-qty-${Index}`}
|
|
|
|
|
handleEditQuantityCancel={
|
|
|
|
|
handleEditQuantityComboCancel
|
|
|
|
|
}
|
|
|
|
|
BSBillingEditQuantity={EditQtyCombo}
|
|
|
|
|
Productdata={Modaldata}
|
|
|
|
|
Index={Index}
|
|
|
|
|
setIndex={setIndex}
|
|
|
|
|
setEditQtyCombo={setEditQtyCombo}
|
2026-02-10 19:55:47 +05:30
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</td>
|
|
|
|
|
)}
|
2026-01-27 18:27:29 +05:30
|
|
|
|
2026-02-10 19:55:47 +05:30
|
|
|
{/* Rate */}
|
|
|
|
|
{item.OptionName === 'Rate' && (
|
|
|
|
|
<td
|
|
|
|
|
key={`rate-${index}`}
|
|
|
|
|
className={`${EditRateCombo ? 'rateTdEditRate' : 'rateTd'} ${isActiveCell ? 'active-cell' : ''}`}
|
|
|
|
|
onClick={() => editField && handleEditRateCombo(row)}
|
|
|
|
|
>
|
2026-02-06 13:54:33 +05:30
|
|
|
{!EditRateCombo || row?.localId !== Index ? (
|
2026-02-10 19:55:47 +05:30
|
|
|
<>
|
|
|
|
|
{allowDecimal
|
|
|
|
|
? Number(row?.OrderRate).toFixed(2)
|
|
|
|
|
: Number(row?.OrderRate)}
|
|
|
|
|
</>
|
2026-02-06 13:54:33 +05:30
|
|
|
) : null}
|
2026-02-10 19:55:47 +05:30
|
|
|
{EditRateCombo && row?.localId === Index && (
|
|
|
|
|
<ComboEditQtyAndRate
|
2026-02-06 13:54:33 +05:30
|
|
|
key={`edit-rate-${Index}`}
|
|
|
|
|
handleEditRateComboCancel={
|
|
|
|
|
handleEditRateComboCancel
|
|
|
|
|
}
|
|
|
|
|
BSBillingEditRate={EditRateCombo}
|
|
|
|
|
Productdata={Modaldata}
|
|
|
|
|
Index={Index}
|
|
|
|
|
setIndex={setIndex}
|
|
|
|
|
setEditRateCombo={setEditRateCombo}
|
2026-02-10 19:55:47 +05:30
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</td>
|
|
|
|
|
)}
|
2026-01-27 18:27:29 +05:30
|
|
|
|
2026-02-10 19:55:47 +05:30
|
|
|
{/* Disc % */}
|
|
|
|
|
{item.OptionName === 'Discount' && (
|
|
|
|
|
<td
|
|
|
|
|
key={`discPer-${index}`}
|
|
|
|
|
className="discPerTd"
|
|
|
|
|
onClick={() => editField && handleEditQuantity(row)}
|
|
|
|
|
>
|
|
|
|
|
{row?.Offer > 0
|
|
|
|
|
? `${(
|
|
|
|
|
(row.Offer / (row?.OrderQty * row?.OrderRate)) *
|
|
|
|
|
100
|
|
|
|
|
).toFixed(2)}%`
|
|
|
|
|
: '-'}
|
|
|
|
|
</td>
|
|
|
|
|
)}
|
2026-01-27 18:27:29 +05:30
|
|
|
|
2026-02-10 19:55:47 +05:30
|
|
|
{/* Disc Amt */}
|
|
|
|
|
{item.OptionName === 'Amount' && (
|
|
|
|
|
<td
|
|
|
|
|
key={`discAmt-${index}`}
|
|
|
|
|
className="discAmtTd"
|
|
|
|
|
onClick={() => editField && handleEditQuantity(row)}
|
|
|
|
|
>
|
|
|
|
|
{row.Offer || '-'}
|
|
|
|
|
</td>
|
|
|
|
|
)}
|
2026-01-27 18:27:29 +05:30
|
|
|
|
2026-02-10 19:55:47 +05:30
|
|
|
{/* Total */}
|
|
|
|
|
{item.OptionName === 'Total' && (
|
|
|
|
|
<td
|
|
|
|
|
key={`total-${index}`}
|
|
|
|
|
className={`totalTd ${isActiveCell ? 'active-cell' : ''}`}
|
|
|
|
|
onClick={() => {
|
|
|
|
|
// if (editField) {
|
|
|
|
|
// handleEditQuantity(row)
|
|
|
|
|
// }
|
|
|
|
|
if (GetCustId) {
|
|
|
|
|
handleCustomerProductPriceHistory(row);
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{allowDecimal
|
|
|
|
|
? Number(row.TotalAmt - (row?.Offer || 0)).toFixed(
|
|
|
|
|
2
|
|
|
|
|
)
|
|
|
|
|
: Number(row.TotalAmt - (row?.Offer || 0))}
|
|
|
|
|
</td>
|
|
|
|
|
)}
|
2026-01-27 18:27:29 +05:30
|
|
|
|
2026-02-10 19:55:47 +05:30
|
|
|
{/* Optional columns */}
|
|
|
|
|
{item.OptionName === 'SalesMan' && (
|
|
|
|
|
<td key={`salesMan-${index}`} className="salesManTd">
|
|
|
|
|
{row.salesMan || '-'}
|
|
|
|
|
</td>
|
|
|
|
|
)}
|
|
|
|
|
{item.OptionName === '%' && (
|
|
|
|
|
<td
|
|
|
|
|
key={`percentage-${index}`}
|
|
|
|
|
className="percentageTd"
|
|
|
|
|
>
|
|
|
|
|
{row.percentage || '-'}
|
|
|
|
|
</td>
|
|
|
|
|
)}
|
|
|
|
|
{item.OptionName === 'Commission' && (
|
|
|
|
|
<td
|
|
|
|
|
key={`commission-${index}`}
|
|
|
|
|
className="commissionTd"
|
|
|
|
|
>
|
|
|
|
|
{row.commission || '-'}
|
|
|
|
|
</td>
|
|
|
|
|
)}
|
|
|
|
|
{item.OptionName === 'StockId' && (
|
|
|
|
|
<td key={`stockId-${index}`} className="stockIdTd">
|
|
|
|
|
{row.stockId || '-'}
|
|
|
|
|
</td>
|
|
|
|
|
)}
|
|
|
|
|
{item.OptionName === 'Points' && (
|
|
|
|
|
<td key={`points-${index}`} className="pointsTd">
|
|
|
|
|
{row.points || '-'}
|
|
|
|
|
</td>
|
|
|
|
|
)}
|
2026-01-27 18:27:29 +05:30
|
|
|
|
2026-02-10 19:55:47 +05:30
|
|
|
{/* Delete */}
|
|
|
|
|
{item.OptionName === 'Delete' && (
|
|
|
|
|
<td key={`delete-${index}`} className="deleteTd">
|
|
|
|
|
<AiOutlineClose
|
|
|
|
|
onClick={() => removeFromCart(row)}
|
|
|
|
|
style={{
|
|
|
|
|
color: '#FF4D4F',
|
|
|
|
|
cursor: 'pointer',
|
|
|
|
|
textAlign: 'center',
|
|
|
|
|
width: '100%',
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</td>
|
|
|
|
|
)}
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
})}
|
2026-01-27 18:27:29 +05:30
|
|
|
</tr>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
{OpenEditTotalAmt && (
|
|
|
|
|
<BSEditTotalAmt
|
|
|
|
|
EditTotalOpen={OpenEditTotalAmt}
|
|
|
|
|
EditTotalClose={handleEditTotalAmountCancel}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
{OpenImeiDetail && (
|
|
|
|
|
<BSImeiDetails
|
|
|
|
|
DeviceDetails={OpenImeiDetail}
|
|
|
|
|
handleDeviceDetailClose={handleImeiDetailClose}
|
|
|
|
|
ProductDetail={Modaldata}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
{EditQuantity && (
|
|
|
|
|
<BSBillingEditQuantity
|
|
|
|
|
handleEditQuantityCancel={handleEditQuantityCancel}
|
|
|
|
|
BSBillingEditQuantity={EditQuantity}
|
|
|
|
|
Productdata={Modaldata}
|
|
|
|
|
Index={Index}
|
2026-02-06 13:54:33 +05:30
|
|
|
setIndex={setIndex}
|
2026-01-27 18:27:29 +05:30
|
|
|
/>
|
|
|
|
|
)}
|
2026-02-06 13:54:33 +05:30
|
|
|
{customerPriceHistoryOpen && GetCustId && (
|
2026-02-05 15:53:37 +05:30
|
|
|
<CustomerPriceHistory
|
|
|
|
|
open={customerPriceHistoryOpen}
|
|
|
|
|
custId={GetCustId}
|
|
|
|
|
setCustomerPriceHistoryOpen={setCustomerPriceHistoryOpen}
|
|
|
|
|
customerProduct={customerProduct}
|
|
|
|
|
setCustomerProduct={setCustomerProduct}
|
|
|
|
|
selectedCustomer={selectedCustomer}
|
|
|
|
|
/>
|
2026-02-06 13:54:33 +05:30
|
|
|
)}
|
2026-01-27 18:27:29 +05:30
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default ComboSalesBillTable;
|