Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -183,12 +183,6 @@ def interact_with_salesforce(mode, entry_type, quantity, extracted_text):
|
|
| 183 |
if not product_name:
|
| 184 |
return "❌ Product Name could not be extracted from the image. Please check the image."
|
| 185 |
|
| 186 |
-
# Assign Product Name to the correct Salesforce field
|
| 187 |
-
if entry_type == "Sales":
|
| 188 |
-
attributes["Product_Name__c"] = product_name # For VENKATA_RAMANA_MOTORS__c
|
| 189 |
-
elif entry_type == "Non-Sales":
|
| 190 |
-
attributes["Productname__c"] = product_name # For UNBILLING_DATA__c
|
| 191 |
-
|
| 192 |
# Convert extracted keys to match Salesforce API field names
|
| 193 |
mapped_attributes = {}
|
| 194 |
for key, value in attributes.items():
|
|
@@ -197,7 +191,10 @@ def interact_with_salesforce(mode, entry_type, quantity, extracted_text):
|
|
| 197 |
mapped_attributes[sf_field_name] = value # Only keep valid fields
|
| 198 |
|
| 199 |
# Ensure Product Name and Quantity are added to mapped attributes
|
| 200 |
-
|
|
|
|
|
|
|
|
|
|
| 201 |
mapped_attributes[field_name] = quantity # Quantity field
|
| 202 |
|
| 203 |
# Ensure at least one valid field exists
|
|
@@ -209,14 +206,14 @@ def interact_with_salesforce(mode, entry_type, quantity, extracted_text):
|
|
| 209 |
return f"✅ Record created in {object_name} with extracted valid attributes, Product Name: {product_name}, and Quantity: {quantity}."
|
| 210 |
|
| 211 |
except Exception as e:
|
| 212 |
-
return f"❌ Error interacting with Salesforce: {str(e)}"
|
| 213 |
-
|
| 214 |
-
if entry_type == "Sales":
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
elif entry_type == "Non-Sales":
|
| 218 |
-
|
| 219 |
-
|
| 220 |
|
| 221 |
# Extract product name
|
| 222 |
product_name = match_product_name(extracted_text)
|
|
|
|
| 183 |
if not product_name:
|
| 184 |
return "❌ Product Name could not be extracted from the image. Please check the image."
|
| 185 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
# Convert extracted keys to match Salesforce API field names
|
| 187 |
mapped_attributes = {}
|
| 188 |
for key, value in attributes.items():
|
|
|
|
| 191 |
mapped_attributes[sf_field_name] = value # Only keep valid fields
|
| 192 |
|
| 193 |
# Ensure Product Name and Quantity are added to mapped attributes
|
| 194 |
+
if entry_type == "Sales":
|
| 195 |
+
mapped_attributes["Product_Name__c"] = product_name # Product Name field for Sales
|
| 196 |
+
elif entry_type == "Non-Sales":
|
| 197 |
+
mapped_attributes["Productname__c"] = product_name # Product Name field for Non-Sales
|
| 198 |
mapped_attributes[field_name] = quantity # Quantity field
|
| 199 |
|
| 200 |
# Ensure at least one valid field exists
|
|
|
|
| 206 |
return f"✅ Record created in {object_name} with extracted valid attributes, Product Name: {product_name}, and Quantity: {quantity}."
|
| 207 |
|
| 208 |
except Exception as e:
|
| 209 |
+
return f"❌ Error interacting with Salesforce: {str(e)}"elif mode == "Exit":
|
| 210 |
+
|
| 211 |
+
if entry_type == "Sales":
|
| 212 |
+
object_name = "Inventory_Management__c"
|
| 213 |
+
field_name = "Quantity_Sold__c"
|
| 214 |
+
elif entry_type == "Non-Sales":
|
| 215 |
+
object_name = "Un_Billable__c"
|
| 216 |
+
field_name = "Sold_Out__c"
|
| 217 |
|
| 218 |
# Extract product name
|
| 219 |
product_name = match_product_name(extracted_text)
|