| Line 5257... |
Line 5257... |
| 5257 |
return orders
|
5257 |
return orders
|
| 5258 |
|
5258 |
|
| 5259 |
def get_store_order_advance_invoice(orderId, storeId):
|
5259 |
def get_store_order_advance_invoice(orderId, storeId):
|
| 5260 |
order = Order.get_by(id = orderId)
|
5260 |
order = Order.get_by(id = orderId)
|
| 5261 |
storeOrderDetail = StoreOrderDetail.query.filter(StoreOrderDetail.orderId == orderId).filter(StoreOrderDetail.storeId == storeId).first()
|
5261 |
storeOrderDetail = StoreOrderDetail.query.filter(StoreOrderDetail.orderId == orderId).filter(StoreOrderDetail.storeId == storeId).first()
|
| 5262 |
filename = "/tmp/recharge" + str(order.id) + ".pdf"
|
- |
|
| - |
|
5262 |
|
| 5263 |
modelName = " "
|
5263 |
modelName = " "
|
| 5264 |
modelNumber = " "
|
5264 |
modelNumber = " "
|
| 5265 |
color = " "
|
5265 |
color = " "
|
| 5266 |
if order.lineitems[0].model_name:
|
5266 |
if order.lineitems[0].model_name:
|
| 5267 |
modelName = modelName + order.lineitems[0].model_name
|
5267 |
modelName = modelName + order.lineitems[0].model_name
|
| Line 5282... |
Line 5282... |
| 5282 |
customerState = order.customer_state
|
5282 |
customerState = order.customer_state
|
| 5283 |
customerMobile = order.customer_mobilenumber
|
5283 |
customerMobile = order.customer_mobilenumber
|
| 5284 |
customerPin = order.customer_pincode
|
5284 |
customerPin = order.customer_pincode
|
| 5285 |
inCash = storeOrderDetail.cashAmount
|
5285 |
inCash = storeOrderDetail.cashAmount
|
| 5286 |
byCard = storeOrderDetail.cardAmount
|
5286 |
byCard = storeOrderDetail.cardAmount
|
| - |
|
5287 |
|
| - |
|
5288 |
if storeOrderDetail.cashRefundAmount > 0 or storeOrderDetail.cashRefundAmount > 0:
|
| - |
|
5289 |
filename = "/tmp/order-refund-" + str(order.id) + ".pdf"
|
| - |
|
5290 |
inCash = storeOrderDetail.cashRefundAmount
|
| - |
|
5291 |
byCard = storeOrderDetail.cardRefundAmount
|
| - |
|
5292 |
return __printStoreOrderCancellationReceipt(order.id, filename, customerName, customerAdd1, customerAdd2, customerCity, customerState, customerMobile, customerPin, product, advanceAmount,inCash, byCard, order.created_timestamp.date())
|
| - |
|
5293 |
else:
|
| - |
|
5294 |
filename = "/tmp/order-" + str(order.id) + ".pdf"
|
| 5287 |
#payMethod = recharge.payMethod
|
5295 |
#payMethod = recharge.payMethod
|
| 5288 |
# if order.status == 15 or order.status == 34:
|
5296 |
# if order.status == 15 or order.status == 34:
|
| 5289 |
# return __printStoreOrderAdvanceInvoice(filename, product, advanceAmount, totalAmount, customerName, delivery, mode, customerAdd1, customerAdd2, customerCity, customerState, customerMobile, customerPin)
|
5297 |
# return __printStoreOrderAdvanceInvoice(filename, product, advanceAmount, totalAmount, customerName, delivery, mode, customerAdd1, customerAdd2, customerCity, customerState, customerMobile, customerPin)
|
| 5290 |
return __printStoreOrderAdvanceInvoice(filename, product, advanceAmount, totalAmount, customerName, delivery, inCash, byCard, customerAdd1, customerAdd2, customerCity, customerState, customerMobile, customerPin)
|
5298 |
return __printStoreOrderAdvanceInvoice(order.id, filename, product, advanceAmount, totalAmount, customerName, delivery, inCash, byCard, customerAdd1, customerAdd2, customerCity, customerState, customerMobile, customerPin)
|
| - |
|
5299 |
|
| - |
|
5300 |
def __printStoreOrderCancellationReceipt(orderId, filename, customerName, customerAdd1, customerAdd2, customerCity, customerState, customerMobile, customerPin, product, advanceAmount,inCash, byCard, createdDate):
|
| - |
|
5301 |
PAGE_HEIGHT=defaultPageSize[1];
|
| - |
|
5302 |
styles = getSampleStyleSheet()
|
| - |
|
5303 |
styles.add(ParagraphStyle(name='prologue', alignment=TA_CENTER, fontName="Courier", rightIndent = 5, fontSize=10), alias='sH')
|
| - |
|
5304 |
styles.add(ParagraphStyle(name='text', alignment=TA_JUSTIFY, fontName="Courier", fontSize=10), alias='text')
|
| - |
|
5305 |
styles.add(ParagraphStyle(name='line', alignment=TA_CENTER, fontName="Courier", fontSize=10), alias='line')
|
| - |
|
5306 |
styles.add(ParagraphStyle(name='epilogue', alignment=TA_CENTER, fontName="Courier", leftIndent = 30, rightIndent=36, fontSize=10), alias='ep')
|
| - |
|
5307 |
|
| - |
|
5308 |
Story = []
|
| - |
|
5309 |
prologueStyle = styles["prologue"]
|
| - |
|
5310 |
lineStyle = styles["line"]
|
| - |
|
5311 |
textStyle = styles["text"]
|
| - |
|
5312 |
epilogueStyle = styles["epilogue"]
|
| 5291 |
|
5313 |
|
| - |
|
5314 |
doc = BaseDocTemplate(filename,showBoundary=0)
|
| 5292 |
|
5315 |
|
| - |
|
5316 |
#Two Columns
|
| - |
|
5317 |
frame1 = Frame(58, doc.bottomMargin, doc.width/2 + 25, doc.height + 7, id='col1')
|
| - |
|
5318 |
|
| - |
|
5319 |
|
| - |
|
5320 |
############### TODO ###############################################################
|
| - |
|
5321 |
Story.append(Paragraph("""Spice Retail Limited<br></br>
|
| - |
|
5322 |
C/O,PIBCO LIMITED,Basement,Punjsons<br></br>
|
| - |
|
5323 |
2,Kalkaji Industrial Area,New Delhi<br></br>
|
| - |
|
5324 |
.<br></br>""", prologueStyle))
|
| - |
|
5325 |
############### ADDRESS TO BE DYNAMIC ##############################################
|
| - |
|
5326 |
|
| - |
|
5327 |
drawLine(Story, lineStyle)
|
| - |
|
5328 |
|
| - |
|
5329 |
Story.append(Paragraph("{0:^39s}".format("*** ADVANCE CANCELLATION RECEIPT ***").replace(" ", " "), textStyle))
|
| - |
|
5330 |
|
| - |
|
5331 |
drawLine(Story, lineStyle)
|
| - |
|
5332 |
|
| - |
|
5333 |
Story.append(Paragraph("{0:<6s}{1:<34s}".format("NAME:", customerName).replace(" ", " "), textStyle))
|
| - |
|
5334 |
Story.append(Paragraph("{0:<10s}{1:<29s}".format("MOBILE:", customerMobile).replace(" ", " "), textStyle))
|
| - |
|
5335 |
Story.append(Paragraph("{0:<10s}{1:<29s}".format("ORDER ID:", str(orderId)).replace(" ", " "), textStyle))
|
| - |
|
5336 |
Story.append(Paragraph("{0:<20s}{1: %d/%m/%Y}".format("ORDER DATE:", createdDate).replace(" ", " "), textStyle))
|
| - |
|
5337 |
Story.append(Paragraph("{0:<20s}{1: %d/%m/%Y}".format("CANCEL DATE:", datetime.datetime.now().date()).replace(" ", " "), textStyle))
|
| - |
|
5338 |
|
| - |
|
5339 |
drawLine(Story, lineStyle)
|
| - |
|
5340 |
|
| - |
|
5341 |
Story.append(Paragraph("{0:^39s}".format("DELIVERY ADDRESS").replace(" ", " "), textStyle))
|
| - |
|
5342 |
|
| - |
|
5343 |
drawLine(Story, lineStyle)
|
| - |
|
5344 |
|
| - |
|
5345 |
Story.append(Paragraph(customerAdd1, textStyle))
|
| - |
|
5346 |
if len(customerAdd2) > 0:
|
| - |
|
5347 |
Story.append(Paragraph(customerAdd2, textStyle))
|
| - |
|
5348 |
Story.append(Paragraph(customerCity, textStyle))
|
| - |
|
5349 |
Story.append(Paragraph(customerState + " - " + customerPin, textStyle))
|
| - |
|
5350 |
|
| - |
|
5351 |
drawLine(Story, lineStyle)
|
| - |
|
5352 |
|
| - |
|
5353 |
Story.append(Paragraph("{0:^39s}".format("PRODUCT NAME").replace(" ", " "), textStyle))
|
| - |
|
5354 |
|
| - |
|
5355 |
drawLine(Story, lineStyle)
|
| - |
|
5356 |
|
| - |
|
5357 |
Story.append(Paragraph(product, textStyle))
|
| - |
|
5358 |
|
| - |
|
5359 |
drawLine(Story, lineStyle)
|
| - |
|
5360 |
|
| - |
|
5361 |
Story.append(Paragraph(('{0:<20s}{1:>19.2f}').format("ADVANCE AMOUNT: ", advanceAmount).replace(' ', ' '),textStyle))
|
| - |
|
5362 |
Story.append(Paragraph(('{0:<30s}{1:>9.2f}').format("LESS-CANCELLATION CHARGES: ", advanceAmount-inCash-byCard).replace(' ', ' '),textStyle))
|
| - |
|
5363 |
Story.append(Paragraph(('{0:<30s}{1:>9.2f}').format("AMOUNT TO BE REFUNDED: ", inCash+byCard).replace(' ', ' '),textStyle))
|
| - |
|
5364 |
if inCash > 0:
|
| - |
|
5365 |
Story.append(Paragraph(('{0:<20s}{1:>19.2f}').format("REFUND IN CASH: ", inCash).replace(' ', ' '),textStyle))
|
| - |
|
5366 |
if byCard > 0:
|
| - |
|
5367 |
Story.append(Paragraph(('{0:<20s}{1:>19.2f}').format("REFUND BY CARD: ", byCard).replace(' ', ' '),textStyle))
|
| - |
|
5368 |
|
| - |
|
5369 |
drawLine(Story, lineStyle)
|
| - |
|
5370 |
|
| - |
|
5371 |
Story.append(Paragraph("CUSTOMER SIGNATURE :", textStyle))
|
| - |
|
5372 |
Story.append(Paragraph(" ", textStyle))
|
| - |
|
5373 |
|
| - |
|
5374 |
drawLine(Story, lineStyle)
|
| - |
|
5375 |
|
| - |
|
5376 |
drawLine(Story, lineStyle)
|
| - |
|
5377 |
|
| - |
|
5378 |
Story.append(Paragraph("Note:", textStyle))
|
| - |
|
5379 |
Story.append(Paragraph("* Original copy of 'Advance Receipt' Shall be provided by Customer to get the refund",textStyle))
|
| - |
|
5380 |
|
| - |
|
5381 |
drawLine(Story, lineStyle)
|
| - |
|
5382 |
|
| - |
|
5383 |
Story.append(Paragraph(('{0:<20s}{1:>19s}').format("Customer care : ", "0120-6744700").replace(' ', ' '),textStyle))
|
| - |
|
5384 |
|
| - |
|
5385 |
drawLine(Story, lineStyle)
|
| - |
|
5386 |
|
| - |
|
5387 |
doc.addPageTemplates([PageTemplate(id='TwoCol',frames=[frame1]), ])
|
| - |
|
5388 |
#start the construction of the pdf
|
| - |
|
5389 |
doc.build(Story)
|
| - |
|
5390 |
try:
|
| - |
|
5391 |
fileToSend = open(filename, "rb")
|
| - |
|
5392 |
pdfFile = fileToSend.read()
|
| - |
|
5393 |
except:
|
| - |
|
5394 |
return bin(0)
|
| - |
|
5395 |
|
| - |
|
5396 |
return pdfFile
|
| - |
|
5397 |
|
| - |
|
5398 |
|
| - |
|
5399 |
|
| - |
|
5400 |
|
| 5293 |
def __printStoreOrderAdvanceInvoice(filename, product, advanceAmount, totalAmount, customerName, delivery, inCash, byCard, customerAdd1, customerAdd2, customerCity, customerState, customerMobile, customerPin):
|
5401 |
def __printStoreOrderAdvanceInvoice(orderId, filename, product, advanceAmount, totalAmount, customerName, delivery, inCash, byCard, customerAdd1, customerAdd2, customerCity, customerState, customerMobile, customerPin):
|
| 5294 |
PAGE_HEIGHT=defaultPageSize[1];
|
5402 |
PAGE_HEIGHT=defaultPageSize[1];
|
| 5295 |
styles = getSampleStyleSheet()
|
5403 |
styles = getSampleStyleSheet()
|
| 5296 |
styles.add(ParagraphStyle(name='prologue', alignment=TA_CENTER, fontName="Courier", rightIndent = 5, fontSize=10), alias='sH')
|
5404 |
styles.add(ParagraphStyle(name='prologue', alignment=TA_CENTER, fontName="Courier", rightIndent = 5, fontSize=10), alias='sH')
|
| 5297 |
styles.add(ParagraphStyle(name='text', alignment=TA_JUSTIFY, fontName="Courier", fontSize=10), alias='text')
|
5405 |
styles.add(ParagraphStyle(name='text', alignment=TA_JUSTIFY, fontName="Courier", fontSize=10), alias='text')
|
| 5298 |
styles.add(ParagraphStyle(name='line', alignment=TA_CENTER, fontName="Courier", fontSize=10), alias='line')
|
5406 |
styles.add(ParagraphStyle(name='line', alignment=TA_CENTER, fontName="Courier", fontSize=10), alias='line')
|
| Line 5331... |
Line 5439... |
| 5331 |
Story.append(Paragraph(customerState + " - " + customerPin, textStyle))
|
5439 |
Story.append(Paragraph(customerState + " - " + customerPin, textStyle))
|
| 5332 |
drawLine(Story, lineStyle)
|
5440 |
drawLine(Story, lineStyle)
|
| 5333 |
|
5441 |
|
| 5334 |
Story.append(Paragraph("{0:<6s}{1:<34s}".format("NAME:", customerName).replace(" ", " "), textStyle))
|
5442 |
Story.append(Paragraph("{0:<6s}{1:<34s}".format("NAME:", customerName).replace(" ", " "), textStyle))
|
| 5335 |
Story.append(Paragraph("{0:<10s}{1:<29s}".format("MOBILE:", customerMobile).replace(" ", " "), textStyle))
|
5443 |
Story.append(Paragraph("{0:<10s}{1:<29s}".format("MOBILE:", customerMobile).replace(" ", " "), textStyle))
|
| - |
|
5444 |
Story.append(Paragraph("{0:<10s}{1:<29s}".format("ORDER ID:", str(orderId)).replace(" ", " "), textStyle))
|
| 5336 |
Story.append(Paragraph("{0:<20s}{1: %d/%m/%Y}".format("EXPECTED DELIVERY:", delivery).replace(" ", " "), textStyle))
|
5445 |
Story.append(Paragraph("{0:<20s}{1: %d/%m/%Y}".format("EXPECTED DELIVERY:", delivery).replace(" ", " "), textStyle))
|
| 5337 |
|
5446 |
|
| 5338 |
drawLine(Story, lineStyle)
|
5447 |
drawLine(Story, lineStyle)
|
| 5339 |
Story.append(Paragraph("{0:^39s}".format("PRODUCT NAME").replace(" ", " "), textStyle))
|
5448 |
Story.append(Paragraph("{0:^39s}".format("PRODUCT NAME").replace(" ", " "), textStyle))
|
| 5340 |
drawLine(Story, lineStyle)
|
5449 |
drawLine(Story, lineStyle)
|
| 5341 |
Story.append(Paragraph("{0:<39s}".format(product).replace(" ", " "), textStyle))
|
5450 |
Story.append(Paragraph("{0:<39s}".format(product).replace(" ", " "), textStyle))
|
| 5342 |
drawLine(Story, lineStyle)
|
5451 |
drawLine(Story, lineStyle)
|
| 5343 |
|
5452 |
|
| 5344 |
Story.append(Paragraph(('{0:<20s}{1:>19.2f}').format("TOTAL PRICE: ", totalAmount).replace(' ', ' '),textStyle))
|
5453 |
Story.append(Paragraph(('{0:<20s}{1:>19.2f}').format("TOTAL PRICE: ", totalAmount).replace(' ', ' '),textStyle))
|
| 5345 |
Story.append(Paragraph(('{0:<20s}{1:>19.2f}').format("ADVANCE AMOUNT: ", advanceAmount).replace(' ', ' '),textStyle))
|
5454 |
Story.append(Paragraph(('{0:<20s}{1:>19.2f}').format("ADVANCE AMOUNT: ", advanceAmount).replace(' ', ' '),textStyle))
|
| - |
|
5455 |
if inCash > 0:
|
| 5346 |
Story.append(Paragraph(('{0:<20s}{1:>19.2f}').format("IN CASH: ", inCash).replace(' ', ' '),textStyle))
|
5456 |
Story.append(Paragraph(('{0:<20s}{1:>19.2f}').format("IN CASH: ", inCash).replace(' ', ' '),textStyle))
|
| - |
|
5457 |
if byCard > 0:
|
| 5347 |
Story.append(Paragraph(('{0:<20s}{1:>19.2f}').format("BY CARD: ", byCard).replace(' ', ' '),textStyle))
|
5458 |
Story.append(Paragraph(('{0:<20s}{1:>19.2f}').format("BY CARD: ", byCard).replace(' ', ' '),textStyle))
|
| 5348 |
Story.append(Paragraph(('{0:<20s}{1:>19.2f}').format("BALANCE TO BE PAID: ", (totalAmount - advanceAmount)).replace(' ', ' '),textStyle))
|
5459 |
Story.append(Paragraph(('{0:<20s}{1:>19.2f}').format("BALANCE TO BE PAID: ", (totalAmount - advanceAmount)).replace(' ', ' '),textStyle))
|
| 5349 |
|
5460 |
|
| 5350 |
drawLine(Story, lineStyle)
|
5461 |
drawLine(Story, lineStyle)
|
| 5351 |
Story.append(Paragraph("Note:", textStyle))
|
5462 |
Story.append(Paragraph("Note:", textStyle))
|
| 5352 |
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))
|
5463 |
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))
|
| Line 5407... |
Line 5518... |
| 5407 |
ds_storeOrderDetail.advanceAmount = thrift_storeOrderDetail.advanceAmount
|
5518 |
ds_storeOrderDetail.advanceAmount = thrift_storeOrderDetail.advanceAmount
|
| 5408 |
ds_storeOrderDetail.cardAmount = thrift_storeOrderDetail.cardAmount
|
5519 |
ds_storeOrderDetail.cardAmount = thrift_storeOrderDetail.cardAmount
|
| 5409 |
ds_storeOrderDetail.cashAmount = thrift_storeOrderDetail.cashAmount
|
5520 |
ds_storeOrderDetail.cashAmount = thrift_storeOrderDetail.cashAmount
|
| 5410 |
ds_storeOrderDetail.storeId = thrift_storeOrderDetail.storeId
|
5521 |
ds_storeOrderDetail.storeId = thrift_storeOrderDetail.storeId
|
| 5411 |
ds_storeOrderDetail.payStatus = thrift_storeOrderDetail.payStatus
|
5522 |
ds_storeOrderDetail.payStatus = thrift_storeOrderDetail.payStatus
|
| - |
|
5523 |
ds_storeOrderDetail.cardRefundAmount = thrift_storeOrderDetail.cardRefundAmount
|
| - |
|
5524 |
ds_storeOrderDetail.cashRefundAmount = thrift_storeOrderDetail.cashRefundAmount
|
| - |
|
5525 |
ds_storeOrderDetail.edcBank = thrift_storeOrderDetail.edcBank
|
| 5412 |
session.commit()
|
5526 |
session.commit()
|
| 5413 |
return True
|
5527 |
return True
|
| 5414 |
|
5528 |
|
| 5415 |
def get_store_order_detail(orderId, storeId):
|
5529 |
def get_store_order_detail(orderId, storeId):
|
| 5416 |
storeOrderDetail = StoreOrderDetail.query.filter(StoreOrderDetail.orderId == orderId).filter(StoreOrderDetail.storeId == storeId).first()
|
5530 |
storeOrderDetail = StoreOrderDetail.query.filter(StoreOrderDetail.orderId == orderId).filter(StoreOrderDetail.storeId == storeId).first()
|