Subversion Repositories SmartDukaan

Rev

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

Rev 1262 Rev 1276
Line 162... Line 162...
162
            order.expected_delivery_time = datetime.datetime.now() + datetime.timedelta(days=logistics_info.deliveryTime)
162
            order.expected_delivery_time = datetime.datetime.now() + datetime.timedelta(days=logistics_info.deliveryTime)
163
            
163
            
164
            catalog_client = InventoryClient().get_client()
164
            catalog_client = InventoryClient().get_client()
165
            catalog_client.reserveItemInWarehouse(item_id, logistics_info.warehouseId, order.lineitems[0].quantity)
165
            catalog_client.reserveItemInWarehouse(item_id, logistics_info.warehouseId, order.lineitems[0].quantity)
166
        
166
        
-
 
167
        try:
167
        #Email the information of order placed to customer
168
            #Email the information of order placed to customer
168
        email_transaction_info_to_user(transaction_id)
169
            email_transaction_info_to_user(transaction_id)
-
 
170
        except Exception as ex:
-
 
171
            #Nothing much to do. Customer will not know that there was a transaction.
-
 
172
            print ex
169
    session.commit()
173
    session.commit()
170
    return True
174
    return True
171
 
175
 
172
def email_transaction_info_to_user(transaction_id):
176
def email_transaction_info_to_user(transaction_id):
173
    transaction = get_transaction(transaction_id)
177
    transaction = get_transaction(transaction_id)
Line 201... Line 205...
201
    for order in transaction.orders:
205
    for order in transaction.orders:
202
        order_date = order.created_timestamp
206
        order_date = order.created_timestamp
203
        html_tr = "<tr><td>" + str(order.id) + "</td>"
207
        html_tr = "<tr><td>" + str(order.id) + "</td>"
204
        
208
        
205
        for lineitem in order.lineitems:
209
        for lineitem in order.lineitems:
206
            html_tr += "<td>" + " ".join([lineitem.brand, lineitem.model_name, lineitem.model_number, lineitem.color]) + "</td>"
210
            html_tr += "<td>" + str(lineitem) + "</td>"
207
            html_tr += "<td>" + str(lineitem.quantity) + "</td>"
211
            html_tr += "<td>" + str(lineitem.quantity) + "</td>"
208
            html_tr += "<td>" + str(lineitem.unit_price) + "</td>"
212
            html_tr += "<td>" + str(lineitem.unit_price) + "</td>"
209
            html_tr += "<td>" + str(lineitem.total_price) + "</td></tr>"
213
            html_tr += "<td>" + str(lineitem.total_price) + "</td></tr>"
210
            total_amount += lineitem.total_price
214
            total_amount += lineitem.total_price
211
            html_table += html_tr
215
            html_table += html_tr
Line 380... Line 384...
380
    query = query.order_by(Order.created_timestamp)
384
    query = query.order_by(Order.created_timestamp)
381
    pending_orders = query.all()
385
    pending_orders = query.all()
382
    
386
    
383
    serial_no = 1
387
    serial_no = 1
384
    for order in pending_orders:
388
    for order in pending_orders:
385
        order.batchNo = batchno_generator.id #FIXME: Batch numbers should be read from a batch number generator
389
        order.batchNo = batchno_generator.id
386
        order.serialNo = serial_no
390
        order.serialNo = serial_no
387
        serial_no += 1
391
        serial_no += 1
388
    session.commit() 
392
    session.commit() 
389
    pending_orders = query.all()
393
    pending_orders = query.all()
390
    return pending_orders
394
    return pending_orders