Omkar008 commited on
Commit
7853c7c
·
verified ·
1 Parent(s): b774beb

Update extract_and_store_supabase.py

Browse files
Files changed (1) hide show
  1. extract_and_store_supabase.py +25 -12
extract_and_store_supabase.py CHANGED
@@ -5,8 +5,21 @@ import requests
5
  from supabase_models import Supabase_Client
6
  from authenticate import get_access_token_v1
7
 
8
- def extract_structure_store_message(filename:str):
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  if attachment_id and message_id:
11
  project_id = os.getenv('PROJECT_ID')
12
  processor_id = os.getenv('PROCESSOR_ID')
@@ -44,19 +57,19 @@ def extract_structure_store_message(filename:str):
44
  )
45
  response_json = response.json()
46
  allowed_entities = [
47
- "due_date",
48
- "invoice_date",
49
- "total_amount",
50
- "total_tax_amount",
51
- "receiver_name",
52
- "invoice_id",
53
  "currency",
54
- "receiver_address",
55
- "invoice_type",
 
 
 
 
 
 
56
  "supplier_name",
57
- "payment_terms",
58
- "line_item",
59
- "line_item/description",
60
  "line_item/quantity",
61
  "line_item/amount",
62
  "line_item/unit_price"
 
5
  from supabase_models import Supabase_Client
6
  from authenticate import get_access_token_v1
7
 
 
8
 
9
+
10
+ def generate_custom_random_string():
11
+ # Length of the provided string (16 characters)
12
+ length = 16
13
+ # Define the character set (hexadecimal characters: 0-9 and a-f)
14
+ characters = string.hexdigits.lower()
15
+ # Generate the random string
16
+ random_string = ''.join(random.choice(characters) for _ in range(length))
17
+ # Add "RAN" in front of the string
18
+ return "RAN" + random_string
19
+
20
+ def extract_structure_store_message(filename:str,user_id:str):
21
+ message_id = generate_custom_random_string()
22
+ attachment_id = 'UPLOADED_MANUALLY'
23
  if attachment_id and message_id:
24
  project_id = os.getenv('PROJECT_ID')
25
  processor_id = os.getenv('PROCESSOR_ID')
 
57
  )
58
  response_json = response.json()
59
  allowed_entities = [
60
+ "credit_card_last_four_digits",
 
 
 
 
 
61
  "currency",
62
+ "end_date",
63
+ "net_amount",
64
+ "payment_type",
65
+ "purchase_time",
66
+ "receipt_date",
67
+ "start_date",
68
+ "supplier_address",
69
+ "supplier_city",
70
  "supplier_name",
71
+ "tip_amount",
72
+ "total_amount",
 
73
  "line_item/quantity",
74
  "line_item/amount",
75
  "line_item/unit_price"