Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -437,25 +437,30 @@ def inventory_report(question):
|
|
437 |
"Currency", "EAN", "UOM", "Quantity", "Gross Weight", "Volume", "Total Value"]
|
438 |
table_data = []
|
439 |
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
|
|
|
|
|
|
|
|
|
|
459 |
# Convert to pandas DataFrame
|
460 |
df = pd.DataFrame(table_data, columns=headers)
|
461 |
print(df)
|
|
|
437 |
"Currency", "EAN", "UOM", "Quantity", "Gross Weight", "Volume", "Total Value"]
|
438 |
table_data = []
|
439 |
|
440 |
+
# Check if 'content' exists and is a list
|
441 |
+
if data1['result'].get('content', []):
|
442 |
+
for index, item in enumerate(data1['result'], start=1):
|
443 |
+
row = [
|
444 |
+
index, # Serial number
|
445 |
+
item['warehouse']['code'],
|
446 |
+
item['warehouse']['name'],
|
447 |
+
item['customer']['code'],
|
448 |
+
item['customer']['name'],
|
449 |
+
item['skuMaster']['code'],
|
450 |
+
item['skuMaster']['name'],
|
451 |
+
item['currency']['code'],
|
452 |
+
item['eanUpc'],
|
453 |
+
item['uom']['code'],
|
454 |
+
item['totalQty'],
|
455 |
+
item['grossWeight'],
|
456 |
+
item['volume'],
|
457 |
+
item['totalValue']
|
458 |
+
]
|
459 |
+
table_data.append(row)
|
460 |
+
else:
|
461 |
+
print("No data available in 'content'.")
|
462 |
+
return "There are no inventory details for the warehouse you have given."
|
463 |
+
|
464 |
# Convert to pandas DataFrame
|
465 |
df = pd.DataFrame(table_data, columns=headers)
|
466 |
print(df)
|