gopichandra commited on
Commit
f4c2740
·
verified ·
1 Parent(s): e1dd14d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -120,8 +120,10 @@ def extract_text(image):
120
 
121
  # Function to find product name from the predefined list
122
  def match_product_name(text):
 
 
123
  for product_name in PRODUCT_NAMES:
124
- if re.search(rf"\b{re.escape(product_name)}\b", text, re.IGNORECASE):
125
  return product_name
126
  return None
127
 
@@ -225,7 +227,8 @@ def subtract_stock_from_inventory(data):
225
 
226
  sf_object.update(record_id, {"Quantity_Sold__c": updated_quantity_sold})
227
 
228
- return f"Stock updated successfully in exit mode. Quantity sold for product '{product_name}': {updated_quantity_sold}."
 
229
  except Exception as e:
230
  return f"Error updating stock in Inventory_Management__c: {str(e)}"
231
 
 
120
 
121
  # Function to find product name from the predefined list
122
  def match_product_name(text):
123
+ # Normalize text and product names for better matching
124
+ normalized_text = text.lower()
125
  for product_name in PRODUCT_NAMES:
126
+ if product_name.lower() in normalized_text:
127
  return product_name
128
  return None
129
 
 
227
 
228
  sf_object.update(record_id, {"Quantity_Sold__c": updated_quantity_sold})
229
 
230
+ return f"Stock updated successfully in exit mode. Quantity sold for product
231
+ '{product_name}': {updated_quantity_sold}."
232
  except Exception as e:
233
  return f"Error updating stock in Inventory_Management__c: {str(e)}"
234