Redmind commited on
Commit
4e5ef51
·
verified ·
1 Parent(s): c1da09a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -19
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
- for index, item in enumerate(data1['result'], start=1):
441
- row = [
442
- index, # Serial number
443
- item['warehouse']['code'],
444
- item['warehouse']['name'],
445
- item['customer']['code'],
446
- item['customer']['name'],
447
- item['skuMaster']['code'],
448
- item['skuMaster']['name'],
449
- item['currency']['code'],
450
- item['eanUpc'],
451
- item['uom']['code'],
452
- item['totalQty'],
453
- item['grossWeight'],
454
- item['volume'],
455
- item['totalValue']
456
- ]
457
- table_data.append(row)
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)