| 4607 |
rajveer |
1 |
#!/usr/bin/python
|
|
|
2 |
|
|
|
3 |
'''
|
|
|
4 |
Creates a CSV report of all the shipped orders and send mail to Sandeep.
|
|
|
5 |
|
|
|
6 |
Created on 20-Feb-2012
|
|
|
7 |
|
|
|
8 |
@author: Rajveer
|
|
|
9 |
'''
|
| 5944 |
mandeep.dh |
10 |
from optparse import OptionParser
|
|
|
11 |
from shop2020.clients.InventoryClient import InventoryClient
|
|
|
12 |
from shop2020.clients.LogisticsClient import LogisticsClient
|
|
|
13 |
from shop2020.clients.TransactionClient import TransactionClient
|
|
|
14 |
from shop2020.thriftpy.model.v1.order.ttypes import Order, DelayReason
|
| 6004 |
rajveer |
15 |
from shop2020.utils.EmailAttachmentSender import get_attachment_part, mail_html
|
| 5944 |
mandeep.dh |
16 |
from shop2020.utils.Utils import to_py_date, to_java_date
|
|
|
17 |
import datetime
|
| 4607 |
rajveer |
18 |
import xlwt
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
if __name__ == '__main__' and __package__ is None:
|
|
|
23 |
import sys
|
|
|
24 |
import os
|
|
|
25 |
sys.path.insert(0, os.getcwd())
|
|
|
26 |
|
| 6501 |
rajveer |
27 |
to = ["sandeep.sachdeva@shop2020.in","suraj.sharma@shop2020.in", "chaitnaya.vats@shop2020.in", "khushal.bhatia@spiceretail.co.in", "rajneesharora@spiceretail.co.in", "chandan.kumar@shop2020.in"]
|
| 4607 |
rajveer |
28 |
|
| 4709 |
rajveer |
29 |
def generate_delayed_orders_file():
|
| 4607 |
rajveer |
30 |
txn_client = TransactionClient().get_client()
|
|
|
31 |
slipped_orders = txn_client.getSlippedSippingDateOrders()
|
|
|
32 |
|
|
|
33 |
wbk = xlwt.Workbook()
|
|
|
34 |
sheet = wbk.add_sheet('main')
|
|
|
35 |
|
|
|
36 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap on, vert centre, horiz center')
|
|
|
37 |
sheet.set_panes_frozen(True)
|
|
|
38 |
sheet.set_horz_split_pos(1)
|
|
|
39 |
sheet.set_remove_splits(True)
|
|
|
40 |
|
|
|
41 |
excel_integer_format = '0'
|
|
|
42 |
integer_style = xlwt.XFStyle()
|
|
|
43 |
integer_style.num_format_str = excel_integer_format
|
|
|
44 |
|
|
|
45 |
date_style = xlwt.XFStyle()
|
|
|
46 |
date_style.num_format_str = "M/D/YY"
|
|
|
47 |
|
|
|
48 |
sheet.write(0, 0, "Order ID", heading_xf)
|
|
|
49 |
sheet.write(0, 1, "Mode.", heading_xf)
|
|
|
50 |
sheet.write(0, 2, "Brand", heading_xf)
|
|
|
51 |
sheet.write(0, 3, "Model Name", heading_xf)
|
|
|
52 |
sheet.write(0, 4, "Model Number", heading_xf)
|
| 5631 |
amar.kumar |
53 |
sheet.write(0, 5, "Colour", heading_xf)
|
| 4607 |
rajveer |
54 |
sheet.write(0, 6, "Creation Date", heading_xf)
|
|
|
55 |
sheet.write(0, 7, "Promised Shipping Date", heading_xf)
|
|
|
56 |
sheet.write(0, 8, "Expected Shipping Date", heading_xf)
|
|
|
57 |
sheet.write(0, 9, "Delay Reason", heading_xf)
|
| 4648 |
rajveer |
58 |
sheet.write(0, 10, "Detailed Reason Text", heading_xf)
|
| 5631 |
amar.kumar |
59 |
|
|
|
60 |
html = """\
|
|
|
61 |
<html>
|
|
|
62 |
<head>
|
|
|
63 |
<style type="text/css">
|
|
|
64 |
table, tr, th { border :1px solid black;}
|
|
|
65 |
</style>
|
|
|
66 |
</head>
|
|
|
67 |
<body>
|
|
|
68 |
<center><h3>Delayed Orders</h3></center>
|
|
|
69 |
<table>
|
|
|
70 |
<tr>
|
|
|
71 |
<th>Order ID</th>
|
|
|
72 |
<th>Mode</th>
|
|
|
73 |
<th>Brand</th>
|
|
|
74 |
<th>Model Name</th>
|
|
|
75 |
<th>Model Number</th>
|
|
|
76 |
<th>Colour</th>
|
|
|
77 |
<th>Creation Date</th>
|
|
|
78 |
<th>Promised Shipping Date</th>
|
|
|
79 |
<th>Expected Shipping Date</th>
|
|
|
80 |
<th>Delay Reason</th>
|
|
|
81 |
<th>Detailed Reason Text</th>
|
|
|
82 |
</tr>
|
|
|
83 |
"""
|
|
|
84 |
|
| 4607 |
rajveer |
85 |
order = Order()
|
|
|
86 |
mode = {}
|
|
|
87 |
mode[0] = 'Prepaid'
|
|
|
88 |
mode[1] = 'COD'
|
|
|
89 |
|
|
|
90 |
i = 1
|
|
|
91 |
for order in slipped_orders:
|
| 5631 |
amar.kumar |
92 |
html +="<tr>"
|
|
|
93 |
sheet.write(i, 0, order.id)
|
|
|
94 |
html +="<td>" + str(order.id) + "</td>"
|
| 4607 |
rajveer |
95 |
sheet.write(i, 1, mode[order.cod])
|
| 5631 |
amar.kumar |
96 |
html +="<td>" + str(mode[order.cod]) + "</td>"
|
| 4607 |
rajveer |
97 |
|
|
|
98 |
lineitem = order.lineitems[0]
|
|
|
99 |
sheet.write(i, 2, lineitem.brand)
|
| 5631 |
amar.kumar |
100 |
html +="<td>" + str(lineitem.brand) + "</td>"
|
| 4607 |
rajveer |
101 |
sheet.write(i, 3, lineitem.model_name)
|
| 5631 |
amar.kumar |
102 |
html +="<td>" + str(lineitem.model_name) + "</td>"
|
| 4607 |
rajveer |
103 |
sheet.write(i, 4, lineitem.model_number)
|
| 5631 |
amar.kumar |
104 |
html +="<td>" + str(lineitem.model_number) + "</td>"
|
| 4607 |
rajveer |
105 |
sheet.write(i, 5, lineitem.color)
|
| 5631 |
amar.kumar |
106 |
html +="<td>" + str(lineitem.color) + "</td>"
|
| 4607 |
rajveer |
107 |
sheet.write(i, 6, to_py_date(order.created_timestamp), date_style)
|
| 5631 |
amar.kumar |
108 |
html +="<td>" + str(to_py_date(order.created_timestamp)) + "</td>"
|
| 4607 |
rajveer |
109 |
sheet.write(i, 7, to_py_date(order.promised_shipping_time), date_style)
|
| 5631 |
amar.kumar |
110 |
html +="<td>" + str(to_py_date(order.promised_shipping_time)) + "</td>"
|
| 4607 |
rajveer |
111 |
sheet.write(i, 8, to_py_date(order.expected_shipping_time), date_style)
|
| 5631 |
amar.kumar |
112 |
html +="<td>" + str(to_py_date(order.expected_shipping_time)) + "</td>"
|
| 4635 |
rajveer |
113 |
if order.delayReason:
|
|
|
114 |
sheet.write(i, 9, DelayReason._VALUES_TO_NAMES[order.delayReason])
|
| 5631 |
amar.kumar |
115 |
html +="<td>" + str(DelayReason._VALUES_TO_NAMES[order.delayReason]) + "</td>"
|
| 4648 |
rajveer |
116 |
sheet.write(i, 10, order.delayReasonText)
|
| 5631 |
amar.kumar |
117 |
html +="<td>" + str(order.delayReasonText) + "</td>"
|
|
|
118 |
html +="</tr>"
|
| 4607 |
rajveer |
119 |
i= i+1
|
|
|
120 |
|
|
|
121 |
today = datetime.date.today()
|
|
|
122 |
datestr = str(today.year) + "-" + str(today.month) + "-" + str(today.day)
|
|
|
123 |
filename = "/tmp/SlippedOrders-" + datestr + ".xls"
|
|
|
124 |
wbk.save(filename)
|
| 5631 |
amar.kumar |
125 |
html +="</table></body></html>"
|
| 4607 |
rajveer |
126 |
try:
|
|
|
127 |
part = get_attachment_part(filename)
|
| 5631 |
amar.kumar |
128 |
mail_html("cnc.center@shop2020.in", "5h0p2o2o", to, "Slipped Orders as on: " + datestr, html, [part])
|
| 4607 |
rajveer |
129 |
finally:
|
|
|
130 |
os.remove(filename)
|
|
|
131 |
|
| 4709 |
rajveer |
132 |
def generate_cancelled_orders_file():
|
|
|
133 |
txn_client = TransactionClient().get_client()
|
|
|
134 |
#cancelled_orders = txn_client.getAllOrders(OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY, to_java_date(datetime.datetime.now() - datetime.timedelta(hours = 24)), to_java_date(datetime.datetime.now()), -1)
|
|
|
135 |
cancelled_orders = txn_client.getCancelledOrders(to_java_date(datetime.datetime.now() - datetime.timedelta(hours = 24)), to_java_date(datetime.datetime.now()))
|
|
|
136 |
|
|
|
137 |
wbk = xlwt.Workbook()
|
|
|
138 |
sheet = wbk.add_sheet('main')
|
|
|
139 |
|
|
|
140 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap on, vert centre, horiz center')
|
|
|
141 |
sheet.set_panes_frozen(True)
|
|
|
142 |
sheet.set_horz_split_pos(1)
|
|
|
143 |
sheet.set_remove_splits(True)
|
|
|
144 |
|
|
|
145 |
excel_integer_format = '0'
|
|
|
146 |
integer_style = xlwt.XFStyle()
|
|
|
147 |
integer_style.num_format_str = excel_integer_format
|
|
|
148 |
|
|
|
149 |
date_style = xlwt.XFStyle()
|
|
|
150 |
date_style.num_format_str = "M/D/YY"
|
|
|
151 |
|
|
|
152 |
sheet.write(0, 0, "Order ID", heading_xf)
|
|
|
153 |
sheet.write(0, 1, "Mode.", heading_xf)
|
|
|
154 |
sheet.write(0, 2, "Brand", heading_xf)
|
|
|
155 |
sheet.write(0, 3, "Model Name", heading_xf)
|
|
|
156 |
sheet.write(0, 4, "Model Number", heading_xf)
|
| 5631 |
amar.kumar |
157 |
sheet.write(0, 5, "Colour", heading_xf)
|
| 4709 |
rajveer |
158 |
sheet.write(0, 6, "Creation Date", heading_xf)
|
|
|
159 |
sheet.write(0, 7, "Promised Shipping Date", heading_xf)
|
|
|
160 |
sheet.write(0, 8, "Expected Shipping Date", heading_xf)
|
|
|
161 |
sheet.write(0, 9, "Cancellation Reason", heading_xf)
|
|
|
162 |
sheet.write(0, 10, "Cancellation Date", heading_xf)
|
|
|
163 |
|
| 5631 |
amar.kumar |
164 |
html = """\
|
|
|
165 |
<html>
|
|
|
166 |
<head>
|
|
|
167 |
<style type="text/css">
|
|
|
168 |
table, tr, th { border :1px solid black;}
|
|
|
169 |
</style>
|
|
|
170 |
</head>
|
|
|
171 |
<body>
|
|
|
172 |
<center><h3>Delayed Orders</h3></center>
|
|
|
173 |
<table>
|
|
|
174 |
<tr>
|
|
|
175 |
<th>Order ID</th>
|
|
|
176 |
<th>Mode</th>
|
|
|
177 |
<th>Brand</th>
|
|
|
178 |
<th>Model Name</th>
|
|
|
179 |
<th>Model Number</th>
|
|
|
180 |
<th>Colour</th>
|
|
|
181 |
<th>Creation Date</th>
|
|
|
182 |
<th>Promised Shipping Date</th>
|
|
|
183 |
<th>Expected Shipping Date</th>
|
|
|
184 |
<th>Cancellation Reason</th>
|
|
|
185 |
<th>Cancellation Date</th>
|
|
|
186 |
</tr>
|
|
|
187 |
"""
|
|
|
188 |
|
|
|
189 |
|
| 4709 |
rajveer |
190 |
order = Order()
|
|
|
191 |
mode = {}
|
|
|
192 |
mode[0] = 'Prepaid'
|
|
|
193 |
mode[1] = 'COD'
|
|
|
194 |
|
|
|
195 |
i = 1
|
|
|
196 |
for order in cancelled_orders:
|
| 5631 |
amar.kumar |
197 |
html +="<tr>"
|
| 4709 |
rajveer |
198 |
sheet.write(i, 0, order.id)
|
| 5631 |
amar.kumar |
199 |
html +="<td>" + str(order.id) + "</td>"
|
| 4709 |
rajveer |
200 |
sheet.write(i, 1, mode[order.cod])
|
| 5631 |
amar.kumar |
201 |
html +="<td>" + str(mode[order.cod]) + "</td>"
|
| 4709 |
rajveer |
202 |
|
|
|
203 |
lineitem = order.lineitems[0]
|
|
|
204 |
sheet.write(i, 2, lineitem.brand)
|
| 5631 |
amar.kumar |
205 |
html +="<td>" + str(lineitem.brand) + "</td>"
|
| 4709 |
rajveer |
206 |
sheet.write(i, 3, lineitem.model_name)
|
| 5631 |
amar.kumar |
207 |
html +="<td>" + str(lineitem.model_name) + "</td>"
|
| 4709 |
rajveer |
208 |
sheet.write(i, 4, lineitem.model_number)
|
| 5631 |
amar.kumar |
209 |
html +="<td>" + str(lineitem.model_number) + "</td>"
|
| 4709 |
rajveer |
210 |
sheet.write(i, 5, lineitem.color)
|
| 5631 |
amar.kumar |
211 |
html +="<td>" + str(lineitem.color) + "</td>"
|
| 4709 |
rajveer |
212 |
|
|
|
213 |
sheet.write(i, 6, to_py_date(order.created_timestamp), date_style)
|
| 5631 |
amar.kumar |
214 |
html +="<td>" + str(to_py_date(order.created_timestamp)) + "</td>"
|
| 4709 |
rajveer |
215 |
sheet.write(i, 7, to_py_date(order.promised_shipping_time), date_style)
|
| 5631 |
amar.kumar |
216 |
html +="<td>" + str(to_py_date(order.promised_shipping_time)) + "</td>"
|
| 4709 |
rajveer |
217 |
sheet.write(i, 8, to_py_date(order.expected_shipping_time), date_style)
|
| 5631 |
amar.kumar |
218 |
html +="<td>" + str(to_py_date(order.expected_shipping_time)) + "</td>"
|
| 4709 |
rajveer |
219 |
sheet.write(i, 9, order.refundReason)
|
| 5631 |
amar.kumar |
220 |
html +="<td>" + str(order.refundReason) + "</td>"
|
| 4709 |
rajveer |
221 |
sheet.write(i, 10, to_py_date(order.refund_timestamp), date_style)
|
| 5631 |
amar.kumar |
222 |
html +="<td>" + str(to_py_date(order.refund_timestamp)) + "</td>"
|
|
|
223 |
html +="<td>" + str(order.delayReasonText) + "</td>"
|
|
|
224 |
html +="</tr>"
|
| 4709 |
rajveer |
225 |
|
|
|
226 |
i= i+1
|
|
|
227 |
|
|
|
228 |
today = datetime.date.today()
|
|
|
229 |
datestr = str(today.year) + "-" + str(today.month) + "-" + str(today.day)
|
|
|
230 |
filename = "/tmp/CancelledOrders-" + datestr + ".xls"
|
|
|
231 |
wbk.save(filename)
|
| 5631 |
amar.kumar |
232 |
html +="</table></body></html>"
|
| 4709 |
rajveer |
233 |
|
|
|
234 |
try:
|
|
|
235 |
part = get_attachment_part(filename)
|
| 5631 |
amar.kumar |
236 |
mail_html("cnc.center@shop2020.in", "5h0p2o2o", to, "Low Inventory Cancelled Orders as on: " + datestr, html, [part])
|
| 4709 |
rajveer |
237 |
finally:
|
|
|
238 |
os.remove(filename)
|
| 4783 |
phani.kuma |
239 |
|
|
|
240 |
def generate_expected_delivery_missed_orders_file():
|
|
|
241 |
|
|
|
242 |
txn_client = TransactionClient().get_client()
|
|
|
243 |
orders_not_delivered = txn_client.getUndeliveredOrdersExpectedDeliveryDateNotMet()
|
|
|
244 |
|
|
|
245 |
print "orders_not_delivered"
|
|
|
246 |
print orders_not_delivered
|
|
|
247 |
|
|
|
248 |
logistics_client = LogisticsClient().get_client()
|
|
|
249 |
providers = logistics_client.getAllProviders()
|
|
|
250 |
providers_map = {}
|
|
|
251 |
for provider in providers:
|
|
|
252 |
providers_map[provider.id] = provider.name
|
|
|
253 |
|
| 5944 |
mandeep.dh |
254 |
inventory_client = InventoryClient().get_client()
|
|
|
255 |
warehouses = inventory_client.getAllWarehouses(True)
|
| 4783 |
phani.kuma |
256 |
warehouses_map = {}
|
|
|
257 |
for warehouse in warehouses:
|
|
|
258 |
warehouses_map[warehouse.id] = warehouse.displayName
|
|
|
259 |
|
|
|
260 |
wbk = xlwt.Workbook()
|
|
|
261 |
sheet = wbk.add_sheet('main')
|
|
|
262 |
|
|
|
263 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap on, vert centre, horiz center')
|
|
|
264 |
sheet.set_panes_frozen(True)
|
|
|
265 |
sheet.set_horz_split_pos(1)
|
|
|
266 |
sheet.set_remove_splits(True)
|
|
|
267 |
|
|
|
268 |
excel_integer_format = '0'
|
|
|
269 |
integer_style = xlwt.XFStyle()
|
|
|
270 |
integer_style.num_format_str = excel_integer_format
|
|
|
271 |
|
|
|
272 |
date_style = xlwt.XFStyle()
|
|
|
273 |
date_style.num_format_str = "M/D/YY"
|
|
|
274 |
|
|
|
275 |
sheet.write(0, 0, "Order ID", heading_xf)
|
|
|
276 |
sheet.write(0, 1, "Mode.", heading_xf)
|
|
|
277 |
sheet.write(0, 2, "Airway BillNo", heading_xf)
|
|
|
278 |
sheet.write(0, 3, "Current Status", heading_xf)
|
|
|
279 |
sheet.write(0, 4, "Shipping Date", heading_xf)
|
|
|
280 |
sheet.write(0, 5, "Pickup Date", heading_xf)
|
|
|
281 |
sheet.write(0, 6, "Expected Delivery Date", heading_xf)
|
|
|
282 |
sheet.write(0, 7, "Warehouse", heading_xf)
|
|
|
283 |
sheet.write(0, 8, "Warehouse ID", heading_xf)
|
|
|
284 |
sheet.write(0, 9, "Logistics Provider", heading_xf)
|
|
|
285 |
sheet.write(0, 10, "Logistics Provider ID", heading_xf)
|
|
|
286 |
sheet.write(0, 11, "Customer City", heading_xf)
|
|
|
287 |
sheet.write(0, 12, "Customer State", heading_xf)
|
|
|
288 |
sheet.write(0, 13, "Customer Pincode", heading_xf)
|
|
|
289 |
|
| 5631 |
amar.kumar |
290 |
html = """\
|
|
|
291 |
<html>
|
|
|
292 |
<head>
|
|
|
293 |
<style type="text/css">
|
|
|
294 |
table, tr, th { border :1px solid black;}
|
|
|
295 |
</style>
|
|
|
296 |
</head>
|
|
|
297 |
<body>
|
|
|
298 |
<center><h3>Delayed Orders</h3></center>
|
|
|
299 |
<table border=1>
|
|
|
300 |
<tr>
|
|
|
301 |
<th>Order ID</th>
|
|
|
302 |
<th>Mode</th>
|
|
|
303 |
<th>Airway BillNo</th>
|
|
|
304 |
<th>Current Status</th>
|
|
|
305 |
<th>Shipping Date</th>
|
|
|
306 |
<th>Pickup Date</th>
|
|
|
307 |
<th>Expected Delivery Date</th>
|
|
|
308 |
<th>Warehouse</th>
|
|
|
309 |
<th>Warehouse ID</th>
|
|
|
310 |
<th>Logistics Provider</th>
|
|
|
311 |
<th>Logistics Provider ID</th>
|
|
|
312 |
<th>Customer City</th>
|
|
|
313 |
<th>Customer State</th>
|
|
|
314 |
<th>Customer Pincode</th>
|
|
|
315 |
</tr>
|
|
|
316 |
"""
|
|
|
317 |
|
| 4783 |
phani.kuma |
318 |
order = Order()
|
|
|
319 |
mode = {}
|
|
|
320 |
mode[0] = 'Prepaid'
|
|
|
321 |
mode[1] = 'COD'
|
|
|
322 |
|
|
|
323 |
i = 1
|
|
|
324 |
for order in orders_not_delivered:
|
| 5631 |
amar.kumar |
325 |
html +="<tr>"
|
| 4783 |
phani.kuma |
326 |
sheet.write(i, 0, order.id)
|
| 5631 |
amar.kumar |
327 |
html +="<td>" + str(order.id) + "</td>"
|
| 4783 |
phani.kuma |
328 |
sheet.write(i, 1, mode[order.cod])
|
| 5631 |
amar.kumar |
329 |
html +="<td>" + str(mode[order.cod]) + "</td>"
|
| 4783 |
phani.kuma |
330 |
sheet.write(i, 2, order.airwaybill_no)
|
| 5631 |
amar.kumar |
331 |
html +="<td>" + str(order.airwaybill_no) + "</td>"
|
| 4783 |
phani.kuma |
332 |
sheet.write(i, 3, order.statusDescription)
|
| 5631 |
amar.kumar |
333 |
html +="<td>" + order.statusDescription + "</td>"
|
| 4783 |
phani.kuma |
334 |
sheet.write(i, 4, to_py_date(order.shipping_timestamp), date_style)
|
| 5631 |
amar.kumar |
335 |
html +="<td>" + str(to_py_date(order.shipping_timestamp)) + "</td>"
|
| 4783 |
phani.kuma |
336 |
sheet.write(i, 5, to_py_date(order.pickup_timestamp), date_style)
|
| 5631 |
amar.kumar |
337 |
html +="<td>" + str(to_py_date(order.pickup_timestamp)) + "</td>"
|
| 4783 |
phani.kuma |
338 |
sheet.write(i, 6, to_py_date(order.expected_delivery_time), date_style)
|
| 5631 |
amar.kumar |
339 |
html +="<td>" + str(to_py_date(order.expected_delivery_time)) + "</td>"
|
| 4783 |
phani.kuma |
340 |
sheet.write(i, 7, warehouses_map.get(order.warehouse_id))
|
| 5631 |
amar.kumar |
341 |
html +="<td>" + str(warehouses_map.get(order.warehouse_id)) + "</td>"
|
| 4783 |
phani.kuma |
342 |
sheet.write(i, 8, order.warehouse_id)
|
| 5631 |
amar.kumar |
343 |
html +="<td>" + str(order.warehouse_id) + "</td>"
|
| 4783 |
phani.kuma |
344 |
sheet.write(i, 9, providers_map.get(order.logistics_provider_id))
|
| 5631 |
amar.kumar |
345 |
html +="<td>" + str(providers_map.get(order.logistics_provider_id)) + "</td>"
|
| 4783 |
phani.kuma |
346 |
sheet.write(i, 10, order.logistics_provider_id)
|
| 5631 |
amar.kumar |
347 |
html +="<td>" + str(order.logistics_provider_id) + "</td>"
|
| 4783 |
phani.kuma |
348 |
sheet.write(i, 11, order.customer_city)
|
| 5631 |
amar.kumar |
349 |
html +="<td>" + str(order.customer_city) + "</td>"
|
| 4783 |
phani.kuma |
350 |
sheet.write(i, 12, order.customer_state)
|
| 5631 |
amar.kumar |
351 |
html +="<td>" + str(order.customer_state) + "</td>"
|
| 4783 |
phani.kuma |
352 |
sheet.write(i, 13, order.customer_pincode)
|
| 5631 |
amar.kumar |
353 |
html +="<td>" + str(order.customer_pincode) + "</td>"
|
| 4709 |
rajveer |
354 |
|
| 5631 |
amar.kumar |
355 |
html +="</tr>"
|
| 4783 |
phani.kuma |
356 |
i= i+1
|
|
|
357 |
|
|
|
358 |
today = datetime.date.today()
|
|
|
359 |
datestr = str(today.year) + "-" + str(today.month) + "-" + str(today.day)
|
|
|
360 |
filename = "/tmp/UndeliveredOrders-" + datestr + ".xls"
|
|
|
361 |
wbk.save(filename)
|
| 5631 |
amar.kumar |
362 |
html +="</table></body></html>"
|
| 4783 |
phani.kuma |
363 |
|
|
|
364 |
try:
|
|
|
365 |
part = get_attachment_part(filename)
|
| 5631 |
amar.kumar |
366 |
mail_html("cnc.center@shop2020.in", "5h0p2o2o", to, "Orders which missed Expected Delivery Date as on: " + datestr, html, [part])
|
| 4783 |
phani.kuma |
367 |
finally:
|
|
|
368 |
os.remove(filename)
|
|
|
369 |
|
| 4709 |
rajveer |
370 |
def main():
|
|
|
371 |
parser = OptionParser()
|
|
|
372 |
parser.add_option("-d", "--delayed", dest="delayed",
|
|
|
373 |
action="store_true",
|
|
|
374 |
help="")
|
|
|
375 |
parser.add_option("-c", "--cancelled", dest="cancelled",
|
|
|
376 |
action="store_true",
|
|
|
377 |
help="")
|
| 4783 |
phani.kuma |
378 |
parser.add_option("-u", "--undelivered", dest="undelivered",
|
|
|
379 |
action="store_true",
|
|
|
380 |
help="")
|
| 4709 |
rajveer |
381 |
|
|
|
382 |
(options, args) = parser.parse_args()
|
|
|
383 |
if options.delayed:
|
|
|
384 |
generate_delayed_orders_file()
|
|
|
385 |
if options.cancelled:
|
|
|
386 |
generate_cancelled_orders_file()
|
| 4783 |
phani.kuma |
387 |
if options.undelivered:
|
|
|
388 |
generate_expected_delivery_missed_orders_file()
|
|
|
389 |
|
| 4607 |
rajveer |
390 |
if __name__ == '__main__':
|
|
|
391 |
main()
|