williamagyapong commited on
Commit
48a2276
·
verified ·
1 Parent(s): 36cedf9

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +14 -5
main.py CHANGED
@@ -5,7 +5,7 @@ from dotenv import load_dotenv
5
  from heyoo import WhatsApp
6
  import assemblyai as aai
7
  import openai
8
- from utility import parse_multiple_transactions, create_transaction
9
  from google.cloud import firestore
10
 
11
 
@@ -134,11 +134,20 @@ def hook():
134
  # messenger.send_message(message=f"{response}", recipient_id=mobile)
135
 
136
  intent = parsed_trans_data[0]['intent'].lower()
 
137
  if intent == 'create':
138
- if create_transaction(mobile, parsed_trans_data):
139
- firestore_msg = "Transaction recorded successfully!"
140
- else:
141
- firestore_msg = "Sorry, could not record transaction!"
 
 
 
 
 
 
 
 
142
  elif intent == 'update': # handle update
143
  pass
144
  elif intent == 'delete': # handle delete
 
5
  from heyoo import WhatsApp
6
  import assemblyai as aai
7
  import openai
8
+ from utility import parse_multiple_transactions, create_inventory, create_sales
9
  from google.cloud import firestore
10
 
11
 
 
134
  # messenger.send_message(message=f"{response}", recipient_id=mobile)
135
 
136
  intent = parsed_trans_data[0]['intent'].lower()
137
+ trans_type = parsed_trans_data[0]['transaction_type'].lower()
138
  if intent == 'create':
139
+ if trans_type == 'purchase':
140
+ if create_inventory(user_phone, parsed_trans_data):
141
+ firestore_msg = "Transaction recorded successfully!"
142
+ else:
143
+ firestore_msg = "Sorry, could not record transaction!"
144
+
145
+ elif trans_type == 'sale':
146
+ if create_sales(user_phone, parsed_trans_data):
147
+ firestore_msg = "Transaction recorded successfully!"
148
+ else:
149
+ firestore_msg = "Sorry, could not record transaction!"
150
+
151
  elif intent == 'update': # handle update
152
  pass
153
  elif intent == 'delete': # handle delete