Subversion Repositories SmartDukaan

Rev

Rev 9882 | Rev 10136 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
104 ashish 1
'''
2
Created on 29-Mar-2010
3
 
4
@author: ashish
5
'''
6056 amit.gupta 6
from elixir import session
7363 rajveer 7
from shop2020.model.v1.order.impl import DataService, RedExpressUpdateService,\
8
    RechargeService
6000 mandeep.dh 9
from shop2020.model.v1.order.impl.Convertors import to_t_transaction, to_t_alert, \
10
    to_t_order, to_t_lineitem, to_t_payment_settlement, to_t_verification_agent, \
7311 kshitij.so 11
    to_t_attribute, to_t_rechargeTransaction, to_t_frc, to_t_hotspot, to_t_sourcedetail, \
7967 anupam.sin 12
    to_t_amazonorder, to_t_storeOrderDetail, to_t_storeOrderCollection, \
8488 amar.kumar 13
    to_t_hotspotServiceMatrix, to_t_ebayOrder, to_t_amazonFbaSalesSnapshot, \
8990 vikram.rag 14
    to_t_snapdealOrder, to_t_flipkartOrder
8282 kshitij.so 15
 
6000 mandeep.dh 16
from shop2020.model.v1.order.impl.DataAccessors import create_transaction, \
17
    get_transactions_for_customer, get_transaction_status, get_line_items_for_order, \
18
    get_transaction, get_transactions_for_shopping_cart_id, \
19
    change_transaction_status, get_orders_for_customer, get_orders_for_transaction, \
20
    get_order, get_returnable_orders_for_customer, \
21
    get_cancellable_orders_for_customer, get_orders_by_billing_date, get_all_orders, \
22
    change_order_status, get_alerts, add_alert, add_billing_details, close_session, \
23
    accept_order, mark_orders_as_picked_up, mark_orders_as_delivered, \
24
    mark_orders_as_rto, order_outofstock, batch_orders, update_non_delivery_reason, \
25
    enqueue_transaction_info_email, get_undelivered_orders, get_order_for_customer, \
26
    get_valid_order_count, get_cust_count_with_successful_txn, \
27
    get_valid_orders_amount_range, get_valid_orders, toggle_doa_flag, \
28
    request_pickup_number, authorize_pickup, receive_return, validate_doa, \
29
    reship_order, refund_order, get_return_orders, process_return, get_return_order, \
30
    mark_doas_as_picked_up, verify_order, is_alive, get_orders_by_shipping_date, \
31
    update_weight, change_warehouse, change_product, add_delay_reason, \
32
    reconcile_cod_collection, get_transactions_requiring_extra_processing, \
33
    mark_transaction_as_processed, get_item_wise_risky_orders_count, \
34
    accept_order_for_item, get_orders_in_batch, get_order_count, \
35
    get_ebs_settlement_summaries, mark_order_cancellation_request_received, \
36
    mark_order_cancellation_request_denied, refund_transaction, \
37
    mark_order_cancellation_request_confirmed, \
38
    mark_transaction_as_payment_flag_removed, accept_orders_for_item_id, \
39
    mark_orders_as_po_raised, mark_orders_as_reversal_initiated, \
40
    mark_orders_as_not_available, update_shipment_address, mark_orders_as_timeout, \
41
    get_order_for_awb, mark_orders_as_shipped_from_warehouse, mark_alerts_as_seen, \
42
    mark_order_doa_request_received, mark_order_doa_request_authorized, \
43
    mark_order_return_request_received, mark_order_return_request_authorized, \
44
    add_invoice_number, get_reshipped_order_ids, validate_return_product, \
45
    get_orders_for_provider_for_status, save_ebs_settlement_summary, \
46
    get_ebs_settlement_date, save_payment_settlements, mark_ebs_settlement_uploaded, \
47
    get_billed_orders_for_vendor, get_settlement_for_Prepaid, \
48
    get_settlements_by_date, get_slipped_sipping_date_orders, \
49
    mark_order_as_lost_in_transit, get_cancelled_orders, mark_order_as_delivered, \
50
    mark_return_orders_as_picked_up, update_orders_as_PORaised, \
51
    get_order_distribution_by_status, get_orders_not_met_expected_delivery_date, \
52
    mark_orders_as_local_connected, mark_orders_as_destinationCityReached, \
53
    mark_orders_as_firstDeliveryAttempted, get_non_delivered_orders_by_courier, \
54
    get_orders_not_local_connected, get_doas_not_picked_up, \
55
    get_return_orders_not_picked_up, get_orders_not_picked_up, get_rto_orders, \
56
    get_order_list, get_order_ids_for_status, update_orders_as_paid_to_vendor, \
57
    update_COD_agent, get_refunded_orders_marked_paid, get_settlement_for_Cod, \
58
    get_order_list_for_vendor, update_order_only_as_paid_to_vendor, \
59
    get_all_verification_agents, get_all_attributes_for_order_id, \
60
    set_order_attribute_for_transaction, get_billed_orders, get_all_return_orders, \
61
    mark_order_as_received_at_store, get_receive_pending_orders, \
62
    get_received_at_store_orders, mark_orders_as_returned_from_store, \
6056 amit.gupta 63
    set_order_attributes, get_orders_collection_at_store, get_order_attribute_value, \
64
    change_jacket_number, mark_order_as_rto_in_transit, get_recharge_order, \
65
    get_recharge_orders, update_recharge_order_status, activate_recharge_txn, \
66
    get_user_wallet, get_user_wallet_history, get_service_providers, \
6396 amit.gupta 67
    get_service_provider_for_device, get_recharge_orders_for_transaction, \
68
    update_amount_in_wallet, get_recharge_orders_for_device, \
69
    get_recharge_orders_for_status, get_plans_for_operator, get_recharge_statistics, \
70
    validate_recharge, get_recharge_denominations, update_availability_status, \
6821 amar.kumar 71
    get_misc_charges, get_available_emi_schemes, refund_recharge_order, \
7073 anupam.sin 72
    create_recharge_transaction, get_physical_orders, get_document, retrieve_invoice, \
7125 amit.gupta 73
    change_shipping_address, get_recharge_transactions, get_recharge_transaction, \
7151 amit.gupta 74
    get_frcs, get_hotspot_store, get_circle, retrieve_hotspot_recharge_invoice, \
7190 amar.kumar 75
    get_recharge_trans, split_freebie_order, get_recharge_transactions_by_number, \
7285 rajveer 76
    update_hotspot_store_password, get_source_detail, get_all_circles, delete_frcs,\
7311 kshitij.so 77
    topup_company_wallet, get_wallet_balance_for_company, \
7343 anupam.sin 78
    add_amazon_order, update_amazon_order_status,get_amazon_order, get_amazon_orders_shipped, \
7371 anupam.sin 79
    get_amazon_orders_cancelled, get_orders_for_store, get_store_order_advance_invoice, add_frc, \
7393 anupam.sin 80
    add_series, get_store_order_detail, save_store_order_detail, get_all_edc_banks, \
7442 vikram.rag 81
    save_refund_amounts_for_store_order, get_collections_for_store,get_amazon_orders_to_acknowledge, \
7607 anupam.sin 82
    change_amazon_order_status,update_timestamp_for_amazon_order,update_source_detail_timestamp, \
83
    get_amazon_order_by_amazonorderid, get_orders_by_mobile_number, get_orders_by_amazon_id, \
7967 anupam.sin 84
    change_courier_provider, convert_store_to_normal, update_freebie_item, update_order_AWB, \
8182 amar.kumar 85
    get_hotspot_service_matrices, get_orders_by_vendor, create_ebay_order, \
86
    get_ebay_order_by_sales_rec_number, get_ebay_order_by_orderId, update_ebay_order, \
8488 amar.kumar 87
    ebay_order_exists, update_order_for_ebay, get_ebay_order, split_ebay_order, \
88
    add_or_update_amazon_fba_sales_snapshot, get_amazon_fba_sales_snapshot_for_days, \
89
    get_amazon_fba_sales_latest_snapshot_for_item, create_snapdeal_order, \
8961 vikram.rag 90
    get_snapdeal_order, snapdeal_order_exists, update_latest_fba_prices_for_item , \
9159 amar.kumar 91
    flipkart_order_exists, create_flipkart_order, get_flipkart_order, get_flipkart_order_by_subOrderId, \
9404 vikram.rag 92
    update_flipkart_order_dates_and_awb,get_order_for_airwayBillNo, \
9651 manish.sha 93
    get_orders_count_created_after_timestamp_for_source, get_min_created_timestamp_undelivered_orders_for_source, \
9945 vikram.rag 94
    update_snapdeal_orders_status, update_flipkart_orders_status, bulk_add_or_update_amazon_fba_sales_snapshot, \
95
    get_created_orders_for_flipkart
7343 anupam.sin 96
 
6000 mandeep.dh 97
from shop2020.model.v1.order.impl.model.DTHRechargeOrder import DTHRechargeOrder
6056 amit.gupta 98
from shop2020.model.v1.order.impl.model.DigitalTransaction import \
99
    DigitalTransaction
6000 mandeep.dh 100
from shop2020.model.v1.order.impl.model.MobileRechargeOrder import \
101
    MobileRechargeOrder
102
from shop2020.thriftpy.model.v1.order.ttypes import TransactionServiceException, \
7442 vikram.rag 103
    RechargeType,AmazonOrdersToAcknowledge
6000 mandeep.dh 104
from shop2020.utils.Utils import to_py_date, get_fdate_tdate, to_java_date
6031 rajveer 105
import datetime
8182 amar.kumar 106
from shop2020.helpers.impl.DataAccessor import close_session
8488 amar.kumar 107
from shop2020.model.v1.user.impl.Converters import to_t_address
1405 ankur.sing 108
 
5527 anupam.sin 109
 
104 ashish 110
 
111
class OrderServiceHandler:
112
 
3187 rajveer 113
    def __init__(self, dbname='transaction', db_hostname='localhost'):
483 rajveer 114
        """
104 ashish 115
        Constructor
483 rajveer 116
        """
3187 rajveer 117
        DataService.initialize(dbname, db_hostname)
104 ashish 118
 
119
    def createTransaction(self, transaction):
120
        """
121
        Parameters:
122
         - transaction
123
        """
766 rajveer 124
        try:
125
            return create_transaction(transaction)
126
        finally:
127
            close_session()
128
 
104 ashish 129
    def getTransaction(self, id):
130
        """
131
            Get transaction methods.
132
 
133
        Parameters:
134
         - id
135
        """
766 rajveer 136
        try:
137
            transaction = get_transaction(id)
138
            return to_t_transaction(transaction)
139
        finally:
140
            close_session()
141
 
483 rajveer 142
    def getTransactionsForCustomer(self, customerId, from_date, to_date, status):
104 ashish 143
        """
144
        Parameters:
483 rajveer 145
         - customerId
104 ashish 146
         - from_date
147
         - to_date
483 rajveer 148
         - status
104 ashish 149
        """
766 rajveer 150
        try:
151
            current_from_date, current_to_date = get_fdate_tdate(from_date, to_date)
152
 
153
            transactions = get_transactions_for_customer(customerId, current_from_date, current_to_date, status)
154
            t_transaction = []
155
            for transaction in transactions:
156
                t_transaction.append(to_t_transaction(transaction))
157
            return t_transaction
158
        finally:
159
            close_session()
483 rajveer 160
 
161
    def getTransactionsForShoppingCartId(self, shoppingCartId):
162
        """
163
        Parameters:
164
            - shoppingCartId
165
        """
766 rajveer 166
        try:
167
            transactions = get_transactions_for_shopping_cart_id(shoppingCartId)
168
            t_transaction = []
169
            for transaction in transactions:
170
                t_transaction.append(to_t_transaction(transaction))
171
            return t_transaction
172
        finally:
173
            close_session()
104 ashish 174
 
483 rajveer 175
    def getTransactionStatus(self, transactionId):
104 ashish 176
        """
177
        Parameters:
483 rajveer 178
         - transactionId
179
        """
766 rajveer 180
        try:
181
            return get_transaction_status(transactionId)
182
        finally:
183
            close_session()
184
 
7293 anupam.sin 185
    def changeTransactionStatus(self, transactionId, status, description, pickUp, orderType, source):
483 rajveer 186
        """
187
        Parameters:
188
         - transactionId
104 ashish 189
         - status
483 rajveer 190
         - description
5387 rajveer 191
         - selfPickup
483 rajveer 192
        """
766 rajveer 193
        try:
7293 anupam.sin 194
            return change_transaction_status(transactionId, status, description, pickUp, orderType, source)
766 rajveer 195
        finally:
196
            close_session()
197
 
1528 ankur.sing 198
    def getOrdersForTransaction(self, transactionId, customerId):
483 rajveer 199
        """
1528 ankur.sing 200
        Returns list of orders for given transaction Id. Also filters based on customer Id so that
201
        only user who owns the transaction can view its order details.
202
 
483 rajveer 203
        Parameters:
204
         - transactionId
1528 ankur.sing 205
         - customerId
483 rajveer 206
        """
766 rajveer 207
        try:
1528 ankur.sing 208
            orders = get_orders_for_transaction(transactionId, customerId)
766 rajveer 209
            return [to_t_order(order) for order in orders]    
210
        finally:
211
            close_session()
212
 
4801 anupam.sin 213
    def getAllOrders(self, statuses, from_date, to_date, warehouse_id):
483 rajveer 214
        """
215
        Parameters:
216
         - status
104 ashish 217
         - from_date
218
         - to_date
483 rajveer 219
         - warehouse_id
104 ashish 220
        """
766 rajveer 221
        try:
222
            current_from_date, current_to_date = get_fdate_tdate(from_date, to_date)        
4801 anupam.sin 223
            orders = get_all_orders(statuses, current_from_date, current_to_date, warehouse_id)
766 rajveer 224
            return [to_t_order(order) for order in orders]
225
        finally:
226
            close_session()
4133 chandransh 227
 
8303 amar.kumar 228
    def getOrdersInBatch(self, statuses, offset, limit, warehouse_id, source):
4133 chandransh 229
        """
230
        Returns at most 'limit' orders with the given statuses for the given warehouse starting from the given offset.
231
        Pass the status as null and the limit as 0 to ignore them.
232
 
233
        Parameters:
234
         - statuses
235
         - offset
236
         - limit
237
         - warehouse_id
238
        """
239
        try:
8303 amar.kumar 240
            orders = get_orders_in_batch(statuses, offset, limit, warehouse_id, source)
4133 chandransh 241
            return [to_t_order(order) for order in orders]
242
        finally:
243
            close_session()
244
 
8303 amar.kumar 245
    def getOrderCount(self, statuses, warehouseId, source):
4133 chandransh 246
        """
247
        Returns the count of orders with the given statuses assigned to the given warehouse.
248
 
249
        Parameters:
250
         - statuses
251
         - warehouseId
252
        """
253
        try:
8303 amar.kumar 254
            return get_order_count(statuses, warehouseId, source)
4133 chandransh 255
        finally:
256
            close_session()
257
 
995 varun.gupt 258
    def getOrdersByBillingDate(self, status, start_billing_date, end_billing_date, warehouse_id):
259
        """
260
        Parameters:
261
         - status
262
         - start_billing_date
263
         - end_billing_date
264
         - warehouse_id
265
        """
266
        try:
267
            current_start_billing_date, current_end_billing_date = get_fdate_tdate(start_billing_date, end_billing_date)
268
            orders = get_orders_by_billing_date(status, current_start_billing_date, current_end_billing_date, warehouse_id)
269
            return [to_t_order(order) for order in orders]
270
        finally:
271
            close_session()
1382 varun.gupt 272
 
3451 chandransh 273
    def getOrdersByShippingDate(self, fromShippingDate, toShippingDate, providerId, warehouseId, cod):
3427 chandransh 274
        """
275
        Returns orders for a particular provider and warehouse which were shipped between the given dates.
3451 chandransh 276
        Returned orders comprise of COD orders if cod parameter is true. It comprises of prepaid orders otherwise.
277
        Pass providerId and warehouseId as -1 to ignore both these parameters.
3427 chandransh 278
 
279
        Parameters:
280
         - fromShippingDate
281
         - toShippingDate
282
         - providerId
283
         - warehouseId
3451 chandransh 284
         - cod
3427 chandransh 285
        """
286
        try:
287
            from_shipping_date, to_shipping_date = get_fdate_tdate(fromShippingDate, toShippingDate)
3451 chandransh 288
            orders = get_orders_by_shipping_date(from_shipping_date, to_shipping_date, providerId, warehouseId, cod)
3427 chandransh 289
            return [to_t_order(order) for order in orders]
290
        finally:
291
            close_session()
292
 
1382 varun.gupt 293
    def getReturnableOrdersForCustomer(self, customerId, limit = None):
294
        """
295
        Parameters:
296
         - customerId
297
         - limit
298
        """
299
        try:
300
            return get_returnable_orders_for_customer(customerId, limit)
301
        finally:
302
            close_session()
995 varun.gupt 303
 
1382 varun.gupt 304
    def getCancellableOrdersForCustomer(self, customerId, limit = None):
305
        """
306
        Parameters:
307
         - customerId
308
         - limit
309
        """
310
        try:
311
            return get_cancellable_orders_for_customer(customerId, limit)
312
        finally:
313
            close_session()
314
 
483 rajveer 315
    def changeOrderStatus(self, orderId, status, description):
316
        """
317
        Parameters:
318
         - orderId
319
         - status
320
         - description
321
         - 
322
        """
766 rajveer 323
        try:
324
            return change_order_status(self, orderId, status, description)
325
        finally:
326
            close_session()
921 rajveer 327
 
3064 chandransh 328
    def verifyOrder(self, orderId):
329
        """
330
        Marks the given order as SUBMITTED_FOR_PROCESSING and updates the verified
331
        timestamp. It is intended to be used for COD orders but can be harmlessly
332
        used for all other orders as well.
333
        Throws an exception if no such order exists.
334
 
335
        Parameters:
336
         - orderId
337
        """
338
        try:
7391 rajveer 339
            return verify_order(orderId)
3064 chandransh 340
        finally:
341
            close_session()
342
 
921 rajveer 343
    def acceptOrder(self, orderId):
344
        """
3064 chandransh 345
        Marks the given order as ACCEPTED and updates the accepted timestamp. If the
346
        given order is not a COD order, it also captures the payment if the same has
347
        not been captured.
348
        Throws an exception if no such order exists.
349
 
921 rajveer 350
        Parameters:
351
         - orderId
352
        """
353
        try:
4285 rajveer 354
            return accept_order(orderId)
921 rajveer 355
        finally:
356
            close_session()
357
 
3014 chandransh 358
    def getOrdersForCustomer(self, customerId, from_date, to_date, statuses):
104 ashish 359
        """
3014 chandransh 360
        Returns list of orders for the given customer created between the given dates and having the given statuses.
361
        Pass and empty list to ignore filtering on statuses.
362
 
104 ashish 363
        Parameters:
364
         - customerId
365
         - from_date
366
         - to_date
3014 chandransh 367
         - statuses
104 ashish 368
        """
766 rajveer 369
        try:
370
            current_from_date, current_to_date = get_fdate_tdate(from_date, to_date)
371
 
3014 chandransh 372
            orders = get_orders_for_customer(customerId, current_from_date, current_to_date, statuses)
766 rajveer 373
            return [to_t_order(order) for order in orders]
374
        finally:
375
            close_session()
1528 ankur.sing 376
 
377
    def getOrderForCustomer(self, orderId, customerId):
378
        """
379
        Returns an order for the order Id. Also checks if the order belongs to the customer whose Id is passed.
380
        Throws exception if either order Id is invalid or order does not below to the customer whose Id is passed.
381
 
382
        Parameters:
383
         - customerId
384
         - orderId
385
        """
386
        try:
387
            return to_t_order(get_order_for_customer(orderId, customerId))
388
        finally:
389
            close_session()
766 rajveer 390
 
483 rajveer 391
    def getOrder(self, id):
392
        """
393
        Parameters:
394
         - id
395
        """
766 rajveer 396
        try:
397
            return to_t_order(get_order(id))
398
        finally:
399
            close_session()
4999 phani.kuma 400
 
401
    def getOrderList(self, order_ids):
402
        """
403
        Parameters:
404
         - order_ids
405
        """
406
        try:
407
            orders = get_order_list(order_ids)
408
            return [to_t_order(order) for order in orders]
409
        finally:
410
            close_session()
411
 
5386 phani.kuma 412
    def getOrderListForVendor(self, order_ids, vendorId):
413
        """
414
        Parameters:
415
         - order_ids
416
         - vendorId
417
        """
418
        try:
419
            orders = get_order_list_for_vendor(order_ids, vendorId)
420
            return [to_t_order(order) for order in orders]
421
        finally:
422
            close_session()
423
 
483 rajveer 424
    def getLineItemsForOrder(self, orderId):
425
        """
426
        Parameters:
427
         - orderId
428
        """
766 rajveer 429
        try:
430
            lineitems = get_line_items_for_order(orderId)
431
            t_lineitems = []
432
            for lineitem in lineitems:
433
                t_lineitems.append(to_t_lineitem(lineitem))
434
            return t_lineitems
435
        finally:
436
            close_session()
1149 chandransh 437
 
7190 amar.kumar 438
    def addBillingDetails(self, orderId, invoice_number, serialNumber, itemNumber, freebieWarehouseId, billedBy, jacketNumber, billingType, vendorId, authorize):
494 rajveer 439
        """
4658 mandeep.dh 440
        Adds jacket number and serial no. to the order. Doesn't update the serial no. if a -1 is supplied.
2783 chandransh 441
        Also marks the order as billed and sets the billing timestamp.
442
        Return false if it doesn't find the order with the given ID.
1149 chandransh 443
 
444
        Parameters:
445
         - orderId
446
         - jacketNumber
4658 mandeep.dh 447
         - serialNumber
2783 chandransh 448
         - itemNumber
7190 amar.kumar 449
         - freebieWarehouseId
2783 chandransh 450
         - billedBy
1149 chandransh 451
        """
452
        try:
7190 amar.kumar 453
            return add_billing_details(orderId, invoice_number, serialNumber, itemNumber, freebieWarehouseId, billedBy, jacketNumber, billingType, vendorId, authorize)
1149 chandransh 454
        finally:
455
            close_session()
1220 chandransh 456
 
6751 amar.kumar 457
    def addInvoiceNumber(self, orderId, invoiceNumber, color, serialNumber, itemNumber):
4579 rajveer 458
        """
459
        Add the invoice number to the order.
460
 
461
        Parameters:
462
         - orderId
463
         - invoice_number
464
        """
465
        try:
6751 amar.kumar 466
            add_invoice_number(orderId, invoiceNumber, color, serialNumber, itemNumber)
4579 rajveer 467
        finally:
468
            close_session()
469
 
1220 chandransh 470
    def batchOrders(self, warehouseId):
471
        """
472
        Create a batch of all the pending orders for the given warehouse.
473
        The returned list is orderd by created_timestamp.
474
        If there are no pending orders, an empty list is returned.
1208 chandransh 475
 
1220 chandransh 476
        Parameters:
477
         - warehouseId
478
        """
479
        try:
480
            pending_orders = batch_orders(warehouseId)
481
            return [to_t_order(order) for order in pending_orders]
482
        finally:
483
            close_session()
484
 
1208 chandransh 485
    def markOrderAsOutOfStock(self, orderId):
486
        """
487
        Mark the given order as out of stock. Throws an exception if the order with the given Id couldn't be found.
488
 
489
 
490
        Parameters:
491
         - orderId
492
        """
493
        try:
494
            return order_outofstock(orderId)
495
        finally:
496
            close_session()
497
 
4910 phani.kuma 498
    def markOrdersAsShippedFromWarehouse(self, warehouseId, providerId, cod, orderIds):
759 chandransh 499
        """
3064 chandransh 500
        Depending on the third parameter, marks either all prepaid or all cod orders BILLED by the
4910 phani.kuma 501
        given warehouse and were picked up by the given provider as SHIPPED_FROM_WH.
759 chandransh 502
 
503
        Parameters:
504
         - warehouseId
505
         - providerId
3064 chandransh 506
         - cod
759 chandransh 507
        """
766 rajveer 508
        try:
4910 phani.kuma 509
            return mark_orders_as_shipped_from_warehouse(warehouseId, providerId, cod, orderIds)
766 rajveer 510
        finally:
511
            close_session()
1113 chandransh 512
 
5713 rajveer 513
    def markOrdersAsReturnedFromStore(self, providerId, orderIds, awbs):
5676 rajveer 514
        """
515
        Parameters:
516
         - providerId
517
         - orderIds
5713 rajveer 518
         - awbs
5676 rajveer 519
        """
520
        try:
5713 rajveer 521
            return mark_orders_as_returned_from_store(providerId, orderIds, awbs)
5676 rajveer 522
        finally:
523
            close_session()
524
 
525
    def setOrderAttributes(self, orderId, attributes):
526
        """
527
        sets attributes for an order
528
 
529
        Parameters:
530
         - orderId
531
         - attributes
532
        """
533
        try:
534
            return set_order_attributes(orderId, attributes)
535
        finally:
536
            close_session()
537
 
538
 
4910 phani.kuma 539
    def markOrdersAsPickedUp(self, providerId, pickupDetails):
4410 rajveer 540
        """
4910 phani.kuma 541
        Marks all SHIPPED_FROM_WH orders of the previous day for a provider as SHIPPED_TO_LOGISTICS.
542
        Raises an exception if we encounter report for an AWB number that we did not ship.
4410 rajveer 543
 
544
        Parameters:
545
         - providerId
4910 phani.kuma 546
         - pickupDetails
4410 rajveer 547
        """
548
        try:
4910 phani.kuma 549
            mark_orders_as_picked_up(providerId, pickupDetails)
4410 rajveer 550
        finally:
551
            close_session()
552
 
4910 phani.kuma 553
    def getOrdersNotPickedUp(self, providerId):
1113 chandransh 554
        """
555
        Returns a list of orders that were shipped from warehouse but did not appear in the pick-up report.
556
 
557
        Parameters:
558
         - providerId
559
        """
560
        try:
4910 phani.kuma 561
            orders_not_picked_up = get_orders_not_picked_up(providerId)
1113 chandransh 562
            return [to_t_order(order) for order in orders_not_picked_up]
563
        finally:
564
            close_session()
1132 chandransh 565
 
566
    def markOrdersAsDelivered(self, providerId, deliveredOrders):
567
        """
568
        Marks all orders with AWBs in the given map as delivered. Also sets the delivery timestamp and
569
        the name of the receiver.
570
        Raises an exception if we encounter report for an AWB number that we did not ship.
571
 
572
        Parameters:
573
         - providerId
574
         - deliveredOrders
575
        """
576
        try:
577
            mark_orders_as_delivered(providerId, deliveredOrders)
578
        finally:
579
            close_session()
1135 chandransh 580
 
4712 rajveer 581
    def markOrderAsDelivered(self, orderId, deliveryTimestamp, receiver):
582
        """
583
        Attributes:
584
         - orderId
585
         - deliveryTimestamp
586
         - receiver
587
        """
588
        try:
589
            mark_order_as_delivered(orderId, to_py_date(deliveryTimestamp), receiver)
590
        finally:
591
            close_session()
592
 
593
 
5555 rajveer 594
    def markOrderAsReceivedAtStore(self, orderId, deliveryTimestamp):
595
        """
596
        Attributes:
597
         - orderId
598
         - deliveryTimestamp
599
        """
600
        try:
601
            mark_order_as_received_at_store(orderId, to_py_date(deliveryTimestamp))
602
        finally:
603
            close_session()
604
 
605
    def getReceivePendingOrders(self, storeId):
606
        """
607
        Attributes:
608
         - storeId
609
        """
610
        try:
611
            orders = get_receive_pending_orders(storeId)
612
            return [to_t_order(order) for order in orders]
613
        finally:
614
            close_session()
615
 
616
    def getReceivedAtStoreOrders(self, storeId):
617
        """
618
        Attributes:
619
         - storeId
620
        """
621
        try:
622
            orders = get_received_at_store_orders(storeId)
623
            return [to_t_order(order) for order in orders]
624
        finally:
625
            close_session()
5713 rajveer 626
 
627
    def getOrdersCollectionAtStore(self, storeId, fromDate, toDate, onlyCod):
628
        """
629
        Parameters:
630
         - storeId
631
         - fromDate
632
         - toDate
633
         - onlyCod
634
        """
635
        try:
636
            orders = get_orders_collection_at_store(storeId, to_py_date(fromDate), to_py_date(toDate), onlyCod)
637
            return [to_t_order(order) for order in orders]
638
        finally:
639
            close_session()
640
 
4910 phani.kuma 641
    def markAsRTOrders(self, providerId, returnedOrders):
1135 chandransh 642
        """
4910 phani.kuma 643
        Mark all orders with AWBs in the given map as RTO. Also sets the delivery timestamp.
1135 chandransh 644
        Raises an exception if we encounter report for an AWB number that we did not ship.
645
 
646
        Parameters:
647
         - providerId
648
         - returnedOrders
649
        """
650
        try:
4910 phani.kuma 651
            mark_orders_as_rto(providerId, returnedOrders)
1135 chandransh 652
        finally:
653
            close_session()
1246 chandransh 654
 
4910 phani.kuma 655
    def getRTOrders(self, providerId):
656
        """
657
        Returns a list of orders that were returned by courier.
658
 
659
        Parameters:
660
         - providerId
661
        """
662
        try:
663
            rto_orders = get_rto_orders(providerId)
664
            return [to_t_order(order) for order in rto_orders]
665
        finally:
666
            close_session()
667
 
1246 chandransh 668
    def updateNonDeliveryReason(self, providerId, undeliveredOrders):
669
        """
670
        Update the status description of orders whose AWB numbers are keys of the Map.
671
 
672
        Parameters:
673
         - providerId
674
         - undelivered_orders
675
        """
676
        try:
4910 phani.kuma 677
            update_non_delivery_reason(providerId, undeliveredOrders)
678
        finally:
679
            close_session()
680
 
681
    def getNonDeliveredOrdersbyCourier(self, providerId):
682
        """
683
        Returns a list of orders that were picked up or shipped four days ago but did not get delivered.
684
 
685
        Parameters:
686
         - providerId
687
        """
688
        try:
689
            orders_not_delivered = get_non_delivered_orders_by_courier(providerId)
4581 phani.kuma 690
            return [to_t_order(order) for order in orders_not_delivered]
1246 chandransh 691
        finally:
692
            close_session()
1405 ankur.sing 693
 
4910 phani.kuma 694
    def markOrdersAsLocalConnected(self, providerId, local_connected_orders):
695
        """
696
        Mark all orders with AWBs in the given map as local connected. Also sets the local connected timestamp.
697
 
698
        Parameters:
699
         - providerId
700
         - local_connected_orders
701
        """
702
        try:
703
            mark_orders_as_local_connected(providerId, local_connected_orders)
704
        finally:
705
            close_session()
706
 
707
    def getOrdersNotLocalConnected(self, providerId):
708
        """
709
        Returns a list of orders that were picked up or shipped but pending local connection.
710
 
711
        Parameters:
712
         - providerId
713
        """
714
        try:
715
            orders_pending_local_connection = get_orders_not_local_connected(providerId)
716
            return [to_t_order(order) for order in orders_pending_local_connection]
717
        finally:
718
            close_session()
719
 
720
    def markOrdersAsDestinationCityReached(self, providerId, destination_city_reached_orders):
721
        """
722
        Mark all orders with AWBs in the given map as reached destination city. Also sets the reached destination timestamp.
723
 
724
        Parameters:
725
         - providerId
726
         - destination_city_reached_orders
727
        """
728
        try:
729
            mark_orders_as_destinationCityReached(providerId, destination_city_reached_orders)
730
        finally:
731
            close_session()
732
 
733
    def markOrdersAsFirstDeliveryAttempted(self, providerId, first_atdl_orders):
734
        """
735
        Mark all orders with AWBs in the given map as first delivery attempt made. Also sets the first delivery attempted timestamp.
736
 
737
        Parameters:
738
         - providerId
739
         - first_atdl_orders
740
        """
741
        try:
742
            mark_orders_as_firstDeliveryAttempted(providerId, first_atdl_orders)
743
        finally:
744
            close_session()
745
 
4783 phani.kuma 746
    def getUndeliveredOrdersExpectedDeliveryDateNotMet(self):
747
        """
748
        Returns the list of orders whose expected delivery date has passed but have not been
749
        delivered yet.
750
        Returns an empty list if no such orders exist.
751
        """
752
        try:
753
            orders_not_delivered = get_orders_not_met_expected_delivery_date()
754
            return [to_t_order(order) for order in orders_not_delivered]
755
        finally:
756
            close_session()
757
 
1405 ankur.sing 758
    def getUndeliveredOrders(self, providerId, warehouseId):
759
        """
760
        Returns the list of orders whose delivery time has passed but have not been
761
        delivered yet for the given provider and warehouse. To get a complete list of
762
        undelivered orders, pass them as -1.
763
        Returns an empty list if no such orders exist.
764
 
765
        Parameters:
766
         - providerId
767
         - warehouseId
768
        """
769
        try:
770
            undelivered_orders = get_undelivered_orders(providerId, warehouseId)
771
            return [to_t_order(order) for order in undelivered_orders]
772
        finally:
773
            close_session()
1351 varun.gupt 774
 
1398 varun.gupt 775
    def enqueueTransactionInfoEmail(self, transactionId):
1351 varun.gupt 776
        """
1398 varun.gupt 777
        Save the email containing order details to be sent to customer later by batch job
1351 varun.gupt 778
 
779
        Parameters:
780
         - transactionId
781
        """
782
        try:
1398 varun.gupt 783
            return enqueue_transaction_info_email(transactionId)
1351 varun.gupt 784
        finally:
785
            close_session()
786
 
4444 rajveer 787
    def getAlerts(self, type, warehouseId, status, timestamp):
483 rajveer 788
        """
789
        Parameters:
4394 rajveer 790
         - type
4444 rajveer 791
         - warehouseId
4394 rajveer 792
         - status
793
         - timestamp
483 rajveer 794
        """
766 rajveer 795
        try:
4444 rajveer 796
            alerts = get_alerts(type, warehouseId, status, timestamp)
766 rajveer 797
 
798
            t_alerts = []
799
            for alert in alerts:
800
                t_alerts.append(to_t_alert(alert)) 
801
 
802
            return t_alerts
803
        finally:
804
            close_session()
4394 rajveer 805
 
4447 rajveer 806
    def addAlert(self, type, warehouseId, description):
483 rajveer 807
        """
808
        Parameters:
809
         - type
4394 rajveer 810
         - description
4447 rajveer 811
         - warehouseId
483 rajveer 812
        """
766 rajveer 813
        try:
4447 rajveer 814
            add_alert(type, warehouseId, description)
766 rajveer 815
        finally:
816
            close_session()
1596 ankur.sing 817
 
4444 rajveer 818
    def markAlertsAsSeen(self, warehouseId):
819
        """
820
        Parameters:
821
         - warehouseId
822
        """
823
        try:
824
            mark_alerts_as_seen(warehouseId)
825
        finally:
826
            close_session()
827
        pass
828
 
1596 ankur.sing 829
    def getValidOrderCount(self, ):
830
        """
831
        Return the number of valid orders. (OrderStatus >= OrderStatus.SUBMITTED_FOR_PROCESSING)
832
        """
1731 ankur.sing 833
        try:
834
            return get_valid_order_count()
835
        finally:
836
            close_session()
1627 ankur.sing 837
 
838
    def getNoOfCustomersWithSuccessfulTransaction(self, ):
839
        """
840
        Returns the number of distinct customers who have done successful transactions
841
        """
1731 ankur.sing 842
        try:
843
            return get_cust_count_with_successful_txn()
844
        finally:
845
            close_session()
1627 ankur.sing 846
 
1731 ankur.sing 847
 
848
    def getValidOrdersAmountRange(self, ):
1627 ankur.sing 849
        """
1731 ankur.sing 850
        Returns the minimum and maximum amounts of a valid order. (OrderStatus >= OrderStatus.SUBMITTED_FOR_PROCESSING)
851
        List contains two values, first minimum amount and second maximum amount.
1627 ankur.sing 852
        """
1731 ankur.sing 853
        try:
854
            return get_valid_orders_amount_range()
855
        finally:
856
            close_session()
1627 ankur.sing 857
 
5874 rajveer 858
    def getValidOrders(self, limit, onlyStore):
1886 ankur.sing 859
        """
860
        Returns list of Orders in descending order by Order creation date. List is restricted to limit Orders.
861
        If limit is passed as 0, then all valid Orders are returned.
862
 
863
        Parameters:
864
         - limit
5874 rajveer 865
         - onlyStore
1886 ankur.sing 866
        """
867
        try:
5874 rajveer 868
            return [to_t_order(order) for order in get_valid_orders(limit, onlyStore)]
1886 ankur.sing 869
        finally:
870
            close_session()
104 ashish 871
 
2536 chandransh 872
    def toggleDOAFlag(self, orderId):
104 ashish 873
        """
2536 chandransh 874
        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.
875
        Returns the final flag status.
876
        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 877
 
132 ashish 878
        Parameters:
2536 chandransh 879
         - orderId
132 ashish 880
        """
2536 chandransh 881
        try:
882
            return toggle_doa_flag(orderId)
883
        finally:
884
            close_session()
483 rajveer 885
 
4454 rajveer 886
    def markOrderDoaRequestReceived(self, orderId):
887
        """
888
        Once user raise the request for a DOA, order status will be changed from DELVIERY_SUCCESS to DOA_REQUEST_RECEIVED
889
 
890
        Parameters:
891
         - orderId
892
        """
893
        try:
894
            return mark_order_doa_request_received(orderId)
895
        finally:
896
            close_session()
897
 
7645 anupam.sin 898
    def markOrderDoaRequestAuthorized(self, orderId, isAuthorized,  fromStore, isReship):
4454 rajveer 899
        """
900
        CRM person can authorize or deny the request reised by customer. If he authorizes order will change from DOA_REQUEST_RECEIVED
901
        to DOA_REQUEST_AUTHORIZED. If he denies, status will be changed back to DELVIERY_SUCCESS.
902
 
903
        Parameters:
904
         - orderId
905
         - isAuthorized
906
        """
907
        try:
7645 anupam.sin 908
            return mark_order_doa_request_authorized(orderId, isAuthorized, fromStore, isReship)
4454 rajveer 909
        finally:
910
            close_session()
911
 
4488 rajveer 912
    def markOrderReturnRequestReceived(self, orderId):
913
        """
914
        Once user raise the request for a DOA, order status will be changed from DELVIERY_SUCCESS to RET_REQUEST_RECEIVED
915
 
916
        Parameters:
917
         - orderId
918
        """
919
        try:
920
            return mark_order_return_request_received(orderId)
921
        finally:
922
            close_session()
923
 
7645 anupam.sin 924
    def markOrderReturnRequestAuthorized(self, orderId, isAuthorized, fromStore, isReship):
4488 rajveer 925
        """
926
        CRM person can authorize or deny the request reised by customer. If he authorizes order will change from RET_REQUEST_RECEIVED
927
        to RET_REQUEST_AUTHORIZED. If he denies, status will be changed back to DELVIERY_SUCCESS.
928
 
929
        Parameters:
930
         - orderId
931
         - isAuthorized
932
        """
933
        try:
7645 anupam.sin 934
            return mark_order_return_request_authorized(orderId, isAuthorized, fromStore, isReship)
4488 rajveer 935
        finally:
936
            close_session()
937
 
4579 rajveer 938
    def requestPickupNumber(self, orderId, providerId):
104 ashish 939
        """
2536 chandransh 940
        Sends out an email to the account manager of the original courier provider used to ship the order.
4452 rajveer 941
        If the order status was DELIVERY_SUCCESS, it is changed to be DOA_PICKUP_REQUEST_RAISED.
942
        If the order status was DOA_PICKUP_REQUEST_RAISED, it is left unchanged.
2536 chandransh 943
        For any other status, it returns false.
944
        Throws an exception if the order with the given id couldn't be found.
104 ashish 945
 
946
        Parameters:
2536 chandransh 947
         - orderId
104 ashish 948
        """
2536 chandransh 949
        try:
4579 rajveer 950
            return request_pickup_number(orderId, providerId)
2536 chandransh 951
        finally:
952
            close_session()
483 rajveer 953
 
4602 rajveer 954
    def authorizePickup(self, orderId, pickupNumber, providerId):
304 ashish 955
        """
4452 rajveer 956
        If the order status is DOA_PICKUP_REQUEST_RAISED, it does the following
2536 chandransh 957
            1. Sends out an email to the customer with the dispatch advice that he has to print as an attachment.
958
            2. Changes order status to be DOA_PICKUP_AUTHORIZED.
959
            3. Returns true
960
        If the order is any other status, it returns false.
961
        Throws an exception if the order with the given id couldn't be found.
304 ashish 962
 
963
        Parameters:
2536 chandransh 964
         - orderId
965
         - pickupNumber
304 ashish 966
        """
2536 chandransh 967
        try:
4602 rajveer 968
            return authorize_pickup(orderId, pickupNumber, providerId)
2536 chandransh 969
        finally:
970
            close_session()    
2764 chandransh 971
 
972
    def markDoasAsPickedUp(self, providerId, pickupDetails):
973
        """
974
        Marks all DOA_PICKUP_AUTHORIZED orders of the previous day for a provider as DOA_RETURN_IN_TRANSIT.
975
 
976
        Parameters:
977
         - providerId
978
         - pickupDetails
979
        """
980
        try:
4910 phani.kuma 981
            mark_doas_as_picked_up(providerId, pickupDetails)
982
        finally:
983
            close_session()
984
 
985
    def getDoasNotPickedUp(self, providerId):
986
        """
987
        Returns a list of orders that were authorized for pickup but did not appear in the pick-up report.
988
 
989
        Parameters:
990
         - providerId
991
        """
992
        try:
993
            orders_not_picked_up = get_doas_not_picked_up(providerId)
2764 chandransh 994
            return [to_t_order(order) for order in orders_not_picked_up]
995
        finally:
996
            close_session()
4910 phani.kuma 997
 
4741 phani.kuma 998
    def markReturnOrdersAsPickedUp(self, providerId, pickupDetails):
999
        """
1000
        Marks all RET_PICKUP_CONFIRMED orders of the previous day for a provider as RET_RETURN_IN_TRANSIT.
1001
 
1002
        Parameters:
1003
         - providerId
1004
         - pickupDetails
1005
        """
1006
        try:
4910 phani.kuma 1007
            mark_return_orders_as_picked_up(providerId, pickupDetails)
1008
        finally:
1009
            close_session()
1010
 
1011
    def getReturnOrdersNotPickedUp(self, providerId):
1012
        """
1013
        Returns a list of orders that were authorized for pickup but did not appear in the pick-up report.
1014
 
1015
        Parameters:
1016
         - providerId
1017
        """
1018
        try:
1019
            orders_not_picked_up = get_return_orders_not_picked_up(providerId)
4741 phani.kuma 1020
            return [to_t_order(order) for order in orders_not_picked_up]
1021
        finally:
1022
            close_session()
4910 phani.kuma 1023
 
4479 rajveer 1024
    def receiveReturn(self, orderId, receiveCondition):
2591 chandransh 1025
        """
4452 rajveer 1026
        If the order status is DOA_PICKUP_CONFIRMED or DOA_RETURN_IN_TRANSIT, marks the order status as DOA_RECEIVED_PRESTINE and returns true.
2591 chandransh 1027
        If the order is in any other state, it returns false.
1028
        Throws an exception if the order with the given id couldn't be found.
1029
 
1030
        Parameters:
1031
         - orderId
1032
        """
1033
        try:
4479 rajveer 1034
            return receive_return(orderId, receiveCondition)
2591 chandransh 1035
        finally:
1036
            close_session()
1037
 
1038
    def validateDoa(self, orderId, isValid):
1039
        """
4452 rajveer 1040
        Used to validate the DOA certificate for an order in the DOA_RECEIVED_PRESTINE state. If the certificate is valid,
2609 chandransh 1041
        the order state is changed to DOA_CERT_PENDING.
2591 chandransh 1042
        If the certificate is invalid, the order state is changed to DOA_CERT_INVALID.
1043
        If the order is in any other state, it returns false.
1044
        Throws an exception if the order with the given id couldn't be found.
1045
 
1046
        Parameters:
1047
         - orderId
1048
         - isValid
1049
        """
1050
        try:
1051
            return validate_doa(orderId, isValid)
1052
        finally:
1053
            close_session()
2628 chandransh 1054
 
4495 rajveer 1055
    def validateReturnProduct(self, orderId, isUsable):
1056
        """
1057
        Parameters:
1058
         - orderId
1059
         - isUsable
1060
        """
1061
        try:
1062
            return validate_return_product(orderId, isUsable)
1063
        finally:
1064
            close_session()
1065
 
2628 chandransh 1066
    def reshipOrder(self, orderId):
1067
        """
4484 rajveer 1068
        If the order is in RTO_RECEIVED_PRESTINE or DOA_CERT_INVALID state, it does the following:
2628 chandransh 1069
            1. Creates a new order for processing in the BILLED state. All billing information is saved.
4484 rajveer 1070
            2. Marks the current order as one of the final states RTO_RESHIPPED and DOA_INVALID_RESHIPPED depending on what state the order started in.
2628 chandransh 1071
 
1072
        If the order is in DOA_CERT_VALID state, it does the following:
1073
            1. Creates a new order for processing in the SUBMITTED_FOR_PROCESSING state.
1074
            2. Creates a return order for the warehouse executive to return the DOA material.
4452 rajveer 1075
            3. Marks the current order as the final DOA_VALID_RESHIPPED state.
2628 chandransh 1076
 
1077
        Returns the id of the newly created order.
1078
 
1079
        Throws an exception if the order with the given id couldn't be found.
1080
 
1081
        Parameters:
1082
         - orderId
1083
        """
1084
        try:
1085
            return reship_order(orderId)
1086
        finally:
1087
            close_session()
1088
 
3226 chandransh 1089
    def refundOrder(self, orderId, refundedBy, reason):
2628 chandransh 1090
        """
4484 rajveer 1091
        If the order is in RTO_RECEIVED_PRESTINE, DOA_CERT_VALID or DOA_CERT_INVALID state, it does the following:
2628 chandransh 1092
            1. Creates a refund request for batch processing.
1093
            2. Creates a return order for the warehouse executive to return the shipped material.
4484 rajveer 1094
            3. Marks the current order as RTO_REFUNDED, DOA_VALID_REFUNDED or DOA_INVALID_REFUNDED final states.
2628 chandransh 1095
 
1096
        If the order is in SUBMITTED_FOR_PROCESSING or INVENTORY_LOW state, it does the following:
1097
            1. Creates a refund request for batch processing.
3226 chandransh 1098
            2. Cancels the reservation of the item in the warehouse.
1099
            3. Marks the current order as the REFUNDED final state.
2628 chandransh 1100
 
3226 chandransh 1101
        For all COD orders, if the order is in INIT, SUBMITTED_FOR_PROCESSING or INVENTORY_LOW state, it does the following:
1102
            1. Cancels the reservation of the item in the warehouse.
1103
            2. Marks the current order as CANCELED.
1104
 
1105
        In all cases, it updates the reason for cancellation or refund and the person who performed the action.
1106
 
2628 chandransh 1107
        Returns True if it is successful, False otherwise.
1108
 
1109
        Throws an exception if the order with the given id couldn't be found.
1110
 
1111
        Parameters:
1112
         - orderId
3226 chandransh 1113
         - refundedBy
1114
         - reason
2628 chandransh 1115
        """
1116
        try:
3226 chandransh 1117
            return refund_order(orderId, refundedBy, reason)
2628 chandransh 1118
        finally:
1119
            close_session()
1120
 
2697 chandransh 1121
    def getReturnOrders(self, warehouseId, fromDate, toDate):
1122
        """
1123
        Get all return orders created between the from and to dates for the given warehouse.
1124
        Ignores the warehouse if it is passed as -1.
1125
 
1126
        Parameters:
1127
         - warehouseId
1128
         - fromDate
1129
         - toDate
1130
        """
1131
        try:
1132
            from_date, to_date = get_fdate_tdate(fromDate, toDate)
1133
            return get_return_orders(warehouseId, from_date, to_date)
1134
        finally:
1135
            close_session()
1136
 
5481 phani.kuma 1137
    def getAllReturnOrders(self, onlyNotProcessed, fromDate, toDate):
1138
        """
1139
        Get all return orders created between the from and to dates for the given warehouse.
1140
        Ignores the warehouse if it is passed as -1.
1141
 
1142
        Parameters:
1143
         - warehouseId
1144
         - fromDate
1145
         - toDate
1146
        """
1147
        try:
1148
            from_date, to_date = get_fdate_tdate(fromDate, toDate)
1149
            return get_all_return_orders(onlyNotProcessed, from_date, to_date)
1150
        finally:
1151
            close_session()
1152
 
2700 chandransh 1153
    def getReturnOrder(self, id):
1154
        """
1155
        Returns the ReturnOrder corresponding to the given id.
1156
        Throws an exception if the return order with the given id couldn't be found.
1157
 
1158
        Parameters:
1159
         - id
1160
        """
1161
        try:
1162
            return get_return_order(id)
1163
        finally:
1164
            close_session()
1165
 
2697 chandransh 1166
    def processReturn(self, returnOrderId):
1167
        """
1168
        Marks the return order with the given id as processed. Raises an exception if no such return order exists.
1169
 
1170
        Parameters:
1171
         - returnOrderId
1172
        """
1173
        try:
1174
            process_return(returnOrderId)
1175
        finally:
1176
            close_session()
4757 mandeep.dh 1177
 
1178
    def updateOrdersAsPORaised(self, itemIdQuantityMap, purchaseOrderId, warehouseId):
2819 chandransh 1179
        """
4757 mandeep.dh 1180
        Updates orders as PO raised. Also updates purchase order id in orders. Pass a map of items mapped to
1181
        the quantities for which the PO is raised.
1182
 
2819 chandransh 1183
        Parameters:
4757 mandeep.dh 1184
         - itemIdQuantityMap
1185
         - purchaseOrderId
2819 chandransh 1186
         - warehouseId
1187
        """
1188
        try:
4757 mandeep.dh 1189
            update_orders_as_PORaised(itemIdQuantityMap, purchaseOrderId, warehouseId)
2819 chandransh 1190
        finally:
1191
            close_session()
4757 mandeep.dh 1192
 
3451 chandransh 1193
    def updateWeight(self, orderId, weight):
1194
        """
1195
        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.
1196
 
1197
        Parameters:
1198
         - orderId
1199
         - weight
1200
        """
1201
        try:
1202
            order = update_weight(orderId, weight)
1203
            return to_t_order(order)
1204
        finally:
1205
            close_session()
1206
 
3469 chandransh 1207
    def changeItem(self, orderId, itemId):
1208
        """
1209
        Change the item to be shipped for this order. Also adjusts the reservation in the inventory accordingly.
1210
        Currently, it also ensures that only a different color of the given item is shipped.
1211
 
1212
        Parameters:
1213
         - orderId
1214
         - itemId
1215
        """
1216
        try:
1217
            order = change_product(orderId, itemId)
1218
            return to_t_order(order)
1219
        finally:
1220
            close_session()
7560 rajveer 1221
 
1222
    def changeCourierProvider(self, orderId, providerId):
1223
        try:
1224
            order = change_courier_provider(orderId, providerId)
1225
            return to_t_order(order)
1226
        finally:
1227
            close_session()
1228
 
3469 chandransh 1229
 
1230
    def shiftToWarehouse(self, orderId, warehouseId):
1231
        """
1232
        Moves the given order to the given warehouse. Also adjusts the inventory reservations accordingly.
1233
 
1234
        Parameters:
1235
         - orderId
1236
         - warehouseId
1237
        """
1238
        try:
1239
            order = change_warehouse(orderId, warehouseId)
1240
            return to_t_order(order)
1241
        finally:
1242
            close_session()
3553 chandransh 1243
 
4647 rajveer 1244
    def addDelayReason(self, orderId, delayReason, furtherDelay, delayReasonText):
3553 chandransh 1245
        """
1246
        Adds the given delay reason to the given order.
3986 chandransh 1247
        Increases the expected delivery time of the given order by the given no. of days.
3553 chandransh 1248
        Raises an exception if no order with the given id can be found.
3469 chandransh 1249
 
3553 chandransh 1250
        Parameters:
1251
         - orderId
1252
         - delayReason
1253
        """
1254
        try:
4647 rajveer 1255
            return add_delay_reason(orderId, delayReason, furtherDelay, delayReasonText)
3553 chandransh 1256
        finally:
1257
            close_session()
1258
 
3956 chandransh 1259
    def reconcileCodCollection(self, collectedAmountMap, xferBy, xferTxnId, xferDate):
1260
        """
1261
        Marks the COD orders with given AWB nos. as having been processed.
1262
        Updates the captured amount for the corresponding payment.
1263
 
1264
        Returns a map of AWBs which were not processed and the associated reason. An AWB is not processed if:
1265
        1. There is no order corresponding to an AWB number.
1266
        2. The captured amount for a payment exceeds the total payment.
1267
        3. The order corresponding to an AWB no. is in a state prior to DELIVERY_SUCCESS.
1268
 
1269
        Parameters:
1270
         - collectedAmountMap
1271
         - xferBy
1272
         - xferTxnId
1273
         - xferDate
1274
        """
1275
        try:
1276
            return reconcile_cod_collection(collectedAmountMap, xferBy, xferTxnId, xferDate)
1277
        finally:
1278
            close_session()
4008 mandeep.dh 1279
 
1280
    def getTransactionsRequiringExtraProcessing(self, category):
1281
        """
1282
        Returns the list of transactions that require some extra processing and
1283
        which belong to a particular category. This is currently used by CRM
1284
        application.
1285
        """
1286
        try:
1287
            return get_transactions_requiring_extra_processing(category)
1288
        finally:
1289
            close_session()
1290
 
1291
    def markTransactionAsProcessed(self, transactionId, category):
1292
        """
1293
        Marks a particular transaction as processed for a particular category.
1294
        It essentially deletes the transaction if it is processed for a particular
1295
        category. This is currently used by CRM application.
1296
        """
1297
        try:
1298
            return mark_transaction_as_processed(transactionId, category)
1299
        finally:
1300
            close_session()
4018 chandransh 1301
 
1302
    def getItemWiseRiskyOrdersCount(self, ):
1303
        """
1304
        Returns a map containing the number of risky orders keyed by item id. A risky order
1305
        is defined as one whose shipping date is about to expire.
1306
        """
1307
        try:
1308
            return get_item_wise_risky_orders_count()
1309
        finally:
1310
            close_session()
3956 chandransh 1311
 
4247 rajveer 1312
    def markOrderCancellationRequestReceived(self, orderId):
1313
        """
1314
        Mark order as cancellation request received. If customer sends request of cancellation of
1315
        a particular order, this method will be called. It will just change status of the order
1316
        depending on its current status. It also records the previous status, so that we can move
1317
        back to that status if cancellation request is denied.
1318
 
1319
        Parameters:
1320
         - orderId
1321
        """
1322
        try:
1323
            return mark_order_cancellation_request_received(orderId)
1324
        finally:
1325
            close_session()
1326
 
1327
 
4662 rajveer 1328
    def markOrderAsLostInTransit(self, orderId):
1329
        """
1330
        Parameters:
1331
         - orderId
1332
        """
1333
        try:
1334
            return mark_order_as_lost_in_transit(orderId)
1335
        finally:
1336
            close_session()
1337
 
4258 rajveer 1338
    def markTransactionAsPaymentFlagRemoved(self, transactionId):
4247 rajveer 1339
        """
4258 rajveer 1340
        If we and/or payment gateway has decided to accept the payment, this method needs to be called.
1341
        Changed transaction and all orders status to payment accepted.
4247 rajveer 1342
 
1343
        Parameters:
4258 rajveer 1344
         - transactionId
4247 rajveer 1345
        """
1346
        try:
4259 anupam.sin 1347
            return mark_transaction_as_payment_flag_removed(transactionId)
4247 rajveer 1348
        finally:
1349
            close_session()
4259 anupam.sin 1350
 
1351
    def refundTransaction(self, transactionId, refundedBy, reason):
1352
        """
1353
        This method is called when a flagged payment is deemed unserviceable and the corresponding orders
1354
        need to be cancelled
1355
 
1356
        Parameters:
1357
         - transactionId
1358
        """
1359
        try:
1360
            return refund_transaction(transactionId, refundedBy, reason)
1361
        finally:
1362
            close_session()
4247 rajveer 1363
 
1364
    def markOrderCancellationRequestDenied(self, orderId):
1365
        """
1366
        If we decide to not to cancel order, we will move the order ro previous status.
1367
 
1368
        Parameters:
1369
         - orderId
1370
        """
1371
        try:
1372
            return mark_order_cancellation_request_denied(orderId)
1373
        finally:
1374
            close_session()
1375
 
1376
    def markOrderCancellationRequestConfirmed(self, orderId):
1377
        """
1378
        If we decide to to cancel order, CRM will call this method to move the status of order to
1379
        cancellation request confirmed. After this OM will be able to cancel the order.
1380
 
1381
        Parameters:
1382
         - orderId
1383
        """
1384
        try:
1385
            return mark_order_cancellation_request_confirmed(orderId)
1386
        finally:
1387
            close_session()
1388
 
4324 mandeep.dh 1389
    def updateShipmentAddress(self, orderId, addressId):
1390
        """
1391
        Updates shipment address of an order. Delivery and shipping date estimates
1392
        etc. are also updated here.
1393
 
1394
        Throws TransactionServiceException in case address change is not
1395
        possible due to certain reasons such as new pincode in address is
1396
        not serviceable etc.
1397
 
1398
        Parameters:
1399
         - orderId
1400
         - addressId
1401
        """
1402
        try:
1403
            update_shipment_address(orderId, addressId)
1404
        finally:
1405
            close_session()
1406
 
4285 rajveer 1407
    def acceptOrdersForItemId(self, itemId, inventory):
1408
        """
1409
        Marks the orders as ACCEPTED for the given itemId and inventory. It also updates the accepted timestamp. If the
1410
        given order is not a COD order, it also captures the payment if the same has not been captured.
1411
 
1412
        Parameters:
1413
         - itemId
1414
         - inventory
1415
        """
1416
        try:
1417
            return accept_orders_for_item_id(itemId, inventory)
1418
        finally:
1419
            close_session()
1420
 
4303 rajveer 1421
 
1422
 
4369 rajveer 1423
    def markOrdersAsPORaised(self, vendorId, itemId, quantity, estimate, isReminder):
4303 rajveer 1424
        """
1425
        Parameters:
1426
         - vendorId
1427
         - itemId
1428
         - quantity
1429
         - estimate
4369 rajveer 1430
         - isReminder
4303 rajveer 1431
        """
1432
        try:
4369 rajveer 1433
            return mark_orders_as_po_raised(vendorId, itemId, quantity, estimate, isReminder)
4303 rajveer 1434
        finally:
1435
            close_session()
1436
 
4369 rajveer 1437
    def markOrdersAsReversalInitiated(self, vendorId, itemId, quantity, estimate, isReminder):
4303 rajveer 1438
        """
1439
        Parameters:
1440
         - vendorId
1441
         - itemId
1442
         - quantity
1443
         - estimate
4369 rajveer 1444
         - isReminder
4303 rajveer 1445
        """
1446
        try:
4369 rajveer 1447
            return mark_orders_as_reversal_initiated(vendorId, itemId, quantity, estimate, isReminder)
4303 rajveer 1448
        finally:
1449
            close_session()
1450
 
4369 rajveer 1451
    def markOrdersAsNotAvailabke(self, vendorId, itemId, quantity, estimate, isReminder):
4303 rajveer 1452
        """
1453
        Parameters:
1454
         - vendorId
1455
         - itemId
1456
         - quantity
1457
         - estimate
4369 rajveer 1458
         - isReminder
4303 rajveer 1459
        """
1460
        try:
4369 rajveer 1461
            return mark_orders_as_not_available(vendorId, itemId, quantity, estimate, isReminder)
4303 rajveer 1462
        finally:
1463
            close_session()
1464
 
1465
 
4369 rajveer 1466
    def markOrdersAsTimeout(self, vendorId):
1467
        """
1468
        Parameters:
1469
         - vendorId
1470
        """
1471
        try:
1472
            return mark_orders_as_timeout(vendorId)
1473
        finally:
1474
            close_session()
4386 anupam.sin 1475
 
1476
    def getOrderForAwb(self, awb):
1477
        """
1478
        Parameters:
1479
         - AirwayBill Number
1480
        """
1481
        try:
1482
            return to_t_order(get_order_for_awb(awb))
1483
        finally:
1484
            close_session()
4369 rajveer 1485
 
4910 phani.kuma 1486
    def getOrdersForProviderForStatus(self, provider_id, order_status_list):
4506 phani.kuma 1487
        """
1488
        Parameters:
1489
         - provider id
1490
         - order status
1491
        """
1492
        try:
4910 phani.kuma 1493
            orders_of_provider_by_status = get_orders_for_provider_for_status(provider_id, order_status_list)
4506 phani.kuma 1494
            return [to_t_order(order) for order in orders_of_provider_by_status if order != None]
1495
        finally:
1496
            close_session()
4600 varun.gupt 1497
 
1498
    def getBilledOrdersForVendor(self, vendorId, billingDateFrom, billingDateTo):
1499
        '''
1500
        Parameters:
1501
         - vendorId
1502
         - billingDateFrom
1503
         - billingDateTo
1504
        '''
1505
        try:
1506
            return [to_t_order(order) for order in get_billed_orders_for_vendor(vendorId, to_py_date(billingDateFrom), to_py_date(billingDateTo))]
1507
        finally:
1508
            close_session()
1509
 
4607 rajveer 1510
    def getSlippedSippingDateOrders(self):
1511
        try:
1512
            return [to_t_order(order) for order in get_slipped_sipping_date_orders()]
1513
        finally:
1514
            close_session()
1515
 
4709 rajveer 1516
    def getCancelledOrders(self, cancelDateFrom, cancelDateTo):
1517
        try:
1518
            return [to_t_order(order) for order in get_cancelled_orders(to_py_date(cancelDateFrom), to_py_date(cancelDateTo))]
1519
        finally:
1520
            close_session()
1521
 
4600 varun.gupt 1522
    def getEBSSettlementSummaries(self):
1523
        try:
1524
            return get_ebs_settlement_summaries()
1525
        finally:
1526
            close_session()
4369 rajveer 1527
 
4600 varun.gupt 1528
    def saveEBSSettlementSummary(self, settlementId, settlementDate, transactionDateFrom, transactionDateTo, amount):
1529
        try:
1530
            save_ebs_settlement_summary(settlementId, to_py_date(settlementDate), to_py_date(transactionDateFrom), to_py_date(transactionDateTo), amount)
1531
        finally:
1532
            close_session()
1533
 
5386 phani.kuma 1534
    def getSettlementForPrepaid(self, referenceId, isRefund):
4600 varun.gupt 1535
        '''
1536
        Parameters:
5189 varun.gupt 1537
         - referenceId
1538
         - isRefund
4600 varun.gupt 1539
        '''
1540
        try:
5386 phani.kuma 1541
            return to_t_payment_settlement(get_settlement_for_Prepaid(referenceId, isRefund))
4600 varun.gupt 1542
        finally:
1543
            close_session()
5386 phani.kuma 1544
 
1545
    def getSettlementForCod(self, orderId, isRefund):
1546
        '''
1547
        Parameters:
1548
         - orderId
1549
         - isRefund
1550
        '''
1551
        try:
1552
            return to_t_payment_settlement(get_settlement_for_Cod(orderId, isRefund))
1553
        finally:
1554
            close_session()
1555
 
4600 varun.gupt 1556
    def getEBSSettlementDate(self, settlementId):
1557
        try:
1558
            return to_java_date(get_ebs_settlement_date(settlementId))
1559
        finally:
1560
            close_session()
1561
 
4905 varun.gupt 1562
    def savePaymentSettlements(self, settlementDate, paymentGatewayId, referenceId, serviceTax, otherCharges, netCollection):
4600 varun.gupt 1563
        try:
4905 varun.gupt 1564
            save_payment_settlements(to_py_date(settlementDate), paymentGatewayId, referenceId, serviceTax, otherCharges, netCollection)
4600 varun.gupt 1565
        finally:
1566
            close_session()
1567
 
1568
    def markEBSSettlementUploaded(self, settlementId):
1569
        try:
1570
            mark_ebs_settlement_uploaded(settlementId)
1571
        finally:
1572
            close_session()
1573
 
4715 varun.gupt 1574
    def getSettlementsByDate(self, settlementDateFrom, settlementDateTo, isRefund):
1575
        try:
1576
            settlements = get_settlements_by_date(to_py_date(settlementDateFrom), to_py_date(settlementDateTo), isRefund)
1577
            return [to_t_payment_settlement(settlement) for settlement in settlements]
1578
        finally:
1579
            close_session()
1580
 
1581
    def getReshippedOrderIds(self, orderIds):
1582
        try:
1583
            return get_reshipped_order_ids(orderIds)
1584
        finally:
1585
            close_session()
1586
 
5481 phani.kuma 1587
    def getBilledOrders(self, vendorId, onlyVendorNotPaid, billingDateFrom, billingDateTo):
4875 varun.gupt 1588
        try:
5481 phani.kuma 1589
            from_date, to_date = get_fdate_tdate(billingDateFrom, billingDateTo)
1590
            return [to_t_order(order) for order in get_billed_orders(vendorId, onlyVendorNotPaid, from_date, to_date)]
4875 varun.gupt 1591
        finally:
1592
            close_session()
1593
 
5062 varun.gupt 1594
    def getStatusDistributionOfOrders(self, startDate, endDate):
1595
        try:
5067 varun.gupt 1596
            distribution = {}
1597
 
1598
            for status, count in get_order_distribution_by_status(to_py_date(startDate), to_py_date(endDate)):
1599
                distribution[status] = count
1600
 
1601
            return distribution
5062 varun.gupt 1602
        finally:
1603
            close_session()
1604
 
5067 varun.gupt 1605
    def getOrderIdsForStatus(self, status, startDatetime, endDatetime):
1606
        try:
1607
            orders = get_order_ids_for_status(status, to_py_date(startDatetime), to_py_date(endDatetime))
1608
            return [order.id for order in orders]
1609
        finally:
1610
            close_session()
1611
 
5099 varun.gupt 1612
    def updateOrderAsPaidToVendor(self, orderId):
1613
        try:
1614
            update_orders_as_paid_to_vendor(orderId)
1615
        finally:
1616
            close_session()
1617
 
5348 anupam.sin 1618
    def updateCODAgent(self, agentEmailId, orderId):
1619
        try:
1620
            update_COD_agent(agentEmailId, orderId)
1621
        finally:
1622
            close_session()
1623
 
5386 phani.kuma 1624
    def updateOrderOnlyAsPaidToVendor(self, orderId):
1625
        try:
1626
            update_order_only_as_paid_to_vendor(orderId)
1627
        finally:
1628
            close_session()
1629
 
5208 varun.gupt 1630
    def getRefundedOrdersMarkedPaid(self):
1631
        try:
1632
            return [to_t_order(order) for order in get_refunded_orders_marked_paid()]
1633
        finally:
1634
            close_session()
5447 anupam.sin 1635
 
1636
    def getAllVerificationAgents(self, minOrderId, maxOrderId):
1637
        try:
1638
            return [to_t_verification_agent(codAgent) for codAgent in get_all_verification_agents(minOrderId, maxOrderId)]
1639
        finally:
5527 anupam.sin 1640
            close_session()
1641
 
1642
    def getAllAttributesForOrderId(self, orderId):
1643
        try:
1644
            return [to_t_attribute(attribute) for attribute in get_all_attributes_for_order_id(orderId)]
1645
        finally:
1646
            close_session()
1647
 
1648
    def setOrderAttributeForTransaction(self, transactionId, attribute):
1649
        try:
1650
            set_order_attribute_for_transaction(transactionId, attribute)                    
1651
        finally:
1652
            close_session()
5593 mandeep.dh 1653
 
1654
    def acceptOrderForItem(self, itemId, quantity, fulfilmentWarehouseId, billingWarehouseId):
1655
        """
1656
        Accepts appropriate order for an item in a given billingWarehouse. Usually
1657
        invoked while scanning IN of items.
1658
 
1659
        Parameters:
1660
         - itemId
1661
         - quantity
1662
         - fulfilmentWarehouseId
1663
         - billingWarehouseId
1664
        """
1665
        try:
1666
            accept_order_for_item(itemId, quantity, fulfilmentWarehouseId, billingWarehouseId)
1667
        finally:
1668
            close_session()
1669
 
5833 rajveer 1670
    def getOrderAttributeValue(self, orderId, attributeName):
1671
        """
1672
        Parameters:
1673
         - orderId
1674
         - attributeName
1675
        """
1676
        try:
6019 rajveer 1677
            return get_order_attribute_value(orderId, attributeName)
5833 rajveer 1678
        finally:
1679
            close_session()
1680
 
6019 rajveer 1681
    def changeJacketNumber(self, orderId, jacketNumber):
1682
        """
1683
        Parameters:
1684
         - orderId
1685
         - jacketNumber
1686
        """
1687
        try:
1688
            return change_jacket_number(orderId, jacketNumber)
1689
        finally:
1690
            close_session()
1691
 
1692
    def markOrderAsRtoInTransit(self, orderId):
1693
        """
1694
        Parameters:
1695
         - orderId
1696
        """
1697
        try:
1698
            return mark_order_as_rto_in_transit(orderId)
1699
        finally:
1700
            close_session()        
1701
 
6000 mandeep.dh 1702
    def createRechargeOrder(self, thriftRechargeOrder):
1703
        """
1704
        Parameters:
1705
         - thriftRechargeOrder
1706
        """
6031 rajveer 1707
        try:
1708
            if thriftRechargeOrder is None or thriftRechargeOrder.rechargeType is None:
1709
                raise TransactionServiceException(102, 'Order or the type is Null')
1710
 
1711
            rechargeOrder = None
1712
            if thriftRechargeOrder.rechargeType == RechargeType.MOBILE:
1713
                rechargeOrder = MobileRechargeOrder()
1714
            elif thriftRechargeOrder.rechargeType == RechargeType.DTH:
1715
                rechargeOrder = DTHRechargeOrder()
1716
 
1717
            if rechargeOrder is None:
1718
                raise TransactionServiceException(102, 'Unsupported recharge type')
6000 mandeep.dh 1719
 
6031 rajveer 1720
            transaction = DigitalTransaction()
1721
            transaction.createdOn = datetime.datetime.now()
6056 amit.gupta 1722
            transaction.userId = thriftRechargeOrder.userId
6031 rajveer 1723
            transaction.orders = [rechargeOrder]
1724
 
6000 mandeep.dh 1725
            rechargeOrder.from_thrift_object(thriftRechargeOrder)
1726
            session.commit()
6031 rajveer 1727
            return rechargeOrder.to_thrift_object()
6000 mandeep.dh 1728
        except:
1729
            raise TransactionServiceException(103, 'Invalid values passed')
1730
        finally:
1731
            self.closeSession()
1732
 
6031 rajveer 1733
    def getRechargeOrder(self, rechargeOrderId):
1734
        """
1735
        Parameters:
1736
         - rechargeOrderId
1737
        """
1738
        try:
6048 rajveer 1739
            return get_recharge_order(rechargeOrderId).to_thrift_object()
6031 rajveer 1740
        finally:
1741
            self.closeSession()
1742
 
1743
    def getRechargeOrders(self, userId):
1744
        """
1745
        Parameters:
1746
         - userId
1747
        """
1748
        try:
1749
            return [order.to_thrift_object() for order in get_recharge_orders(userId)]
1750
        finally:
1751
            self.closeSession()
1752
 
6000 mandeep.dh 1753
    def updateRechargeOrderStatus(self, rechargeOrderId, rechargeOrderStatus):
1754
        """
1755
        Parameters:
1756
         - rechargeOrderId
1757
         - rechargeOrderStatus
1758
        """
6031 rajveer 1759
        try:
1760
            return update_recharge_order_status(rechargeOrderId, rechargeOrderStatus)
1761
        finally:
1762
            self.closeSession()
1763
 
1764
    def activateRechargeTxn(self, rechargeOrderId):
6000 mandeep.dh 1765
        """
1766
        Parameters:
6031 rajveer 1767
         - rechargeOrderId
6000 mandeep.dh 1768
        """
6031 rajveer 1769
        try:
1770
            return True
1771
            activate_recharge_txn(rechargeOrderId)
1772
        finally:
1773
            self.closeSession()
6000 mandeep.dh 1774
 
6031 rajveer 1775
    def getUserWallet(self, userId):
6000 mandeep.dh 1776
        """
1777
        Parameters:
6031 rajveer 1778
         - userId
6000 mandeep.dh 1779
        """
6031 rajveer 1780
        try:
1781
            return get_user_wallet(userId).to_thrift_object()
1782
        finally:
1783
            self.closeSession()
6000 mandeep.dh 1784
 
6031 rajveer 1785
    def getUserWalletHistory(self, userId):
6000 mandeep.dh 1786
        """
1787
        Parameters:
6031 rajveer 1788
         - userId
6000 mandeep.dh 1789
        """
6031 rajveer 1790
        try:
1791
            return [wallet.to_thrift_object() for wallet in get_user_wallet_history(userId)]
1792
        finally:
1793
            self.closeSession()
6000 mandeep.dh 1794
 
6206 rajveer 1795
    def getServiceProviders(self, rechargeType, onlyActive):
6048 rajveer 1796
        """
1797
        Parameters:
1798
         - rechargeType
6206 rajveer 1799
         - onlyActive
6048 rajveer 1800
        """
6077 anupam.sin 1801
 
6048 rajveer 1802
        try:
6206 rajveer 1803
            return get_service_providers(rechargeType, onlyActive)
6048 rajveer 1804
        finally:
1805
            self.closeSession()
1806
 
6049 rajveer 1807
    def getServiceProviderForDevice(self, rechargeType, deviceNumber):
6048 rajveer 1808
        """
1809
        Parameters:
1810
         - deviceNumber
1811
        """
1812
        try:
6049 rajveer 1813
            return get_service_provider_for_device(rechargeType, deviceNumber)
6048 rajveer 1814
        finally:
1815
            self.closeSession()
6056 amit.gupta 1816
 
6591 anupam.sin 1817
    def validateRecharge(self, rechargeType, deviceNumber, userSelectedProviderId, clientAddress):
6269 rajveer 1818
        """
1819
        Parameters:
1820
         - deviceNumber
1821
        """
1822
        try:
6591 anupam.sin 1823
            return validate_recharge(rechargeType, deviceNumber, userSelectedProviderId, clientAddress)
6269 rajveer 1824
        finally:
1825
            self.closeSession()
1826
 
6056 amit.gupta 1827
    def getRechargeOrdersForTransaction(self, txId):
1828
        """
1829
        Parameters:
1830
         - transactionId
1831
        """
1832
        try:
1833
            return get_recharge_orders_for_transaction(txId).to_thrift_object()
1834
        finally:
1835
            self.closeSession()
6048 rajveer 1836
 
6094 rajveer 1837
    def getRechargeOrdersForDevice(self, deviceNumber):
1838
        """
1839
        Parameters:
1840
        - deviceNumber
1841
        """
1842
        try:
1843
            return [order.to_thrift_object() for order in get_recharge_orders_for_device(deviceNumber)]
1844
        finally:
1845
            self.closeSession()
1846
 
6154 rajveer 1847
    def getRechargeOrdersForStatus(self, status):
1848
        """
1849
        Parameters:
1850
        - status
1851
        """
1852
        try:
1853
            return [order.to_thrift_object() for order in get_recharge_orders_for_status(status)]
1854
        finally:
1855
            self.closeSession()
1856
 
6159 rajveer 1857
    def getPlansForOperator(self, operatorId):
1858
        """
1859
        Parameters:
1860
        - operatorId
1861
        """
1862
        try:
1863
            return [plan.to_thrift_object() for plan in get_plans_for_operator(operatorId)]
1864
        finally:
1865
            self.closeSession()
1866
 
1867
 
6094 rajveer 1868
    def addAmountToWallet(self, userId, orderId, amount):
1869
        """
1870
        Parameters:
1871
        - userId
1872
        - orderId
1873
        - amount
1874
        """
1875
        try:
8729 anupam.sin 1876
            update_amount_in_wallet(userId, amount, orderId, 0)
6094 rajveer 1877
        finally:
1878
            self.closeSession()
1879
 
6188 rajveer 1880
    def getRechargeStatistics(self):
1881
        """
1882
        Parameters:
1883
        """
1884
        try:
1885
            return get_recharge_statistics()
1886
        finally:
1887
            self.closeSession()
1888
 
6307 anupam.sin 1889
    def getRechargeDenominations(self, operatorId, circleCode, denominationType):
6289 anupam.sin 1890
        try:
1891
            returnList = []
6307 anupam.sin 1892
            rechargeDenominations = get_recharge_denominations(operatorId, circleCode, denominationType)
6289 anupam.sin 1893
            for rechargeDenomination in rechargeDenominations:
1894
                returnList.append(rechargeDenomination.to_thrift_object())
1895
            return returnList
1896
        finally:
1897
            self.closeSession() 
6188 rajveer 1898
 
6371 rajveer 1899
    def updateAvailabilityStatus(self, operatorId, circleId, isAvailable):
1900
        try:
1901
            update_availability_status(operatorId, circleId, isAvailable)
1902
        finally:
1903
            self.closeSession() 
1904
 
6396 amit.gupta 1905
    def getAvailableEmiSchemes(self):
1906
        try:
1907
            return get_available_emi_schemes()
1908
        finally:
1909
            self.closeSession()
1910
 
6389 rajveer 1911
    def getMiscCharges(self, transactionId):
1912
        try:
1913
            return get_misc_charges(transactionId)
1914
        finally:
1915
            self.closeSession()
1916
 
6507 anupam.sin 1917
    def refundRechargeOrder (self, rechargeOrderId):
1918
        try:
1919
            return refund_recharge_order(rechargeOrderId)
1920
        finally:
1921
            self.closeSession()
6821 amar.kumar 1922
 
1923
    def getPhysicalOrders(self, start_date, end_date):
1924
        try:
6832 amar.kumar 1925
            return [to_t_order(order) for order in get_physical_orders(to_py_date(start_date), to_py_date(end_date))]
6821 amar.kumar 1926
        finally:
1927
            self.closeSession()
6507 anupam.sin 1928
 
6906 rajveer 1929
    def getDocument(self, docType, docSource):
1930
        try:
1931
            return get_document(docType, docSource)
1932
        finally:
1933
            self.closeSession()
6988 rajveer 1934
 
7075 rajveer 1935
    def retrieveInvoice(self, orderId, userId):
6988 rajveer 1936
        try:
7075 rajveer 1937
            return retrieve_invoice(orderId,userId)
6988 rajveer 1938
        finally:
1939
            self.closeSession()
6906 rajveer 1940
 
7027 rajveer 1941
    def receiveUpdatesForRedExpress(self, awbNumber):
1942
        try:
7032 rajveer 1943
            return RedExpressUpdateService.get_updates_for_user(awbNumber)
7027 rajveer 1944
        finally:
1945
            self.closeSession()
1946
 
6985 anupam.sin 1947
    def changeShippingAddress(self, orderId, line1, line2, city, state, pin):
1948
        try:
1949
            return change_shipping_address(orderId, line1, line2, city, state, pin)
1950
        finally:
1951
            self.closeSession()
1952
 
7073 anupam.sin 1953
    def createRechargeTransaction(self, t_rechargeTransaction):
1954
        try:
1955
            return to_t_rechargeTransaction(create_recharge_transaction(t_rechargeTransaction))
1956
        finally:
1957
            self.closeSession()
7084 rajveer 1958
 
1959
    def getRechargeTransactions(self, storeId):
1960
        try:
1961
            return [to_t_rechargeTransaction(txn) for txn in get_recharge_transactions(storeId)]
1962
        finally:
1963
            self.closeSession()
1964
 
7151 amit.gupta 1965
    def getRechargeTrans(self, storeId, startdate, enddate, status):
1966
        try:
1967
            return [to_t_rechargeTransaction(txn) for txn in get_recharge_trans(storeId,startdate, enddate, status)]
1968
        finally:
1969
            self.closeSession()
7084 rajveer 1970
 
7080 anupam.sin 1971
    def getRechargeTransaction(self, rechargeId):
1972
        try:
1973
            return to_t_rechargeTransaction(get_recharge_transaction(rechargeId))
1974
        finally:
1975
            self.closeSession()
1976
 
1977
    def getFRCs(self, circleId, operatorId):
1978
        try:
1979
            return [to_t_frc(frc) for frc in get_frcs(circleId, operatorId)]
1980
        finally:
1981
            self.closeSession()
1982
 
7096 anupam.sin 1983
    def getHotspotStore(self, id, hotspotid):
1984
        try:
1985
            return to_t_hotspot(get_hotspot_store(id, hotspotid))
1986
        finally:
1987
            self.closeSession()
1988
 
1989
    def getTelecomCircle(self, id, code):
1990
        try:
1991
            return get_circle(id, code).to_thrift_object()
1992
        finally:
1993
            self.closeSession()
1994
 
7109 anupam.sin 1995
    def retrieveHotspotRechargeInvoice(self, rechargeId):
1996
        try:
1997
            return retrieve_hotspot_recharge_invoice(rechargeId)
1998
        finally:
1999
            self.closeSession()
7190 amar.kumar 2000
 
2001
    def splitFreebieOrder(self, orderId, splitReason, shippingDate):
2002
        try:
2003
            return split_freebie_order(orderId, splitReason, shippingDate)
2004
        finally:
2005
            self.closeSession()
7109 anupam.sin 2006
 
7172 anupam.sin 2007
    def getRechargeTransactionsByNumber(self, number, storeId):
7169 anupam.sin 2008
        try:
7172 anupam.sin 2009
            return [to_t_rechargeTransaction(txn) for txn in get_recharge_transactions_by_number(number, storeId)]
7169 anupam.sin 2010
        finally:
2011
            self.closeSession()
2012
 
2013
    def updateHotspotStorePassword(self, storeId, password):
2014
        try:
2015
            return update_hotspot_store_password(storeId, password)
2016
        finally:
2017
            self.closeSession()
2018
 
7263 anupam.sin 2019
    def getSourceDetail(self, source):
2020
        try:
2021
            return to_t_sourcedetail(get_source_detail(source))
2022
        finally:
2023
            self.closeSession()
2024
 
7267 anupam.sin 2025
    def getAllCircles(self):
2026
        try:
2027
            return [circle.to_thrift_object() for circle in get_all_circles()]
2028
        finally:
2029
            self.closeSession()
7263 anupam.sin 2030
 
7267 anupam.sin 2031
    def deleteFrcs(self, frcIdsToDelete):
2032
        try:
2033
            return delete_frcs(frcIdsToDelete)
2034
        finally:
2035
            self.closeSession()
7285 rajveer 2036
 
2037
    def topupCompanyWallet(self, companyId, amount):
2038
        try:
2039
            return topup_company_wallet(companyId, amount)
2040
        finally:
2041
            self.closeSession()
2042
 
2043
    def getWalletBalanceForCompany(self, companyId):
2044
        try:
2045
            return get_wallet_balance_for_company(companyId)
2046
        finally:
2047
            self.closeSession()
7311 kshitij.so 2048
 
2049
    def addAmazonOrder(self,amazonOrder):
2050
        try:
2051
            add_amazon_order(amazonOrder)
2052
        except:
2053
            self.closeSession()
2054
 
7322 vikram.rag 2055
    def updateAmazonOrderStatus(self,orderId,status):
7311 kshitij.so 2056
        try:
7577 rajveer 2057
            return update_amazon_order_status(orderId,status)
7311 kshitij.so 2058
        finally:
2059
            self.closeSession()
7322 vikram.rag 2060
 
7683 vikram.rag 2061
    def getAmazonOrdersShipped(self):
7311 kshitij.so 2062
        try:
7683 vikram.rag 2063
            ordersShipped = get_amazon_orders_shipped()
7311 kshitij.so 2064
        finally:
2065
            self.closeSession()
2066
            return ordersShipped
2067
 
2068
    def getAmazonOrdersCancelled(self,interval):
2069
        ordersCancelled=None
2070
        try:
2071
            ordersCancelled = get_amazon_orders_cancelled(interval)
2072
        except:
2073
            ordersCancelled=None
2074
        finally:
2075
            self.closeSession()
2076
            return ordersCancelled
2077
 
7322 vikram.rag 2078
    def getAmazonOrder(self,orderId):
2079
        result = None
2080
        try:
7343 anupam.sin 2081
            result = to_t_amazonorder(get_amazon_order(orderId))
7322 vikram.rag 2082
        finally:
2083
            self.closeSession()
7542 vikram.rag 2084
            return result
2085
 
2086
    def getAmazonOrderByAmazonOrderId(self,amazonOrderId):
2087
        result = []
2088
        try:
2089
            for amazonOrder in get_amazon_order_by_amazonorderid(amazonOrderId): 
2090
                result.append(to_t_amazonorder(amazonOrder))
2091
        except:
2092
            return None
2093
        finally:
2094
            self.closeSession()
2095
            return result
7343 anupam.sin 2096
 
2097
    def getOrdersForStore(self, id, storeId, startDate, endDate, statuses):
2098
        try:
2099
            return [to_t_order(order) for order in get_orders_for_store(id, storeId, to_py_date(startDate), to_py_date(endDate), statuses)]
2100
        finally:
2101
            self.closeSession()
2102
 
7386 anupam.sin 2103
    def getStoreOrderAdvanceInvoice(self, orderId, storeId):
7343 anupam.sin 2104
        try:
7386 anupam.sin 2105
            return get_store_order_advance_invoice(orderId, storeId)
7343 anupam.sin 2106
        finally:
2107
            self.closeSession()
7363 rajveer 2108
 
2109
    def getSaholicRechargeBalance(self):
2110
        try:
2111
            return RechargeService.getBalance()
2112
        finally:
2113
            self.closeSession()
2114
 
7370 anupam.sin 2115
    def addFrc(self, circle, operatorId, denomination, maxDiscount):
2116
        try:
2117
            return add_frc(circle, operatorId, denomination, maxDiscount)
2118
        except:
2119
            return False
2120
        finally:
2121
            self.closeSession()
2122
 
7371 anupam.sin 2123
    def addSeries(self, circle, operatorId, series):
2124
        try:
2125
            return add_series(circle, operatorId, series)
2126
        except:
2127
            return "Error Occured. Try Again."
2128
        finally:
2129
            self.closeSession()
2130
 
7386 anupam.sin 2131
    def saveStoreOrderDetail(self, storeOrderDetail):
2132
        try:
2133
            return save_store_order_detail(storeOrderDetail)
2134
        except:
2135
            return False
2136
        finally:
2137
            self.closeSession()
2138
 
2139
 
2140
    def getStoreOrderDetail(self, orderId, storeId):
2141
        try:
2142
            return to_t_storeOrderDetail(get_store_order_detail(orderId, storeId))
2143
        finally:
2144
            self.closeSession()
2145
 
2146
    def getAllEdcBanks(self):
2147
        try:
2148
            return get_all_edc_banks()
2149
        finally:
2150
            self.closeSession()
7393 anupam.sin 2151
 
2152
    def saveRefundAmountsForStoreOrder(self, orderId, storeId, cashRefundAmount, cardRefundAmount):
2153
        try:
7399 anupam.sin 2154
            return save_refund_amounts_for_store_order(orderId, storeId, cashRefundAmount, cardRefundAmount)
7393 anupam.sin 2155
        finally:
2156
            self.closeSession()
7386 anupam.sin 2157
 
7427 anupam.sin 2158
    def getCollectionsForStore(self, storeId, startDate, endDate):
2159
        try:
2160
            return [to_t_storeOrderCollection(collection) for collection in get_collections_for_store(storeId, startDate, endDate)]
2161
        finally:
2162
            self.closeSession()
7442 vikram.rag 2163
 
2164
    def getAmazonOrdersToAcknowledge(self):
2165
        try:
2166
            ordersack = []
2167
            for amazonOrderId,amazonOrderCode,status,txnid,count in get_amazon_orders_to_acknowledge():
2168
                orderack = AmazonOrdersToAcknowledge()
2169
                orderack.amazonOrderId = amazonOrderId
2170
                orderack.amazonOrderItemId = amazonOrderCode
2171
                orderack.status = status
2172
                orderack.transaction_id = txnid
2173
                orderack.count = count
2174
                ordersack.append(orderack)
2175
            return ordersack    
2176
        except:
2177
            return None
2178
        finally:
2179
            self.closeSession()   
2180
 
2181
    def changeAmazonOrderStatus(self,amazonOrderCode,status):
2182
        try:
2183
            change_amazon_order_status(amazonOrderCode,status) 
2184
        finally:
7460 kshitij.so 2185
            self.closeSession()
2186
 
7741 kshitij.so 2187
    def updateTimestampForAmazonOrder(self,orderDeliveryMap):
7460 kshitij.so 2188
        try:
7741 kshitij.so 2189
            return update_timestamp_for_amazon_order(orderDeliveryMap)
7530 kshitij.so 2190
        except:
2191
            return False
7460 kshitij.so 2192
        finally:
7530 kshitij.so 2193
            self.closeSession()
2194
 
2195
    def updateSourceDetailTimestamp(self,id,lastUpdatedOn):
2196
        try:
2197
            return update_source_detail_timestamp(id,lastUpdatedOn)
2198
        except:
2199
            return False
2200
        finally:
7442 vikram.rag 2201
            self.closeSession()   
7607 anupam.sin 2202
 
2203
    def getOrdersByMobileNumber(self, mobileNumber):
2204
        try:
2205
            orders = get_orders_by_mobile_number(mobileNumber)
2206
            return [to_t_order(order) for order in orders]
2207
        finally:
2208
            self.closeSession()
7427 anupam.sin 2209
 
7645 anupam.sin 2210
    def getOrdersByAmazonOrderCode(self, amazonId):
7607 anupam.sin 2211
        try:
2212
            orders = get_orders_by_amazon_id(amazonId)
2213
            return [to_t_order(order) for order in orders]
2214
        finally:
2215
            self.closeSession()
7730 anupam.sin 2216
 
2217
    def convertStoreToNormal(self, orderId):
2218
        try:
2219
            return convert_store_to_normal(orderId)
2220
        except:
2221
            return False
2222
        finally:
2223
            self.closeSession()
7822 amar.kumar 2224
 
2225
    def updateFreebieItem(self, orderId, newFreebieItemId):
2226
        try:
2227
            return to_t_order(update_freebie_item(orderId, newFreebieItemId))
2228
        finally:
2229
            self.closeSession()
7938 manish.sha 2230
 
7967 anupam.sin 2231
    def getHotspotServiceMatrices(self):
2232
        try:
2233
            return [to_t_hotspotServiceMatrix(hotpotServiceMatrix) for hotpotServiceMatrix in get_hotspot_service_matrices()]
2234
        finally:
2235
            self.closeSession()
2236
 
7938 manish.sha 2237
    def updateOrderAWB(self, orderId, airwayBillNo):
2238
        try:
7985 manish.sha 2239
            return to_t_order(update_order_AWB(orderId, airwayBillNo))
7938 manish.sha 2240
        finally:
2241
            close_session()
8182 amar.kumar 2242
    def getOrdersByVendor(self, vendors, statuses):
2243
        try:
2244
            return [to_t_order(order) for order in get_orders_by_vendor(vendors, statuses)]
2245
        finally:
2246
            close_session()
7607 anupam.sin 2247
 
8182 amar.kumar 2248
    def createEbayOrder(self, ebayOrder):
2249
        try:
2250
            create_ebay_order(ebayOrder)
2251
        finally:
2252
            close_session()
2253
    def getEbayOrderByOrderId(self, orderId):
2254
        try:
2255
            return to_t_ebayOrder(get_ebay_order_by_orderId(orderId))
2256
        finally:
2257
            close_session()
2258
 
2259
    def getEbayOrderBySalesRecNumber(self, salesRecordNumber):
2260
        try:
2261
            return to_t_ebayOrder(get_ebay_order_by_sales_rec_number(salesRecordNumber))
2262
        finally:
2263
            close_session()
2264
 
8241 amar.kumar 2265
    def getEbayOrder(self, salesRecordNumber, listingId, paisaPayId):
8182 amar.kumar 2266
        try:
8253 amar.kumar 2267
            return [to_t_ebayOrder(order) for order in get_ebay_order(salesRecordNumber, listingId, paisaPayId)]
8182 amar.kumar 2268
        finally:
2269
            close_session()
2270
 
2271
    def updateEbayOrder(self, ebayOrder):
2272
        try:
2273
            update_ebay_order(ebayOrder)
2274
        finally:
2275
            close_session()
2276
 
2277
    def ebayOrderExists(self, salesRecNumber, ebayListingId):
2278
        try:
2279
            return ebay_order_exists(salesRecNumber, ebayListingId)
2280
        finally:
2281
            close_session()
2282
 
2283
    def updateOrderForEbay(self, order):
2284
        try:
2285
            update_order_for_ebay(order)
2286
        finally:
2287
            close_session()
2288
 
2289
    def splitEbayOrder(self, orderId, splitOrderQty, splitOrderItemId, usePowerShip):
2290
        try:
2291
            return to_t_order(split_ebay_order(orderId, splitOrderQty, splitOrderItemId, usePowerShip))
2292
        finally:
2293
            close_session()
8282 kshitij.so 2294
 
2295
    def addOrUpdateAmazonFbaSalesSnapshot(self,amazonfbasalessnapshot):
2296
        try:
2297
            add_or_update_amazon_fba_sales_snapshot(amazonfbasalessnapshot)
2298
        finally:
2299
            close_session()
2300
 
2301
    def getAmazonFbaSalesSnapshotForDays(self,days):
2302
        fbasalessnapshot = []
2303
        try:
2304
            snapshots = get_amazon_fba_sales_snapshot_for_days(days)
2305
            for snapshot in snapshots:
2306
                fbasalessnapshot.append(to_t_amazonFbaSalesSnapshot(snapshot)) 
2307
            return fbasalessnapshot
2308
        except:
2309
            return None
2310
        finally:
2311
            close_session()
2312
 
2313
    def getAmazonFbaSalesLatestSnapshotForItem(self,item_id):
2314
        try:
8363 vikram.rag 2315
            return to_t_amazonFbaSalesSnapshot(get_amazon_fba_sales_latest_snapshot_for_item(item_id))
8282 kshitij.so 2316
        except:
2317
            return None
2318
        finally:
2319
            close_session()
8532 vikram.rag 2320
 
8488 amar.kumar 2321
    def createSnapdealOrder(self, snapdeal_order):
2322
        try:
2323
            create_snapdeal_order(snapdeal_order)
2324
        finally:
2325
            close_session()
2326
 
2327
    def getSnapdealOrder(self, orderId, reference_code, suborder_id):
2328
        try:
8543 amar.kumar 2329
            return to_t_snapdealOrder(get_snapdeal_order(orderId, reference_code, suborder_id))
8488 amar.kumar 2330
        finally:
2331
            close_session()
2332
 
8802 amar.kumar 2333
    def snapdealOrderExists(self, suborder_id, referenceCode):
8488 amar.kumar 2334
        try:
8802 amar.kumar 2335
            return snapdeal_order_exists(suborder_id, referenceCode)
8488 amar.kumar 2336
        finally:
2337
            close_session()   
8532 vikram.rag 2338
 
2339
    def updateLatestFbaPricesForItem(self,fbaitemprices):
2340
        try:        
2341
            update_latest_fba_prices_for_item(fbaitemprices)
2342
        finally:
8961 vikram.rag 2343
            close_session()
2344
 
2345
    def flipkartOrderExists(self,flipkartOrderId,flipkartSubOrderId):
2346
        try:
2347
            return flipkart_order_exists(flipkartOrderId,flipkartSubOrderId)
2348
        finally:
2349
            self.closeSession()
8532 vikram.rag 2350
 
8961 vikram.rag 2351
    def createFlipkartOrder(self,flipkartOrder):
2352
        try:
2353
            create_flipkart_order(flipkartOrder)
2354
        finally:           
8990 vikram.rag 2355
            self.closeSession()
2356
 
2357
    def getFlipkartOrder(self,orderId):
2358
        try:
2359
            return to_t_flipkartOrder(get_flipkart_order(orderId))
2360
        finally:
9159 amar.kumar 2361
            self.closeSession()    
2362
 
2363
    def getFlipkartOrderByOrderItemId(self, flipkartOrderItemId):
2364
        try:
2365
            return to_t_flipkartOrder(get_flipkart_order_by_subOrderId(flipkartOrderItemId))
2366
        finally:
2367
            close_session()    
9107 vikram.rag 2368
            self.closeSession()
2369
 
2370
    def updateFlipkartOrderDatesAndAWB(self,flipkartOrderId,flipkartSubOrderId,date,awb):
2371
        try:
2372
            return update_flipkart_order_dates_and_awb(flipkartOrderId,flipkartSubOrderId,date,awb)
2373
        finally:
2374
            self.closeSession()
9338 manish.sha 2375
 
9571 vikram.rag 2376
    def getOrdersCreatedAfterTimestampForSource(self,timestamp,source):
9404 vikram.rag 2377
        try:
9571 vikram.rag 2378
            return get_orders_count_created_after_timestamp_for_source(timestamp,source)
9404 vikram.rag 2379
        finally:
2380
            self.closeSession()
2381
 
2382
 
9338 manish.sha 2383
    def getOrderForAirwayBillNo(self, airwaybillNo):
2384
        try:
2385
            return to_t_order(get_order_for_airwayBillNo(airwaybillNo))
2386
        finally:
2387
            close_session()
2388
 
9651 manish.sha 2389
    def getMinCreatedTimeStampUndeliveredOrdersForSource(self, source): 
2390
        try:
2391
            return get_min_created_timestamp_undelivered_orders_for_source(source)
2392
        finally:
2393
            close_session()
2394
 
9882 manish.sha 2395
    def updateSnapdealOrdersStatus(self, orders):
9651 manish.sha 2396
        try:
9882 manish.sha 2397
            update_snapdeal_orders_status(orders)
9651 manish.sha 2398
        finally:
2399
            close_session()
2400
 
2401
    def updateFlipkartOrdersStatus(self, delivered_orders):
2402
        try:
2403
            update_flipkart_orders_status(delivered_orders)
2404
        finally:
2405
            close_session()
9801 manish.sha 2406
 
2407
    def bulkAddOrUpdateAmazonFbaSalesSnapshot(self, amazonfbasalessnapshotlist):  
2408
        try:
2409
            bulk_add_or_update_amazon_fba_sales_snapshot(amazonfbasalessnapshotlist)
2410
        finally:
9945 vikram.rag 2411
            close_session()
2412
 
2413
    def getCreatedOrdersForFlipkart(self,flipkartorderids):
2414
        try:
2415
            return get_created_orders_for_flipkart(flipkartorderids)
2416
        finally:
2417
            close_session()    
9651 manish.sha 2418
 
2536 chandransh 2419
    def closeSession(self, ):
2420
        close_session()
3376 rajveer 2421
 
2422
    def isAlive(self, ):
2423
        """
5447 anupam.sin 2424
        For checking whether service is alive or not. It also checks connectivity with database
3376 rajveer 2425
        """
2426
        try:
2427
            return is_alive()
2428
        finally:
6988 rajveer 2429
            close_session()