| Line 5096... |
Line 5096... |
| 5096 |
|
5096 |
|
| 5097 |
def get_amazon_order(order_id):
|
5097 |
def get_amazon_order(order_id):
|
| 5098 |
return AmazonOrder.get_by(orderId=order_id)
|
5098 |
return AmazonOrder.get_by(orderId=order_id)
|
| 5099 |
|
5099 |
|
| 5100 |
|
5100 |
|
| - |
|
5101 |
def get_orders_for_store(orderId, storeId, startDate, endDate, statuses):
|
| - |
|
5102 |
orders = []
|
| - |
|
5103 |
query = Order.query
|
| - |
|
5104 |
if storeId < 1:
|
| - |
|
5105 |
return orders
|
| - |
|
5106 |
elif orderId > 0:
|
| - |
|
5107 |
query = query.filter(Order.id == orderId)
|
| - |
|
5108 |
else :
|
| - |
|
5109 |
if startDate:
|
| - |
|
5110 |
query = query.filter(cast(Order.created_timestamp, DATE) >= startDate.date())
|
| - |
|
5111 |
|
| - |
|
5112 |
if endDate:
|
| - |
|
5113 |
query = query.filter(cast(Order.created_timestamp, DATE) <= endDate.date())
|
| - |
|
5114 |
|
| - |
|
5115 |
if len(statuses) > 0:
|
| - |
|
5116 |
query = query.filter(Order.status.in_(statuses))
|
| - |
|
5117 |
|
| - |
|
5118 |
orders = query.filter(Order.storeId == storeId).all()
|
| - |
|
5119 |
return orders
|
| - |
|
5120 |
|
| - |
|
5121 |
def get_store_order_advance_invoice(orderId):
|
| - |
|
5122 |
order = Order.get_by(id = orderId)
|
| - |
|
5123 |
filename = "/tmp/recharge" + str(order.id) + ".pdf"
|
| - |
|
5124 |
product = order.lineitems[0].brand + order.lineitems[0].model_name + order.lineitems[0].model_number + order.lineitems[0].color
|
| - |
|
5125 |
amount = order.advanceAmount
|
| - |
|
5126 |
totalAmount = order.total_amount
|
| - |
|
5127 |
delivery = order.created_timestamp
|
| - |
|
5128 |
customerName = order.customer_name
|
| - |
|
5129 |
#payMethod = recharge.payMethod
|
| - |
|
5130 |
return __printStoreOrderAdvanceInvoice(filename, product, amount, totalAmount, customerName, delivery)
|
| - |
|
5131 |
|
| - |
|
5132 |
|
| - |
|
5133 |
def __printStoreOrderAdvanceInvoice(filename, product, amount, totalAmount, customerName, delivery):
|
| - |
|
5134 |
PAGE_HEIGHT=defaultPageSize[1];
|
| - |
|
5135 |
styles = getSampleStyleSheet()
|
| - |
|
5136 |
styles.add(ParagraphStyle(name='prologue', alignment=TA_CENTER, fontName="Courier", rightIndent = 5, fontSize=10), alias='sH')
|
| - |
|
5137 |
styles.add(ParagraphStyle(name='text', alignment=TA_JUSTIFY, fontName="Courier", fontSize=10), alias='text')
|
| - |
|
5138 |
styles.add(ParagraphStyle(name='line', alignment=TA_CENTER, fontName="Courier", fontSize=10), alias='line')
|
| - |
|
5139 |
styles.add(ParagraphStyle(name='epilogue', alignment=TA_CENTER, fontName="Courier", leftIndent = 30, rightIndent=36, fontSize=10), alias='ep')
|
| - |
|
5140 |
|
| - |
|
5141 |
Story = []
|
| - |
|
5142 |
prologueStyle = styles["prologue"]
|
| - |
|
5143 |
lineStyle = styles["line"]
|
| - |
|
5144 |
textStyle = styles["text"]
|
| - |
|
5145 |
epilogueStyle = styles["epilogue"]
|
| - |
|
5146 |
|
| - |
|
5147 |
doc = BaseDocTemplate(filename,showBoundary=0)
|
| - |
|
5148 |
|
| - |
|
5149 |
#Two Columns
|
| - |
|
5150 |
frame1 = Frame(58, doc.bottomMargin, doc.width/2 + 25, doc.height + 7, id='col1')
|
| - |
|
5151 |
|
| - |
|
5152 |
|
| - |
|
5153 |
|
| - |
|
5154 |
Story.append(Paragraph("""Spice Retail Limited<br></br>
|
| - |
|
5155 |
C/O,PIBCO LIMITED,Basement,Punjsons<br></br>
|
| - |
|
5156 |
2,Kalkaji Industrial Area,New Delhi<br></br>
|
| - |
|
5157 |
.<br></br>
|
| - |
|
5158 |
TIN NO. 07430284979<br></br>
|
| - |
|
5159 |
Service Tax No:AAACM0294PST001<br></br><br></br><br></br>""", prologueStyle))
|
| - |
|
5160 |
drawLine(Story, lineStyle)
|
| - |
|
5161 |
|
| - |
|
5162 |
|
| - |
|
5163 |
Story.append(Paragraph("{0:<6s}{1:<34s}".format("NAME:", customerName).replace(" ", " "), textStyle))
|
| - |
|
5164 |
Story.append(Paragraph("{0:<15s}{1: %d/%m/%Y}".format("EXP DELIVERY:", delivery).replace(" ", " "), textStyle))
|
| - |
|
5165 |
Story.append(Paragraph("{0:<15s}{1:<25s}".format("PAYMENT MODE:", "CARD").replace(" ", " "), textStyle))
|
| - |
|
5166 |
|
| - |
|
5167 |
drawLine(Story, lineStyle)
|
| - |
|
5168 |
Story.append(Paragraph("{0:<15s}{1:<25s}".format("PAYMENT MODE:", "CARD").replace(" ", " "), textStyle))
|
| - |
|
5169 |
drawLine(Story, lineStyle)
|
| - |
|
5170 |
Story.append(Paragraph("{0:<39s}".format(product).replace(" ", " "), textStyle))
|
| - |
|
5171 |
drawLine(Story, lineStyle)
|
| - |
|
5172 |
|
| - |
|
5173 |
Story.append(Paragraph(('{0:<20s}{1:>19.2f}').format("TOTAL PRICE: ", totalAmount).replace(' ', ' '),textStyle))
|
| - |
|
5174 |
Story.append(Paragraph(('{0:<20s}{1:>19.2f}').format("ADVANCE PAID: ", amount).replace(' ', ' '),textStyle))
|
| - |
|
5175 |
|
| - |
|
5176 |
drawLine(Story, lineStyle)
|
| - |
|
5177 |
|
| - |
|
5178 |
doc.addPageTemplates([PageTemplate(id='TwoCol',frames=[frame1]), ])
|
| - |
|
5179 |
|
| - |
|
5180 |
#start the construction of the pdf
|
| - |
|
5181 |
doc.build(Story)
|
| - |
|
5182 |
|
| - |
|
5183 |
try:
|
| - |
|
5184 |
fileToSend = open(filename, "rb")
|
| - |
|
5185 |
pdfFile = fileToSend.read()
|
| - |
|
5186 |
except:
|
| - |
|
5187 |
return bin(0)
|
| - |
|
5188 |
|
| - |
|
5189 |
return pdfFile
|
| - |
|
5190 |
|
| 5101 |
if __name__ == '__main__':
|
5191 |
if __name__ == '__main__':
|
| 5102 |
print 'helllo'
|
5192 |
print 'helllo'
|
| 5103 |
|
5193 |
|