Subversion Repositories SmartDukaan

Rev

Rev 5527 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5527 Rev 5583
Line 15... Line 15...
15
import sys
15
import sys
16
 
16
 
17
from thrift.Thrift import TException
17
from thrift.Thrift import TException
18
import traceback
18
import traceback
19
from shop2020.thriftpy.logistics.ttypes import PickUpType
19
from shop2020.thriftpy.logistics.ttypes import PickUpType
-
 
20
from shop2020.thriftpy.model.v1.order.ttypes import OrderType
20
 
21
 
21
if __name__ == '__main__' and __package__ is None:
22
if __name__ == '__main__' and __package__ is None:
22
    import os
23
    import os
23
    sys.path.insert(0, os.getcwd())
24
    sys.path.insert(0, os.getcwd())
24
 
25
 
Line 81... Line 82...
81
                      help="process the transaction as a COD transaction")
82
                      help="process the transaction as a COD transaction")
82
    parser.add_option("-H", "--host", dest="hostname",
83
    parser.add_option("-H", "--host", dest="hostname",
83
                      default="localhost",
84
                      default="localhost",
84
                      type="string", help="The HOST where the DB server is running",
85
                      type="string", help="The HOST where the DB server is running",
85
                      metavar="HOST")
86
                      metavar="HOST")
-
 
87
    parser.add_option("-O", "--type", dest="orderType",
-
 
88
                      type="string", help="The type of order viz. B2B, B2C, B2Cbulk")
86
    (options, args) = parser.parse_args()
89
    (options, args) = parser.parse_args()
87
    if len(args) != 0:
90
    if len(args) != 0:
88
        parser.error("You've supplied extra arguments. Are you sure you want to run this program?")
91
        parser.error("You've supplied extra arguments. Are you sure you want to run this program?")
89
    if options.txn_id == None:
92
    if options.txn_id == None:
90
        parser.error("No Transaction id supplied")
93
        parser.error("No Transaction id supplied")
-
 
94
    if options.orderType == None:
-
 
95
        parser.error("Please pass an orderType")
-
 
96
        
-
 
97
    orderTypeInteger = OrderType._NAMES_TO_VALUES.get(options.orderType)
-
 
98
    
-
 
99
    if orderTypeInteger == None:
-
 
100
        parser.error("Invalid OrderType. Allowed values are B2B, B2C and B2Cbulk")
-
 
101
        
91
    DataService.initialize(db_hostname=options.hostname, echoOn=True)
102
    DataService.initialize(db_hostname=options.hostname, echoOn=True)
92
    transaction = DataAccessors.get_transaction(options.txn_id)
103
    transaction = DataAccessors.get_transaction(options.txn_id)
93
    if(options.cod):
104
    if(options.cod):
94
        DataAccessors.change_transaction_status(options.txn_id, TransactionStatus.COD_IN_PROCESS, "COD payment awaited", PickUpType.COURIER, transaction.orders[0].orderType)
105
        DataAccessors.change_transaction_status(options.txn_id, TransactionStatus.COD_IN_PROCESS, "COD payment awaited", PickUpType.COURIER, orderTypeInteger)
95
    else:
106
    else:
96
        DataAccessors.change_transaction_status(options.txn_id, TransactionStatus.AUTHORIZED, "Payment received for the order", PickUpType.COURIER, transaction.orders[0].orderType)
107
        DataAccessors.change_transaction_status(options.txn_id, TransactionStatus.AUTHORIZED, "Payment received for the order", PickUpType.COURIER, orderTypeInteger)
97
    
108
    
98
    DataAccessors.enqueue_transaction_info_email(options.txn_id)
109
    DataAccessors.enqueue_transaction_info_email(options.txn_id)
99
    
110
    
100
    user_service_client = UserClient()
111
    user_service_client = UserClient()
101
    reset_cart(transaction, user_service_client)
112
    reset_cart(transaction, user_service_client)