gopichandra commited on
Commit
0dec35e
·
verified ·
1 Parent(s): 2f73ecf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -278,9 +278,9 @@ def pull_data_from_salesforce(data_type):
278
  )
279
 
280
  if data_type == "Inventory":
281
- query = "SELECT Productname__c, Model__c, H_p__c, Stage__c, Current_Stocks__c, soldstock__c, Price__c FROM Inventory_Management__c LIMIT 100"
282
  else:
283
- query = "SELECT Productname__c, Model__c, H_p__c, Stage__c, Current_Stock__c, soldstock__c, Price__c FROM Un_Billable__c LIMIT 100"
284
 
285
  response = sf.query_all(query)
286
  records = response.get("records", [])
@@ -290,6 +290,11 @@ def pull_data_from_salesforce(data_type):
290
 
291
  df = pd.DataFrame(records)
292
  df = df.drop(columns=['attributes'], errors='ignore')
 
 
 
 
 
293
 
294
  # Rename columns for better readability
295
  df.rename(columns={
@@ -300,7 +305,7 @@ def pull_data_from_salesforce(data_type):
300
  "Current_Stocks__c": "Current Stocks",
301
  "Current_Stock__c": "Current Stocks",
302
  "soldstock__c": "Sold Stock",
303
- "Price__c": "Price"
304
  }, inplace=True)
305
 
306
  excel_path = "salesforce_data.xlsx"
 
278
  )
279
 
280
  if data_type == "Inventory":
281
+ query = "SELECT Productname__c, Model__c, H_p__c, Stage__c, Current_Stocks__c, soldstock__c,Last_Modified_Date__c FROM Inventory_Management__c LIMIT 100"
282
  else:
283
+ query = "SELECT Productname__c, Model__c, H_p__c, Stage__c, Current_Stock__c, soldstock__c, Last_Modified_Date__c FROM Un_Billable__c LIMIT 100"
284
 
285
  response = sf.query_all(query)
286
  records = response.get("records", [])
 
290
 
291
  df = pd.DataFrame(records)
292
  df = df.drop(columns=['attributes'], errors='ignore')
293
+
294
+ # Format the Last_Modified_Date__c field to show only the date
295
+ if "Last_Modified_Date__c" in df.columns:
296
+ df["Last_Modified_Date__c"] = pd.to_datetime(df["Last_Modified_Date__c"]).dt.date
297
+
298
 
299
  # Rename columns for better readability
300
  df.rename(columns={
 
305
  "Current_Stocks__c": "Current Stocks",
306
  "Current_Stock__c": "Current Stocks",
307
  "soldstock__c": "Sold Stock",
308
+ "Last_Modified_Date__c": "Last Modified Date"
309
  }, inplace=True)
310
 
311
  excel_path = "salesforce_data.xlsx"