nagasurendra commited on
Commit
7696f9c
·
verified ·
1 Parent(s): 3938579

Update order.py

Browse files
Files changed (1) hide show
  1. order.py +3 -17
order.py CHANGED
@@ -24,7 +24,7 @@ def order_summary():
24
 
25
  # Fetch the previous order if its Billing_Status__c is 'Pending'
26
  pending_result = sf.query(f"""
27
- SELECT Id, Total_Bill__c, Discount__c, Total_Amount__c
28
  FROM Order__c
29
  WHERE Customer_Email__c = '{email}' AND Billing_Status__c = 'Pending'
30
  ORDER BY CreatedDate DESC
@@ -33,23 +33,9 @@ def order_summary():
33
  pending_order = pending_result.get("records", [])[0] if pending_result.get("records") else None
34
 
35
  if not order:
36
- return render_template("order.html", order=None)
37
 
38
- if pending_order:
39
- # Add the pending bill's total to the current order
40
- previous_total = pending_order["Total_Bill__c"]
41
- order["Total_Amount__c"] += previous_total # Add the pending bill amount
42
- order["Discount__c"] += pending_order["Discount__c"] # Add any discounts if applicable
43
- order["Total_Bill__c"] += previous_total # Update the total bill
44
-
45
- # Optionally, you can update the order in Salesforce to reflect the new total
46
- # sf.Order__c.update(order['Id'], {
47
- # 'Total_Amount__c': order['Total_Amount__c'],
48
- # 'Discount__c': order['Discount__c'],
49
- # 'Total_Bill__c': order['Total_Bill__c']
50
- # })
51
-
52
- return render_template("order.html", order=order)
53
 
54
  except Exception as e:
55
  print(f"Error fetching order details: {str(e)}")
 
24
 
25
  # Fetch the previous order if its Billing_Status__c is 'Pending'
26
  pending_result = sf.query(f"""
27
+ SELECT Id, Order_Details__c, Total_Bill__c, Discount__c
28
  FROM Order__c
29
  WHERE Customer_Email__c = '{email}' AND Billing_Status__c = 'Pending'
30
  ORDER BY CreatedDate DESC
 
33
  pending_order = pending_result.get("records", [])[0] if pending_result.get("records") else None
34
 
35
  if not order:
36
+ return render_template("order.html", order=None, pending_order=None)
37
 
38
+ return render_template("order.html", order=order, pending_order=pending_order)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
  except Exception as e:
41
  print(f"Error fetching order details: {str(e)}")