Merge pull request 'FIX #51 Issue Solving for updated' (#52) from newdeployment into main

Reviewed-on: Pozomind/pozo-retail-app#52
This commit is contained in:
karthikalakshmi 2026-02-02 19:36:00 +05:30
commit 441aab2d70
3 changed files with 480 additions and 409 deletions

View File

@ -101,7 +101,7 @@ export const getPurProdvaraiantdata = createAsyncThunk(
data?.prodName !== undefined data?.prodName !== undefined
) { ) {
return await axiosRetailInstanceData.get( return await axiosRetailInstanceData.get(
`/ProductCardList?CompId=${data?.CompId}&BranchId=${data?.BranchId}&AppId=${data?.AppId}&prodName=${encodeURIComponent(data?.prodName)}` `/ProductCardList?CompId=${data?.CompId}&BranchId=${data?.BranchId}&AppId=${data?.AppId}&prodName=${encodeURIComponent(data?.prodName)}&type=S`
); );
} }
} }

View File

@ -327,7 +327,10 @@ const BSC1Payment = (props) => {
)?.PreferenceCatDetails; )?.PreferenceCatDetails;
const sportsAppPreference = commonModulePreference?.find( const sportsAppPreference = commonModulePreference?.find(
(preference) => preference?.PreferredSubCatName === 'SportsApp' (preference) => preference?.PreferredSubCatName === 'SportsApp'
&&
preference?.PreferredStatus == 'Y'
); );
console.log(sportsAppPreference,commonModulePreference,"sportsAppPreference")
const bookingTypePreference = appPreferences?.find( const bookingTypePreference = appPreferences?.find(
(preference) => preference?.PreferredCatName === 'Booking Type' (preference) => preference?.PreferredCatName === 'Booking Type'
)?.PreferenceCatDetails; )?.PreferenceCatDetails;

View File

@ -1,18 +1,32 @@
import { shallowEqual, useSelector } from "react-redux"; import { shallowEqual, useSelector } from 'react-redux';
import { GlobalAccessForOthers, GlobalCardAccess, GlobalCombosearch, GlobalItemCard, GlobalProductCategorie, GlobalSelectedDatas, GlobalWithoutSubCatItemCard, triggerProductCard } from "../../../../Features/BookingScreen/BookingData/BookingData"; import {
import { DefaultModal } from "../../../../Components/Modal/DefaultModal"; GlobalAccessForOthers,
import { useCallback, useEffect, useRef, useState } from "react"; GlobalCardAccess,
import { Tables } from "../../../../Components/Tables/Table"; GlobalCombosearch,
import { InputField } from "../../../../Components/Forms/InputField"; GlobalItemCard,
import { Form, Pagination, Tooltip } from "antd"; GlobalProductCategorie,
import { getSession } from "../../../../Services/Others"; GlobalSelectedDatas,
import { Messages } from "../../../../Components/Notifications/Messages"; GlobalWithoutSubCatItemCard,
import { useDispatch } from "react-redux"; triggerProductCard,
import { PutStockPrice } from "../../../../Features/StockPriceUpdate/StockPriceUpdateMaster"; } from '../../../../Features/BookingScreen/BookingData/BookingData';
import PriceChange from "../../../../Images/PayOptImgs/PriceChange.svg" import { DefaultModal } from '../../../../Components/Modal/DefaultModal';
import { useCallback, useEffect, useRef, useState } from 'react';
const ProductPriceChange = ({ showButton = true, priceChangeProduct = null, productPriceChange = false, setProductPriceChange = () => { }, setPriceChangeProduct = () => { } }) => { import { Tables } from '../../../../Components/Tables/Table';
import { InputField } from '../../../../Components/Forms/InputField';
import { Form, Pagination, Tooltip } from 'antd';
import { getSession } from '../../../../Services/Others';
import { Messages } from '../../../../Components/Notifications/Messages';
import { useDispatch } from 'react-redux';
import { PutStockPrice } from '../../../../Features/StockPriceUpdate/StockPriceUpdateMaster';
import PriceChange from '../../../../Images/PayOptImgs/PriceChange.svg';
const ProductPriceChange = ({
showButton = true,
priceChangeProduct = [],
productPriceChange = false,
setProductPriceChange = () => {},
setPriceChangeProduct = () => {},
}) => {
const formRef = useRef(null); const formRef = useRef(null);
const dispatch = useDispatch(); const dispatch = useDispatch();
@ -32,20 +46,32 @@ const ProductPriceChange = ({ showButton = true, priceChangeProduct = null, prod
const comboSearch = useSelector(GlobalCombosearch); const comboSearch = useSelector(GlobalCombosearch);
const ProdCat = useSelector(GlobalProductCategorie, shallowEqual); const ProdCat = useSelector(GlobalProductCategorie, shallowEqual);
const ItemCard = useSelector(GlobalItemCard, shallowEqual); const ItemCard = useSelector(GlobalItemCard, shallowEqual);
const withoutSubCatItemCard = useSelector(GlobalWithoutSubCatItemCard, shallowEqual); const withoutSubCatItemCard = useSelector(
GlobalWithoutSubCatItemCard,
shallowEqual
);
const CardAccess = useSelector(GlobalCardAccess, shallowEqual); const CardAccess = useSelector(GlobalCardAccess, shallowEqual);
const globalAccessForOthers = useSelector(GlobalAccessForOthers, shallowEqual); const globalAccessForOthers = useSelector(
GlobalAccessForOthers,
shallowEqual
);
const SelectedDatas = useSelector(GlobalSelectedDatas, shallowEqual); const SelectedDatas = useSelector(GlobalSelectedDatas, shallowEqual);
const [tableData, setTableData] = useState([]); const [tableData, setTableData] = useState([]);
const [editingKey, setEditingKey] = useState(null); const [editingKey, setEditingKey] = useState(null);
const [priceChangedProducts, setPriceChangedProducts] = useState([]); const [priceChangedProducts, setPriceChangedProducts] = useState([]);
console.log(comboSearch, "comboSearch") console.log(comboSearch, 'comboSearch');
// console.log(noSubcatCardData, "noSubcatCardData") // console.log(noSubcatCardData, "noSubcatCardData")
useEffect(() => { useEffect(() => {
if (ProdCat && (ItemCard || withoutSubCatItemCard) && (!noSubcatCardData || noSubcatCardData?.length === 0)) { if (
setNoSubcatCardData(ItemCard?.length === 0 ? withoutSubCatItemCard : ItemCard); ProdCat &&
(ItemCard || withoutSubCatItemCard) &&
(!noSubcatCardData || noSubcatCardData?.length === 0)
) {
setNoSubcatCardData(
ItemCard?.length === 0 ? withoutSubCatItemCard : ItemCard
);
} }
}, [ProdCat, ItemCard, withoutSubCatItemCard, noSubcatCardData]); }, [ProdCat, ItemCard, withoutSubCatItemCard, noSubcatCardData]);
@ -56,7 +82,9 @@ const ProductPriceChange = ({ showButton = true, priceChangeProduct = null, prod
key: 'SlNo', key: 'SlNo',
width: '60px', width: '60px',
align: 'center', align: 'center',
render: (text, record, index) => <div>{(currentPage - 1) * pageSize + index + 1}</div> render: (text, record, index) => (
<div>{(currentPage - 1) * pageSize + index + 1}</div>
),
}, },
{ {
title: 'Product Name', title: 'Product Name',
@ -90,22 +118,20 @@ const ProductPriceChange = ({ showButton = true, priceChangeProduct = null, prod
if (value === '') { if (value === '') {
return Promise.resolve(); return Promise.resolve();
} else if (parseFloat(value) < 1) { } else if (parseFloat(value) < 1) {
return Promise.reject(`MRP should be greater than 0`) return Promise.reject(`MRP should be greater than 0`);
} }
return Promise.resolve(); return Promise.resolve();
}, },
}, },
]}> ]}
>
<InputField <InputField
value={text} value={text}
placeholder="Enter New MRP" placeholder="Enter New MRP"
onChange={(e) => handleNewMRPChange(e?.target?.value, index)} onChange={(e) => handleNewMRPChange(e?.target?.value, index)}
inputMode="decimal" inputMode="decimal"
onInput={(e) => { onInput={(e) => {
let cleanedValue = e.target.value.replace( let cleanedValue = e.target.value.replace(/[^0-9.]/g, ''); // Remove invalid characters
/[^0-9.]/g,
''
); // Remove invalid characters
const parts = cleanedValue.split('.'); const parts = cleanedValue.split('.');
if (cleanedValue.startsWith('.')) { if (cleanedValue.startsWith('.')) {
@ -149,7 +175,9 @@ const ProductPriceChange = ({ showButton = true, priceChangeProduct = null, prod
if (value === '') { if (value === '') {
return Promise.resolve(); return Promise.resolve();
} else if (parseFloat(value) < 1) { } else if (parseFloat(value) < 1) {
return Promise.reject(`Sell Price should be greater than 0`) return Promise.reject(
`Sell Price should be greater than 0`
);
} }
return Promise.resolve(); return Promise.resolve();
}, },
@ -159,13 +187,12 @@ const ProductPriceChange = ({ showButton = true, priceChangeProduct = null, prod
<InputField <InputField
value={text} value={text}
placeholder="Enter New Sell Price" placeholder="Enter New Sell Price"
onChange={(e) => handleNewSellPriceChange(e?.target?.value, index)} onChange={(e) =>
handleNewSellPriceChange(e?.target?.value, index)
}
inputMode="decimal" inputMode="decimal"
onInput={(e) => { onInput={(e) => {
let cleanedValue = e.target.value.replace( let cleanedValue = e.target.value.replace(/[^0-9.]/g, ''); // Remove invalid characters
/[^0-9.]/g,
''
); // Remove invalid characters
const parts = cleanedValue.split('.'); const parts = cleanedValue.split('.');
if (cleanedValue.startsWith('.')) { if (cleanedValue.startsWith('.')) {
@ -191,49 +218,57 @@ const ProductPriceChange = ({ showButton = true, priceChangeProduct = null, prod
: SelectedDatas?.[0]?.AppId === 0 && SelectedDatas?.[0]?.CompId === 0 : SelectedDatas?.[0]?.AppId === 0 && SelectedDatas?.[0]?.CompId === 0
? [] ? []
: SelectedDatas : SelectedDatas
: ItemCard?.length === 0 || (ItemCard?.[0]?.AppId === 0 && ItemCard?.[0]?.CompId === 0) : ItemCard?.length === 0 ||
(ItemCard?.[0]?.AppId === 0 && ItemCard?.[0]?.CompId === 0)
? noSubcatCardData ? noSubcatCardData
: ItemCard : ItemCard
: ''; : [];
console.log(cardData, "noSubcatCardDatanoSubcatCardData", ItemCard) console.log(cardData, 'noSubcatCardDatanoSubcatCardData', ItemCard);
useEffect(() => { useEffect(() => {
const extractStockDtls = (data) => { const extractStockDtls = (data) => {
if (data?.length === 0) return []; if (data?.length === 0 || !data) return [];
let stockDtls = []; let stockDtls = [];git
data?.forEach(item => { data?.forEach((item) => {
let products = item?.ProductDetail?.flatMap(product => product); let products = item?.ProductDetail?.flatMap((product) => product);
let variants = products?.flatMap(product => product?.ProdVariantDetails); let variants = products?.flatMap(
const filteredVariants = variants?.filter(variant => variant?.StockDetails?.length > 0); (product) => product?.ProdVariantDetails
const stocks = filteredVariants?.flatMap(variant => );
variant?.StockDetails?.map(stock => ({ const filteredVariants = variants?.filter(
(variant) => variant?.StockDetails?.length > 0
);
const stocks = filteredVariants?.flatMap((variant) =>
variant?.StockDetails?.map((stock) => ({
...stock, ...stock,
ProdName: products?.[0]?.ProdName + (variant?.ProdVariantName ? ` (${variant?.ProdVariantName})` : ''), ProdName:
products?.[0]?.ProdName +
(variant?.ProdVariantName
? ` (${variant?.ProdVariantName})`
: ''),
StockAvailable: products?.[0]?.StockAvailable, StockAvailable: products?.[0]?.StockAvailable,
ProdVariantName: variant?.ProdVariantName ProdVariantName: variant?.ProdVariantName,
})) }))
); );
stockDtls.push(...stocks?.filter(stock => stockDtls.push(
stock?.StockAvailable === 'Y' ...stocks?.filter((stock) =>
? stock?.BatchRef stock?.StockAvailable === 'Y' ? stock?.BatchRef : true
: true )
)); );
}); });
console.log("extractStockDtls", stockDtls); console.log('extractStockDtls', stockDtls);
return stockDtls; return stockDtls;
} };
setTableData(extractStockDtls(priceChangeProduct || cardData)) setTableData(extractStockDtls(priceChangeProduct || cardData || []));
setCurrentPage(1) setCurrentPage(1);
}, [cardData, priceChangeProduct]) }, [cardData, priceChangeProduct]);
const handleNewMRPChange = (value, index) => { const handleNewMRPChange = (value, index) => {
const updatedTableData = [...tableData]; const updatedTableData = [...tableData];
updatedTableData[index].NewMRP = value; updatedTableData[index].NewMRP = value;
setTableData(updatedTableData); setTableData(updatedTableData);
@ -244,7 +279,9 @@ const ProductPriceChange = ({ showButton = true, priceChangeProduct = null, prod
}); });
const priceChangedProdList = [...priceChangedProducts]; const priceChangedProdList = [...priceChangedProducts];
const prodIndex = priceChangedProdList?.findIndex(prod => prod?.InwardDtlId === updatedTableData[index]?.InwardDtlId); const prodIndex = priceChangedProdList?.findIndex(
(prod) => prod?.InwardDtlId === updatedTableData[index]?.InwardDtlId
);
if (prodIndex !== -1) { if (prodIndex !== -1) {
priceChangedProdList[prodIndex] = { priceChangedProdList[prodIndex] = {
...priceChangedProdList?.[prodIndex], ...priceChangedProdList?.[prodIndex],
@ -253,7 +290,7 @@ const ProductPriceChange = ({ showButton = true, priceChangeProduct = null, prod
}; };
} }
setPriceChangedProducts(priceChangedProdList); setPriceChangedProducts(priceChangedProdList);
} };
const handleNewSellPriceChange = (value, index) => { const handleNewSellPriceChange = (value, index) => {
const updatedTableData = [...tableData]; const updatedTableData = [...tableData];
@ -267,7 +304,9 @@ const ProductPriceChange = ({ showButton = true, priceChangeProduct = null, prod
updatedTableData[index].NewSellPrice = null; updatedTableData[index].NewSellPrice = null;
setTableData(updatedTableData); setTableData(updatedTableData);
const priceChangedProdList = [...priceChangedProducts]; const priceChangedProdList = [...priceChangedProducts];
const prodIndex = priceChangedProdList?.findIndex(prod => prod?.InwardDtlId === updatedTableData[index]?.InwardDtlId); const prodIndex = priceChangedProdList?.findIndex(
(prod) => prod?.InwardDtlId === updatedTableData[index]?.InwardDtlId
);
if (prodIndex !== -1) { if (prodIndex !== -1) {
priceChangedProdList.splice(prodIndex, 1); priceChangedProdList.splice(prodIndex, 1);
@ -286,7 +325,9 @@ const ProductPriceChange = ({ showButton = true, priceChangeProduct = null, prod
updatedTableData[index].NewSellPrice = null; updatedTableData[index].NewSellPrice = null;
setTableData(updatedTableData); setTableData(updatedTableData);
const priceChangedProdList = [...priceChangedProducts]; const priceChangedProdList = [...priceChangedProducts];
const prodIndex = priceChangedProdList?.findIndex(prod => prod?.InwardDtlId === updatedTableData[index]?.InwardDtlId); const prodIndex = priceChangedProdList?.findIndex(
(prod) => prod?.InwardDtlId === updatedTableData[index]?.InwardDtlId
);
if (prodIndex !== -1) { if (prodIndex !== -1) {
priceChangedProdList.splice(prodIndex, 1); priceChangedProdList.splice(prodIndex, 1);
@ -302,41 +343,47 @@ const ProductPriceChange = ({ showButton = true, priceChangeProduct = null, prod
}); });
const priceChangedProdList = [...priceChangedProducts]; const priceChangedProdList = [...priceChangedProducts];
const prodIndex = priceChangedProdList?.findIndex(prod => prod?.InwardDtlId === updatedTableData[index]?.InwardDtlId); const prodIndex = priceChangedProdList?.findIndex(
(prod) => prod?.InwardDtlId === updatedTableData[index]?.InwardDtlId
);
if (prodIndex !== -1) { if (prodIndex !== -1) {
priceChangedProdList[prodIndex] = { priceChangedProdList[prodIndex] = {
...priceChangedProdList[prodIndex], ...priceChangedProdList[prodIndex],
SellPrice: String(value) SellPrice: String(value),
}; };
} else { } else {
priceChangedProdList.push({ priceChangedProdList.push({
ProdId: updatedTableData[index]?.ProdId, ProdId: updatedTableData[index]?.ProdId,
ProdName: updatedTableData[index]?.ProdName, ProdName: updatedTableData[index]?.ProdName,
MRP: String(updatedTableData[index]?.NewMRP || updatedTableData[index]?.MRP), MRP: String(
updatedTableData[index]?.NewMRP || updatedTableData[index]?.MRP
),
SellPrice: String(value), SellPrice: String(value),
AdjComment: "string", AdjComment: 'string',
InwardDtlId: updatedTableData[index]?.InwardDtlId InwardDtlId: updatedTableData[index]?.InwardDtlId,
}); });
} }
setPriceChangedProducts(priceChangedProdList); setPriceChangedProducts(priceChangedProdList);
} };
const edit = (record, index) => { const edit = (record, index) => {
console.log("edit", record, index); console.log('edit', record, index);
setEditingKey(index); setEditingKey(index);
} };
const handleSubmit = async () => { const handleSubmit = async () => {
console.log("submit"); console.log('submit');
if (priceChangedProducts?.length > 0) { if (priceChangedProducts?.length > 0) {
console.log("priceChangedProducts", priceChangedProducts); console.log('priceChangedProducts', priceChangedProducts);
const validation = priceChangedProducts?.every((prod) => { const validation = priceChangedProducts?.every((prod) => {
if (parseFloat(prod?.MRP) < parseFloat(prod?.SellPrice)) { if (parseFloat(prod?.MRP) < parseFloat(prod?.SellPrice)) {
setMessageType('error'); setMessageType('error');
setMessageData(`${prod?.ProdName}: MRP cannot be less than Sell Price`); setMessageData(
`${prod?.ProdName}: MRP cannot be less than Sell Price`
);
return false; return false;
} }
if (!parseFloat(prod?.SellPrice) || !parseFloat(prod?.MRP)) { if (!parseFloat(prod?.SellPrice) || !parseFloat(prod?.MRP)) {
@ -354,7 +401,7 @@ const ProductPriceChange = ({ showButton = true, priceChangeProduct = null, prod
BranchId: BranchId, BranchId: BranchId,
ProductDetails: priceChangedProducts, ProductDetails: priceChangedProducts,
UpdatedBy: UserId, UpdatedBy: UserId,
} };
const res = await dispatch(PutStockPrice(data))?.unwrap(); const res = await dispatch(PutStockPrice(data))?.unwrap();
if (res?.data?.statusCode === 1) { if (res?.data?.statusCode === 1) {
@ -365,42 +412,52 @@ const ProductPriceChange = ({ showButton = true, priceChangeProduct = null, prod
setEditingKey(null); setEditingKey(null);
setPriceChangedProducts([]); setPriceChangedProducts([]);
setTableData([]); setTableData([]);
dispatch(triggerProductCard()) dispatch(triggerProductCard());
setPriceChangeProduct(null); setPriceChangeProduct(null);
formRef.current.resetFields(); formRef.current.resetFields();
} else { } else {
setMessageData('Error Updating Product Price') setMessageData('Error Updating Product Price');
setMessageType('error'); setMessageType('error');
} }
} else { } else {
setMessageType('error'); setMessageType('error');
setMessageData('No changes made / No sell price entered'); setMessageData('No changes made / No sell price entered');
} }
};
}
const onComplete = useCallback(() => { const onComplete = useCallback(() => {
setMessageData(null); setMessageData(null);
setMessageType(null); setMessageType(null);
}, []) }, []);
return ( return (
<> <>
<Messages
<Messages messageData={messageData} messageType={messageType} onComplete={onComplete} /> messageData={messageData}
{showButton ? <Tooltip title="Price Change"> messageType={messageType}
<button className="price-change-btn" type="button" onClick={() => { onComplete={onComplete}
/>
{showButton ? (
<Tooltip title="Price Change">
<button
className="price-change-btn"
type="button"
onClick={() => {
if (comboSearch) { if (comboSearch) {
setMessageType('warning'); setMessageType('warning');
setMessageData('Price change will not work for combo products'); setMessageData('Price change will not work for combo products');
return return;
} }
setPriceChangeModal(true) setPriceChangeModal(true);
}}> }}
>
{/* <FaIndianRupeeSign size={35}/> */} {/* <FaIndianRupeeSign size={35}/> */}
<img src={PriceChange} alt="" width={30} /> <img src={PriceChange} alt="" width={30} />
</button> </button>
</Tooltip> : <></>} </Tooltip>
) : (
<></>
)}
<DefaultModal <DefaultModal
title="Price Change" title="Price Change"
className={'price-change-modal'} className={'price-change-modal'}
@ -422,28 +479,39 @@ const ProductPriceChange = ({ showButton = true, priceChangeProduct = null, prod
<Form ref={formRef}> <Form ref={formRef}>
<Tables <Tables
columns={priceChangeColumns} columns={priceChangeColumns}
data={tableData?.slice((currentPage - 1) * pageSize, currentPage * pageSize)} data={tableData?.slice(
(currentPage - 1) * pageSize,
currentPage * pageSize
)}
onRow={(record, index) => ({ onRow={(record, index) => ({
onClick: () => { onClick: () => {
edit(record, index); edit(record, index);
}, },
})} })}
/> />
<div style={{ display: 'flex', justifyContent: 'center', margin: '20px 0' }}> <div
style={{
display: 'flex',
justifyContent: 'center',
margin: '20px 0',
}}
>
<Pagination <Pagination
current={currentPage} current={currentPage}
pageSize={pageSize} pageSize={pageSize}
total={tableData?.length} total={tableData?.length}
onChange={(page) => setCurrentPage(page)} onChange={(page) => setCurrentPage(page)}
showSizeChanger={false} showSizeChanger={false}
showTotal={(total, range) => `${range[0]}-${range[1]} of ${total} items`} showTotal={(total, range) =>
`${range[0]}-${range[1]} of ${total} items`
}
/> />
</div> </div>
</Form> </Form>
</div> </div>
</DefaultModal> </DefaultModal>
</> </>
) );
} };
export default ProductPriceChange; export default ProductPriceChange;