Subversion Repositories SmartDukaan

Rev

Rev 2764 | Rev 2819 | 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
'''
6
from shop2020.model.v1.order.impl import DataService
7
from shop2020.model.v1.order.impl.DataAccessors import create_transaction,\
1382 varun.gupt 8
    create_order, get_new_transaction, get_transactions_for_customer, get_transaction_status,\
9
    get_line_items_for_order, get_transaction, get_transactions_for_shopping_cart_id,\
10
    change_transaction_status, get_orders_for_customer,get_orders_for_transaction, get_order,\
11
    get_returnable_orders_for_customer, get_cancellable_orders_for_customer, get_orders_by_billing_date,\
12
    get_all_orders, change_order_status, get_alerts, set_alert, add_billing_details,\
13
    mark_orders_as_manifested, close_session, accept_order, bill_order, mark_orders_as_picked_up,\
1208 chandransh 14
    mark_orders_as_delivered, mark_orders_as_failed, add_jacket_number,\
1405 ankur.sing 15
    order_outofstock, batch_orders, update_non_delivery_reason, enqueue_transaction_info_email,\
1627 ankur.sing 16
    get_undelivered_orders, get_order_for_customer, get_valid_order_count,\
1886 ankur.sing 17
    get_cust_count_with_successful_txn, get_valid_orders_amount_range,\
2591 chandransh 18
    get_valid_orders, toggle_doa_flag, request_pickup_number, authorize_pickup,\
2697 chandransh 19
    receive_return, validate_doa, reship_order, refund_order, get_return_orders,\
2764 chandransh 20
    process_return, get_return_order, mark_doas_as_picked_up
1405 ankur.sing 21
 
104 ashish 22
from shop2020.model.v1.order.impl.Convertors import to_t_transaction,\
1348 chandransh 23
    to_t_alert, to_t_order, to_t_lineitem
483 rajveer 24
from shop2020.thriftpy.model.v1.order.ttypes import Transaction, OrderStatus,\
2783 chandransh 25
    LineItem, Order, TransactionServiceException
738 chandransh 26
from shop2020.utils.Utils import to_py_date, get_fdate_tdate
104 ashish 27
 
28
class OrderServiceHandler:
29
 
1249 chandransh 30
    def __init__(self, dbname='transaction'):
483 rajveer 31
        """
104 ashish 32
        Constructor
483 rajveer 33
        """
1249 chandransh 34
        DataService.initialize(dbname)
104 ashish 35
 
36
    def createTransaction(self, transaction):
37
        """
38
        Parameters:
39
         - transaction
40
        """
766 rajveer 41
        try:
42
            return create_transaction(transaction)
43
        finally:
44
            close_session()
45
 
104 ashish 46
    def getTransaction(self, id):
47
        """
48
            Get transaction methods.
49
 
50
        Parameters:
51
         - id
52
        """
766 rajveer 53
        try:
54
            transaction = get_transaction(id)
55
            return to_t_transaction(transaction)
56
        finally:
57
            close_session()
58
 
483 rajveer 59
    def getTransactionsForCustomer(self, customerId, from_date, to_date, status):
104 ashish 60
        """
61
        Parameters:
483 rajveer 62
         - customerId
104 ashish 63
         - from_date
64
         - to_date
483 rajveer 65
         - status
104 ashish 66
        """
766 rajveer 67
        try:
68
            current_from_date, current_to_date = get_fdate_tdate(from_date, to_date)
69
 
70
            transactions = get_transactions_for_customer(customerId, current_from_date, current_to_date, status)
71
            t_transaction = []
72
            for transaction in transactions:
73
                t_transaction.append(to_t_transaction(transaction))
74
            return t_transaction
75
        finally:
76
            close_session()
483 rajveer 77
 
78
    def getTransactionsForShoppingCartId(self, shoppingCartId):
79
        """
80
        Parameters:
81
            - shoppingCartId
82
        """
766 rajveer 83
        try:
84
            transactions = get_transactions_for_shopping_cart_id(shoppingCartId)
85
            t_transaction = []
86
            for transaction in transactions:
87
                t_transaction.append(to_t_transaction(transaction))
88
            return t_transaction
89
        finally:
90
            close_session()
104 ashish 91
 
483 rajveer 92
    def getTransactionStatus(self, transactionId):
104 ashish 93
        """
94
        Parameters:
483 rajveer 95
         - transactionId
96
        """
766 rajveer 97
        try:
98
            return get_transaction_status(transactionId)
99
        finally:
100
            close_session()
101
 
483 rajveer 102
    def changeTransactionStatus(self, transactionId, status, description):
103
        """
104
        Parameters:
105
         - transactionId
104 ashish 106
         - status
483 rajveer 107
         - description
108
        """
766 rajveer 109
        try:
110
            return change_transaction_status(transactionId, status, description)
111
        finally:
112
            close_session()
113
 
1528 ankur.sing 114
    def getOrdersForTransaction(self, transactionId, customerId):
483 rajveer 115
        """
1528 ankur.sing 116
        Returns list of orders for given transaction Id. Also filters based on customer Id so that
117
        only user who owns the transaction can view its order details.
118
 
483 rajveer 119
        Parameters:
120
         - transactionId
1528 ankur.sing 121
         - customerId
483 rajveer 122
        """
766 rajveer 123
        try:
1528 ankur.sing 124
            orders = get_orders_for_transaction(transactionId, customerId)
766 rajveer 125
            return [to_t_order(order) for order in orders]    
126
        finally:
127
            close_session()
128
 
483 rajveer 129
    def getAllOrders(self, status, from_date, to_date, warehouse_id):
130
        """
131
        Parameters:
132
         - status
104 ashish 133
         - from_date
134
         - to_date
483 rajveer 135
         - warehouse_id
104 ashish 136
        """
766 rajveer 137
        try:
138
            current_from_date, current_to_date = get_fdate_tdate(from_date, to_date)        
139
            orders = get_all_orders(status, current_from_date, current_to_date, warehouse_id)
140
            return [to_t_order(order) for order in orders]
141
        finally:
142
            close_session()
143
 
995 varun.gupt 144
    def getOrdersByBillingDate(self, status, start_billing_date, end_billing_date, warehouse_id):
145
        """
146
        Parameters:
147
         - status
148
         - start_billing_date
149
         - end_billing_date
150
         - warehouse_id
151
        """
152
        try:
153
            current_start_billing_date, current_end_billing_date = get_fdate_tdate(start_billing_date, end_billing_date)
154
            orders = get_orders_by_billing_date(status, current_start_billing_date, current_end_billing_date, warehouse_id)
155
            return [to_t_order(order) for order in orders]
156
        finally:
157
            close_session()
1382 varun.gupt 158
 
159
    def getReturnableOrdersForCustomer(self, customerId, limit = None):
160
        """
161
        Parameters:
162
         - customerId
163
         - limit
164
        """
165
        try:
166
            return get_returnable_orders_for_customer(customerId, limit)
167
        finally:
168
            close_session()
995 varun.gupt 169
 
1382 varun.gupt 170
    def getCancellableOrdersForCustomer(self, customerId, limit = None):
171
        """
172
        Parameters:
173
         - customerId
174
         - limit
175
        """
176
        try:
177
            return get_cancellable_orders_for_customer(customerId, limit)
178
        finally:
179
            close_session()
180
 
483 rajveer 181
    def changeOrderStatus(self, orderId, status, description):
182
        """
183
        Parameters:
184
         - orderId
185
         - status
186
         - description
187
         - 
188
        """
766 rajveer 189
        try:
190
            return change_order_status(self, orderId, status, description)
191
        finally:
192
            close_session()
921 rajveer 193
 
194
    def acceptOrder(self, orderId):
195
        """
196
        Parameters:
197
         - orderId
198
        """
199
        try:
200
            return accept_order(self, orderId)
201
        finally:
202
            close_session()
203
 
204
    def billOrder(self, orderId):
205
        """
206
        Parameters:
207
         - orderId
208
        """
209
        try:
210
            return bill_order(self, orderId)
211
        finally:
212
            close_session()
766 rajveer 213
 
483 rajveer 214
    def getOrdersForCustomer(self, customerId, from_date, to_date, status):
104 ashish 215
        """
216
        Parameters:
217
         - customerId
218
         - from_date
219
         - to_date
220
         - status
221
        """
766 rajveer 222
        try:
223
            current_from_date, current_to_date = get_fdate_tdate(from_date, to_date)
224
 
225
            orders = get_orders_for_customer(customerId, current_from_date, current_to_date, status)
226
            return [to_t_order(order) for order in orders]
227
        finally:
228
            close_session()
1528 ankur.sing 229
 
230
    def getOrderForCustomer(self, orderId, customerId):
231
        """
232
        Returns an order for the order Id. Also checks if the order belongs to the customer whose Id is passed.
233
        Throws exception if either order Id is invalid or order does not below to the customer whose Id is passed.
234
 
235
        Parameters:
236
         - customerId
237
         - orderId
238
        """
239
        try:
240
            return to_t_order(get_order_for_customer(orderId, customerId))
241
        finally:
242
            close_session()
766 rajveer 243
 
483 rajveer 244
    def getOrder(self, id):
245
        """
246
        Parameters:
247
         - id
248
        """
766 rajveer 249
        try:
250
            return to_t_order(get_order(id))
251
        finally:
252
            close_session()
253
 
483 rajveer 254
    def getLineItemsForOrder(self, orderId):
255
        """
256
        Parameters:
257
         - orderId
258
        """
766 rajveer 259
        try:
260
            lineitems = get_line_items_for_order(orderId)
261
            t_lineitems = []
262
            for lineitem in lineitems:
263
                t_lineitems.append(to_t_lineitem(lineitem))
264
            return t_lineitems
265
        finally:
266
            close_session()
1149 chandransh 267
 
268
    def addBillingDetails(self, orderId, invoice_number, billed_by):
494 rajveer 269
        """
1149 chandransh 270
        Add billing details such as the bill number and the biller to the Order.
271
 
494 rajveer 272
        Parameters:
273
         - orderId
274
         - invoice_number
275
         - billed_by
276
        """
766 rajveer 277
        try:
1149 chandransh 278
            return add_billing_details(orderId, invoice_number, billed_by)
766 rajveer 279
        finally:
280
            close_session()
1149 chandransh 281
 
2783 chandransh 282
    def addJacketNumber(self, orderId, jacketNumber, imeiNumber, itemNumber, billedBy):
1149 chandransh 283
        """
2783 chandransh 284
        Adds jacket number and IMEI no. to the order. Doesn't update the IMEI no. if a -1 is supplied.
285
        Also marks the order as billed and sets the billing timestamp.
286
        Return false if it doesn't find the order with the given ID.
1149 chandransh 287
 
288
        Parameters:
289
         - orderId
290
         - jacketNumber
2783 chandransh 291
         - imeiNumber
292
         - itemNumber
293
         - billedBy
1149 chandransh 294
        """
295
        try:
2783 chandransh 296
            return add_jacket_number(self, orderId, jacketNumber, imeiNumber, itemNumber, billedBy)
297
        except TransactionServiceException:
298
            print "ERROR: Couldn't find the order with the given id"
299
            return False
1149 chandransh 300
        finally:
301
            close_session()
1220 chandransh 302
 
303
    def batchOrders(self, warehouseId):
304
        """
305
        Create a batch of all the pending orders for the given warehouse.
306
        The returned list is orderd by created_timestamp.
307
        If there are no pending orders, an empty list is returned.
1208 chandransh 308
 
1220 chandransh 309
        Parameters:
310
         - warehouseId
311
        """
312
        try:
313
            pending_orders = batch_orders(warehouseId)
314
            return [to_t_order(order) for order in pending_orders]
315
        finally:
316
            close_session()
317
 
1208 chandransh 318
    def markOrderAsOutOfStock(self, orderId):
319
        """
320
        Mark the given order as out of stock. Throws an exception if the order with the given Id couldn't be found.
321
 
322
 
323
        Parameters:
324
         - orderId
325
        """
326
        try:
327
            return order_outofstock(orderId)
328
        finally:
329
            close_session()
330
 
759 chandransh 331
    def markOrdersAsManifested(self, warehouseId, providerId):
332
        """
333
        Marks all BILLED orders for a warehouse and a provider as SHIPPED_FROM_WH
334
 
335
        Parameters:
336
         - warehouseId
337
         - providerId
338
        """
766 rajveer 339
        try:
340
            return mark_orders_as_manifested(warehouseId, providerId)
341
        finally:
342
            close_session()
1113 chandransh 343
 
344
    def markOrdersAsPickedUp(self, providerId, pickupDetails):
345
        """
346
        Marks all SHIPPED_FROM_WH orders of the previous day for a provider as SHIPPED_TO_LOGISTICS.
347
        Returns a list of orders that were shipped from warehouse but did not appear in the pick-up report.
348
        Raises an exception if we encounter report for an AWB number that we did not ship.
349
 
350
        Parameters:
351
         - providerId
352
         - pickupDetails
353
        """
354
        try:
355
            orders_not_picked_up = mark_orders_as_picked_up(providerId, pickupDetails)
356
            return [to_t_order(order) for order in orders_not_picked_up]
357
        finally:
358
            close_session()
1132 chandransh 359
 
360
    def markOrdersAsDelivered(self, providerId, deliveredOrders):
361
        """
362
        Marks all orders with AWBs in the given map as delivered. Also sets the delivery timestamp and
363
        the name of the receiver.
364
        Raises an exception if we encounter report for an AWB number that we did not ship.
365
 
366
        Parameters:
367
         - providerId
368
         - deliveredOrders
369
        """
370
        try:
371
            mark_orders_as_delivered(providerId, deliveredOrders)
372
        finally:
373
            close_session()
1135 chandransh 374
 
375
    def markOrdersAsFailed(self, providerId, returnedOrders):
376
        """
377
        Mark all orders with AWBs in the given map as failed. Also sets the delivery timestamp.
378
        Raises an exception if we encounter report for an AWB number that we did not ship.
379
 
380
        Parameters:
381
         - providerId
382
         - returnedOrders
383
        """
384
        try:
385
            mark_orders_as_failed(providerId, returnedOrders)
386
        finally:
387
            close_session()
1246 chandransh 388
 
389
    def updateNonDeliveryReason(self, providerId, undeliveredOrders):
390
        """
391
        Update the status description of orders whose AWB numbers are keys of the Map.
392
 
393
        Parameters:
394
         - providerId
395
         - undelivered_orders
396
        """
397
        try:
398
            update_non_delivery_reason(providerId, undeliveredOrders)
399
        finally:
400
            close_session()
1405 ankur.sing 401
 
402
    def getUndeliveredOrders(self, providerId, warehouseId):
403
        """
404
        Returns the list of orders whose delivery time has passed but have not been
405
        delivered yet for the given provider and warehouse. To get a complete list of
406
        undelivered orders, pass them as -1.
407
        Returns an empty list if no such orders exist.
408
 
409
        Parameters:
410
         - providerId
411
         - warehouseId
412
        """
413
        try:
414
            undelivered_orders = get_undelivered_orders(providerId, warehouseId)
415
            return [to_t_order(order) for order in undelivered_orders]
416
        finally:
417
            close_session()
1351 varun.gupt 418
 
1398 varun.gupt 419
    def enqueueTransactionInfoEmail(self, transactionId):
1351 varun.gupt 420
        """
1398 varun.gupt 421
        Save the email containing order details to be sent to customer later by batch job
1351 varun.gupt 422
 
423
        Parameters:
424
         - transactionId
425
        """
426
        try:
1398 varun.gupt 427
            return enqueue_transaction_info_email(transactionId)
1351 varun.gupt 428
        finally:
429
            close_session()
430
 
483 rajveer 431
    def getAlerts(self, orderId, valid):
432
        """
433
        Parameters:
434
         - orderId
435
         - valid
436
        """
766 rajveer 437
        try:
438
            alerts = get_alerts(orderId, valid)
439
 
440
            t_alerts = []
441
 
442
            for alert in alerts:
443
                t_alerts.append(to_t_alert(alert)) 
444
 
445
            return t_alerts
446
        finally:
447
            close_session()
448
 
483 rajveer 449
    def setAlert(self, orderId, unset, type, comment):
450
        """
451
        Parameters:
452
         - orderId
453
         - unset
454
         - type
455
         - comment
456
        """
766 rajveer 457
        try:
458
            set_alert(orderId, unset, type, comment)
459
        finally:
460
            close_session()
1596 ankur.sing 461
 
462
    def getValidOrderCount(self, ):
463
        """
464
        Return the number of valid orders. (OrderStatus >= OrderStatus.SUBMITTED_FOR_PROCESSING)
465
        """
1731 ankur.sing 466
        try:
467
            return get_valid_order_count()
468
        finally:
469
            close_session()
1627 ankur.sing 470
 
471
    def getNoOfCustomersWithSuccessfulTransaction(self, ):
472
        """
473
        Returns the number of distinct customers who have done successful transactions
474
        """
1731 ankur.sing 475
        try:
476
            return get_cust_count_with_successful_txn()
477
        finally:
478
            close_session()
1627 ankur.sing 479
 
1731 ankur.sing 480
 
481
    def getValidOrdersAmountRange(self, ):
1627 ankur.sing 482
        """
1731 ankur.sing 483
        Returns the minimum and maximum amounts of a valid order. (OrderStatus >= OrderStatus.SUBMITTED_FOR_PROCESSING)
484
        List contains two values, first minimum amount and second maximum amount.
1627 ankur.sing 485
        """
1731 ankur.sing 486
        try:
487
            return get_valid_orders_amount_range()
488
        finally:
489
            close_session()
1627 ankur.sing 490
 
1886 ankur.sing 491
    def getValidOrders(self, limit):
492
        """
493
        Returns list of Orders in descending order by Order creation date. List is restricted to limit Orders.
494
        If limit is passed as 0, then all valid Orders are returned.
495
 
496
        Parameters:
497
         - limit
498
        """
499
        try:
500
            return [to_t_order(order) for order in get_valid_orders(limit)]
501
        finally:
502
            close_session()
104 ashish 503
 
2536 chandransh 504
    def toggleDOAFlag(self, orderId):
104 ashish 505
        """
2536 chandransh 506
        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.
507
        Returns the final flag status.
508
        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 509
 
132 ashish 510
        Parameters:
2536 chandransh 511
         - orderId
132 ashish 512
        """
2536 chandransh 513
        try:
514
            return toggle_doa_flag(orderId)
515
        finally:
516
            close_session()
483 rajveer 517
 
2536 chandransh 518
    def requestPickupNumber(self, orderId):
104 ashish 519
        """
2536 chandransh 520
        Sends out an email to the account manager of the original courier provider used to ship the order.
521
        If the order status was DELIVERY_SUCCESS, it is changed to be DOA_PICKUP_REQUESTED.
522
        If the order status was DOA_PICKUP_REQUESTED, it is left unchanged.
523
        For any other status, it returns false.
524
        Throws an exception if the order with the given id couldn't be found.
104 ashish 525
 
526
        Parameters:
2536 chandransh 527
         - orderId
104 ashish 528
        """
2536 chandransh 529
        try:
530
            return request_pickup_number(orderId)
531
        finally:
532
            close_session()
483 rajveer 533
 
2536 chandransh 534
    def authorizePickup(self, orderId, pickupNumber):
304 ashish 535
        """
2536 chandransh 536
        If the order status is DOA_PICKUP_REQUESTED, it does the following
537
            1. Sends out an email to the customer with the dispatch advice that he has to print as an attachment.
538
            2. Changes order status to be DOA_PICKUP_AUTHORIZED.
539
            3. Returns true
540
        If the order is any other status, it returns false.
541
        Throws an exception if the order with the given id couldn't be found.
304 ashish 542
 
543
        Parameters:
2536 chandransh 544
         - orderId
545
         - pickupNumber
304 ashish 546
        """
2536 chandransh 547
        try:
548
            return authorize_pickup(orderId, pickupNumber)
549
        finally:
550
            close_session()    
2764 chandransh 551
 
552
    def markDoasAsPickedUp(self, providerId, pickupDetails):
553
        """
554
        Marks all DOA_PICKUP_AUTHORIZED orders of the previous day for a provider as DOA_RETURN_IN_TRANSIT.
555
        Returns a list of orders that were authorized for pickup but did not appear in the pick-up report.
556
 
557
        Parameters:
558
         - providerId
559
         - pickupDetails
560
        """
561
        try:
562
            orders_not_picked_up = mark_doas_as_picked_up(providerId, pickupDetails)
563
            return [to_t_order(order) for order in orders_not_picked_up]
564
        finally:
565
            close_session()
2591 chandransh 566
 
2616 chandransh 567
    def receiveReturn(self, orderId):
2591 chandransh 568
        """
2599 chandransh 569
        If the order status is DOA_RETURN_AUTHORIZED or DOA_RETURN_IN_TRANSIT, marks the order status as DOA_RECEIVED and returns true.
2591 chandransh 570
        If the order is in any other state, it returns false.
571
        Throws an exception if the order with the given id couldn't be found.
572
 
573
        Parameters:
574
         - orderId
575
        """
576
        try:
2616 chandransh 577
            return receive_return(orderId)
2591 chandransh 578
        finally:
579
            close_session()
580
 
581
    def validateDoa(self, orderId, isValid):
582
        """
2599 chandransh 583
        Used to validate the DOA certificate for an order in the DOA_RECEIVED state. If the certificate is valid,
2609 chandransh 584
        the order state is changed to DOA_CERT_PENDING.
2591 chandransh 585
        If the certificate is invalid, the order state is changed to DOA_CERT_INVALID.
586
        If the order is in any other state, it returns false.
587
        Throws an exception if the order with the given id couldn't be found.
588
 
589
        Parameters:
590
         - orderId
591
         - isValid
592
        """
593
        try:
594
            return validate_doa(orderId, isValid)
595
        finally:
596
            close_session()
2628 chandransh 597
 
598
    def reshipOrder(self, orderId):
599
        """
600
        If the order is in SALES_RET_RECEIVED or DOA_CERT_INVALID state, it does the following:
601
            1. Creates a new order for processing in the BILLED state. All billing information is saved.
602
            2. Marks the current order as one of the final states SALES_RET_RESHIPPED and DOA_INVALID_RESHIPPED depending on what state the order started in.
603
 
604
        If the order is in DOA_CERT_VALID state, it does the following:
605
            1. Creates a new order for processing in the SUBMITTED_FOR_PROCESSING state.
606
            2. Creates a return order for the warehouse executive to return the DOA material.
607
            3. Marks the current order as the final DOA_RESHIPPED state.
608
 
609
        Returns the id of the newly created order.
610
 
611
        Throws an exception if the order with the given id couldn't be found.
612
 
613
        Parameters:
614
         - orderId
615
        """
616
        try:
617
            return reship_order(orderId)
618
        finally:
619
            close_session()
620
 
621
    def refundOrder(self, orderId):
622
        """
623
        If the order is in SALES_RET_RECEIVED, DOA_CERT_VALID or DOA_CERT_INVALID state, it does the following:
624
            1. Creates a refund request for batch processing.
625
            2. Creates a return order for the warehouse executive to return the shipped material.
626
            3. Marks the current order as SALES_RET_REFUNDED, DOA_VALID_REFUNDED or DOA_INVALID_REFUNDED final states.
627
 
628
        If the order is in SUBMITTED_FOR_PROCESSING or INVENTORY_LOW state, it does the following:
629
            1. Creates a refund request for batch processing.
630
            2. Marks the current order as the REFUNDED final state.
631
 
632
        Returns True if it is successful, False otherwise.
633
 
634
        Throws an exception if the order with the given id couldn't be found.
635
 
636
        Parameters:
637
         - orderId
638
        """
639
        try:
640
            return refund_order(orderId)
641
        finally:
642
            close_session()
643
 
2697 chandransh 644
    def getReturnOrders(self, warehouseId, fromDate, toDate):
645
        """
646
        Get all return orders created between the from and to dates for the given warehouse.
647
        Ignores the warehouse if it is passed as -1.
648
 
649
        Parameters:
650
         - warehouseId
651
         - fromDate
652
         - toDate
653
        """
654
        try:
655
            from_date, to_date = get_fdate_tdate(fromDate, toDate)
656
            return get_return_orders(warehouseId, from_date, to_date)
657
        finally:
658
            close_session()
659
 
2700 chandransh 660
    def getReturnOrder(self, id):
661
        """
662
        Returns the ReturnOrder corresponding to the given id.
663
        Throws an exception if the return order with the given id couldn't be found.
664
 
665
        Parameters:
666
         - id
667
        """
668
        try:
669
            return get_return_order(id)
670
        finally:
671
            close_session()
672
 
2697 chandransh 673
    def processReturn(self, returnOrderId):
674
        """
675
        Marks the return order with the given id as processed. Raises an exception if no such return order exists.
676
 
677
        Parameters:
678
         - returnOrderId
679
        """
680
        try:
681
            process_return(returnOrderId)
682
        finally:
683
            close_session()
2591 chandransh 684
 
2536 chandransh 685
    def closeSession(self, ):
686
        close_session()