Subversion Repositories SmartDukaan

Rev

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

Rev 7423 Rev 7427
Line 5321... Line 5321...
5321
    else:
5321
    else:
5322
        filename = "/tmp/order-" + str(order.id) + ".pdf"
5322
        filename = "/tmp/order-" + str(order.id) + ".pdf"
5323
    #payMethod = recharge.payMethod
5323
    #payMethod = recharge.payMethod
5324
#    if order.status == 15 or order.status == 34:
5324
#    if order.status == 15 or order.status == 34:
5325
#        return __printStoreOrderAdvanceInvoice(filename, product, advanceAmount, totalAmount, customerName, delivery, mode, customerAdd1, customerAdd2, customerCity, customerState, customerMobile, customerPin)
5325
#        return __printStoreOrderAdvanceInvoice(filename, product, advanceAmount, totalAmount, customerName, delivery, mode, customerAdd1, customerAdd2, customerCity, customerState, customerMobile, customerPin)
5326
    return __printStoreOrderAdvanceInvoice(store, order.id, filename, product, advanceAmount, totalAmount, customerName, delivery, inCash, byCard, customerAdd1, customerAdd2, customerCity, customerState, customerMobile, customerPin)
5326
    return __printStoreOrderAdvanceInvoice(store, order.id, filename, product, advanceAmount, totalAmount, customerName, delivery, inCash, byCard, customerAdd1, customerAdd2, customerCity, customerState, customerMobile, customerPin, order.created_timestamp.date())
5327
 
5327
 
5328
def __printStoreOrderCancellationReceipt(store, orderId, filename, customerName, customerAdd1, customerAdd2, customerCity, customerState, customerMobile, customerPin, product, advanceAmount,inCash, byCard, createdDate, cancelDate): 
5328
def __printStoreOrderCancellationReceipt(store, orderId, filename, customerName, customerAdd1, customerAdd2, customerCity, customerState, customerMobile, customerPin, product, advanceAmount,inCash, byCard, createdDate, cancelDate): 
5329
    PAGE_HEIGHT=defaultPageSize[1];
5329
    PAGE_HEIGHT=defaultPageSize[1];
5330
    styles = getSampleStyleSheet()
5330
    styles = getSampleStyleSheet()
5331
    styles.add(ParagraphStyle(name='prologue', alignment=TA_CENTER, fontName="Courier", rightIndent = 5, fontSize=10), alias='sH')
5331
    styles.add(ParagraphStyle(name='prologue', alignment=TA_CENTER, fontName="Courier", rightIndent = 5, fontSize=10), alias='sH')
Line 5349... Line 5349...
5349
    Story.append(Paragraph(store.line2 + ', ' + store.city, prologueStyle))
5349
    Story.append(Paragraph(store.line2 + ', ' + store.city, prologueStyle))
5350
    Story.append(Paragraph(store.state + ' - ' + store.pin, prologueStyle))
5350
    Story.append(Paragraph(store.state + ' - ' + store.pin, prologueStyle))
5351
    
5351
    
5352
    drawLine(Story, lineStyle)
5352
    drawLine(Story, lineStyle)
5353
    
5353
    
5354
    Story.append(Paragraph("{0:^39s}".format("*** ADVANCE CANCELLATION RECEIPT ***").replace(" ", " "), textStyle))
5354
    Story.append(Paragraph("{0:^39s}".format("*** ADVANCE REFUND RECEIPT ***").replace(" ", " "), textStyle))
5355
    
5355
    
5356
    drawLine(Story, lineStyle)
5356
    drawLine(Story, lineStyle)
5357
   
5357
   
5358
    Story.append(Paragraph("{0:<6s}{1:<34s}".format("NAME:", customerName).replace(" ", "&nbsp;"), textStyle))
5358
    Story.append(Paragraph("{0:<6s}{1:<34s}".format("NAME:", customerName).replace(" ", "&nbsp;"), textStyle))
5359
    Story.append(Paragraph("{0:<10s}{1:<29s}".format("MOBILE:", customerMobile).replace(" ", "&nbsp;"), textStyle))
5359
    Story.append(Paragraph("{0:<10s}{1:<29s}".format("MOBILE:", customerMobile).replace(" ", "&nbsp;"), textStyle))
Line 5386... Line 5386...
5386
    
5386
    
5387
    Story.append(Paragraph(('{0:<20s}{1:>19.2f}').format("ADVANCE AMOUNT: ", advanceAmount).replace(' ', '&nbsp;'),textStyle))
5387
    Story.append(Paragraph(('{0:<20s}{1:>19.2f}').format("ADVANCE AMOUNT: ", advanceAmount).replace(' ', '&nbsp;'),textStyle))
5388
    Story.append(Paragraph(('{0:<30s}{1:>9.2f}').format("LESS-CANCELLATION CHARGES: ", advanceAmount-inCash-byCard).replace(' ', '&nbsp;'),textStyle))
5388
    Story.append(Paragraph(('{0:<30s}{1:>9.2f}').format("LESS-CANCELLATION CHARGES: ", advanceAmount-inCash-byCard).replace(' ', '&nbsp;'),textStyle))
5389
    Story.append(Paragraph(('{0:<30s}{1:>9.2f}').format("AMOUNT TO BE REFUNDED: ", inCash+byCard).replace(' ', '&nbsp;'),textStyle))
5389
    Story.append(Paragraph(('{0:<30s}{1:>9.2f}').format("AMOUNT TO BE REFUNDED: ", inCash+byCard).replace(' ', '&nbsp;'),textStyle))
5390
    if inCash > 0:
5390
    if inCash > 0:
5391
        Story.append(Paragraph(('{0:<20s}{1:>19.2f}').format("REFUND IN CASH: ", inCash).replace(' ', '&nbsp;'),textStyle))
5391
        Story.append(Paragraph(('{0:>20s}{1:>19.2f}').format("REFUND IN CASH: ", inCash).replace(' ', '&nbsp;'),textStyle))
5392
    if byCard > 0:
5392
    if byCard > 0:
5393
        Story.append(Paragraph(('{0:<20s}{1:>19.2f}').format("REFUND BY CARD: ", byCard).replace(' ', '&nbsp;'),textStyle))
5393
        Story.append(Paragraph(('{0:>20s}{1:>19.2f}').format("REFUND BY CARD: ", byCard).replace(' ', '&nbsp;'),textStyle))
5394
        
5394
        
5395
    drawLine(Story, lineStyle)
5395
    drawLine(Story, lineStyle)
5396
    
5396
    
5397
    Story.append(Paragraph("CUSTOMER SIGNATURE :", textStyle))
5397
    Story.append(Paragraph("CUSTOMER SIGNATURE :", textStyle))
5398
    Story.append(Paragraph("&nbsp;", textStyle))
5398
    Story.append(Paragraph("&nbsp;", textStyle))
Line 5400... Line 5400...
5400
    drawLine(Story, lineStyle)
5400
    drawLine(Story, lineStyle)
5401
    
5401
    
5402
    drawLine(Story, lineStyle)
5402
    drawLine(Story, lineStyle)
5403
    
5403
    
5404
    Story.append(Paragraph("Note:", textStyle))                                        
5404
    Story.append(Paragraph("Note:", textStyle))                                        
5405
    Story.append(Paragraph("* Original copy of 'Advance Receipt' Shall be provided  by Customer to get the refund",textStyle))                                        
5405
    Story.append(Paragraph("* Original copy of 'Advance Receipt' Shall be provided  by Customer to get the refund",textStyle))
-
 
5406
    Story.append(Paragraph("* All disputes subject to Delhi jusrisdiction",textStyle))                                        
5406
    
5407
    
5407
    drawLine(Story, lineStyle)
5408
    drawLine(Story, lineStyle)
5408
    
5409
    
5409
    Story.append(Paragraph(('{0:<20s}{1:>19s}').format("Customer care : ", "0120-6744700").replace(' ', '&nbsp;'),textStyle))
5410
    Story.append(Paragraph(('{0:<20s}{1:>19s}').format("Customer care : ", "0120-6744700").replace(' ', '&nbsp;'),textStyle))
5410
    
5411
    
Line 5422... Line 5423...
5422
    return pdfFile
5423
    return pdfFile
5423
    
5424
    
5424
    
5425
    
5425
    
5426
    
5426
    
5427
    
5427
def __printStoreOrderAdvanceInvoice(store, orderId, filename, product, advanceAmount, totalAmount, customerName, delivery, inCash, byCard, customerAdd1, customerAdd2, customerCity, customerState, customerMobile, customerPin): 
5428
def __printStoreOrderAdvanceInvoice(store, orderId, filename, product, advanceAmount, totalAmount, customerName, delivery, inCash, byCard, customerAdd1, customerAdd2, customerCity, customerState, customerMobile, customerPin, createdDate): 
5428
    PAGE_HEIGHT=defaultPageSize[1];
5429
    PAGE_HEIGHT=defaultPageSize[1];
5429
    styles = getSampleStyleSheet()
5430
    styles = getSampleStyleSheet()
5430
    styles.add(ParagraphStyle(name='prologue', alignment=TA_CENTER, fontName="Courier", rightIndent = 5, fontSize=10), alias='sH')
5431
    styles.add(ParagraphStyle(name='prologue', alignment=TA_CENTER, fontName="Courier", rightIndent = 5, fontSize=10), alias='sH')
5431
    styles.add(ParagraphStyle(name='text', alignment=TA_JUSTIFY, fontName="Courier", fontSize=10), alias='text')
5432
    styles.add(ParagraphStyle(name='text', alignment=TA_JUSTIFY, fontName="Courier", fontSize=10), alias='text')
5432
    styles.add(ParagraphStyle(name='line', alignment=TA_CENTER, fontName="Courier", fontSize=10), alias='line')
5433
    styles.add(ParagraphStyle(name='line', alignment=TA_CENTER, fontName="Courier", fontSize=10), alias='line')
Line 5463... Line 5464...
5463
    Story.append(Paragraph(customerState + " - " + customerPin, textStyle))
5464
    Story.append(Paragraph(customerState + " - " + customerPin, textStyle))
5464
    drawLine(Story, lineStyle)
5465
    drawLine(Story, lineStyle)
5465
    
5466
    
5466
    Story.append(Paragraph("{0:<6s}{1:<34s}".format("NAME:", customerName).replace(" ", "&nbsp;"), textStyle))
5467
    Story.append(Paragraph("{0:<6s}{1:<34s}".format("NAME:", customerName).replace(" ", "&nbsp;"), textStyle))
5467
    Story.append(Paragraph("{0:<10s}{1:<29s}".format("MOBILE:", customerMobile).replace(" ", "&nbsp;"), textStyle))
5468
    Story.append(Paragraph("{0:<10s}{1:<29s}".format("MOBILE:", customerMobile).replace(" ", "&nbsp;"), textStyle))
5468
    Story.append(Paragraph("{0:<10s}{1:<29s}".format("ORDER ID:", str(orderId)).replace(" ", "&nbsp;"), textStyle))
5469
    Story.append(Paragraph("{0:<10s}{1:<12s}{2:7s}{3:  %d/%m/%Y}".format("ORDER ID:", str(orderId), "DATE:", createdDate).replace(" ", "&nbsp;"), textStyle))
5469
    Story.append(Paragraph("{0:<20s}{1:  %d/%m/%Y}".format("EXPECTED DELIVERY:", delivery).replace(" ", "&nbsp;"), textStyle))
5470
    Story.append(Paragraph("{0:<20s}{1:  %d/%m/%Y}".format("EXPECTED DELIVERY:", delivery).replace(" ", "&nbsp;"), textStyle))
-
 
5471
    Story.append(Paragraph("{0:<20s}{1:  %d/%m/%Y}".format("CURRENT DATE:", datetime.datetime.now().date()).replace(" ", "&nbsp;"), textStyle))
5470
    
5472
    
5471
    drawLine(Story, lineStyle)
5473
    drawLine(Story, lineStyle)
5472
    Story.append(Paragraph("{0:^39s}".format("PRODUCT NAME").replace(" ", "&nbsp;"), textStyle))
5474
    Story.append(Paragraph("{0:^39s}".format("PRODUCT NAME").replace(" ", "&nbsp;"), textStyle))
5473
    drawLine(Story, lineStyle)
5475
    drawLine(Story, lineStyle)
5474
    Story.append(Paragraph("{0:<39s}".format(product).replace(" ", "&nbsp;"), textStyle))
5476
    Story.append(Paragraph("{0:<39s}".format(product).replace(" ", "&nbsp;"), textStyle))
5475
    drawLine(Story, lineStyle)
5477
    drawLine(Story, lineStyle)
5476
    
5478
    
5477
    Story.append(Paragraph(('{0:<20s}{1:>19.2f}').format("TOTAL PRICE: ", totalAmount).replace(' ', '&nbsp;'),textStyle))
5479
    Story.append(Paragraph(('{0:<20s}{1:>19.2f}').format("TOTAL PRICE: ", totalAmount).replace(' ', '&nbsp;'),textStyle))
5478
    Story.append(Paragraph(('{0:<20s}{1:>19.2f}').format("ADVANCE AMOUNT: ", advanceAmount).replace(' ', '&nbsp;'),textStyle))
5480
    Story.append(Paragraph(('{0:<20s}{1:>19.2f}').format("ADVANCE AMOUNT: ", advanceAmount).replace(' ', '&nbsp;'),textStyle))
5479
    if inCash > 0:
5481
    if inCash > 0:
5480
        Story.append(Paragraph(('{0:<20s}{1:>19.2f}').format("IN CASH: ", inCash).replace(' ', '&nbsp;'),textStyle))
5482
        Story.append(Paragraph(('{0:>13s}{1:>26.2f}').format("IN CASH: ", inCash).replace(' ', '&nbsp;'),textStyle))
5481
    if byCard > 0:
5483
    if byCard > 0:
5482
        Story.append(Paragraph(('{0:<20s}{1:>19.2f}').format("BY CARD: ", byCard).replace(' ', '&nbsp;'),textStyle))
5484
        Story.append(Paragraph(('{0:>13s}{1:>26.2f}').format("BY CARD: ", byCard).replace(' ', '&nbsp;'),textStyle))
5483
    Story.append(Paragraph(('{0:<20s}{1:>19.2f}').format("BALANCE TO BE PAID: ", (totalAmount - advanceAmount)).replace(' ', '&nbsp;'),textStyle))
5485
    Story.append(Paragraph(('{0:<20s}{1:>19.2f}').format("BALANCE TO BE PAID: ", (totalAmount - advanceAmount)).replace(' ', '&nbsp;'),textStyle))
5484
    
5486
    
5485
    drawLine(Story, lineStyle)
5487
    drawLine(Story, lineStyle)
5486
    Story.append(Paragraph("Note:", textStyle))                                        
5488
    Story.append(Paragraph("Note:", textStyle))                                        
5487
    Story.append(Paragraph("* In case of cancellation of order on customer request, 10% of product amount subject to minimum Rs 500/- shall be deducted by Spice Retail Limited as cancellation charges. Customer shall provide original copy of 'Advance Receipt' to get the balance amount as refund",textStyle))                                        
5489
    Story.append(Paragraph("* In case of cancellation of order on customer request, 10% of product amount subject to minimum Rs 500/- shall be deducted as cancellation charges. Customer shall provide original copy of 'Advance Receipt' to get the balance amount as refund",textStyle))                                        
5488
    Story.append(Paragraph("* In case of cancellation of order other than customer request, original copy of 'Advance Receipt' shall be provided by customer to get the refund",textStyle))                                        
-
 
5489
    Story.append(Paragraph("* Balance amount as mentioned above to be paid at the time of delivery of product to courier agency. Refusal to accept the product delivered through courier shall be deemed as cancellation of order and cancellation charges shall become applicable.",textStyle))                                         
5490
    Story.append(Paragraph("* Balance amount as mentioned above to be paid at the time of delivery of product to courier agency. Refusal to accept the product delivered through courier shall be deemed as cancellation of order and cancellation charges shall become applicable.",textStyle))                                         
5490
    Story.append(Paragraph("* The product as mentioned above shall be made available to the customer, subject to its availability from the manufacturer",textStyle))                                        
5491
    Story.append(Paragraph("* The product as mentioned above shall be made available to the customer, subject to its availability from the manufacturer",textStyle))
-
 
5492
    Story.append(Paragraph("* All disputes subject to Delhi Jurisdiction",textStyle))                                        
5491
    drawLine(Story, lineStyle)
5493
    drawLine(Story, lineStyle)
5492
    Story.append(Paragraph(('{0:<20s}{1:>19s}').format("Customer care : ", "0120-6744700").replace(' ', '&nbsp;'),textStyle))
5494
    Story.append(Paragraph(('{0:<20s}{1:>19s}').format("Customer care : ", "0120-6744700").replace(' ', '&nbsp;'),textStyle))
5493
    drawLine(Story, lineStyle)
5495
    drawLine(Story, lineStyle)
5494
    
5496
    
5495
    doc.addPageTemplates([PageTemplate(id='TwoCol',frames=[frame1]), ])
5497
    doc.addPageTemplates([PageTemplate(id='TwoCol',frames=[frame1]), ])
Line 5572... Line 5574...
5572
        storeOrderDetail.cardRefundAmount = cardRefundAmount
5574
        storeOrderDetail.cardRefundAmount = cardRefundAmount
5573
        session.commit()
5575
        session.commit()
5574
        return True
5576
        return True
5575
    else:
5577
    else:
5576
        return False
5578
        return False
-
 
5579
 
-
 
5580
def get_collections_for_store(storeId, startdate, enddate):
-
 
5581
    if startdate == -1:
-
 
5582
        startdate = None
-
 
5583
    if enddate == -1:
-
 
5584
        enddate = None
-
 
5585
    if storeId== 0:
-
 
5586
        storeId = None
-
 
5587
        
-
 
5588
    if storeId:
-
 
5589
        store = HotspotStore.get_by(id = storeId)
-
 
5590
        
-
 
5591
    hotspotId = store.hotspotId
-
 
5592
        
-
 
5593
    query = StoreOrderCollection.query
-
 
5594
    if storeId is not None:
-
 
5595
        query = query.filter(StoreOrderCollection.hotspotId == hotspotId)
-
 
5596
    else:
-
 
5597
        return []
-
 
5598
        
-
 
5599
    if startdate is not None and enddate is not None:
-
 
5600
        startdate = to_py_date(startdate).date()
-
 
5601
        enddate = to_py_date(enddate).date()
-
 
5602
        if startdate == enddate:
-
 
5603
            query = query.filter(cast(StoreOrderCollection.pushedAt, DATE) == enddate)
-
 
5604
        elif enddate < startdate:
-
 
5605
            query = query.filter(between(cast(StoreOrderCollection.pushedAt, DATE), enddate, startdate))
-
 
5606
        else:
-
 
5607
            query = query.filter(between(cast(StoreOrderCollection.pushedAt, DATE), startdate, enddate))
-
 
5608
    elif startdate is not None:
-
 
5609
        startdate = to_py_date(startdate).date()
-
 
5610
        query = query.filter(cast(StoreOrderCollection.pushedAt, DATE) >= startdate)
-
 
5611
    elif enddate is not None:
-
 
5612
        enddate = to_py_date(enddate).date()
-
 
5613
        query = query.filter(cast(StoreOrderCollection.pushedAt, DATE) <= enddate)
-
 
5614
 
-
 
5615
    return query.filter(StoreOrderCollection.pushedToOcr == 1).all()    
-
 
5616
 
5577
    
5617
    
5578
    
5618
    
5579
if __name__ == '__main__':
5619
if __name__ == '__main__':
5580
    print datetime.datetime.now()
5620
    print datetime.datetime.now()
5581
    print datetime.datetime.now().date()
5621
    print datetime.datetime.now().date()