Subversion Repositories SmartDukaan

Rev

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