| Line 11... |
Line 11... |
| 11 |
from elixir import *
|
11 |
from elixir import *
|
| 12 |
from random import randrange
|
12 |
from random import randrange
|
| 13 |
from reportlab.lib.units import inch
|
13 |
from reportlab.lib.units import inch
|
| 14 |
from reportlab.pdfgen.canvas import Canvas
|
14 |
from reportlab.pdfgen.canvas import Canvas
|
| 15 |
from reportlab.rl_config import defaultPageSize
|
15 |
from reportlab.rl_config import defaultPageSize
|
| - |
|
16 |
from reportlab.lib.enums import TA_CENTER
|
| 16 |
from reportlab.lib.styles import ParagraphStyle
|
17 |
from reportlab.lib.styles import ParagraphStyle
|
| 17 |
from reportlab.lib.styles import getSampleStyleSheet
|
18 |
from reportlab.lib.styles import getSampleStyleSheet
|
| 18 |
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer
|
19 |
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Image
|
| 19 |
from shop2020.clients.AlertClient import AlertClient
|
20 |
from shop2020.clients.AlertClient import AlertClient
|
| 20 |
from shop2020.clients.CatalogClient import CatalogClient
|
21 |
from shop2020.clients.CatalogClient import CatalogClient
|
| 21 |
from shop2020.clients.HelperClient import HelperClient
|
22 |
from shop2020.clients.HelperClient import HelperClient
|
| 22 |
from shop2020.clients.InventoryClient import InventoryClient
|
23 |
from shop2020.clients.InventoryClient import InventoryClient
|
| 23 |
from shop2020.clients.LogisticsClient import LogisticsClient
|
24 |
from shop2020.clients.LogisticsClient import LogisticsClient
|
| Line 4187... |
Line 4188... |
| 4187 |
else:
|
4188 |
else:
|
| 4188 |
return None
|
4189 |
return None
|
| 4189 |
|
4190 |
|
| 4190 |
def myFirstPage(canvas, doc):
|
4191 |
def myFirstPage(canvas, doc):
|
| 4191 |
canvas.saveState()
|
4192 |
canvas.saveState()
|
| 4192 |
canvas.setFont('Times-Bold',14)
|
- |
|
| 4193 |
canvas.drawCentredString(PAGE_WIDTH/2.0, PAGE_HEIGHT- inch, "MOBILE HAND SET INSURANCE – THEFT & BURGLARY RISKS ONLY")
|
- |
|
| 4194 |
canvas.setTitle("Insurance Terms")
|
4193 |
canvas.setTitle("Theft-Insurance-Policy")
|
| 4195 |
canvas.restoreState()
|
4194 |
canvas.restoreState()
|
| 4196 |
|
4195 |
|
| 4197 |
|
4196 |
|
| 4198 |
def __generate_policy_doc(order, filename):
|
4197 |
def __generate_policy_doc(order, filename):
|
| 4199 |
PAGE_HEIGHT=defaultPageSize[1]; PAGE_WIDTH=defaultPageSize[0]
|
4198 |
PAGE_HEIGHT=defaultPageSize[1]; PAGE_WIDTH=defaultPageSize[0]
|
| 4200 |
styles = getSampleStyleSheet()
|
4199 |
styles = getSampleStyleSheet()
|
| 4201 |
styles.add(ParagraphStyle(name='left', leftIndent=12,fontSize=11), alias='li')
|
4200 |
styles.add(ParagraphStyle(name='left', leftIndent=12,fontSize=11), alias='li')
|
| 4202 |
styles.add(ParagraphStyle(name='bullet', bulletIndent=24, leftIndent=24), alias='bull')
|
4201 |
styles.add(ParagraphStyle(name='bullet', bulletIndent=24, leftIndent=24), alias='bull')
|
| - |
|
4202 |
styles.add(ParagraphStyle(name='insurerName', alignment=TA_CENTER, fontName="Times-Bold", fontSize=16), alias='iN')
|
| - |
|
4203 |
styles.add(ParagraphStyle(name='insurerAdd', alignment=TA_CENTER, fontName="Helvetica",leading=15, fontSize=12), alias='iA')
|
| - |
|
4204 |
styles.add(ParagraphStyle(name='subHeading', alignment=TA_CENTER, fontName="Helvetica", fontSize=13), alias='sH')
|
| 4203 |
|
4205 |
|
| 4204 |
invoiceNumber = str(order.invoice_number)
|
4206 |
invoiceNumber = str(order.invoice_number)
|
| 4205 |
billing_timestamp = str(order.billing_timestamp.date())
|
4207 |
billing_timestamp = str(order.billing_timestamp.date())
|
| 4206 |
|
4208 |
|
| 4207 |
doc = SimpleDocTemplate(filename)
|
4209 |
doc = SimpleDocTemplate(filename)
|
| 4208 |
Story = [Spacer(1,0.4*inch)]
|
4210 |
Story = [Spacer(0, 0)]
|
| 4209 |
style = styles["Normal"]
|
4211 |
style = styles["Normal"]
|
| - |
|
4212 |
|
| - |
|
4213 |
|
| - |
|
4214 |
file_name = os.path.dirname(os.path.realpath(__file__)) + '/../resources/nia-logo.jpg'
|
| - |
|
4215 |
image = Image(file_name, width=100, height=100)
|
| - |
|
4216 |
Story.append(image)
|
| - |
|
4217 |
Story.append(Spacer(1,0.2*inch))
|
| - |
|
4218 |
|
| - |
|
4219 |
text = ("""<u>The New India Assurance Company Limited</u>""")
|
| - |
|
4220 |
p = Paragraph(text, styles['insurerName'])
|
| - |
|
4221 |
Story.append(p)
|
| - |
|
4222 |
Story.append(Spacer(1,0.2*inch))
|
| - |
|
4223 |
|
| - |
|
4224 |
text = ("""DO-IX, 35/1, Fortune Park, 1st Floor, Park Road, Tasker Town, Shivajinagar, Bangalore 560051""")
|
| - |
|
4225 |
p = Paragraph(text, styles['insurerAdd'])
|
| - |
|
4226 |
Story.append(p)
|
| - |
|
4227 |
Story.append(Spacer(1,0.3*inch))
|
| - |
|
4228 |
|
| - |
|
4229 |
text = ("""MOBILE HAND SET INSURANCE – THEFT & BURGLARY RISKS ONLY""")
|
| - |
|
4230 |
p = Paragraph(text, styles['subHeading'])
|
| - |
|
4231 |
Story.append(p)
|
| - |
|
4232 |
Story.append(Spacer(1,1*inch))
|
| - |
|
4233 |
|
| 4210 |
text = ("""<u><b>Subject Matter Of Insurance</b></u> : <i>New Mobile Handsets</i> alone and <i>Tablets with 'Voice Calls'</i> only.
|
4234 |
text = ("""<u><b>Subject Matter Of Insurance</b></u> : <i>New Mobile Handsets</i> alone and <i>Tablets with 'Voice Calls'</i> only.
|
| 4211 |
Sold 'online' by <b>Spice Online Retail Private Limited, New Delhi</b>, to its customers.""")
|
4235 |
Sold 'online' by <b>Spice Online Retail Private Limited, New Delhi</b>, to its customers.""")
|
| 4212 |
p = Paragraph(text, style)
|
4236 |
p = Paragraph(text, style)
|
| 4213 |
Story.append(p)
|
4237 |
Story.append(p)
|
| 4214 |
Story.append(Spacer(1,0.2*inch))
|
4238 |
Story.append(Spacer(1,0.2*inch))
|
| Line 4237... |
Line 4261... |
| 4237 |
Story.append(p)
|
4261 |
Story.append(p)
|
| 4238 |
Story.append(Spacer(1,0.2*inch))
|
4262 |
Story.append(Spacer(1,0.2*inch))
|
| 4239 |
text = ("<b>RISK COVERAGE</b> – Theft and/or burglary only")
|
4263 |
text = ("<b>RISK COVERAGE</b> – Theft and/or burglary only")
|
| 4240 |
p = Paragraph(text, style)
|
4264 |
p = Paragraph(text, style)
|
| 4241 |
Story.append(p)
|
4265 |
Story.append(p)
|
| 4242 |
Story.append(Spacer(1,0.2*inch))
|
4266 |
Story.append(Spacer(1,0.4*inch))
|
| 4243 |
text = ("Terms and Conditions of Insurance:")
|
4267 |
text = ("Terms and Conditions of Insurance:")
|
| 4244 |
p = Paragraph(text, styles["h2"])
|
4268 |
p = Paragraph(text, styles["h2"])
|
| 4245 |
Story.append(p)
|
4269 |
Story.append(p)
|
| 4246 |
Story.append(Spacer(1,0.1*inch))
|
4270 |
Story.append(Spacer(1,0.1*inch))
|
| 4247 |
text = ("""Insurance Premium paid will not be refunded.""")
|
4271 |
text = ("""Insurance Premium paid will not be refunded.""")
|
| Line 4249... |
Line 4273... |
| 4249 |
Story.append(p)
|
4273 |
Story.append(p)
|
| 4250 |
Story.append(Spacer(1,0.1*inch))
|
4274 |
Story.append(Spacer(1,0.1*inch))
|
| 4251 |
text = ("""Insurance will be invalidated for returned products.""")
|
4275 |
text = ("""Insurance will be invalidated for returned products.""")
|
| 4252 |
p = Paragraph(text, styles["bullet"], bulletText='\xe2\x80\xa2')
|
4276 |
p = Paragraph(text, styles["bullet"], bulletText='\xe2\x80\xa2')
|
| 4253 |
Story.append(p)
|
4277 |
Story.append(p)
|
| 4254 |
Story.append(Spacer(1,0.2*inch))
|
4278 |
Story.append(Spacer(1,0.4*inch))
|
| 4255 |
text = ("Exclusions:")
|
4279 |
text = ("Exclusions:")
|
| 4256 |
p = Paragraph(text, styles["h2"])
|
4280 |
p = Paragraph(text, styles["h2"])
|
| 4257 |
Story.append(p)
|
4281 |
Story.append(p)
|
| 4258 |
Story.append(Spacer(1,0.1*inch))
|
4282 |
Story.append(Spacer(1,0.1*inch))
|
| 4259 |
text = ("Insurer is not liable")
|
4283 |
text = ("Insurer is not liable")
|
| Line 4364... |
Line 4388... |
| 4364 |
Story.append(Spacer(1,0.2*inch))
|
4388 |
Story.append(Spacer(1,0.2*inch))
|
| 4365 |
|
4389 |
|
| 4366 |
doc.build(Story, onFirstPage=myFirstPage)
|
4390 |
doc.build(Story, onFirstPage=myFirstPage)
|
| 4367 |
|
4391 |
|
| 4368 |
if __name__ == '__main__':
|
4392 |
if __name__ == '__main__':
|
| 4369 |
try:
|
- |
|
| 4370 |
DataService.initialize("transaction", "localhost", True)
|
- |
|
| 4371 |
order = Order.get_by(id = 127)
|
- |
|
| 4372 |
__generate_policy_doc(order, "/home/anupam/Desktop/testing.pdf")
|
- |
|
| 4373 |
print "Done"
|
- |
|
| 4374 |
except:
|
- |
|
| 4375 |
print "error"
|
- |
|
| 4376 |
|
4393 |
DataService.initialize("transaction", "localhost", True)
|
| - |
|
4394 |
order = Order.get_by(id = 127)
|
| - |
|
4395 |
__generate_policy_doc(order, "/home/anupam/Desktop/testing.pdf")
|
| - |
|
4396 |
|