Subversion Repositories SmartDukaan

Rev

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

Rev 8074 Rev 10698
Line 47... Line 47...
47
def create_orders(user, items):
47
def create_orders(user, items):
48
    orders = []
48
    orders = []
49
    for item in items:
49
    for item in items:
50
        line_item = create_line_item(int(item[ITEM_ID_KEY]), item[PRICE_KEY], item[QUANTITY_KEY])
50
        line_item = create_line_item(int(item[ITEM_ID_KEY]), item[PRICE_KEY], item[QUANTITY_KEY])
51
        addressId = add_address_for_user(item[ADDRESS_KEY], user.userId, False)
51
        addressId = add_address_for_user(item[ADDRESS_KEY], user.userId, False)
52
        orders.append(create_order(user.userId, addressId, line_item, 0, 0, 0, 0, None))
52
        orders.append(create_order(user.userId, addressId, line_item, 0, 0, 0, 0, None, 0, 0))
53
    return orders
53
    return orders
54
    
54
    
55
 
55
 
56
def create_transaction(user, items):
56
def create_transaction(user, items):
57
    txn = Transaction()
57
    txn = Transaction()
Line 75... Line 75...
75
    attributes.append(Attribute(RTGS_BRANCH_ATTR, rtgs_branch))
75
    attributes.append(Attribute(RTGS_BRANCH_ATTR, rtgs_branch))
76
    attributes.append(Attribute(IFSC_ATTR, str(ifsc)))
76
    attributes.append(Attribute(IFSC_ATTR, str(ifsc)))
77
    payment_client.updatePaymentDetails(payment_id, None, None, None, None, None, None, None, None, PaymentStatus.SUCCESS, None, attributes)
77
    payment_client.updatePaymentDetails(payment_id, None, None, None, None, None, None, None, None, PaymentStatus.SUCCESS, None, attributes)
78
    
78
    
79
def load_orders(file):
79
def load_orders(file):
80
    workbook = xlrd.open_workbook(file)
80
    workbook = xlrd.open_workbook(file, encoding_override="UTF-8")
81
    sheet = workbook.sheet_by_index(0)
81
    sheet = workbook.sheet_by_index(0)
82
    num_rows = sheet.nrows
82
    num_rows = sheet.nrows
83
    
83
    
84
    email, rtgs_id, rtgs_bank, rtgs_branch, ifsc, amount = sheet.col_values(1)[0:6]
84
    email, rtgs_id, rtgs_bank, rtgs_branch, ifsc, amount = sheet.col_values(1)[0:6]
85
    
85
    
Line 114... Line 114...
114
    create_payment(user, amount, txn_id, rtgs_id, rtgs_bank, rtgs_branch, ifsc)
114
    create_payment(user, amount, txn_id, rtgs_id, rtgs_bank, rtgs_branch, ifsc)
115
    transaction_client.changeTransactionStatus(txn_id, TransactionStatus.AUTHORIZED, "Payment received for the order", 0, 0, OrderSource.WEBSITE);
115
    transaction_client.changeTransactionStatus(txn_id, TransactionStatus.AUTHORIZED, "Payment received for the order", 0, 0, OrderSource.WEBSITE);
116
    transaction_client.changeTransactionStatus(txn_id, TransactionStatus.IN_PROCESS, "RTGS Payment accepted", 0, 0, OrderSource.WEBSITE);
116
    transaction_client.changeTransactionStatus(txn_id, TransactionStatus.IN_PROCESS, "RTGS Payment accepted", 0, 0, OrderSource.WEBSITE);
117
 
117
 
118
def main():
118
def main():
-
 
119
    
119
    parser = optparse.OptionParser()
120
    parser = optparse.OptionParser()
120
    parser.add_option("-f", "--file", dest="file",
121
    parser.add_option("-f", "--file", dest="file",
121
                   help="Excel file with bulk orders.")
122
                   help="Excel file with bulk orders.")
122
    parser.add_option("-d", "--db_server", dest="host",
123
    parser.add_option("-d", "--db_server", dest="host",
123
                      default="localhost",
124
                      default="localhost",
Line 125... Line 126...
125
    (options, args) = parser.parse_args()
126
    (options, args) = parser.parse_args()
126
    if len(args) != 0:
127
    if len(args) != 0:
127
        parser.error("You've supplied extra arguments. Are you sure you want to run this program?")
128
        parser.error("You've supplied extra arguments. Are you sure you want to run this program?")
128
    if options.file == None:
129
    if options.file == None:
129
        parser.error("Excel File with bulk orders not supplied.")
130
        parser.error("Excel File with bulk orders not supplied.")
130
 
131
    
131
    Dataservice.initialize(db_hostname=options.host)
132
    Dataservice.initialize(db_hostname=options.host)
132
    
133
    
133
    load_orders(options.file)
134
    load_orders(options.file)
134
    #load_orders('/home/vikas/RTGS.xls')
135
    #load_orders('/home/manish/Downloads/Eveready_BulkOrder.xls')
135
    
136
    
136
if __name__ == '__main__':
137
if __name__ == '__main__':
137
    main()
138
    main()