Added Bulk Upload post funtionalies
This commit is contained in:
parent
727f042abe
commit
53eecf6dc3
|
|
@ -113,8 +113,11 @@ const StockList = () => {
|
||||||
const [addnewAccess, setaddnewAccess] = useState(true);
|
const [addnewAccess, setaddnewAccess] = useState(true);
|
||||||
const [page, setpage] = useState(1);
|
const [page, setpage] = useState(1);
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
const [openExcel, setOpenExcel] = useState(false);
|
||||||
|
|
||||||
const [Exceldatasubmit, setExceldatasubmit] = useState(null);
|
const [Exceldatasubmit, setExceldatasubmit] = useState(null);
|
||||||
|
console.log(Exceldatasubmit,'Exceldatasubmit111');
|
||||||
|
|
||||||
const [Totaltax, setTotaltax] = useState(null);
|
const [Totaltax, setTotaltax] = useState(null);
|
||||||
const [Totalamount, setTotalamount] = useState(null);
|
const [Totalamount, setTotalamount] = useState(null);
|
||||||
const [Taxdatas, setTaxdatas] = useState();
|
const [Taxdatas, setTaxdatas] = useState();
|
||||||
|
|
@ -252,6 +255,7 @@ const StockList = () => {
|
||||||
setpage(1);
|
setpage(1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
const queryClient = useQueryClient();
|
||||||
const { data, isLoading, error } = useQuery({
|
const { data, isLoading, error } = useQuery({
|
||||||
queryKey: ['purchaseEntry', dateStrings, page],
|
queryKey: ['purchaseEntry', dateStrings, page],
|
||||||
queryFn: fetchDataget,
|
queryFn: fetchDataget,
|
||||||
|
|
@ -277,7 +281,6 @@ const StockList = () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const filteredData = debouncedSearchText ? countData || [] : data || [];
|
const filteredData = debouncedSearchText ? countData || [] : data || [];
|
||||||
console.log('1111111111111111', filteredData);
|
|
||||||
async function searchData({ queryKey }) {
|
async function searchData({ queryKey }) {
|
||||||
const [_, SearchText] = queryKey;
|
const [_, SearchText] = queryKey;
|
||||||
|
|
||||||
|
|
@ -848,12 +851,12 @@ const StockList = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCancel = () => {
|
const handleCancel = () => {
|
||||||
setOpen(false);
|
setOpenExcel(false);
|
||||||
handleResetExcelData();
|
handleResetExcelData();
|
||||||
};
|
};
|
||||||
|
|
||||||
const openModal = () => {
|
const openModal = () => {
|
||||||
setOpen(true);
|
setOpenExcel(true);
|
||||||
// setEditState(false);
|
// setEditState(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1006,71 +1009,97 @@ const StockList = () => {
|
||||||
return acc + amount;
|
return acc + amount;
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
|
const inwardDate = groupInfo.InwardDate
|
||||||
|
? moment(groupInfo.InwardDate, 'YYYY-MM-DD').format('YYYY-MM-DDTHH:mm:ss')
|
||||||
|
: null;
|
||||||
|
const suppInvoiceDate = groupInfo.SupplierInvoiceDate
|
||||||
|
? moment(groupInfo.SupplierInvoiceDate, 'YYYY-MM-DD').format('YYYY-MM-DDTHH:mm:ss')
|
||||||
|
: null;
|
||||||
|
const deliveryInvoiceDate = groupInfo.DeliveryInvoiceDate
|
||||||
|
? moment(groupInfo.DeliveryInvoiceDate, 'YYYY-MM-DD').format('YYYY-MM-DDTHH:mm:ss')
|
||||||
|
: null;
|
||||||
|
const dueDate = groupInfo.DueDate
|
||||||
|
? moment(groupInfo.DueDate, 'YYYY-MM-DD').format('YYYY-MM-DDTHH:mm:ss')
|
||||||
|
: null;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...commonData, // Assuming commonData is defined elsewhere
|
AppId: parseInt(commonData.AppId),
|
||||||
|
CompId: parseInt(commonData.CompId),
|
||||||
|
BranchId: parseInt(commonData.BranchId),
|
||||||
|
CreatedBy: parseInt(commonData.CreatedBy),
|
||||||
SuppName: groupInfo.Supplier,
|
SuppName: groupInfo.Supplier,
|
||||||
OwnWithPaid: groupInfo.OwnWithPaid,
|
OwnWithPaid: groupInfo.OwnWithPaid || '',
|
||||||
InvoiceDeliveryChallan: groupInfo.InvoiceDeliveryChallan,
|
InvoiceDeliveryChallan: groupInfo.InvoiceDeliveryChallan || '',
|
||||||
PayType: groupInfo.PaymentType,
|
PaymentType: groupInfo.PaymentMode || groupInfo.PaymentType || '',
|
||||||
PaymentType: groupInfo.PaymentMode || groupInfo.PaymentType,
|
PaymentAmount: PaymentAmount,
|
||||||
PaymentMode: groupInfo.PaymentMode,
|
InvoiceDate: inwardDate,
|
||||||
PaymentAmount: PaymentAmount.toFixed(2),
|
SuppInvoiceNo: groupInfo.SupplierInvoiceNumber || '',
|
||||||
InvoiceDate: groupInfo.InwardDate
|
SuppInvoiceDate: suppInvoiceDate,
|
||||||
? moment(groupInfo.InwardDate, 'YYYY-MM-DD').format(
|
DeliveryChallanNo: groupInfo.DeliveryChallanNo || '',
|
||||||
'YYYY-MM-DDTHH:mm:ss'
|
DeliveryInvoiceDate: deliveryInvoiceDate,
|
||||||
)
|
DueDate: dueDate,
|
||||||
: null,
|
InvoiceAmount: Totalamount,
|
||||||
SuppInvoiceNo: groupInfo.SupplierInvoiceNumber,
|
TaxAmount: Totaltax,
|
||||||
SuppInvoiceDate: groupInfo.SupplierInvoiceDate
|
TotalAmount: Totalamount,
|
||||||
? moment(groupInfo.SupplierInvoiceDate, 'YYYY-MM-DD').format(
|
BillAmount: Billamount,
|
||||||
'YYYY-MM-DDTHH:mm:ss'
|
|
||||||
)
|
|
||||||
: null,
|
|
||||||
DeliveryChallanNo: groupInfo.DeliveryChallanNo,
|
|
||||||
DeliveryInvoiceDate: groupInfo.DeliveryInvoiceDate
|
|
||||||
? moment(groupInfo.DeliveryInvoiceDate, 'YYYY-MM-DD').format(
|
|
||||||
'YYYY-MM-DDTHH:mm:ss'
|
|
||||||
)
|
|
||||||
: null,
|
|
||||||
DueDate: groupInfo.DueDate
|
|
||||||
? moment(groupInfo.DueDate, 'YYYY-MM-DD').format(
|
|
||||||
'YYYY-MM-DDTHH:mm:ss'
|
|
||||||
)
|
|
||||||
: null,
|
|
||||||
InvoiceAmount: Totalamount.toFixed(2),
|
|
||||||
TaxAmount: Totaltax.toFixed(2),
|
|
||||||
TotalAmount: Totalamount.toFixed(2),
|
|
||||||
BillAmount: Billamount.toFixed(2),
|
|
||||||
PaymentStatus: 'S',
|
|
||||||
PurOrderStatus: 'P',
|
PurOrderStatus: 'P',
|
||||||
ProdDetails: products.map((item) => ({
|
LocationType: 'Supplier',
|
||||||
ProdName: item.ProductName,
|
PaymentStatus: 'S',
|
||||||
ProdVariantName: item.VariantName,
|
ProdDetails: products.map((item) => {
|
||||||
Quantity: item.Quantity,
|
const matchedProduct = Productdata?.find(
|
||||||
ReceivedQty: item.ReceivedQty,
|
(p) =>
|
||||||
RejectedQty: item.RejectedQty,
|
p.ProdName === item.ProductName &&
|
||||||
AcceptedQty: item.AcceptedQty,
|
p.ProdVariantName === item.VariantName
|
||||||
FreeQty: item.FreeQty,
|
);
|
||||||
ManufDate: item.ManufactureDate
|
const inwardPrice = parseFloat(item.PurchaseRate) || 0;
|
||||||
? moment(item.ManufactureDate, 'YYYY-MM-DD').format(
|
const acceptedQty = parseFloat(item.AcceptedQty) || 0;
|
||||||
'YYYY-MM-DDTHH:mm:ss'
|
const rejectedQty = parseFloat(item.RejectedQty) || 0;
|
||||||
)
|
const receivedQty = parseFloat(item.ReceivedQty) || 0;
|
||||||
: null,
|
const amount = parseFloat(String(item.Amount || '').replace(/,/g, '')) || 0;
|
||||||
ExpDate: item.ExpireDate
|
const taxPercent = parseFloat(matchedProduct?.TaxPercentage || item.Tax || 0);
|
||||||
? moment(item.ExpireDate, 'YYYY-MM-DD').format(
|
const taxAmt = taxPercent > 0 ? (amount * taxPercent) / (100 + taxPercent) : 0;
|
||||||
'YYYY-MM-DDTHH:mm:ss'
|
const imeiList = item.IMEI
|
||||||
)
|
? String(item.IMEI).split(',').map((imei, idx) => ({
|
||||||
: null,
|
SerialNumber: String(idx + 1),
|
||||||
BatchNo: item.BatchNo,
|
IMEI1: imei.trim(),
|
||||||
ModelNo: item.ModelNo,
|
IMEI2: '',
|
||||||
InwardPrice: item.PurchaseRate,
|
MacId: '',
|
||||||
Amount: item.Amount,
|
}))
|
||||||
MRP: item.MRP,
|
: [];
|
||||||
SellPrice: item.SalesPrice,
|
return {
|
||||||
OnePcsPrice: item.AmountPerPiece,
|
ProdName: item.ProductName,
|
||||||
NoOfPcs: item.NumberofPieceInside,
|
ProdVariantName: item.VariantName || '',
|
||||||
WhSalePrice: item.WholesalePrice,
|
ReceivedQty: receivedQty,
|
||||||
})),
|
AcceptedQty: acceptedQty,
|
||||||
|
RejectedQty: rejectedQty,
|
||||||
|
RejectionReason: '',
|
||||||
|
ManufDate: item.ManufactureDate
|
||||||
|
? moment(item.ManufactureDate, 'YYYY-MM-DD').format('YYYY-MM-DDTHH:mm:ss')
|
||||||
|
: null,
|
||||||
|
ExpDate: item.ExpireDate
|
||||||
|
? moment(item.ExpireDate, 'YYYY-MM-DD').format('YYYY-MM-DDTHH:mm:ss')
|
||||||
|
: null,
|
||||||
|
IssuedQty: 0,
|
||||||
|
BalanceQty: acceptedQty,
|
||||||
|
InwardPrice: inwardPrice,
|
||||||
|
MRP: parseFloat(item.MRP) || matchedProduct?.MRP || 0,
|
||||||
|
SellPrice: parseFloat(item.SalesPrice) || matchedProduct?.SellPrice || 0,
|
||||||
|
WhSalePrice: parseFloat(item.WholesalePrice) || 0,
|
||||||
|
OfferPrice: 0,
|
||||||
|
SpecialPrice: 0,
|
||||||
|
TaxId: matchedProduct?.TaxId || '',
|
||||||
|
TaxType: 0,
|
||||||
|
TaxAmt: parseFloat(taxAmt.toFixed(2)),
|
||||||
|
PurDisc: 0,
|
||||||
|
FreeItem: parseFloat(item.FreeQty) || 0,
|
||||||
|
Amount: amount,
|
||||||
|
OnePcsPrice: parseFloat(item.AmountPerPiece) || matchedProduct?.OnePcsPrice || 0,
|
||||||
|
NoOfPcs: parseFloat(item.NumberofPieceInside) || matchedProduct?.NoOfPcs || 0,
|
||||||
|
OnePcsAvailable: matchedProduct?.OnePcsAvailable || 'Y',
|
||||||
|
ModelNumber: item.ModelNo || '',
|
||||||
|
ProductIdentifierDtls: imeiList,
|
||||||
|
};
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -1080,14 +1109,7 @@ const StockList = () => {
|
||||||
if (response?.data?.statusCode == 1) {
|
if (response?.data?.statusCode == 1) {
|
||||||
setMessageType('success');
|
setMessageType('success');
|
||||||
setMessageData(response?.data?.response);
|
setMessageData(response?.data?.response);
|
||||||
// dispatch(
|
queryClient.invalidateQueries({ queryKey: ['purchaseEntry'] });
|
||||||
// getStockData({
|
|
||||||
// AppId: AppId,
|
|
||||||
// BranchId: BranchId,
|
|
||||||
// CompId: CompId,
|
|
||||||
// StockAvailable: 'Y',
|
|
||||||
// })
|
|
||||||
// );
|
|
||||||
await Bulkuploadsubdata();
|
await Bulkuploadsubdata();
|
||||||
} else {
|
} else {
|
||||||
setMessageType('error');
|
setMessageType('error');
|
||||||
|
|
@ -1380,7 +1402,7 @@ const StockList = () => {
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<DefaultModal
|
<DefaultModal
|
||||||
open={open}
|
open={openExcel}
|
||||||
title="Bulk Upload"
|
title="Bulk Upload"
|
||||||
footer={true}
|
footer={true}
|
||||||
width={excelDataValues?.length > 0 ? 3000 : 600}
|
width={excelDataValues?.length > 0 ? 3000 : 600}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue