| 104 |
ashish |
1 |
'''
|
|
|
2 |
Created on 29-Mar-2010
|
|
|
3 |
|
|
|
4 |
@author: ashish
|
|
|
5 |
'''
|
|
|
6 |
from shop2020.model.v1.order.impl import DataService
|
|
|
7 |
from shop2020.model.v1.order.impl.DataAccessors import create_transaction,\
|
| 1382 |
varun.gupt |
8 |
create_order, get_new_transaction, get_transactions_for_customer, get_transaction_status,\
|
|
|
9 |
get_line_items_for_order, get_transaction, get_transactions_for_shopping_cart_id,\
|
|
|
10 |
change_transaction_status, get_orders_for_customer,get_orders_for_transaction, get_order,\
|
|
|
11 |
get_returnable_orders_for_customer, get_cancellable_orders_for_customer, get_orders_by_billing_date,\
|
|
|
12 |
get_all_orders, change_order_status, get_alerts, set_alert, add_billing_details,\
|
|
|
13 |
mark_orders_as_manifested, close_session, accept_order, bill_order, mark_orders_as_picked_up,\
|
| 1208 |
chandransh |
14 |
mark_orders_as_delivered, mark_orders_as_failed, add_jacket_number,\
|
| 1405 |
ankur.sing |
15 |
order_outofstock, batch_orders, update_non_delivery_reason, enqueue_transaction_info_email,\
|
| 1627 |
ankur.sing |
16 |
get_undelivered_orders, get_order_for_customer, get_valid_order_count,\
|
| 1886 |
ankur.sing |
17 |
get_cust_count_with_successful_txn, get_valid_orders_amount_range,\
|
| 2591 |
chandransh |
18 |
get_valid_orders, toggle_doa_flag, request_pickup_number, authorize_pickup,\
|
| 2697 |
chandransh |
19 |
receive_return, validate_doa, reship_order, refund_order, get_return_orders,\
|
| 2819 |
chandransh |
20 |
process_return, get_return_order, mark_doas_as_picked_up,\
|
| 3451 |
chandransh |
21 |
create_purchase_order, verify_order, is_alive, get_orders_by_shipping_date,\
|
| 3956 |
chandransh |
22 |
update_weight, change_warehouse, change_product, add_delay_reason,\
|
| 4008 |
mandeep.dh |
23 |
reconcile_cod_collection, get_transactions_requiring_extra_processing,\
|
| 4133 |
chandransh |
24 |
mark_transaction_as_processed, get_item_wise_risky_orders_count,\
|
|
|
25 |
get_orders_in_batch, get_order_count
|
| 1405 |
ankur.sing |
26 |
|
| 104 |
ashish |
27 |
from shop2020.model.v1.order.impl.Convertors import to_t_transaction,\
|
| 1348 |
chandransh |
28 |
to_t_alert, to_t_order, to_t_lineitem
|
| 483 |
rajveer |
29 |
from shop2020.thriftpy.model.v1.order.ttypes import Transaction, OrderStatus,\
|
| 2783 |
chandransh |
30 |
LineItem, Order, TransactionServiceException
|
| 738 |
chandransh |
31 |
from shop2020.utils.Utils import to_py_date, get_fdate_tdate
|
| 104 |
ashish |
32 |
|
|
|
33 |
class OrderServiceHandler:
|
|
|
34 |
|
| 3187 |
rajveer |
35 |
def __init__(self, dbname='transaction', db_hostname='localhost'):
|
| 483 |
rajveer |
36 |
"""
|
| 104 |
ashish |
37 |
Constructor
|
| 483 |
rajveer |
38 |
"""
|
| 3187 |
rajveer |
39 |
DataService.initialize(dbname, db_hostname)
|
| 104 |
ashish |
40 |
|
|
|
41 |
def createTransaction(self, transaction):
|
|
|
42 |
"""
|
|
|
43 |
Parameters:
|
|
|
44 |
- transaction
|
|
|
45 |
"""
|
| 766 |
rajveer |
46 |
try:
|
|
|
47 |
return create_transaction(transaction)
|
|
|
48 |
finally:
|
|
|
49 |
close_session()
|
|
|
50 |
|
| 104 |
ashish |
51 |
def getTransaction(self, id):
|
|
|
52 |
"""
|
|
|
53 |
Get transaction methods.
|
|
|
54 |
|
|
|
55 |
Parameters:
|
|
|
56 |
- id
|
|
|
57 |
"""
|
| 766 |
rajveer |
58 |
try:
|
|
|
59 |
transaction = get_transaction(id)
|
|
|
60 |
return to_t_transaction(transaction)
|
|
|
61 |
finally:
|
|
|
62 |
close_session()
|
|
|
63 |
|
| 483 |
rajveer |
64 |
def getTransactionsForCustomer(self, customerId, from_date, to_date, status):
|
| 104 |
ashish |
65 |
"""
|
|
|
66 |
Parameters:
|
| 483 |
rajveer |
67 |
- customerId
|
| 104 |
ashish |
68 |
- from_date
|
|
|
69 |
- to_date
|
| 483 |
rajveer |
70 |
- status
|
| 104 |
ashish |
71 |
"""
|
| 766 |
rajveer |
72 |
try:
|
|
|
73 |
current_from_date, current_to_date = get_fdate_tdate(from_date, to_date)
|
|
|
74 |
|
|
|
75 |
transactions = get_transactions_for_customer(customerId, current_from_date, current_to_date, status)
|
|
|
76 |
t_transaction = []
|
|
|
77 |
for transaction in transactions:
|
|
|
78 |
t_transaction.append(to_t_transaction(transaction))
|
|
|
79 |
return t_transaction
|
|
|
80 |
finally:
|
|
|
81 |
close_session()
|
| 483 |
rajveer |
82 |
|
|
|
83 |
def getTransactionsForShoppingCartId(self, shoppingCartId):
|
|
|
84 |
"""
|
|
|
85 |
Parameters:
|
|
|
86 |
- shoppingCartId
|
|
|
87 |
"""
|
| 766 |
rajveer |
88 |
try:
|
|
|
89 |
transactions = get_transactions_for_shopping_cart_id(shoppingCartId)
|
|
|
90 |
t_transaction = []
|
|
|
91 |
for transaction in transactions:
|
|
|
92 |
t_transaction.append(to_t_transaction(transaction))
|
|
|
93 |
return t_transaction
|
|
|
94 |
finally:
|
|
|
95 |
close_session()
|
| 104 |
ashish |
96 |
|
| 483 |
rajveer |
97 |
def getTransactionStatus(self, transactionId):
|
| 104 |
ashish |
98 |
"""
|
|
|
99 |
Parameters:
|
| 483 |
rajveer |
100 |
- transactionId
|
|
|
101 |
"""
|
| 766 |
rajveer |
102 |
try:
|
|
|
103 |
return get_transaction_status(transactionId)
|
|
|
104 |
finally:
|
|
|
105 |
close_session()
|
|
|
106 |
|
| 483 |
rajveer |
107 |
def changeTransactionStatus(self, transactionId, status, description):
|
|
|
108 |
"""
|
|
|
109 |
Parameters:
|
|
|
110 |
- transactionId
|
| 104 |
ashish |
111 |
- status
|
| 483 |
rajveer |
112 |
- description
|
|
|
113 |
"""
|
| 766 |
rajveer |
114 |
try:
|
|
|
115 |
return change_transaction_status(transactionId, status, description)
|
|
|
116 |
finally:
|
|
|
117 |
close_session()
|
|
|
118 |
|
| 1528 |
ankur.sing |
119 |
def getOrdersForTransaction(self, transactionId, customerId):
|
| 483 |
rajveer |
120 |
"""
|
| 1528 |
ankur.sing |
121 |
Returns list of orders for given transaction Id. Also filters based on customer Id so that
|
|
|
122 |
only user who owns the transaction can view its order details.
|
|
|
123 |
|
| 483 |
rajveer |
124 |
Parameters:
|
|
|
125 |
- transactionId
|
| 1528 |
ankur.sing |
126 |
- customerId
|
| 483 |
rajveer |
127 |
"""
|
| 766 |
rajveer |
128 |
try:
|
| 1528 |
ankur.sing |
129 |
orders = get_orders_for_transaction(transactionId, customerId)
|
| 766 |
rajveer |
130 |
return [to_t_order(order) for order in orders]
|
|
|
131 |
finally:
|
|
|
132 |
close_session()
|
|
|
133 |
|
| 483 |
rajveer |
134 |
def getAllOrders(self, status, from_date, to_date, warehouse_id):
|
|
|
135 |
"""
|
|
|
136 |
Parameters:
|
|
|
137 |
- status
|
| 104 |
ashish |
138 |
- from_date
|
|
|
139 |
- to_date
|
| 483 |
rajveer |
140 |
- warehouse_id
|
| 104 |
ashish |
141 |
"""
|
| 766 |
rajveer |
142 |
try:
|
|
|
143 |
current_from_date, current_to_date = get_fdate_tdate(from_date, to_date)
|
|
|
144 |
orders = get_all_orders(status, current_from_date, current_to_date, warehouse_id)
|
|
|
145 |
return [to_t_order(order) for order in orders]
|
|
|
146 |
finally:
|
|
|
147 |
close_session()
|
| 4133 |
chandransh |
148 |
|
|
|
149 |
def getOrdersInBatch(self, statuses, offset, limit, warehouse_id):
|
|
|
150 |
"""
|
|
|
151 |
Returns at most 'limit' orders with the given statuses for the given warehouse starting from the given offset.
|
|
|
152 |
Pass the status as null and the limit as 0 to ignore them.
|
|
|
153 |
|
|
|
154 |
Parameters:
|
|
|
155 |
- statuses
|
|
|
156 |
- offset
|
|
|
157 |
- limit
|
|
|
158 |
- warehouse_id
|
|
|
159 |
"""
|
|
|
160 |
try:
|
|
|
161 |
orders = get_orders_in_batch(statuses, offset, limit, warehouse_id)
|
|
|
162 |
return [to_t_order(order) for order in orders]
|
|
|
163 |
finally:
|
|
|
164 |
close_session()
|
|
|
165 |
|
|
|
166 |
def getOrderCount(self, statuses, warehouseId):
|
|
|
167 |
"""
|
|
|
168 |
Returns the count of orders with the given statuses assigned to the given warehouse.
|
|
|
169 |
|
|
|
170 |
Parameters:
|
|
|
171 |
- statuses
|
|
|
172 |
- warehouseId
|
|
|
173 |
"""
|
|
|
174 |
try:
|
|
|
175 |
return get_order_count(statuses, warehouseId)
|
|
|
176 |
finally:
|
|
|
177 |
close_session()
|
|
|
178 |
|
| 995 |
varun.gupt |
179 |
def getOrdersByBillingDate(self, status, start_billing_date, end_billing_date, warehouse_id):
|
|
|
180 |
"""
|
|
|
181 |
Parameters:
|
|
|
182 |
- status
|
|
|
183 |
- start_billing_date
|
|
|
184 |
- end_billing_date
|
|
|
185 |
- warehouse_id
|
|
|
186 |
"""
|
|
|
187 |
try:
|
|
|
188 |
current_start_billing_date, current_end_billing_date = get_fdate_tdate(start_billing_date, end_billing_date)
|
|
|
189 |
orders = get_orders_by_billing_date(status, current_start_billing_date, current_end_billing_date, warehouse_id)
|
|
|
190 |
return [to_t_order(order) for order in orders]
|
|
|
191 |
finally:
|
|
|
192 |
close_session()
|
| 1382 |
varun.gupt |
193 |
|
| 3451 |
chandransh |
194 |
def getOrdersByShippingDate(self, fromShippingDate, toShippingDate, providerId, warehouseId, cod):
|
| 3427 |
chandransh |
195 |
"""
|
|
|
196 |
Returns orders for a particular provider and warehouse which were shipped between the given dates.
|
| 3451 |
chandransh |
197 |
Returned orders comprise of COD orders if cod parameter is true. It comprises of prepaid orders otherwise.
|
|
|
198 |
Pass providerId and warehouseId as -1 to ignore both these parameters.
|
| 3427 |
chandransh |
199 |
|
|
|
200 |
Parameters:
|
|
|
201 |
- fromShippingDate
|
|
|
202 |
- toShippingDate
|
|
|
203 |
- providerId
|
|
|
204 |
- warehouseId
|
| 3451 |
chandransh |
205 |
- cod
|
| 3427 |
chandransh |
206 |
"""
|
|
|
207 |
try:
|
|
|
208 |
from_shipping_date, to_shipping_date = get_fdate_tdate(fromShippingDate, toShippingDate)
|
| 3451 |
chandransh |
209 |
orders = get_orders_by_shipping_date(from_shipping_date, to_shipping_date, providerId, warehouseId, cod)
|
| 3427 |
chandransh |
210 |
return [to_t_order(order) for order in orders]
|
|
|
211 |
finally:
|
|
|
212 |
close_session()
|
|
|
213 |
|
| 1382 |
varun.gupt |
214 |
def getReturnableOrdersForCustomer(self, customerId, limit = None):
|
|
|
215 |
"""
|
|
|
216 |
Parameters:
|
|
|
217 |
- customerId
|
|
|
218 |
- limit
|
|
|
219 |
"""
|
|
|
220 |
try:
|
|
|
221 |
return get_returnable_orders_for_customer(customerId, limit)
|
|
|
222 |
finally:
|
|
|
223 |
close_session()
|
| 995 |
varun.gupt |
224 |
|
| 1382 |
varun.gupt |
225 |
def getCancellableOrdersForCustomer(self, customerId, limit = None):
|
|
|
226 |
"""
|
|
|
227 |
Parameters:
|
|
|
228 |
- customerId
|
|
|
229 |
- limit
|
|
|
230 |
"""
|
|
|
231 |
try:
|
|
|
232 |
return get_cancellable_orders_for_customer(customerId, limit)
|
|
|
233 |
finally:
|
|
|
234 |
close_session()
|
|
|
235 |
|
| 483 |
rajveer |
236 |
def changeOrderStatus(self, orderId, status, description):
|
|
|
237 |
"""
|
|
|
238 |
Parameters:
|
|
|
239 |
- orderId
|
|
|
240 |
- status
|
|
|
241 |
- description
|
|
|
242 |
-
|
|
|
243 |
"""
|
| 766 |
rajveer |
244 |
try:
|
|
|
245 |
return change_order_status(self, orderId, status, description)
|
|
|
246 |
finally:
|
|
|
247 |
close_session()
|
| 921 |
rajveer |
248 |
|
| 3064 |
chandransh |
249 |
def verifyOrder(self, orderId):
|
|
|
250 |
"""
|
|
|
251 |
Marks the given order as SUBMITTED_FOR_PROCESSING and updates the verified
|
|
|
252 |
timestamp. It is intended to be used for COD orders but can be harmlessly
|
|
|
253 |
used for all other orders as well.
|
|
|
254 |
Throws an exception if no such order exists.
|
|
|
255 |
|
|
|
256 |
Parameters:
|
|
|
257 |
- orderId
|
|
|
258 |
"""
|
|
|
259 |
try:
|
|
|
260 |
return verify_order(self, orderId)
|
|
|
261 |
finally:
|
|
|
262 |
close_session()
|
|
|
263 |
|
| 921 |
rajveer |
264 |
def acceptOrder(self, orderId):
|
|
|
265 |
"""
|
| 3064 |
chandransh |
266 |
Marks the given order as ACCEPTED and updates the accepted timestamp. If the
|
|
|
267 |
given order is not a COD order, it also captures the payment if the same has
|
|
|
268 |
not been captured.
|
|
|
269 |
Throws an exception if no such order exists.
|
|
|
270 |
|
| 921 |
rajveer |
271 |
Parameters:
|
|
|
272 |
- orderId
|
|
|
273 |
"""
|
|
|
274 |
try:
|
|
|
275 |
return accept_order(self, orderId)
|
|
|
276 |
finally:
|
|
|
277 |
close_session()
|
|
|
278 |
|
|
|
279 |
def billOrder(self, orderId):
|
|
|
280 |
"""
|
|
|
281 |
Parameters:
|
|
|
282 |
- orderId
|
|
|
283 |
"""
|
|
|
284 |
try:
|
|
|
285 |
return bill_order(self, orderId)
|
|
|
286 |
finally:
|
|
|
287 |
close_session()
|
| 766 |
rajveer |
288 |
|
| 3014 |
chandransh |
289 |
def getOrdersForCustomer(self, customerId, from_date, to_date, statuses):
|
| 104 |
ashish |
290 |
"""
|
| 3014 |
chandransh |
291 |
Returns list of orders for the given customer created between the given dates and having the given statuses.
|
|
|
292 |
Pass and empty list to ignore filtering on statuses.
|
|
|
293 |
|
| 104 |
ashish |
294 |
Parameters:
|
|
|
295 |
- customerId
|
|
|
296 |
- from_date
|
|
|
297 |
- to_date
|
| 3014 |
chandransh |
298 |
- statuses
|
| 104 |
ashish |
299 |
"""
|
| 766 |
rajveer |
300 |
try:
|
|
|
301 |
current_from_date, current_to_date = get_fdate_tdate(from_date, to_date)
|
|
|
302 |
|
| 3014 |
chandransh |
303 |
orders = get_orders_for_customer(customerId, current_from_date, current_to_date, statuses)
|
| 766 |
rajveer |
304 |
return [to_t_order(order) for order in orders]
|
|
|
305 |
finally:
|
|
|
306 |
close_session()
|
| 1528 |
ankur.sing |
307 |
|
|
|
308 |
def getOrderForCustomer(self, orderId, customerId):
|
|
|
309 |
"""
|
|
|
310 |
Returns an order for the order Id. Also checks if the order belongs to the customer whose Id is passed.
|
|
|
311 |
Throws exception if either order Id is invalid or order does not below to the customer whose Id is passed.
|
|
|
312 |
|
|
|
313 |
Parameters:
|
|
|
314 |
- customerId
|
|
|
315 |
- orderId
|
|
|
316 |
"""
|
|
|
317 |
try:
|
|
|
318 |
return to_t_order(get_order_for_customer(orderId, customerId))
|
|
|
319 |
finally:
|
|
|
320 |
close_session()
|
| 766 |
rajveer |
321 |
|
| 483 |
rajveer |
322 |
def getOrder(self, id):
|
|
|
323 |
"""
|
|
|
324 |
Parameters:
|
|
|
325 |
- id
|
|
|
326 |
"""
|
| 766 |
rajveer |
327 |
try:
|
|
|
328 |
return to_t_order(get_order(id))
|
|
|
329 |
finally:
|
|
|
330 |
close_session()
|
|
|
331 |
|
| 483 |
rajveer |
332 |
def getLineItemsForOrder(self, orderId):
|
|
|
333 |
"""
|
|
|
334 |
Parameters:
|
|
|
335 |
- orderId
|
|
|
336 |
"""
|
| 766 |
rajveer |
337 |
try:
|
|
|
338 |
lineitems = get_line_items_for_order(orderId)
|
|
|
339 |
t_lineitems = []
|
|
|
340 |
for lineitem in lineitems:
|
|
|
341 |
t_lineitems.append(to_t_lineitem(lineitem))
|
|
|
342 |
return t_lineitems
|
|
|
343 |
finally:
|
|
|
344 |
close_session()
|
| 1149 |
chandransh |
345 |
|
|
|
346 |
def addBillingDetails(self, orderId, invoice_number, billed_by):
|
| 494 |
rajveer |
347 |
"""
|
| 1149 |
chandransh |
348 |
Add billing details such as the bill number and the biller to the Order.
|
|
|
349 |
|
| 494 |
rajveer |
350 |
Parameters:
|
|
|
351 |
- orderId
|
|
|
352 |
- invoice_number
|
|
|
353 |
- billed_by
|
|
|
354 |
"""
|
| 766 |
rajveer |
355 |
try:
|
| 1149 |
chandransh |
356 |
return add_billing_details(orderId, invoice_number, billed_by)
|
| 766 |
rajveer |
357 |
finally:
|
|
|
358 |
close_session()
|
| 1149 |
chandransh |
359 |
|
| 2842 |
chandransh |
360 |
def addJacketNumber(self, orderId, jacketNumber, imeiNumber, itemNumber, billedBy, billingType):
|
| 1149 |
chandransh |
361 |
"""
|
| 2783 |
chandransh |
362 |
Adds jacket number and IMEI no. to the order. Doesn't update the IMEI no. if a -1 is supplied.
|
|
|
363 |
Also marks the order as billed and sets the billing timestamp.
|
|
|
364 |
Return false if it doesn't find the order with the given ID.
|
| 1149 |
chandransh |
365 |
|
|
|
366 |
Parameters:
|
|
|
367 |
- orderId
|
|
|
368 |
- jacketNumber
|
| 2783 |
chandransh |
369 |
- imeiNumber
|
|
|
370 |
- itemNumber
|
|
|
371 |
- billedBy
|
| 1149 |
chandransh |
372 |
"""
|
|
|
373 |
try:
|
| 2842 |
chandransh |
374 |
return add_jacket_number(self, orderId, jacketNumber, imeiNumber, itemNumber, billedBy, billingType)
|
| 2783 |
chandransh |
375 |
except TransactionServiceException:
|
|
|
376 |
print "ERROR: Couldn't find the order with the given id"
|
|
|
377 |
return False
|
| 1149 |
chandransh |
378 |
finally:
|
|
|
379 |
close_session()
|
| 1220 |
chandransh |
380 |
|
|
|
381 |
def batchOrders(self, warehouseId):
|
|
|
382 |
"""
|
|
|
383 |
Create a batch of all the pending orders for the given warehouse.
|
|
|
384 |
The returned list is orderd by created_timestamp.
|
|
|
385 |
If there are no pending orders, an empty list is returned.
|
| 1208 |
chandransh |
386 |
|
| 1220 |
chandransh |
387 |
Parameters:
|
|
|
388 |
- warehouseId
|
|
|
389 |
"""
|
|
|
390 |
try:
|
|
|
391 |
pending_orders = batch_orders(warehouseId)
|
|
|
392 |
return [to_t_order(order) for order in pending_orders]
|
|
|
393 |
finally:
|
|
|
394 |
close_session()
|
|
|
395 |
|
| 1208 |
chandransh |
396 |
def markOrderAsOutOfStock(self, orderId):
|
|
|
397 |
"""
|
|
|
398 |
Mark the given order as out of stock. Throws an exception if the order with the given Id couldn't be found.
|
|
|
399 |
|
|
|
400 |
|
|
|
401 |
Parameters:
|
|
|
402 |
- orderId
|
|
|
403 |
"""
|
|
|
404 |
try:
|
|
|
405 |
return order_outofstock(orderId)
|
|
|
406 |
finally:
|
|
|
407 |
close_session()
|
|
|
408 |
|
| 3064 |
chandransh |
409 |
def markOrdersAsManifested(self, warehouseId, providerId, cod):
|
| 759 |
chandransh |
410 |
"""
|
| 3064 |
chandransh |
411 |
Depending on the third parameter, marks either all prepaid or all cod orders BILLED by the
|
|
|
412 |
given warehouse and were picked up by the given provider as SHIPPED_FROM_WH.
|
| 759 |
chandransh |
413 |
|
|
|
414 |
Parameters:
|
|
|
415 |
- warehouseId
|
|
|
416 |
- providerId
|
| 3064 |
chandransh |
417 |
- cod
|
| 759 |
chandransh |
418 |
"""
|
| 766 |
rajveer |
419 |
try:
|
| 3064 |
chandransh |
420 |
return mark_orders_as_manifested(warehouseId, providerId, cod)
|
| 766 |
rajveer |
421 |
finally:
|
|
|
422 |
close_session()
|
| 1113 |
chandransh |
423 |
|
|
|
424 |
def markOrdersAsPickedUp(self, providerId, pickupDetails):
|
|
|
425 |
"""
|
|
|
426 |
Marks all SHIPPED_FROM_WH orders of the previous day for a provider as SHIPPED_TO_LOGISTICS.
|
|
|
427 |
Returns a list of orders that were shipped from warehouse but did not appear in the pick-up report.
|
|
|
428 |
Raises an exception if we encounter report for an AWB number that we did not ship.
|
|
|
429 |
|
|
|
430 |
Parameters:
|
|
|
431 |
- providerId
|
|
|
432 |
- pickupDetails
|
|
|
433 |
"""
|
|
|
434 |
try:
|
|
|
435 |
orders_not_picked_up = mark_orders_as_picked_up(providerId, pickupDetails)
|
|
|
436 |
return [to_t_order(order) for order in orders_not_picked_up]
|
|
|
437 |
finally:
|
|
|
438 |
close_session()
|
| 1132 |
chandransh |
439 |
|
|
|
440 |
def markOrdersAsDelivered(self, providerId, deliveredOrders):
|
|
|
441 |
"""
|
|
|
442 |
Marks all orders with AWBs in the given map as delivered. Also sets the delivery timestamp and
|
|
|
443 |
the name of the receiver.
|
|
|
444 |
Raises an exception if we encounter report for an AWB number that we did not ship.
|
|
|
445 |
|
|
|
446 |
Parameters:
|
|
|
447 |
- providerId
|
|
|
448 |
- deliveredOrders
|
|
|
449 |
"""
|
|
|
450 |
try:
|
|
|
451 |
mark_orders_as_delivered(providerId, deliveredOrders)
|
|
|
452 |
finally:
|
|
|
453 |
close_session()
|
| 1135 |
chandransh |
454 |
|
|
|
455 |
def markOrdersAsFailed(self, providerId, returnedOrders):
|
|
|
456 |
"""
|
|
|
457 |
Mark all orders with AWBs in the given map as failed. Also sets the delivery timestamp.
|
|
|
458 |
Raises an exception if we encounter report for an AWB number that we did not ship.
|
|
|
459 |
|
|
|
460 |
Parameters:
|
|
|
461 |
- providerId
|
|
|
462 |
- returnedOrders
|
|
|
463 |
"""
|
|
|
464 |
try:
|
|
|
465 |
mark_orders_as_failed(providerId, returnedOrders)
|
|
|
466 |
finally:
|
|
|
467 |
close_session()
|
| 1246 |
chandransh |
468 |
|
|
|
469 |
def updateNonDeliveryReason(self, providerId, undeliveredOrders):
|
|
|
470 |
"""
|
|
|
471 |
Update the status description of orders whose AWB numbers are keys of the Map.
|
|
|
472 |
|
|
|
473 |
Parameters:
|
|
|
474 |
- providerId
|
|
|
475 |
- undelivered_orders
|
|
|
476 |
"""
|
|
|
477 |
try:
|
|
|
478 |
update_non_delivery_reason(providerId, undeliveredOrders)
|
|
|
479 |
finally:
|
|
|
480 |
close_session()
|
| 1405 |
ankur.sing |
481 |
|
|
|
482 |
def getUndeliveredOrders(self, providerId, warehouseId):
|
|
|
483 |
"""
|
|
|
484 |
Returns the list of orders whose delivery time has passed but have not been
|
|
|
485 |
delivered yet for the given provider and warehouse. To get a complete list of
|
|
|
486 |
undelivered orders, pass them as -1.
|
|
|
487 |
Returns an empty list if no such orders exist.
|
|
|
488 |
|
|
|
489 |
Parameters:
|
|
|
490 |
- providerId
|
|
|
491 |
- warehouseId
|
|
|
492 |
"""
|
|
|
493 |
try:
|
|
|
494 |
undelivered_orders = get_undelivered_orders(providerId, warehouseId)
|
|
|
495 |
return [to_t_order(order) for order in undelivered_orders]
|
|
|
496 |
finally:
|
|
|
497 |
close_session()
|
| 1351 |
varun.gupt |
498 |
|
| 1398 |
varun.gupt |
499 |
def enqueueTransactionInfoEmail(self, transactionId):
|
| 1351 |
varun.gupt |
500 |
"""
|
| 1398 |
varun.gupt |
501 |
Save the email containing order details to be sent to customer later by batch job
|
| 1351 |
varun.gupt |
502 |
|
|
|
503 |
Parameters:
|
|
|
504 |
- transactionId
|
|
|
505 |
"""
|
|
|
506 |
try:
|
| 1398 |
varun.gupt |
507 |
return enqueue_transaction_info_email(transactionId)
|
| 1351 |
varun.gupt |
508 |
finally:
|
|
|
509 |
close_session()
|
|
|
510 |
|
| 483 |
rajveer |
511 |
def getAlerts(self, orderId, valid):
|
|
|
512 |
"""
|
|
|
513 |
Parameters:
|
|
|
514 |
- orderId
|
|
|
515 |
- valid
|
|
|
516 |
"""
|
| 766 |
rajveer |
517 |
try:
|
|
|
518 |
alerts = get_alerts(orderId, valid)
|
|
|
519 |
|
|
|
520 |
t_alerts = []
|
|
|
521 |
|
|
|
522 |
for alert in alerts:
|
|
|
523 |
t_alerts.append(to_t_alert(alert))
|
|
|
524 |
|
|
|
525 |
return t_alerts
|
|
|
526 |
finally:
|
|
|
527 |
close_session()
|
|
|
528 |
|
| 483 |
rajveer |
529 |
def setAlert(self, orderId, unset, type, comment):
|
|
|
530 |
"""
|
|
|
531 |
Parameters:
|
|
|
532 |
- orderId
|
|
|
533 |
- unset
|
|
|
534 |
- type
|
|
|
535 |
- comment
|
|
|
536 |
"""
|
| 766 |
rajveer |
537 |
try:
|
|
|
538 |
set_alert(orderId, unset, type, comment)
|
|
|
539 |
finally:
|
|
|
540 |
close_session()
|
| 1596 |
ankur.sing |
541 |
|
|
|
542 |
def getValidOrderCount(self, ):
|
|
|
543 |
"""
|
|
|
544 |
Return the number of valid orders. (OrderStatus >= OrderStatus.SUBMITTED_FOR_PROCESSING)
|
|
|
545 |
"""
|
| 1731 |
ankur.sing |
546 |
try:
|
|
|
547 |
return get_valid_order_count()
|
|
|
548 |
finally:
|
|
|
549 |
close_session()
|
| 1627 |
ankur.sing |
550 |
|
|
|
551 |
def getNoOfCustomersWithSuccessfulTransaction(self, ):
|
|
|
552 |
"""
|
|
|
553 |
Returns the number of distinct customers who have done successful transactions
|
|
|
554 |
"""
|
| 1731 |
ankur.sing |
555 |
try:
|
|
|
556 |
return get_cust_count_with_successful_txn()
|
|
|
557 |
finally:
|
|
|
558 |
close_session()
|
| 1627 |
ankur.sing |
559 |
|
| 1731 |
ankur.sing |
560 |
|
|
|
561 |
def getValidOrdersAmountRange(self, ):
|
| 1627 |
ankur.sing |
562 |
"""
|
| 1731 |
ankur.sing |
563 |
Returns the minimum and maximum amounts of a valid order. (OrderStatus >= OrderStatus.SUBMITTED_FOR_PROCESSING)
|
|
|
564 |
List contains two values, first minimum amount and second maximum amount.
|
| 1627 |
ankur.sing |
565 |
"""
|
| 1731 |
ankur.sing |
566 |
try:
|
|
|
567 |
return get_valid_orders_amount_range()
|
|
|
568 |
finally:
|
|
|
569 |
close_session()
|
| 1627 |
ankur.sing |
570 |
|
| 1886 |
ankur.sing |
571 |
def getValidOrders(self, limit):
|
|
|
572 |
"""
|
|
|
573 |
Returns list of Orders in descending order by Order creation date. List is restricted to limit Orders.
|
|
|
574 |
If limit is passed as 0, then all valid Orders are returned.
|
|
|
575 |
|
|
|
576 |
Parameters:
|
|
|
577 |
- limit
|
|
|
578 |
"""
|
|
|
579 |
try:
|
|
|
580 |
return [to_t_order(order) for order in get_valid_orders(limit)]
|
|
|
581 |
finally:
|
|
|
582 |
close_session()
|
| 104 |
ashish |
583 |
|
| 2536 |
chandransh |
584 |
def toggleDOAFlag(self, orderId):
|
| 104 |
ashish |
585 |
"""
|
| 2536 |
chandransh |
586 |
Toggle the DOA flag of an order. This should be used to flag an order for follow-up and unflag it when the follow-up is complete.
|
|
|
587 |
Returns the final flag status.
|
|
|
588 |
Throws an exception if the order with the given id couldn't be found or if the order status is not DELVIERY_SUCCESS.
|
| 483 |
rajveer |
589 |
|
| 132 |
ashish |
590 |
Parameters:
|
| 2536 |
chandransh |
591 |
- orderId
|
| 132 |
ashish |
592 |
"""
|
| 2536 |
chandransh |
593 |
try:
|
|
|
594 |
return toggle_doa_flag(orderId)
|
|
|
595 |
finally:
|
|
|
596 |
close_session()
|
| 483 |
rajveer |
597 |
|
| 2536 |
chandransh |
598 |
def requestPickupNumber(self, orderId):
|
| 104 |
ashish |
599 |
"""
|
| 2536 |
chandransh |
600 |
Sends out an email to the account manager of the original courier provider used to ship the order.
|
|
|
601 |
If the order status was DELIVERY_SUCCESS, it is changed to be DOA_PICKUP_REQUESTED.
|
|
|
602 |
If the order status was DOA_PICKUP_REQUESTED, it is left unchanged.
|
|
|
603 |
For any other status, it returns false.
|
|
|
604 |
Throws an exception if the order with the given id couldn't be found.
|
| 104 |
ashish |
605 |
|
|
|
606 |
Parameters:
|
| 2536 |
chandransh |
607 |
- orderId
|
| 104 |
ashish |
608 |
"""
|
| 2536 |
chandransh |
609 |
try:
|
|
|
610 |
return request_pickup_number(orderId)
|
|
|
611 |
finally:
|
|
|
612 |
close_session()
|
| 483 |
rajveer |
613 |
|
| 2536 |
chandransh |
614 |
def authorizePickup(self, orderId, pickupNumber):
|
| 304 |
ashish |
615 |
"""
|
| 2536 |
chandransh |
616 |
If the order status is DOA_PICKUP_REQUESTED, it does the following
|
|
|
617 |
1. Sends out an email to the customer with the dispatch advice that he has to print as an attachment.
|
|
|
618 |
2. Changes order status to be DOA_PICKUP_AUTHORIZED.
|
|
|
619 |
3. Returns true
|
|
|
620 |
If the order is any other status, it returns false.
|
|
|
621 |
Throws an exception if the order with the given id couldn't be found.
|
| 304 |
ashish |
622 |
|
|
|
623 |
Parameters:
|
| 2536 |
chandransh |
624 |
- orderId
|
|
|
625 |
- pickupNumber
|
| 304 |
ashish |
626 |
"""
|
| 2536 |
chandransh |
627 |
try:
|
|
|
628 |
return authorize_pickup(orderId, pickupNumber)
|
|
|
629 |
finally:
|
|
|
630 |
close_session()
|
| 2764 |
chandransh |
631 |
|
|
|
632 |
def markDoasAsPickedUp(self, providerId, pickupDetails):
|
|
|
633 |
"""
|
|
|
634 |
Marks all DOA_PICKUP_AUTHORIZED orders of the previous day for a provider as DOA_RETURN_IN_TRANSIT.
|
|
|
635 |
Returns a list of orders that were authorized for pickup but did not appear in the pick-up report.
|
|
|
636 |
|
|
|
637 |
Parameters:
|
|
|
638 |
- providerId
|
|
|
639 |
- pickupDetails
|
|
|
640 |
"""
|
|
|
641 |
try:
|
|
|
642 |
orders_not_picked_up = mark_doas_as_picked_up(providerId, pickupDetails)
|
|
|
643 |
return [to_t_order(order) for order in orders_not_picked_up]
|
|
|
644 |
finally:
|
|
|
645 |
close_session()
|
| 2591 |
chandransh |
646 |
|
| 2616 |
chandransh |
647 |
def receiveReturn(self, orderId):
|
| 2591 |
chandransh |
648 |
"""
|
| 2599 |
chandransh |
649 |
If the order status is DOA_RETURN_AUTHORIZED or DOA_RETURN_IN_TRANSIT, marks the order status as DOA_RECEIVED and returns true.
|
| 2591 |
chandransh |
650 |
If the order is in any other state, it returns false.
|
|
|
651 |
Throws an exception if the order with the given id couldn't be found.
|
|
|
652 |
|
|
|
653 |
Parameters:
|
|
|
654 |
- orderId
|
|
|
655 |
"""
|
|
|
656 |
try:
|
| 2616 |
chandransh |
657 |
return receive_return(orderId)
|
| 2591 |
chandransh |
658 |
finally:
|
|
|
659 |
close_session()
|
|
|
660 |
|
|
|
661 |
def validateDoa(self, orderId, isValid):
|
|
|
662 |
"""
|
| 2599 |
chandransh |
663 |
Used to validate the DOA certificate for an order in the DOA_RECEIVED state. If the certificate is valid,
|
| 2609 |
chandransh |
664 |
the order state is changed to DOA_CERT_PENDING.
|
| 2591 |
chandransh |
665 |
If the certificate is invalid, the order state is changed to DOA_CERT_INVALID.
|
|
|
666 |
If the order is in any other state, it returns false.
|
|
|
667 |
Throws an exception if the order with the given id couldn't be found.
|
|
|
668 |
|
|
|
669 |
Parameters:
|
|
|
670 |
- orderId
|
|
|
671 |
- isValid
|
|
|
672 |
"""
|
|
|
673 |
try:
|
|
|
674 |
return validate_doa(orderId, isValid)
|
|
|
675 |
finally:
|
|
|
676 |
close_session()
|
| 2628 |
chandransh |
677 |
|
|
|
678 |
def reshipOrder(self, orderId):
|
|
|
679 |
"""
|
|
|
680 |
If the order is in SALES_RET_RECEIVED or DOA_CERT_INVALID state, it does the following:
|
|
|
681 |
1. Creates a new order for processing in the BILLED state. All billing information is saved.
|
|
|
682 |
2. Marks the current order as one of the final states SALES_RET_RESHIPPED and DOA_INVALID_RESHIPPED depending on what state the order started in.
|
|
|
683 |
|
|
|
684 |
If the order is in DOA_CERT_VALID state, it does the following:
|
|
|
685 |
1. Creates a new order for processing in the SUBMITTED_FOR_PROCESSING state.
|
|
|
686 |
2. Creates a return order for the warehouse executive to return the DOA material.
|
|
|
687 |
3. Marks the current order as the final DOA_RESHIPPED state.
|
|
|
688 |
|
|
|
689 |
Returns the id of the newly created order.
|
|
|
690 |
|
|
|
691 |
Throws an exception if the order with the given id couldn't be found.
|
|
|
692 |
|
|
|
693 |
Parameters:
|
|
|
694 |
- orderId
|
|
|
695 |
"""
|
|
|
696 |
try:
|
|
|
697 |
return reship_order(orderId)
|
|
|
698 |
finally:
|
|
|
699 |
close_session()
|
|
|
700 |
|
| 3226 |
chandransh |
701 |
def refundOrder(self, orderId, refundedBy, reason):
|
| 2628 |
chandransh |
702 |
"""
|
|
|
703 |
If the order is in SALES_RET_RECEIVED, DOA_CERT_VALID or DOA_CERT_INVALID state, it does the following:
|
|
|
704 |
1. Creates a refund request for batch processing.
|
|
|
705 |
2. Creates a return order for the warehouse executive to return the shipped material.
|
|
|
706 |
3. Marks the current order as SALES_RET_REFUNDED, DOA_VALID_REFUNDED or DOA_INVALID_REFUNDED final states.
|
|
|
707 |
|
|
|
708 |
If the order is in SUBMITTED_FOR_PROCESSING or INVENTORY_LOW state, it does the following:
|
|
|
709 |
1. Creates a refund request for batch processing.
|
| 3226 |
chandransh |
710 |
2. Cancels the reservation of the item in the warehouse.
|
|
|
711 |
3. Marks the current order as the REFUNDED final state.
|
| 2628 |
chandransh |
712 |
|
| 3226 |
chandransh |
713 |
For all COD orders, if the order is in INIT, SUBMITTED_FOR_PROCESSING or INVENTORY_LOW state, it does the following:
|
|
|
714 |
1. Cancels the reservation of the item in the warehouse.
|
|
|
715 |
2. Marks the current order as CANCELED.
|
|
|
716 |
|
|
|
717 |
In all cases, it updates the reason for cancellation or refund and the person who performed the action.
|
|
|
718 |
|
| 2628 |
chandransh |
719 |
Returns True if it is successful, False otherwise.
|
|
|
720 |
|
|
|
721 |
Throws an exception if the order with the given id couldn't be found.
|
|
|
722 |
|
|
|
723 |
Parameters:
|
|
|
724 |
- orderId
|
| 3226 |
chandransh |
725 |
- refundedBy
|
|
|
726 |
- reason
|
| 2628 |
chandransh |
727 |
"""
|
|
|
728 |
try:
|
| 3226 |
chandransh |
729 |
return refund_order(orderId, refundedBy, reason)
|
| 2628 |
chandransh |
730 |
finally:
|
|
|
731 |
close_session()
|
|
|
732 |
|
| 2697 |
chandransh |
733 |
def getReturnOrders(self, warehouseId, fromDate, toDate):
|
|
|
734 |
"""
|
|
|
735 |
Get all return orders created between the from and to dates for the given warehouse.
|
|
|
736 |
Ignores the warehouse if it is passed as -1.
|
|
|
737 |
|
|
|
738 |
Parameters:
|
|
|
739 |
- warehouseId
|
|
|
740 |
- fromDate
|
|
|
741 |
- toDate
|
|
|
742 |
"""
|
|
|
743 |
try:
|
|
|
744 |
from_date, to_date = get_fdate_tdate(fromDate, toDate)
|
|
|
745 |
return get_return_orders(warehouseId, from_date, to_date)
|
|
|
746 |
finally:
|
|
|
747 |
close_session()
|
|
|
748 |
|
| 2700 |
chandransh |
749 |
def getReturnOrder(self, id):
|
|
|
750 |
"""
|
|
|
751 |
Returns the ReturnOrder corresponding to the given id.
|
|
|
752 |
Throws an exception if the return order with the given id couldn't be found.
|
|
|
753 |
|
|
|
754 |
Parameters:
|
|
|
755 |
- id
|
|
|
756 |
"""
|
|
|
757 |
try:
|
|
|
758 |
return get_return_order(id)
|
|
|
759 |
finally:
|
|
|
760 |
close_session()
|
|
|
761 |
|
| 2697 |
chandransh |
762 |
def processReturn(self, returnOrderId):
|
|
|
763 |
"""
|
|
|
764 |
Marks the return order with the given id as processed. Raises an exception if no such return order exists.
|
|
|
765 |
|
|
|
766 |
Parameters:
|
|
|
767 |
- returnOrderId
|
|
|
768 |
"""
|
|
|
769 |
try:
|
|
|
770 |
process_return(returnOrderId)
|
|
|
771 |
finally:
|
|
|
772 |
close_session()
|
| 2591 |
chandransh |
773 |
|
| 2819 |
chandransh |
774 |
def createPurchaseOrder(self, warehouseId):
|
|
|
775 |
"""
|
|
|
776 |
Creates a purchase order corresponding to all the pending orders of the given warehouse.
|
|
|
777 |
Returns the PO no. of the newly created purchase order.
|
|
|
778 |
|
|
|
779 |
Parameters:
|
|
|
780 |
- warehouseId
|
|
|
781 |
"""
|
|
|
782 |
try:
|
|
|
783 |
return create_purchase_order(warehouseId)
|
|
|
784 |
finally:
|
|
|
785 |
close_session()
|
| 3451 |
chandransh |
786 |
|
|
|
787 |
def updateWeight(self, orderId, weight):
|
|
|
788 |
"""
|
|
|
789 |
Set the weight of the given order to the provided value. Will attempt to update the weight of the item in the catalog as well.
|
|
|
790 |
|
|
|
791 |
Parameters:
|
|
|
792 |
- orderId
|
|
|
793 |
- weight
|
|
|
794 |
"""
|
|
|
795 |
try:
|
|
|
796 |
order = update_weight(orderId, weight)
|
|
|
797 |
return to_t_order(order)
|
|
|
798 |
finally:
|
|
|
799 |
close_session()
|
|
|
800 |
|
| 3469 |
chandransh |
801 |
def changeItem(self, orderId, itemId):
|
|
|
802 |
"""
|
|
|
803 |
Change the item to be shipped for this order. Also adjusts the reservation in the inventory accordingly.
|
|
|
804 |
Currently, it also ensures that only a different color of the given item is shipped.
|
|
|
805 |
|
|
|
806 |
Parameters:
|
|
|
807 |
- orderId
|
|
|
808 |
- itemId
|
|
|
809 |
"""
|
|
|
810 |
try:
|
|
|
811 |
order = change_product(orderId, itemId)
|
|
|
812 |
return to_t_order(order)
|
|
|
813 |
finally:
|
|
|
814 |
close_session()
|
|
|
815 |
|
|
|
816 |
def shiftToWarehouse(self, orderId, warehouseId):
|
|
|
817 |
"""
|
|
|
818 |
Moves the given order to the given warehouse. Also adjusts the inventory reservations accordingly.
|
|
|
819 |
|
|
|
820 |
Parameters:
|
|
|
821 |
- orderId
|
|
|
822 |
- warehouseId
|
|
|
823 |
"""
|
|
|
824 |
try:
|
|
|
825 |
order = change_warehouse(orderId, warehouseId)
|
|
|
826 |
return to_t_order(order)
|
|
|
827 |
finally:
|
|
|
828 |
close_session()
|
| 3553 |
chandransh |
829 |
|
| 3986 |
chandransh |
830 |
def addDelayReason(self, orderId, delayReason, furtherDelay):
|
| 3553 |
chandransh |
831 |
"""
|
|
|
832 |
Adds the given delay reason to the given order.
|
| 3986 |
chandransh |
833 |
Increases the expected delivery time of the given order by the given no. of days.
|
| 3553 |
chandransh |
834 |
Raises an exception if no order with the given id can be found.
|
| 3469 |
chandransh |
835 |
|
| 3553 |
chandransh |
836 |
Parameters:
|
|
|
837 |
- orderId
|
|
|
838 |
- delayReason
|
|
|
839 |
"""
|
|
|
840 |
try:
|
| 3986 |
chandransh |
841 |
return add_delay_reason(orderId, delayReason, furtherDelay)
|
| 3553 |
chandransh |
842 |
finally:
|
|
|
843 |
close_session()
|
|
|
844 |
|
| 3956 |
chandransh |
845 |
def reconcileCodCollection(self, collectedAmountMap, xferBy, xferTxnId, xferDate):
|
|
|
846 |
"""
|
|
|
847 |
Marks the COD orders with given AWB nos. as having been processed.
|
|
|
848 |
Updates the captured amount for the corresponding payment.
|
|
|
849 |
|
|
|
850 |
Returns a map of AWBs which were not processed and the associated reason. An AWB is not processed if:
|
|
|
851 |
1. There is no order corresponding to an AWB number.
|
|
|
852 |
2. The captured amount for a payment exceeds the total payment.
|
|
|
853 |
3. The order corresponding to an AWB no. is in a state prior to DELIVERY_SUCCESS.
|
|
|
854 |
|
|
|
855 |
Parameters:
|
|
|
856 |
- collectedAmountMap
|
|
|
857 |
- xferBy
|
|
|
858 |
- xferTxnId
|
|
|
859 |
- xferDate
|
|
|
860 |
"""
|
|
|
861 |
try:
|
|
|
862 |
return reconcile_cod_collection(collectedAmountMap, xferBy, xferTxnId, xferDate)
|
|
|
863 |
finally:
|
|
|
864 |
close_session()
|
| 4008 |
mandeep.dh |
865 |
|
|
|
866 |
def getTransactionsRequiringExtraProcessing(self, category):
|
|
|
867 |
"""
|
|
|
868 |
Returns the list of transactions that require some extra processing and
|
|
|
869 |
which belong to a particular category. This is currently used by CRM
|
|
|
870 |
application.
|
|
|
871 |
"""
|
|
|
872 |
try:
|
|
|
873 |
return get_transactions_requiring_extra_processing(category)
|
|
|
874 |
finally:
|
|
|
875 |
close_session()
|
|
|
876 |
|
|
|
877 |
def markTransactionAsProcessed(self, transactionId, category):
|
|
|
878 |
"""
|
|
|
879 |
Marks a particular transaction as processed for a particular category.
|
|
|
880 |
It essentially deletes the transaction if it is processed for a particular
|
|
|
881 |
category. This is currently used by CRM application.
|
|
|
882 |
"""
|
|
|
883 |
try:
|
|
|
884 |
return mark_transaction_as_processed(transactionId, category)
|
|
|
885 |
finally:
|
|
|
886 |
close_session()
|
| 4018 |
chandransh |
887 |
|
|
|
888 |
def getItemWiseRiskyOrdersCount(self, ):
|
|
|
889 |
"""
|
|
|
890 |
Returns a map containing the number of risky orders keyed by item id. A risky order
|
|
|
891 |
is defined as one whose shipping date is about to expire.
|
|
|
892 |
"""
|
|
|
893 |
try:
|
|
|
894 |
return get_item_wise_risky_orders_count()
|
|
|
895 |
finally:
|
|
|
896 |
close_session()
|
| 3956 |
chandransh |
897 |
|
| 2536 |
chandransh |
898 |
def closeSession(self, ):
|
|
|
899 |
close_session()
|
| 3376 |
rajveer |
900 |
|
|
|
901 |
def isAlive(self, ):
|
|
|
902 |
"""
|
|
|
903 |
For checking weather service is active alive or not. It also checks connectivity with database
|
|
|
904 |
"""
|
|
|
905 |
try:
|
|
|
906 |
return is_alive()
|
|
|
907 |
finally:
|
|
|
908 |
close_session()
|