AIEmailAutomationUtility 0.0.34__py3-none-any.whl → 0.0.36__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,10 +4,10 @@ from email.message import Message
4
4
  import datetime
5
5
  import time
6
6
  import loggerutility as logger
7
- from flask import Flask,request
8
7
  import json
9
8
  from email.mime.multipart import MIMEMultipart
10
9
  from email.mime.text import MIMEText
10
+ from bs4 import BeautifulSoup
11
11
 
12
12
  class Email_Draft:
13
13
  def draft_email(self, email_config, email_details, response_content):
@@ -60,6 +60,7 @@ class Email_Draft:
60
60
  # Extract response content
61
61
  body = response_content.get('body', '')
62
62
  table_html = response_content.get('table_', '')
63
+ aligned_table_html = self.align_numeric_cells_right(table_html)
63
64
  signature = response_content.get('signature', '')
64
65
  email_body = email_details['body']
65
66
 
@@ -72,7 +73,7 @@ class Email_Draft:
72
73
  html_content = (
73
74
  "<html><body>"
74
75
  f"<p>{body_html}</p>"
75
- f"{table_html}"
76
+ f"{aligned_table_html}"
76
77
  f"<b>GST Extra as per applicable.</b>"
77
78
  f"<p>{signature_html}</p>"
78
79
  "<hr>"
@@ -174,3 +175,26 @@ class Email_Draft:
174
175
 
175
176
  except Exception as e:
176
177
  logger.log(f"Error in Draft_Save: {str(e)}")
178
+
179
+ def align_numeric_cells_right(self,table_html):
180
+ soup = BeautifulSoup(table_html, 'html.parser')
181
+ rows = soup.find_all('tr')
182
+
183
+ for row in rows[1:]: # Skip header row
184
+ cells = row.find_all('td')
185
+ for cell in cells:
186
+ text = cell.get_text(strip=True)
187
+ # Check if the content is numeric (int or float)
188
+ try:
189
+ float(text.replace(',', '')) # Handle values like '7,500.00'
190
+ # If 'text-align: right;' is not present, add it
191
+ style = cell.get('style', '')
192
+ if 'text-align: right' not in style:
193
+ if style:
194
+ style += '; '
195
+ style += 'text-align: right;'
196
+ cell['style'] = style
197
+ except ValueError:
198
+ continue # Not numeric
199
+
200
+ return str(soup)
@@ -396,18 +396,22 @@ class Process_Category:
396
396
  csv_data_status = "Fail"
397
397
  csv_data_response = f"-"
398
398
  else:
399
- action_taken = f"Saved the mail to the label: {LABEL}"
400
- csv_data_status = "Success"
401
- csv_data_response = f""
402
-
403
- logger.log(f"Marking email as UNREAD. ")
404
- # print(f"email_id: {email_id}, type: {type(email_id)}")
405
- mail.store(email_id, '-FLAGS', '\\Seen')
406
- mail.create(LABEL)
407
- mail.copy(email_id, LABEL)
408
- mail.store(email_id, '+FLAGS', '\\Deleted') # Mark for deletion
409
- mail.expunge()
410
- logger.log(f"Mail removed from inbox and added to '{LABEL}' label.")
399
+ val_mail_id = email_config.get('email')
400
+ val_mail_pass = email_config.get('password')
401
+
402
+ if val_mail_id != None and val_mail_pass != None:
403
+ action_taken = f"Saved the mail to the label: {LABEL}"
404
+ csv_data_status = "Success"
405
+ csv_data_response = f""
406
+
407
+ logger.log(f"Marking email as UNREAD. ")
408
+ # print(f"email_id: {email_id}, type: {type(email_id)}")
409
+ mail.store(email_id, '-FLAGS', '\\Seen')
410
+ mail.create(LABEL)
411
+ mail.copy(email_id, LABEL)
412
+ mail.store(email_id, '+FLAGS', '\\Deleted') # Mark for deletion
413
+ mail.expunge()
414
+ logger.log(f"Mail removed from inbox and added to '{LABEL}' label.")
411
415
 
412
416
  current_timestamp = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
413
417
  filename = f'{uid}{current_timestamp}'
@@ -592,6 +596,9 @@ class Process_Category:
592
596
  if ai_result["status"] == "Success":
593
597
  logger.log(f"ai_result ::: {ai_result}")
594
598
  product_data = json.loads(ai_result["message"])
599
+ # If it's a dict, wrap in list
600
+ if isinstance(product_data, dict):
601
+ product_data = json.dumps([product_data], indent=4)
595
602
  else:
596
603
  product_data = []
597
604
  return product_data
@@ -635,10 +642,8 @@ class Process_Category:
635
642
  Sr. No., Requested Description, Item Code, Item Description, Make, Inventory Unit, Price, Discount, Rate, Quantity, Total, Price Pickup Source, Availability
636
643
 
637
644
  - If any value is missing, use a dash ("-") instead.
638
- - "Total" is calculated as Rate × Quantity.
639
645
  - "Availability" should be a blank column.
640
- - Only the numeric values in the table rows are right-aligned(Ensure the alignment applies only to the data cells (i.e., <td>), not the header cells (<th>).)
641
- Original Email Subject: {subject}
646
+ Original Email Subject: {subject}
642
647
 
643
648
  Return only the following JSON String format:
644
649
  {{
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: AIEmailAutomationUtility
3
- Version: 0.0.34
4
- Summary: Added a vector lookup for fallback products those return as NA.
3
+ Version: 0.0.36
4
+ Summary: Skip the logic of email and password authentication for uploading msg file.
5
5
  Author: Proteus Technology PVT. LTD.
6
6
  Author-email: <apps@baseinformation.com>
7
7
  Keywords: python,first package
@@ -13,4 +13,4 @@ Classifier: Operating System :: MacOS :: MacOS X
13
13
  Classifier: Operating System :: Microsoft :: Windows
14
14
  License-File: LICENCE.txt
15
15
 
16
- Added a vector lookup for fallback products those return as NA.
16
+ Skip the logic of email and password authentication for uploading msg file.
@@ -1,15 +1,15 @@
1
1
  AIEmailAutomationUtility/EmailReplyAssistant.py,sha256=R_wJna3-ITsVxQEccryhM93T_Nf_Oxo8DXnS-sDN8VE,6679
2
2
  AIEmailAutomationUtility/Email_Classification.py,sha256=Ar0g4Ff8HOT7xICktd3nP_C_vCyeY-xCpUjVCVRWAyc,9417
3
3
  AIEmailAutomationUtility/Email_DocumentUploader.py,sha256=BWNRt2X-E2HCogBaKDfl7cZZNSkZUeIsVs8iXjFjH88,3218
4
- AIEmailAutomationUtility/Email_Draft.py,sha256=JYZijUh_zan2asyMYQwIBwIpGNJ5SSQGma5AL1meaXk,7808
4
+ AIEmailAutomationUtility/Email_Draft.py,sha256=TGLqV0yzXLIdBnRcEY3CgmcDJVgiP3LN1vLPXTBj5rY,8831
5
5
  AIEmailAutomationUtility/Email_Read.py,sha256=_JwHTJZmxjuMPTbn90D9YStW7NSJd3t4R_cwUZ1tn20,31470
6
6
  AIEmailAutomationUtility/Email_Upload_Document.py,sha256=3bdkxfDlwoeRp-46KPw2Gs1dqBhEIoA1yE5GCudpdV8,1320
7
- AIEmailAutomationUtility/Process_Category.py,sha256=IMqvDVvuMNeLtQ2heFIyp1UKkz2AN1hAT02lXo8Pywk,53664
7
+ AIEmailAutomationUtility/Process_Category.py,sha256=FtScGPRZfqE9zm2zauR6uT751jTsT4rVY8sxQJFvOQA,53813
8
8
  AIEmailAutomationUtility/Save_Draft.py,sha256=yzLgFN14I_lXE6qL0I3tKNduvcnWdbsY9i2mKdTtio4,5348
9
9
  AIEmailAutomationUtility/Save_Transaction.py,sha256=Gg1w6hhzHmEFjsuzYvkq-3-EsWReetjLHsYSv5YIGgM,3816
10
10
  AIEmailAutomationUtility/__init__.py,sha256=Jad3IdPRsVMeLqEEh-FbCrc1lE2tzJO2DTG5Hgmxh5g,391
11
- AIEmailAutomationUtility-0.0.34.dist-info/LICENCE.txt,sha256=2qX9IkEUBx0VJp1Vh9O2dsRwE-IpYId0lXDyn7OVsJ8,1073
12
- AIEmailAutomationUtility-0.0.34.dist-info/METADATA,sha256=eCpEKv1Cvin8-cceIQZ6OvbOsZ36o9EeijDAYgrM7Pw,627
13
- AIEmailAutomationUtility-0.0.34.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
14
- AIEmailAutomationUtility-0.0.34.dist-info/top_level.txt,sha256=3jTWrTUblVkaP7mpwY2UBSnrlfot5Ykpfsehyke-Uzw,25
15
- AIEmailAutomationUtility-0.0.34.dist-info/RECORD,,
11
+ AIEmailAutomationUtility-0.0.36.dist-info/LICENCE.txt,sha256=2qX9IkEUBx0VJp1Vh9O2dsRwE-IpYId0lXDyn7OVsJ8,1073
12
+ AIEmailAutomationUtility-0.0.36.dist-info/METADATA,sha256=uYOAi_nEs31p3yFSQbWWMRM_vQNT-5NA521wkCNK2uo,651
13
+ AIEmailAutomationUtility-0.0.36.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
14
+ AIEmailAutomationUtility-0.0.36.dist-info/top_level.txt,sha256=3jTWrTUblVkaP7mpwY2UBSnrlfot5Ykpfsehyke-Uzw,25
15
+ AIEmailAutomationUtility-0.0.36.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.45.1)
2
+ Generator: bdist_wheel (0.43.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5