Subversion Repositories SmartDukaan

Rev

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

Rev 1493 Rev 1528
Line 252... Line 252...
252
        query = query.filter(Order.created_timestamp >from_date)
252
        query = query.filter(Order.created_timestamp >from_date)
253
    if to_date:
253
    if to_date:
254
        query = query.filter(Order.created_timestamp < to_date)
254
        query = query.filter(Order.created_timestamp < to_date)
255
    return query.all()
255
    return query.all()
256
 
256
 
-
 
257
def get_order_for_customer(order_id, customer_id):
-
 
258
    if not customer_id:
-
 
259
        raise TransactionServiceException(101, "bad customer id")
-
 
260
    order = get_order(order_id)
-
 
261
    if order.customer_id != customer_id:
-
 
262
        raise TransactionServiceException(108, "order: " + str(order_id) + " does not belong to customer: " + str(customer_id))
-
 
263
    return order
-
 
264
 
257
def get_all_orders(status, from_date, to_date, warehouse_id):
265
def get_all_orders(status, from_date, to_date, warehouse_id):
258
    if not warehouse_id:
266
    if not warehouse_id:
259
        raise TransactionServiceException(101, "bad warehouse id")
267
        raise TransactionServiceException(101, "bad warehouse id")
260
    query = Order.query.filter(Order.warehouse_id == warehouse_id)
268
    query = Order.query.filter(Order.warehouse_id == warehouse_id)
261
    if status:
269
    if status:
Line 305... Line 313...
305
    if end_billing_date:
313
    if end_billing_date:
306
        query = query.filter(Order.billing_timestamp <= end_billing_date)
314
        query = query.filter(Order.billing_timestamp <= end_billing_date)
307
    
315
    
308
    return query.all()
316
    return query.all()
309
 
317
 
310
def get_orders_for_transaction(transaction_id):
318
def get_orders_for_transaction(transaction_id, customer_id):
311
    orders = Order.query.filter_by(transaction_id=transaction_id).all()
319
    orders = Order.query.filter_by(transaction_id=transaction_id, customer_id=customer_id).all()
-
 
320
    
312
    if not orders:
321
    if not orders:
313
        raise TransactionServiceException(101, "No order for the transaction")
322
        raise TransactionServiceException(101, "No order for the transaction")
314
    return orders
323
    return orders
315
 
324
 
316
def get_undelivered_orders(provider_id, warehouse_id):
325
def get_undelivered_orders(provider_id, warehouse_id):