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