DivyaShah2025 commited on
Commit
10e104c
·
verified ·
1 Parent(s): d41fade

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. Proforma_Invoice_Abbott_20250712.pdf +5 -5
  2. 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:20250712191149+05'00') /Creator (ReportLab PDF Library - www.reportlab.com) /Keywords () /ModDate (D:20250712191149+05'00') /Producer (ReportLab PDF Library - www.reportlab.com)
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 1094
57
  >>
58
  stream
59
- GasaoflH(3'Rf-pmRpX+9EgO=7>@^K$(5lJkQZ6GC>OUqJu<IBO[W@CpEO1QFc\tqP^mhAF*2R-#%Sd"s.0o)_\fru%%';m!pk,YLnEWiDZ/1]?H3FhTPpE1d.)'.!/cR=Ciq+''n=D<LII>\I%U:5LsRW.65oYmIhcGB92a%[(sCL^f"MOn*:D#B3lI==hdbD<J:J:(I0%*2REm4dq9&aZVm!GIdJ`MFrsS?=2IPDqg*aJ'-LB8s7T,K(RujY"RG\(ajFiNCQG`$+aij#&.P7KDkdZVa4[e^GRcWFpctdl&S;S"dfI#c8qJ1*6c4SXh*elA8/A3ho@`)*p&E25@j#%Jig1E!7Lo;9\f`I*,ES:XaLTfpbK$oa0-N?cp@H_02S2ZGO@L()QeColiU:TrI8Cq*Xn?OX3/8N&MMq2lYL)_@A^TN?[@3"#>1X/W.Bn,"%D1Y;t(*Y5g!MN=T@!82Hjfg_EZ:R^j[cr(*W,/4b.B`D3cG1Zmo'7^m%/!Whgp@Qa\Y7RP-8NW7rTFB4AbhY,@uZMMd2D6\Nf\1?7D_H]]?UO>"&>\+@!k4b#^)5uo)V;hap!\u0Om([?rb_ab32Uj4D,*SkY3TZ.enMt4g=^3L;dSSh@U?B6(cfCX&aE4/kQ^k%T9XGTot+<e2Xa^7XR=On0\@2)Nn97i&R5j$I;4$*k/-McYi0gHnZR.4GsHjmN)jGN:FM4DNVJBm<H^jG8PDGZFg<]Zb[+&JS0sfclKre'ukT<$*s9;&!EJIoVbQ\cm[U"@h51=`Oh*Y1tjFuKu4M&#]#9XPJmeW0C$I(e*s?"=Vuh;0Ob2Ge&JRWF&eH4c9ERPUfh8VV;kUT@KUr'9creQC;k^;@#<aGgcZ/,gC'Y@$:CbpBhTM?:VbC#9I(V1)p:XK6)p/"G:"j1B?jD2ZYDQUBF+f>[OYd_A-%FNq4p$l<Q/[;WIh$jhE=ZR'5ef(qKZ!uj=YY^gs!uSB/\Wms'\,l)>#s?@A>Tq^atEOch``8m7`Ld23WmVg"T[PVC;\eZ>BdL93,Zd`GtL/N,`t/MJDgb=4$6IQ^,s!YGKB66[`CGHD[N"D['DF")be`ZN~>endstream
60
  endobj
61
  xref
62
  0 10
@@ -73,7 +73,7 @@ xref
73
  trailer
74
  <<
75
  /ID
76
- [<62c478dc2f38a0ce31f699b3694f8912><62c478dc2f38a0ce31f699b3694f8912>]
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
- 14842
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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,2t$fA93"al)ZKoF4`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, f"{product['rate']:.2f}")
151
- c.drawString(480, row_y, f"{product['total']:.2f}")
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, f"{subtotal:.2f}")
158
  c.drawString(400, row_y - 40, f"GST @ {gst_percentage}%")
159
- c.drawString(480, row_y - 40, f"{gst_amount:.2f}")
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, f"{grand_total:.2f}")
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="youremail@domain.com", # ✅ your verified sender
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>"