Ocr Product add new
This commit is contained in:
parent
c8ff7fc011
commit
f01cc07077
|
|
@ -115,7 +115,7 @@ const CameraModal = ({
|
||||||
}
|
}
|
||||||
setStream(null);
|
setStream(null);
|
||||||
setCameraOn(false);
|
setCameraOn(false);
|
||||||
console.log('Camera stoppejjd');
|
console.log('Camera stopped');
|
||||||
};
|
};
|
||||||
|
|
||||||
const captureImage = () => {
|
const captureImage = () => {
|
||||||
|
|
@ -878,7 +878,7 @@ const InvoiceImageExtractorModal = ({
|
||||||
extractedText,
|
extractedText,
|
||||||
products: productTableData,
|
products: productTableData,
|
||||||
supplierSuggestions: supplierSuggestions,
|
supplierSuggestions: supplierSuggestions,
|
||||||
TotalAmtData: TotalAmtData,
|
TotalAmtData: parseFloat(TotalAmtData)?.toFixed(2),
|
||||||
});
|
});
|
||||||
handleClose({ submit: true });
|
handleClose({ submit: true });
|
||||||
message.success('Applied to purchase form!');
|
message.success('Applied to purchase form!');
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,7 @@ import {
|
||||||
getsingleQrcodeData,
|
getsingleQrcodeData,
|
||||||
productTypeDataSelector,
|
productTypeDataSelector,
|
||||||
getProductTypeData,
|
getProductTypeData,
|
||||||
|
bulkpostdata,
|
||||||
} from '../../Features/ProductPage/ProductPage.js';
|
} from '../../Features/ProductPage/ProductPage.js';
|
||||||
import { postConfiguration } from '../../Features/ConfigMasterPage/ConfigMasterPage.js';
|
import { postConfiguration } from '../../Features/ConfigMasterPage/ConfigMasterPage.js';
|
||||||
import SupplierProductMappingForm from '../SupplierProductMapping/SuplierProductMappingForm.jsx';
|
import SupplierProductMappingForm from '../SupplierProductMapping/SuplierProductMappingForm.jsx';
|
||||||
|
|
@ -687,7 +688,8 @@ const StockForm = ({ formType }) => {
|
||||||
const allSupplierProducts = response?.data?.data || [];
|
const allSupplierProducts = response?.data?.data || [];
|
||||||
|
|
||||||
const matchingProdIds = [];
|
const matchingProdIds = [];
|
||||||
|
const NewImageProducts=[]
|
||||||
|
console.log(unmatchedProducts,"unmatchedProductsunmatchedProducts")
|
||||||
// check if the unmatched products exists in our products list
|
// check if the unmatched products exists in our products list
|
||||||
unmatchedProducts.forEach((item) => {
|
unmatchedProducts.forEach((item) => {
|
||||||
const match = allSupplierProducts?.[0]?.ProductDetails.find(
|
const match = allSupplierProducts?.[0]?.ProductDetails.find(
|
||||||
|
|
@ -698,8 +700,90 @@ const StockForm = ({ formType }) => {
|
||||||
if (match) {
|
if (match) {
|
||||||
matchingProdIds.push(match.ProdId);
|
matchingProdIds.push(match.ProdId);
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
NewImageProducts.push(item?.parsedData);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
console.log(NewImageProducts,"NewImageProductsNewImageProducts")
|
||||||
|
// Bulk upload new image products
|
||||||
|
if (NewImageProducts.length > 0) {
|
||||||
|
const newProductsData = NewImageProducts.map(product => ({
|
||||||
|
AppId: AppId || 0,
|
||||||
|
CompId: CompId || "",
|
||||||
|
BranchId: BranchId || "",
|
||||||
|
CreatedBy: UserId || 0,
|
||||||
|
ProdName: product.description?.trim() || "",
|
||||||
|
ProdVariantName: "",
|
||||||
|
Size: 1 || "",
|
||||||
|
UOM: product.unit || "",
|
||||||
|
MRP: parseFloat(product.rate) || 0,
|
||||||
|
WhSalePrice: 0,
|
||||||
|
SellPrice: parseFloat(product.rate) || 0,
|
||||||
|
ProdCat: "General",
|
||||||
|
ProdSubCat: "",
|
||||||
|
Brand: "",
|
||||||
|
AutoGenerateQr: "",
|
||||||
|
QRCode: "",
|
||||||
|
StockAvailable: 'No',
|
||||||
|
TaxId: "",
|
||||||
|
HSNCode: "",
|
||||||
|
PartNumber: "",
|
||||||
|
Rack: 0,
|
||||||
|
ManufDate: "",
|
||||||
|
ExpDate: "",
|
||||||
|
AvailableFrom: "",
|
||||||
|
AvailableTo: "",
|
||||||
|
ProdLogo: "",
|
||||||
|
OnePcsAvailable: "No",
|
||||||
|
AutoGenerateSingleQr:'No',
|
||||||
|
TaxId: 'NIL - 0%',
|
||||||
|
OnePcQR: "",
|
||||||
|
TokenAvailable: 'No',
|
||||||
|
OpeningQty: 0,
|
||||||
|
QtyBasedPrice: "",
|
||||||
|
InwardDate: "",
|
||||||
|
SuppId: suppId || "",
|
||||||
|
Reference: "",
|
||||||
|
ReceivedQty: 0,
|
||||||
|
AcceptedQty: 0,
|
||||||
|
RejectedQty: 0,
|
||||||
|
RejectionReason: "",
|
||||||
|
IssuedQty: 0,
|
||||||
|
BalanceQty: 0,
|
||||||
|
InwardPrice: 0,
|
||||||
|
OfferPrice: 0,
|
||||||
|
SpecialPrice: 0,
|
||||||
|
Cess: 0,
|
||||||
|
}));
|
||||||
|
|
||||||
|
const bulkResponse = await dispatch(bulkpostdata({ ProdDetails: newProductsData })).unwrap();
|
||||||
|
|
||||||
|
if (bulkResponse?.data?.statusCode === 1) {
|
||||||
|
// After successful bulk upload, check the condition again
|
||||||
|
const updatedResponse = await dispatch(
|
||||||
|
getSupplaierIdBasedProducts({ CompId, AppId, BranchId, SuppId: suppId })
|
||||||
|
).unwrap();
|
||||||
|
if (updatedResponse?.data?.statusCode === 1) {
|
||||||
|
const updatedAllSupplierProducts = updatedResponse?.data?.data || [];
|
||||||
|
const updatedMatchingProdIds = [];
|
||||||
|
|
||||||
|
unmatchedProducts.forEach((item) => {
|
||||||
|
const match = updatedAllSupplierProducts?.[0]?.ProductDetails.find(
|
||||||
|
(supp) =>
|
||||||
|
supp?.ProdName?.toLowerCase() ===
|
||||||
|
item?.parsedData?.description?.toLowerCase()
|
||||||
|
);
|
||||||
|
if (match) {
|
||||||
|
updatedMatchingProdIds.push(match.ProdId);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (updatedMatchingProdIds.length > 0) {
|
||||||
|
matchingProdIds.push(...updatedMatchingProdIds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// if there is matching products, map them to the supplier
|
// if there is matching products, map them to the supplier
|
||||||
if (matchingProdIds.length > 0) {
|
if (matchingProdIds.length > 0) {
|
||||||
setLoadingText('Mapping products to supplier...');
|
setLoadingText('Mapping products to supplier...');
|
||||||
|
|
@ -1003,7 +1087,9 @@ const StockForm = ({ formType }) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSuppInvoiceNoChange = (e) => {
|
const handleSuppInvoiceNoChange = (e) => {
|
||||||
formProductRef.current?.setFieldsValue({ SuppInvoiceNo: e.target.value });
|
const value = e.target.value;
|
||||||
|
formRef.current?.setFieldsValue({ SuppInvoiceNo: value });
|
||||||
|
setExtractorData(prev => prev ? { ...prev, invoiceNo: value } : null);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleInvoiceTypeChange = (value) => {
|
const handleInvoiceTypeChange = (value) => {
|
||||||
|
|
@ -1032,13 +1118,16 @@ const StockForm = ({ formType }) => {
|
||||||
formRef?.current?.getFieldsValue(),
|
formRef?.current?.getFieldsValue(),
|
||||||
'formRefformRefformRefformRef'
|
'formRefformRefformRefformRef'
|
||||||
);
|
);
|
||||||
|
if(extractorData?.invoiceNo !== null && extractorData?.invoiceNo !== ""){
|
||||||
formRef?.current?.setFieldsValue({
|
formRef?.current?.setFieldsValue({
|
||||||
SuppInvoiceNo: extractorData?.invoiceNo,
|
SuppInvoiceNo: extractorData?.invoiceNo,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
formRef?.current?.setFieldsValue({
|
formRef?.current?.setFieldsValue({
|
||||||
PaymentAmount: extractorData?.TotalAmtData,
|
PaymentAmount: extractorData?.TotalAmtData,
|
||||||
});
|
});
|
||||||
setPaymentAmount(extractorData?.TotalAmtData);
|
setPaymentAmount((extractorData?.TotalAmtData));
|
||||||
onSuppInvoiceDateChange(
|
onSuppInvoiceDateChange(
|
||||||
extractorData?.date,
|
extractorData?.date,
|
||||||
extractorData?.date?.format('DD-MM-YYYY') || ''
|
extractorData?.date?.format('DD-MM-YYYY') || ''
|
||||||
|
|
@ -3854,7 +3943,7 @@ const StockForm = ({ formType }) => {
|
||||||
{PurchaseData.reduce(
|
{PurchaseData.reduce(
|
||||||
(acc, data) => acc + data?.Amount,
|
(acc, data) => acc + data?.Amount,
|
||||||
0
|
0
|
||||||
)}
|
)?.toFixed(2)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{!orderType && (
|
{!orderType && (
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue