Upload folder using huggingface_hub
Browse files- Proforma_Invoice_Abbott_20250712.pdf +5 -5
- app.py +13 -6
Proforma_Invoice_Abbott_20250712.pdf
CHANGED
|
@@ -42,7 +42,7 @@ endobj
|
|
| 42 |
endobj
|
| 43 |
7 0 obj
|
| 44 |
<<
|
| 45 |
-
/Author (anonymous) /CreationDate (D:
|
| 46 |
/Subject (unspecified) /Title (untitled) /Trapped /False
|
| 47 |
>>
|
| 48 |
endobj
|
|
@@ -53,10 +53,10 @@ endobj
|
|
| 53 |
endobj
|
| 54 |
9 0 obj
|
| 55 |
<<
|
| 56 |
-
/Filter [ /ASCII85Decode /FlateDecode ] /Length
|
| 57 |
>>
|
| 58 |
stream
|
| 59 |
-
|
| 60 |
endobj
|
| 61 |
xref
|
| 62 |
0 10
|
|
@@ -73,7 +73,7 @@ xref
|
|
| 73 |
trailer
|
| 74 |
<<
|
| 75 |
/ID
|
| 76 |
-
[<
|
| 77 |
% ReportLab generated PDF document -- digest (http://www.reportlab.com)
|
| 78 |
|
| 79 |
/Info 7 0 R
|
|
@@ -81,5 +81,5 @@ trailer
|
|
| 81 |
/Size 10
|
| 82 |
>>
|
| 83 |
startxref
|
| 84 |
-
|
| 85 |
%%EOF
|
|
|
|
| 42 |
endobj
|
| 43 |
7 0 obj
|
| 44 |
<<
|
| 45 |
+
/Author (anonymous) /CreationDate (D:20250712194344+05'00') /Creator (ReportLab PDF Library - www.reportlab.com) /Keywords () /ModDate (D:20250712194344+05'00') /Producer (ReportLab PDF Library - www.reportlab.com)
|
| 46 |
/Subject (unspecified) /Title (untitled) /Trapped /False
|
| 47 |
>>
|
| 48 |
endobj
|
|
|
|
| 53 |
endobj
|
| 54 |
9 0 obj
|
| 55 |
<<
|
| 56 |
+
/Filter [ /ASCII85Decode /FlateDecode ] /Length 1106
|
| 57 |
>>
|
| 58 |
stream
|
| 59 |
+
Gasaofok&K'Rf-pmRsQl;Cn!DaRBn0VPho!OFYfFRQ#ddj2@6#=erplO,O701nlFbP3m=WF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oF4`1r~>endstream
|
| 60 |
endobj
|
| 61 |
xref
|
| 62 |
0 10
|
|
|
|
| 73 |
trailer
|
| 74 |
<<
|
| 75 |
/ID
|
| 76 |
+
[<a112cf557d12b4b50a28254a28e2036a><a112cf557d12b4b50a28254a28e2036a>]
|
| 77 |
% ReportLab generated PDF document -- digest (http://www.reportlab.com)
|
| 78 |
|
| 79 |
/Info 7 0 R
|
|
|
|
| 81 |
/Size 10
|
| 82 |
>>
|
| 83 |
startxref
|
| 84 |
+
14854
|
| 85 |
%%EOF
|
app.py
CHANGED
|
@@ -8,6 +8,8 @@ import json
|
|
| 8 |
import base64
|
| 9 |
from sendgrid import SendGridAPIClient
|
| 10 |
from sendgrid.helpers.mail import Mail, Attachment, FileContent, FileName, FileType, Disposition
|
|
|
|
|
|
|
| 11 |
|
| 12 |
|
| 13 |
# Initialize OpenAI
|
|
@@ -49,6 +51,9 @@ def parse_natural_language(prompt_text):
|
|
| 49 |
|
| 50 |
return parsed
|
| 51 |
|
|
|
|
|
|
|
|
|
|
| 52 |
def generate_proforma_invoice_from_prompt(prompt_text):
|
| 53 |
# Call OpenAI to parse
|
| 54 |
parsed = parse_natural_language(prompt_text)
|
|
@@ -141,26 +146,28 @@ def generate_proforma_invoice_from_prompt(prompt_text):
|
|
| 141 |
c.drawString(480, table_top - 15, "Value")
|
| 142 |
c.line(50, table_top - 20, width - 50, table_top - 20)
|
| 143 |
|
|
|
|
|
|
|
| 144 |
c.setFont("Helvetica", 10)
|
| 145 |
row_y = table_top - 35
|
| 146 |
for product in product_rows:
|
| 147 |
c.drawString(50, row_y, product['description'])
|
| 148 |
c.drawString(250, row_y, product['code'])
|
| 149 |
c.drawString(350, row_y, str(product['qty']))
|
| 150 |
-
c.drawString(400, row_y,
|
| 151 |
-
c.drawString(480, row_y,
|
| 152 |
row_y -= 20
|
| 153 |
|
| 154 |
# Totals
|
| 155 |
c.line(350, row_y - 10, width - 50, row_y - 10)
|
| 156 |
c.drawString(400, row_y - 25, "Total")
|
| 157 |
-
c.drawString(480, row_y - 25,
|
| 158 |
c.drawString(400, row_y - 40, f"GST @ {gst_percentage}%")
|
| 159 |
-
c.drawString(480, row_y - 40,
|
| 160 |
c.line(350, row_y - 45, width - 50, row_y - 45)
|
| 161 |
c.setFont("Helvetica-Bold", 10)
|
| 162 |
c.drawString(400, row_y - 60, "GRAND TOTAL")
|
| 163 |
-
c.drawString(480, row_y - 60,
|
| 164 |
|
| 165 |
# Bank Details
|
| 166 |
bank_y = row_y - 90
|
|
@@ -199,7 +206,7 @@ def send_invoice_email(pdf_filename):
|
|
| 199 |
raise RuntimeError("SENDGRID_API_KEY is not set in your environment")
|
| 200 |
|
| 201 |
message = Mail(
|
| 202 |
-
from_email="
|
| 203 |
to_emails="truevybescg@gmail.com",
|
| 204 |
subject="New Proforma Invoice",
|
| 205 |
html_content="<p>Dear True Vybes Team,<br><br>Please find attached the new Proforma Invoice.<br><br>Regards,<br>Automated System</p>"
|
|
|
|
| 8 |
import base64
|
| 9 |
from sendgrid import SendGridAPIClient
|
| 10 |
from sendgrid.helpers.mail import Mail, Attachment, FileContent, FileName, FileType, Disposition
|
| 11 |
+
import locale
|
| 12 |
+
locale.setlocale(locale.LC_ALL, 'en_IN')
|
| 13 |
|
| 14 |
|
| 15 |
# Initialize OpenAI
|
|
|
|
| 51 |
|
| 52 |
return parsed
|
| 53 |
|
| 54 |
+
def format_inr(value):
|
| 55 |
+
return "Rs. {:,.2f}".format(value)
|
| 56 |
+
|
| 57 |
def generate_proforma_invoice_from_prompt(prompt_text):
|
| 58 |
# Call OpenAI to parse
|
| 59 |
parsed = parse_natural_language(prompt_text)
|
|
|
|
| 146 |
c.drawString(480, table_top - 15, "Value")
|
| 147 |
c.line(50, table_top - 20, width - 50, table_top - 20)
|
| 148 |
|
| 149 |
+
|
| 150 |
+
# Product rows
|
| 151 |
c.setFont("Helvetica", 10)
|
| 152 |
row_y = table_top - 35
|
| 153 |
for product in product_rows:
|
| 154 |
c.drawString(50, row_y, product['description'])
|
| 155 |
c.drawString(250, row_y, product['code'])
|
| 156 |
c.drawString(350, row_y, str(product['qty']))
|
| 157 |
+
c.drawString(400, row_y, format_inr(product['rate']))
|
| 158 |
+
c.drawString(480, row_y, format_inr(product['total']))
|
| 159 |
row_y -= 20
|
| 160 |
|
| 161 |
# Totals
|
| 162 |
c.line(350, row_y - 10, width - 50, row_y - 10)
|
| 163 |
c.drawString(400, row_y - 25, "Total")
|
| 164 |
+
c.drawString(480, row_y - 25, format_inr(subtotal))
|
| 165 |
c.drawString(400, row_y - 40, f"GST @ {gst_percentage}%")
|
| 166 |
+
c.drawString(480, row_y - 40, format_inr(gst_amount))
|
| 167 |
c.line(350, row_y - 45, width - 50, row_y - 45)
|
| 168 |
c.setFont("Helvetica-Bold", 10)
|
| 169 |
c.drawString(400, row_y - 60, "GRAND TOTAL")
|
| 170 |
+
c.drawString(480, row_y - 60, format_inr(grand_total))
|
| 171 |
|
| 172 |
# Bank Details
|
| 173 |
bank_y = row_y - 90
|
|
|
|
| 206 |
raise RuntimeError("SENDGRID_API_KEY is not set in your environment")
|
| 207 |
|
| 208 |
message = Mail(
|
| 209 |
+
from_email="truevybescg@gmail.com", # ✅ your verified sender
|
| 210 |
to_emails="truevybescg@gmail.com",
|
| 211 |
subject="New Proforma Invoice",
|
| 212 |
html_content="<p>Dear True Vybes Team,<br><br>Please find attached the new Proforma Invoice.<br><br>Regards,<br>Automated System</p>"
|