Merge pull request 'Ocr' (#11) from Ocr into main

Reviewed-on: Pozomind/pozo-retail-app#11
This commit is contained in:
karthikalakshmi 2026-01-28 05:23:08 -05:00
commit aa6af21cdb
2 changed files with 96 additions and 7 deletions

View File

@ -878,7 +878,7 @@ const InvoiceImageExtractorModal = ({
extractedText,
products: productTableData,
supplierSuggestions: supplierSuggestions,
TotalAmtData: TotalAmtData,
TotalAmtData: parseFloat(TotalAmtData)?.toFixed(2),
});
handleClose({ submit: true });
message.success('Applied to purchase form!');

View File

@ -73,6 +73,7 @@ import {
getsingleQrcodeData,
productTypeDataSelector,
getProductTypeData,
bulkpostdata,
} from '../../Features/ProductPage/ProductPage.js';
import { postConfiguration } from '../../Features/ConfigMasterPage/ConfigMasterPage.js';
import SupplierProductMappingForm from '../SupplierProductMapping/SuplierProductMappingForm.jsx';
@ -687,7 +688,8 @@ const StockForm = ({ formType }) => {
const allSupplierProducts = response?.data?.data || [];
const matchingProdIds = [];
const NewImageProducts=[]
console.log(unmatchedProducts,"unmatchedProductsunmatchedProducts")
// check if the unmatched products exists in our products list
unmatchedProducts.forEach((item) => {
const match = allSupplierProducts?.[0]?.ProductDetails.find(
@ -698,8 +700,90 @@ const StockForm = ({ formType }) => {
if (match) {
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 (matchingProdIds.length > 0) {
setLoadingText('Mapping products to supplier...');
@ -1003,7 +1087,9 @@ const StockForm = ({ formType }) => {
};
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) => {
@ -1032,13 +1118,16 @@ const StockForm = ({ formType }) => {
formRef?.current?.getFieldsValue(),
'formRefformRefformRefformRef'
);
if(extractorData?.invoiceNo !== null && extractorData?.invoiceNo !== ""){
formRef?.current?.setFieldsValue({
SuppInvoiceNo: extractorData?.invoiceNo,
});
}
formRef?.current?.setFieldsValue({
PaymentAmount: extractorData?.TotalAmtData,
});
setPaymentAmount(extractorData?.TotalAmtData);
setPaymentAmount((extractorData?.TotalAmtData));
onSuppInvoiceDateChange(
extractorData?.date,
extractorData?.date?.format('DD-MM-YYYY') || ''
@ -3854,7 +3943,7 @@ const StockForm = ({ formType }) => {
{PurchaseData.reduce(
(acc, data) => acc + data?.Amount,
0
)}
)?.toFixed(2)}
</div>
</div>
{!orderType && (