Merge pull request 'combo-table8-Hold-qty-edit-issue' (#151) from combo-table8-Hold-qty-edit-issue into main
Reviewed-on: Pozomind/pozo-retail-app#151
This commit is contained in:
commit
5aff627aa7
|
|
@ -36,8 +36,10 @@ const ComboEditQtyAndRate = (props) => {
|
|||
const formRef = useRef(null);
|
||||
const quantityInputRef = useRef(null);
|
||||
const priceChangeInputRef = useRef(null);
|
||||
const modalRef = useRef(null);
|
||||
const { setIndex = () => {}, setEditQtyCombo = () => {}, setEditRateCombo = () => {} } = props;
|
||||
|
||||
|
||||
const [disableSubmitButton, setDisableSubmitButton] = useState(false);
|
||||
const SessionData = useSelector(StoredSessionData);
|
||||
// const AppId = SessionData?.AppId;
|
||||
|
|
@ -139,14 +141,21 @@ const ComboEditQtyAndRate = (props) => {
|
|||
}, [RadioBtnSelection, props.BSBillingEditQuantity, props.BSBillingEditRate]);
|
||||
|
||||
useEffect(() => {
|
||||
const handleKeyDown = (event) => {
|
||||
if (preferenceshortcutkey && event.shiftKey && event.key === 'E') {
|
||||
event.preventDefault();
|
||||
if (PriceChangeaccess && props.Productdata?.Offer <= 0) {
|
||||
onRadioBtnChange('Price');
|
||||
}
|
||||
}
|
||||
};
|
||||
const handleKeyDown = (event) => {
|
||||
const navigationKeys = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'];
|
||||
if (event.key === 'Escape' || navigationKeys.includes(event.key)) {
|
||||
event.preventDefault();
|
||||
if (props.BSBillingEditQuantity) {
|
||||
props.handleEditQuantityCancel?.();
|
||||
setEditQtyCombo(false);
|
||||
}
|
||||
if (props.BSBillingEditRate) {
|
||||
props.handleEditRateComboCancel?.();
|
||||
setEditRateCombo(false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
if (EditOpen) {
|
||||
document.addEventListener('keydown', handleKeyDown);
|
||||
|
|
@ -160,8 +169,12 @@ const ComboEditQtyAndRate = (props) => {
|
|||
preferenceshortcutkey,
|
||||
PriceChangeaccess,
|
||||
props.Productdata?.Offer,
|
||||
props.BSBillingEditQuantity,
|
||||
props.BSBillingEditRate,
|
||||
]);
|
||||
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
const BillOrder = SettingDataSelector?.[0]?.SettingDtlDetails?.find(
|
||||
(item) => item.SettingIdName === 'BillItemsOrder'
|
||||
|
|
@ -3203,6 +3216,7 @@ const ComboEditQtyAndRate = (props) => {
|
|||
ref={quantityInputRef}
|
||||
type="number"
|
||||
value={Quantity}
|
||||
min="0"
|
||||
onChange={(e) => setQuantity(e.target.value)}
|
||||
onBlur={() => {
|
||||
if (Quantity && Quantity.trim() !== '') {
|
||||
|
|
|
|||
|
|
@ -125,7 +125,6 @@ const ComboSalesBillTable = () => {
|
|||
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);
|
||||
|
|
@ -236,6 +235,48 @@ const ComboSalesBillTable = () => {
|
|||
}
|
||||
}
|
||||
}, [tableOptions]);
|
||||
|
||||
// Merge same items in hold order
|
||||
useEffect(() => {
|
||||
if (OrderType === 'Hold' && tableData?.length > 0) {
|
||||
const mergedData = [];
|
||||
const processedIds = new Set();
|
||||
|
||||
tableData.forEach((item) => {
|
||||
const key = `${item.InwardDtlId}-${item.BookingTypeName}-${item.OrderRate}`;
|
||||
|
||||
if (processedIds.has(key)) return;
|
||||
|
||||
// Find all items with same InwardDtlId, BookingTypeName, and OrderRate
|
||||
const sameItems = tableData.filter(
|
||||
(i) =>
|
||||
i.InwardDtlId === item.InwardDtlId &&
|
||||
i.BookingTypeName === item.BookingTypeName &&
|
||||
i.OrderRate === item.OrderRate
|
||||
);
|
||||
|
||||
if (sameItems.length > 1) {
|
||||
// Merge quantities
|
||||
const totalQty = sameItems.reduce((sum, i) => sum + i.OrderQty, 0);
|
||||
const mergedItem = {
|
||||
...sameItems[0],
|
||||
OrderQty: totalQty,
|
||||
TotalAmt: totalQty * item.OrderRate,
|
||||
TaxAmt: ((totalQty * item.OrderRate * item.TaxPercentage) / (100 + item.TaxPercentage)),
|
||||
};
|
||||
mergedData.push(mergedItem);
|
||||
} else {
|
||||
mergedData.push(item);
|
||||
}
|
||||
|
||||
processedIds.add(key);
|
||||
});
|
||||
if (mergedData.length !== tableData.length) {
|
||||
dispatch(changeOrderCardDetails(mergedData));
|
||||
}
|
||||
}
|
||||
}, [tableData?.length, OrderType]);
|
||||
|
||||
useEffect(() => {
|
||||
if (SelectedFont) {
|
||||
WebFont.load({
|
||||
|
|
@ -347,7 +388,7 @@ const ComboSalesBillTable = () => {
|
|||
if (OtherServicesglobal && value.Type == 'OS' && value.ServiceType == 'I') {
|
||||
setEditQuantity(false);
|
||||
} else {
|
||||
if (value?.SalesId) {
|
||||
if (value?.SalesId && OrderType !== 'Hold') {
|
||||
setEditQuantity(false);
|
||||
} else {
|
||||
setEditQuantity(true);
|
||||
|
|
@ -360,7 +401,7 @@ const ComboSalesBillTable = () => {
|
|||
if (OtherServicesglobal && value.Type == 'OS' && value.ServiceType == 'I') {
|
||||
setEditQtyCombo(false);
|
||||
} else {
|
||||
if (value?.SalesId) {
|
||||
if (value?.SalesId && OrderType !== 'Hold') {
|
||||
setEditQtyCombo(false);
|
||||
} else {
|
||||
setEditQtyCombo(true);
|
||||
|
|
@ -374,7 +415,7 @@ const ComboSalesBillTable = () => {
|
|||
if (OtherServicesglobal && value.Type == 'OS' && value.ServiceType == 'I') {
|
||||
setEditRateCombo(false);
|
||||
} else {
|
||||
if (value?.SalesId) {
|
||||
if (value?.SalesId && OrderType !== 'Hold') {
|
||||
setEditRateCombo(false);
|
||||
} else {
|
||||
setEditRateCombo(true);
|
||||
|
|
@ -2196,7 +2237,6 @@ const ComboSalesBillTable = () => {
|
|||
tableOptions,
|
||||
]);
|
||||
|
||||
console.log(combinedTableData, 'combinedTableData', tableData);
|
||||
const displayTableData =
|
||||
BillOrderPre === 'N' ? [...combinedTableData].reverse() : combinedTableData;
|
||||
|
||||
|
|
@ -2410,7 +2450,7 @@ const ComboSalesBillTable = () => {
|
|||
? 'wheat'
|
||||
: 'inherit'
|
||||
: 'none',
|
||||
background: row?.SalesId
|
||||
background: row?.SalesId && OrderType !== 'Hold'
|
||||
? 'rgb(243, 248, 213)'
|
||||
: GlobEstBooking === 'ParEst' &&
|
||||
GlobProdwisedata?.includes(
|
||||
|
|
|
|||
|
|
@ -1204,6 +1204,7 @@ export default function BSC1Search(props) {
|
|||
let ProdNamedata = ProductList?.find((item) => item.ProdName === data);
|
||||
const removedDefault = removeDefaultVariantStock(ProdNamedata);
|
||||
setSelectedProduct(removedDefault);
|
||||
formRef.current.resetFields(['ItemName']);
|
||||
};
|
||||
const ProductSelected = (item) => {
|
||||
if (item.OverAllExpStatus == 'Y') {
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ const PublicQrCodeShare = (qrCodeUrl) => {
|
|||
toEmail: toEmail,
|
||||
type: 'M',
|
||||
fileUrl: qrCodeUrl.qrCodeUrl,
|
||||
HeaderType:"SelfBooking"
|
||||
};
|
||||
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in New Issue