Subversion Repositories SmartDukaan

Rev

Rev 7101 | Rev 7120 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7101 Rev 7109
Line 4636... Line 4636...
4636
    if circle:
4636
    if circle:
4637
        return circle
4637
        return circle
4638
    else:
4638
    else:
4639
        raise TransactionServiceException(119, 'No such circle')
4639
        raise TransactionServiceException(119, 'No such circle')
4640
    
4640
    
-
 
4641
def retrieve_hotspot_recharge_invoice(id):
-
 
4642
    recharge = RechargeTransaction.get_by(id = id)
-
 
4643
    filename = "tmp/recharge" + str(recharge.invoiceNumber) + ".pdf"
-
 
4644
    operator = ServiceProvider.get_by(id = recharge.operatorId).name
-
 
4645
    amount = recharge.amount
-
 
4646
    telNum = "+91 " + str(recharge.deviceNum)
-
 
4647
    customerName = recharge.name
-
 
4648
    invNum = str(recharge.invoiceNumber)
-
 
4649
    billingTime = recharge.responseTime
-
 
4650
    return __printRechargeInvoice(filename, operator, amount, telNum, customerName, invNum, billingTime)
-
 
4651
 
-
 
4652
def __printRechargeInvoice(filename, operator, amount, telNum, customerName, invNum, billingTime): 
-
 
4653
    PAGE_HEIGHT=defaultPageSize[1];
-
 
4654
    styles = getSampleStyleSheet()
-
 
4655
    styles.add(ParagraphStyle(name='prologue', alignment=TA_CENTER, fontName="Courier", rightIndent = 5, fontSize=10), alias='sH')
-
 
4656
    styles.add(ParagraphStyle(name='text', alignment=TA_JUSTIFY, fontName="Courier", fontSize=10), alias='text')
-
 
4657
    styles.add(ParagraphStyle(name='line', alignment=TA_CENTER, fontName="Courier", fontSize=10), alias='line')
-
 
4658
    styles.add(ParagraphStyle(name='epilogue', alignment=TA_CENTER, fontName="Courier", leftIndent = 30, rightIndent=36, fontSize=10), alias='ep')
-
 
4659
    
-
 
4660
    Story = []
-
 
4661
    prologueStyle = styles["prologue"]
-
 
4662
    lineStyle = styles["line"]
-
 
4663
    textStyle = styles["text"]
-
 
4664
    epilogueStyle = styles["epilogue"]
-
 
4665
 
-
 
4666
    doc = BaseDocTemplate(filename,showBoundary=0)
-
 
4667
 
-
 
4668
    #Two Columns
-
 
4669
    frame1 = Frame(58, doc.bottomMargin, doc.width/2 + 25, doc.height + 7, id='col1')
-
 
4670
    
-
 
4671
    
-
 
4672
 
-
 
4673
    Story.append(Paragraph("""Spice Retail Limited<br></br>
-
 
4674
        C/O,PIBCO LIMITED,Basement,Punjsons<br></br>
-
 
4675
        2,Kalkaji Industrial Area,New Delhi<br></br>
-
 
4676
          .<br></br>
-
 
4677
        TIN NO. 07430284979<br></br>
-
 
4678
        Service Tax No:AAACM0294PST001<br></br><br></br><br></br>""", prologueStyle))
-
 
4679
    drawLine(Story, lineStyle)
-
 
4680
    
-
 
4681
    Story.append(Paragraph('{0:7s}{1:>11s}{2:  %d/%m/%Y  %H:%M:%S}'.format("INV NO:", invNum, billingTime).replace(" ", "&nbsp;"), textStyle))
-
 
4682
    drawLine(Story, lineStyle)
-
 
4683
    
-
 
4684
    Story.append(Paragraph("{0:<6s}{1:<34s}".format("NAME:", customerName).replace(" ", "&nbsp;"), textStyle))
-
 
4685
    Story.append(Paragraph("{0:<9s}{1:<31s}".format("TEL NO.:", telNum).replace(" ", "&nbsp;"), textStyle))
-
 
4686
    drawLine(Story, lineStyle)
-
 
4687
    
-
 
4688
    Story.append(Paragraph(('{0:<16s}{1:>13s}{2:11.2f}').format(operator, "RECHARGE", amount).replace(' ', '&nbsp;'),textStyle))
-
 
4689
    drawLine(Story, lineStyle)
-
 
4690
    doc.addPageTemplates([PageTemplate(id='TwoCol',frames=[frame1]), ])
-
 
4691
 
-
 
4692
    #start the construction of the pdf
-
 
4693
    doc.build(Story)
-
 
4694
    
-
 
4695
    try:
-
 
4696
        fileToSend = open(filename, "rb")
-
 
4697
        pdfFile = fileToSend.read()
-
 
4698
    except:
-
 
4699
        return bin(0)
4641
    
4700
    
-
 
4701
    return pdfFile
4642
 
4702
 
4643
if __name__ == '__main__':
4703
if __name__ == '__main__':
4644
    print 'helllo'
4704
    print 'helllo'
4645
4705