Subversion Repositories SmartDukaan

Rev

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

Rev 3724 Rev 3768
Line 33... Line 33...
33
AMOUNT_KEY = 'amount'
33
AMOUNT_KEY = 'amount'
34
 
34
 
35
user_client = UserClient().get_client()
35
user_client = UserClient().get_client()
36
transaction_client = TransactionClient().get_client()
36
transaction_client = TransactionClient().get_client()
37
payment_client = PaymentClient().get_client()
37
payment_client = PaymentClient().get_client()
38
Dataservice.initialize()
-
 
39
 
38
 
40
def create_orders(user, items):
39
def create_orders(user, items):
41
    orders = []
40
    orders = []
42
    for item in items:
41
    for item in items:
43
        for i in range (0, int(item[QUANTITY_KEY])):
-
 
44
            line_item = create_line_item(int(item[ITEM_ID_KEY]), item[PRICE_KEY])
42
        line_item = create_line_item(int(item[ITEM_ID_KEY]), item[PRICE_KEY], item[QUANTITY_KEY])
45
            orders.append(create_order(user.userId, user.defaultAddressId, line_item))
43
        orders.append(create_order(user.userId, user.defaultAddressId, line_item))
46
    return orders
44
    return orders
47
    
45
    
48
 
46
 
49
def create_transaction(user, items):
47
def create_transaction(user, items):
50
    txn = Transaction()
48
    txn = Transaction()
Line 103... Line 101...
103
 
101
 
104
def main():
102
def main():
105
    parser = optparse.OptionParser()
103
    parser = optparse.OptionParser()
106
    parser.add_option("-f", "--file", dest="file",
104
    parser.add_option("-f", "--file", dest="file",
107
                   help="Excel file with bulk orders.")
105
                   help="Excel file with bulk orders.")
-
 
106
    parser.add_option("-d", "--db_server", dest="host",
-
 
107
                      default="localhost",
-
 
108
                   help="Database server.")
108
    (options, args) = parser.parse_args()
109
    (options, args) = parser.parse_args()
109
    if len(args) != 0:
110
    if len(args) != 0:
110
        parser.error("You've supplied extra arguments. Are you sure you want to run this program?")
111
        parser.error("You've supplied extra arguments. Are you sure you want to run this program?")
111
    if options.file == None:
112
    #if options.file == None:
112
        parser.error("Excel File with bulk orders not supplied.")
113
    #    parser.error("Excel File with bulk orders not supplied.")
-
 
114
 
-
 
115
    Dataservice.initialize(db_hostname=options.host)
113
    
116
    
114
    load_orders(options.file)
117
    #load_orders(options.file)
115
    #load_orders('/home/vikas/tmp/Bulk Orders.xls')
118
    load_orders('/home/vikas/RTGS.xls')
116
    
119
    
117
if __name__ == '__main__':
120
if __name__ == '__main__':
118
    main()
121
    main()
119
122