| Line 1... |
Line 1... |
| 1 |
#!/usr/bin/python
|
1 |
#!/usr/bin/python
|
| 2 |
'''
|
2 |
'''
|
| 3 |
It processes the following orders:
|
3 |
It processes the following orders:
|
| 4 |
1. Orders in DOA_PICKUP_CONFIRMED status : get details of orders that
|
4 |
1. Orders in DOA_PICKUP_CONFIRMED status : get details of orders that
|
| 5 |
were in DOA_PICKUP_CONFIRMED status from database and
|
5 |
were in DOA_PICKUP_CONFIRMED status from database and
|
| 6 |
calls aramex api to know whether they are picked up by armaex
|
6 |
calls aramex api to know whether they are picked up by aramex
|
| 7 |
and changes the status to DOA_RETURN_IN_TRANSIT if it is done.
|
7 |
and changes the status to DOA_RETURN_IN_TRANSIT if it is done.
|
| 8 |
2. Orders in RET_PICKUP_CONFIRMED status : get details of orders that
|
8 |
2. Orders in RET_PICKUP_CONFIRMED status : get details of orders that
|
| 9 |
were in RET_PICKUP_CONFIRMED status from database and
|
9 |
were in RET_PICKUP_CONFIRMED status from database and
|
| 10 |
calls aramex api to know whether they are picked up by armaex
|
10 |
calls aramex api to know whether they are picked up by aramex
|
| 11 |
and changes the status to RET_RETURN_IN_TRANSIT if it is done.
|
11 |
and changes the status to RET_RETURN_IN_TRANSIT if it is done.
|
| 12 |
3. Orders in SHIPPED_FROM_WH status: get details of orders that
|
12 |
3. Orders in SHIPPED_FROM_WH status: get details of orders that
|
| 13 |
were in SHIPPED_FROM_WH status from database and
|
13 |
were in SHIPPED_FROM_WH status from database and
|
| 14 |
calls aramex api to know whether they are picked up by armaex
|
14 |
calls aramex api to know whether they are picked up by aramex
|
| 15 |
and changes the status to SHIPPED_TO_LOGST if it is done.
|
15 |
and changes the status to SHIPPED_TO_LOGST if it is done.
|
| 16 |
4. Orders in SHIPPED_TO_LOGST status: get details of orders that
|
16 |
4. Orders in SHIPPED_TO_LOGST status: get details of orders that
|
| 17 |
were in SHIPPED_TO_LOGST status from database and
|
17 |
were in SHIPPED_TO_LOGST status from database and
|
| 18 |
calls aramex api to know their status and changes the status accordingly.
|
18 |
calls aramex api to know their status and changes the status accordingly.
|
| 19 |
|
19 |
|
| Line 152... |
Line 152... |
| 152 |
|
152 |
|
| 153 |
try:
|
153 |
try:
|
| 154 |
if doas_not_picked_up:
|
154 |
if doas_not_picked_up:
|
| 155 |
print "DOAs not Picked up:"
|
155 |
print "DOAs not Picked up:"
|
| 156 |
print doas_not_picked_up
|
156 |
print doas_not_picked_up
|
| 157 |
mismatch_file = "/tmp/DoaPickupMismatch.csv"
|
157 |
mismatch_file = "/tmp/Aramex_DoaPickupMismatch.csv"
|
| 158 |
print "Some of our DOA orders were not picked up. Printing report to:" + mismatch_file
|
158 |
print "Some of our DOA orders were not picked up. Printing report to:" + mismatch_file
|
| 159 |
print_dao_return_pickup_mismatch_report(mismatch_file, doas_not_picked_up)
|
159 |
print_dao_return_pickup_mismatch_report(mismatch_file, doas_not_picked_up)
|
| 160 |
pickup_mismatch_part = [get_attachment_part(mismatch_file)]
|
160 |
pickup_mismatch_part = [get_attachment_part(mismatch_file)]
|
| 161 |
mail(from_user, from_pwd, to,\
|
161 |
mail(from_user, from_pwd, to,\
|
| 162 |
"DOA Pickup Mismatch for " + provider.name,\
|
162 |
"DOA Pickup Mismatch for " + provider.name,\
|
| Line 175... |
Line 175... |
| 175 |
|
175 |
|
| 176 |
try:
|
176 |
try:
|
| 177 |
if returns_not_picked_up:
|
177 |
if returns_not_picked_up:
|
| 178 |
print "Return Orders not Picked up:"
|
178 |
print "Return Orders not Picked up:"
|
| 179 |
print returns_not_picked_up
|
179 |
print returns_not_picked_up
|
| 180 |
mismatch_file = "/tmp/ReturnsPickupMismatch.csv"
|
180 |
mismatch_file = "/tmp/Aramex_ReturnsPickupMismatch.csv"
|
| 181 |
print "Some of our Return orders were not picked up. Printing report to:" + mismatch_file
|
181 |
print "Some of our Return orders were not picked up. Printing report to:" + mismatch_file
|
| 182 |
print_dao_return_pickup_mismatch_report(mismatch_file, returns_not_picked_up)
|
182 |
print_dao_return_pickup_mismatch_report(mismatch_file, returns_not_picked_up)
|
| 183 |
pickup_mismatch_part = [get_attachment_part(mismatch_file)]
|
183 |
pickup_mismatch_part = [get_attachment_part(mismatch_file)]
|
| 184 |
mail(from_user, from_pwd, to,\
|
184 |
mail(from_user, from_pwd, to,\
|
| 185 |
"Return orders Pickup Mismatch for " + provider.name,\
|
185 |
"Return orders Pickup Mismatch for " + provider.name,\
|
| Line 198... |
Line 198... |
| 198 |
|
198 |
|
| 199 |
try:
|
199 |
try:
|
| 200 |
if orders_not_picked_up:
|
200 |
if orders_not_picked_up:
|
| 201 |
print "Orders not Picked up:"
|
201 |
print "Orders not Picked up:"
|
| 202 |
print orders_not_picked_up
|
202 |
print orders_not_picked_up
|
| 203 |
mismatch_file = "/tmp/PickupMismatch.csv"
|
203 |
mismatch_file = "/tmp/Aramex_PickupMismatch.csv"
|
| 204 |
print "Some of our orders were not picked up. Printing report to:" + mismatch_file
|
204 |
print "Some of our orders were not picked up. Printing report to:" + mismatch_file
|
| 205 |
print_pickup_mismatch_report(mismatch_file, orders_not_picked_up)
|
205 |
print_pickup_mismatch_report(mismatch_file, orders_not_picked_up)
|
| 206 |
pickup_mismatch_part = [get_attachment_part(mismatch_file)]
|
206 |
pickup_mismatch_part = [get_attachment_part(mismatch_file)]
|
| 207 |
mail(from_user, from_pwd, to,\
|
207 |
mail(from_user, from_pwd, to,\
|
| 208 |
"Order Pickup Mismatch for " + provider.name,\
|
208 |
"Order Pickup Mismatch for " + provider.name,\
|
| Line 221... |
Line 221... |
| 221 |
|
221 |
|
| 222 |
try:
|
222 |
try:
|
| 223 |
if orders_pending_local_connection:
|
223 |
if orders_pending_local_connection:
|
| 224 |
print "Local Connection Pending Orders:"
|
224 |
print "Local Connection Pending Orders:"
|
| 225 |
print orders_pending_local_connection
|
225 |
print orders_pending_local_connection
|
| 226 |
mismatch_file = "/tmp/LocalConnectionPendingOrders.csv"
|
226 |
mismatch_file = "/tmp/Aramex_LocalConnectionPendingOrders.csv"
|
| 227 |
print "Some of our Orders were not Shipped to Destination yet. Printing report to:" + mismatch_file
|
227 |
print "Some of our Orders were not Shipped to Destination yet. Printing report to:" + mismatch_file
|
| 228 |
print_undelivered_orders_report(mismatch_file, orders_pending_local_connection)
|
228 |
print_undelivered_orders_report(mismatch_file, orders_pending_local_connection)
|
| 229 |
pickup_mismatch_part = [get_attachment_part(mismatch_file)]
|
229 |
pickup_mismatch_part = [get_attachment_part(mismatch_file)]
|
| 230 |
mail(from_user, from_pwd, to,\
|
230 |
mail(from_user, from_pwd, to,\
|
| 231 |
"Orders that are not Shipped to Destination yet for " + provider.name,\
|
231 |
"Orders that are not Shipped to Destination yet for " + provider.name,\
|
| Line 244... |
Line 244... |
| 244 |
|
244 |
|
| 245 |
try:
|
245 |
try:
|
| 246 |
if returned_orders:
|
246 |
if returned_orders:
|
| 247 |
print "Returned Orders:"
|
247 |
print "Returned Orders:"
|
| 248 |
print returned_orders
|
248 |
print returned_orders
|
| 249 |
returned_orders_file = "/tmp/ReturnedOrders.csv"
|
249 |
returned_orders_file = "/tmp/Aramex_ReturnedOrders.csv"
|
| 250 |
print "Some of our Orders were returned by logistics provider. Printing report to:" + returned_orders_file
|
250 |
print "Some of our Orders were returned by logistics provider. Printing report to:" + returned_orders_file
|
| 251 |
print_rto_orders_report(returned_orders_file, returned_orders)
|
251 |
print_rto_orders_report(returned_orders_file, returned_orders)
|
| 252 |
returned_orders_report = [get_attachment_part(returned_orders_file)]
|
252 |
returned_orders_report = [get_attachment_part(returned_orders_file)]
|
| 253 |
mail(from_user, from_pwd, to,\
|
253 |
mail(from_user, from_pwd, to,\
|
| 254 |
"Returned Orders Report for " + provider.name,\
|
254 |
"Returned Orders Report for " + provider.name,\
|
| Line 267... |
Line 267... |
| 267 |
|
267 |
|
| 268 |
try:
|
268 |
try:
|
| 269 |
if orders_not_delivered:
|
269 |
if orders_not_delivered:
|
| 270 |
print "Undelivered Orders:"
|
270 |
print "Undelivered Orders:"
|
| 271 |
print orders_not_delivered
|
271 |
print orders_not_delivered
|
| 272 |
mismatch_file = "/tmp/UndeliveredOrders.csv"
|
272 |
mismatch_file = "/tmp/Aramex_UndeliveredOrders.csv"
|
| 273 |
print "Some of our Orders were not delivered. Printing report to:" + mismatch_file
|
273 |
print "Some of our Orders were not delivered. Printing report to:" + mismatch_file
|
| 274 |
print_undelivered_orders_report(mismatch_file, orders_not_delivered)
|
274 |
print_undelivered_orders_report(mismatch_file, orders_not_delivered)
|
| 275 |
pickup_mismatch_part = [get_attachment_part(mismatch_file)]
|
275 |
pickup_mismatch_part = [get_attachment_part(mismatch_file)]
|
| 276 |
mail(from_user, from_pwd, to,\
|
276 |
mail(from_user, from_pwd, to,\
|
| 277 |
"Orders that are undelivered but picked up or shipped four days ago for " + provider.name,\
|
277 |
"Orders that are undelivered but picked up or shipped four days ago for " + provider.name,\
|