| 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.enums import TA_CENTER,TA_JUSTIFY
|
| 17 |
from reportlab.lib.styles import ParagraphStyle
|
17 |
from reportlab.lib.styles import ParagraphStyle
|
| 18 |
from reportlab.lib.styles import getSampleStyleSheet
|
18 |
from reportlab.lib.styles import getSampleStyleSheet
|
| 19 |
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Image
|
19 |
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Image, \
|
| - |
|
20 |
BaseDocTemplate, Frame, PageTemplate
|
| 20 |
from shop2020.clients.AlertClient import AlertClient
|
21 |
from shop2020.clients.AlertClient import AlertClient
|
| 21 |
from shop2020.clients.CatalogClient import CatalogClient
|
22 |
from shop2020.clients.CatalogClient import CatalogClient
|
| 22 |
from shop2020.clients.HelperClient import HelperClient
|
23 |
from shop2020.clients.HelperClient import HelperClient
|
| 23 |
from shop2020.clients.InventoryClient import InventoryClient
|
24 |
from shop2020.clients.InventoryClient import InventoryClient
|
| 24 |
from shop2020.clients.LogisticsClient import LogisticsClient
|
25 |
from shop2020.clients.LogisticsClient import LogisticsClient
|
| Line 64... |
Line 65... |
| 64 |
import sys
|
65 |
import sys
|
| 65 |
import time
|
66 |
import time
|
| 66 |
import traceback
|
67 |
import traceback
|
| 67 |
import urllib
|
68 |
import urllib
|
| 68 |
|
69 |
|
| 69 |
|
- |
|
| 70 |
import time
|
- |
|
| 71 |
|
- |
|
| 72 |
|
- |
|
| 73 |
from shop2020.config.client.ConfigClient import ConfigClient
|
70 |
from shop2020.config.client.ConfigClient import ConfigClient
|
| 74 |
from shop2020.model.v1.order.impl.model.RechargePlan import RechargePlan
|
71 |
from shop2020.model.v1.order.impl.model.RechargePlan import RechargePlan
|
| 75 |
from shop2020.model.v1.order.impl.model.RechargeOrder import RechargeOrder
|
72 |
from shop2020.model.v1.order.impl.model.RechargeOrder import RechargeOrder
|
| 76 |
from shop2020.model.v1.order.impl.model.UserWallet import UserWallet
|
73 |
from shop2020.model.v1.order.impl.model.UserWallet import UserWallet
|
| 77 |
from shop2020.model.v1.order.impl.model.UserWalletHistory import UserWalletHistory
|
74 |
from shop2020.model.v1.order.impl.model.UserWalletHistory import UserWalletHistory
|
| Line 4398... |
Line 4395... |
| 4398 |
p = Paragraph(text, style)
|
4395 |
p = Paragraph(text, style)
|
| 4399 |
Story.append(p)
|
4396 |
Story.append(p)
|
| 4400 |
Story.append(Spacer(1,0.2*inch))
|
4397 |
Story.append(Spacer(1,0.2*inch))
|
| 4401 |
|
4398 |
|
| 4402 |
doc.build(Story, onFirstPage=myFirstPage)
|
4399 |
doc.build(Story, onFirstPage=myFirstPage)
|
| - |
|
4400 |
|
| - |
|
4401 |
def drawLine(Story, style):
|
| - |
|
4402 |
Story.append(Paragraph('-'*40, style))
|
| - |
|
4403 |
|
| - |
|
4404 |
def generateHotSpotInvoice():
|
| - |
|
4405 |
|
| - |
|
4406 |
##########TO BE PASSED TO THIS METHOD####################################
|
| - |
|
4407 |
#########################################################################
|
| - |
|
4408 |
filename = "/home/anupam/test.pdf" ##########
|
| - |
|
4409 |
itemCode = "SPICEMI450WHT" ##########
|
| - |
|
4410 |
lotNumber = "12345678901234" ##########
|
| - |
|
4411 |
itemName = "Spice Stellar Craze Mi-450 White" ##########
|
| - |
|
4412 |
qty = 1 ##########
|
| - |
|
4413 |
unitPrice = 3099.50 ##########
|
| - |
|
4414 |
vat = 310.23 ##########
|
| - |
|
4415 |
billingTime = datetime.datetime.now() ##########
|
| - |
|
4416 |
invNum = "885182994" ##########
|
| - |
|
4417 |
counter = 1 ##########
|
| - |
|
4418 |
ourInvoiceNum = "209809" ##########
|
| - |
|
4419 |
customerId = "12345678909" ##########
|
| - |
|
4420 |
customerName = "ANUPAM PRATAP SINGH" ##########
|
| - |
|
4421 |
telNum = "" ##########
|
| - |
|
4422 |
#########################################################################
|
| - |
|
4423 |
|
| - |
|
4424 |
PAGE_HEIGHT=defaultPageSize[1];
|
| - |
|
4425 |
styles = getSampleStyleSheet()
|
| - |
|
4426 |
styles.add(ParagraphStyle(name='prologue', alignment=TA_CENTER, fontName="Courier", rightIndent = 5, fontSize=10), alias='sH')
|
| - |
|
4427 |
styles.add(ParagraphStyle(name='text', alignment=TA_JUSTIFY, fontName="Courier", fontSize=10), alias='text')
|
| - |
|
4428 |
styles.add(ParagraphStyle(name='line', alignment=TA_CENTER, fontName="Courier", fontSize=10), alias='line')
|
| - |
|
4429 |
styles.add(ParagraphStyle(name='epilogue', alignment=TA_CENTER, fontName="Courier", leftIndent = 30, rightIndent=36, fontSize=10), alias='ep')
|
| - |
|
4430 |
|
| - |
|
4431 |
Story = []
|
| - |
|
4432 |
prologueStyle = styles["prologue"]
|
| - |
|
4433 |
lineStyle = styles["line"]
|
| - |
|
4434 |
textStyle = styles["text"]
|
| - |
|
4435 |
epilogueStyle = styles["epilogue"]
|
| - |
|
4436 |
|
| - |
|
4437 |
doc = BaseDocTemplate(filename,showBoundary=0)
|
| - |
|
4438 |
|
| - |
|
4439 |
#Two Columns
|
| - |
|
4440 |
frame1 = Frame(58, doc.bottomMargin, doc.width/2 + 25, doc.height + 7, id='col1')
|
| - |
|
4441 |
|
| - |
|
4442 |
|
| - |
|
4443 |
|
| - |
|
4444 |
Story.append(Paragraph("""Spice Retail Limited<br></br>
|
| - |
|
4445 |
C/O,PIBCO LIMITED,Basement,Punjsons<br></br>
|
| - |
|
4446 |
2,Kalkaji Industrial Area,New Delhi<br></br>
|
| - |
|
4447 |
.<br></br>
|
| - |
|
4448 |
TIN NO. 07430284979<br></br>
|
| - |
|
4449 |
Service Tax No:AAACM0294PST001<br></br>
|
| - |
|
4450 |
D U P L I C A T E<br></br>
|
| - |
|
4451 |
I N V O I C E<br></br>""", prologueStyle))
|
| - |
|
4452 |
drawLine(Story, lineStyle)
|
| - |
|
4453 |
|
| - |
|
4454 |
Story.append(Paragraph('{0:7s}{1:>11s}{2: %d/%m/%Y %H:%M:%S}'.format("INV NO:", invNum, billingTime).replace(" ", " "), textStyle))
|
| - |
|
4455 |
Story.append(Paragraph("{0:8s}{1:>5d}{2:>11s}{3:>11s}".format('COUNTER:', counter, "CASHIER:", "SUPERADMIN").replace(" ", " "), textStyle))
|
| - |
|
4456 |
Story.append(Paragraph("MN INV NO&DT: {0:<13s}{1:%d/%m/%Y} ".format(ourInvoiceNum, billingTime).replace(" ", " "), textStyle))
|
| - |
|
4457 |
drawLine(Story, lineStyle)
|
| - |
|
4458 |
|
| - |
|
4459 |
Story.append(Paragraph("{0:<13s}{1:<27s}".format("CUSTOMER ID:", customerId).replace(" ", " "), textStyle))
|
| - |
|
4460 |
Story.append(Paragraph("{0:<6s}{1:<34s}".format("NAME:", customerName + " " + ourInvoiceNum).replace(" ", " "), textStyle))
|
| - |
|
4461 |
Story.append(Paragraph("{0:<9s}{1:<31s}".format("TEL NO.:", telNum).replace(" ", " "), textStyle))
|
| - |
|
4462 |
drawLine(Story, lineStyle)
|
| - |
|
4463 |
|
| - |
|
4464 |
Story.append(Paragraph("ITEM" + " "*12 + "LOT NUMBER<br></br>" + \
|
| - |
|
4465 |
" ITEM NAME<br></br>" + \
|
| - |
|
4466 |
" "*5 + "QTY" + " "*21 + "AMOUNT(INR)", textStyle))
|
| - |
|
4467 |
drawLine(Story, lineStyle)
|
| - |
|
4468 |
|
| - |
|
4469 |
Story.append(Paragraph(('{0:<16s}{1:24s}').format(itemCode, lotNumber).replace(' ', ' '),textStyle))
|
| - |
|
4470 |
Story.append(Paragraph((' {0:<39s}').format(itemName).replace(' ', ' '),textStyle))
|
| - |
|
4471 |
Story.append(Paragraph(('{0:<3d}{1:>10s}{2:13.2f}{3:14.2f}').format(qty, 'PCS', unitPrice, qty*unitPrice).replace(' ', ' '),textStyle))
|
| - |
|
4472 |
Story.append(Paragraph(('{0:<3s}{1:37.2f}').format("VAT", vat).replace(' ', ' '),textStyle))
|
| - |
|
4473 |
Story.append(Paragraph(('{0:<10s}{1:30.2f}').format("ITEM TOTAL", vat + unitPrice*qty).replace(' ', ' '),textStyle))
|
| - |
|
4474 |
|
| - |
|
4475 |
drawLine(Story, lineStyle)
|
| - |
|
4476 |
Story.append(Paragraph(('{0:13s}{1:>12s}{2:15.2f}').format("GROSS TOTAL:","INR", vat + unitPrice*qty).replace(' ', ' '),textStyle))
|
| - |
|
4477 |
drawLine(Story, lineStyle)
|
| - |
|
4478 |
|
| - |
|
4479 |
Story.append(Paragraph(('{0:13s}{1:>12s}{2:15.2f}').format("NET TOTAL:","INR", vat + unitPrice*qty).replace(' ', ' '),textStyle))
|
| - |
|
4480 |
Story.append(Paragraph(('{0:13s}{1:>12s}{2:15.2f}').format("NET VAT:","INR", vat).replace(' ', ' '),textStyle))
|
| - |
|
4481 |
drawLine(Story, lineStyle)
|
| - |
|
4482 |
|
| - |
|
4483 |
Story.append(Paragraph(('{0:13s}{1:>12s}{2:15.2f}').format("SPICE ONLINE:","INR", vat + unitPrice*qty).replace(' ', ' '),textStyle))
|
| - |
|
4484 |
drawLine(Story, lineStyle)
|
| - |
|
4485 |
|
| - |
|
4486 |
Story.append(Paragraph(('{0:16s}{1:>4d}').format("NUMBER OF ITEMS:",qty,).replace(' ', ' '),textStyle))
|
| - |
|
4487 |
Story.append(Paragraph(('{0:16s}{1:>9.6f}').format("TOTAL ITEMS :",qty,).replace(' ', ' '),textStyle))
|
| - |
|
4488 |
|
| - |
|
4489 |
Story.append(Paragraph("Goods once Sold Will not be taken back.<br></br>All Disputes subject to Delhi Jurisdiction",epilogueStyle))
|
| - |
|
4490 |
|
| - |
|
4491 |
|
| - |
|
4492 |
doc.addPageTemplates([PageTemplate(id='TwoCol',frames=[frame1]), ])
|
| - |
|
4493 |
|
| - |
|
4494 |
#start the construction of the pdf
|
| - |
|
4495 |
doc.build(Story)
|
| - |
|
4496 |
print 'done'
|
| 4403 |
|
4497 |
|
| 4404 |
if __name__ == '__main__':
|
4498 |
if __name__ == '__main__':
|
| 4405 |
DataService.initialize("transaction", "localhost", True)
|
- |
|
| 4406 |
order = Order.get_by(id = 127)
|
4499 |
print 'helllo'
|
| 4407 |
__generate_policy_doc(order, "/home/anupam/Desktop/testing.pdf")
|
- |
|
| 4408 |
|
4500 |
|