Subversion Repositories SmartDukaan

Rev

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

Rev 23513 Rev 23516
Line 464... Line 464...
464
    return True
464
    return True
465
 
465
 
466
def update_reservation_for_order(item_id, warehouse_id, source_id, order_id, created_timestamp, promised_shipping_timestamp, quantity):    
466
def update_reservation_for_order(item_id, warehouse_id, source_id, order_id, created_timestamp, promised_shipping_timestamp, quantity):    
467
    if not warehouse_id:
467
    if not warehouse_id:
468
        raise InventoryServiceException(101, "bad warehouse_id")
468
        raise InventoryServiceException(101, "bad warehouse_id")
469
    warehouse = warehouseMap.get(warehouse_id)
469
    warehouse = get_Warehouse(warehouse_id)
470
 
-
 
-
 
470
    '''item_pricing = get_item_pricing(item_id, warehouse.vendor.id)
-
 
471
    if not item_pricing:
-
 
472
        raise InventoryServiceException(101, "No Pricing Info found for vendor and Item")'''
471
    query = CurrentInventorySnapshot.query.filter(CurrentInventorySnapshot.item_id == item_id).filter(CurrentInventorySnapshot.availability - CurrentInventorySnapshot.reserved >= quantity)
473
    query = CurrentInventorySnapshot.query.filter_by(warehouse_id = warehouse_id, item_id = item_id)
-
 
474
    try:
472
    item_current_inventory_snapshots = query.all()
475
        new_current_inventory_snapshot = query.one()
-
 
476
    except:
473
    for current_inventory_snapshot in item_current_inventory_snapshots:
477
        new_current_inventory_snapshot = CurrentInventorySnapshot()
474
        warehouseMap.get(current_inventory_snapshot.warehouse_id).state_id
478
        new_current_inventory_snapshot.warehouse_id = warehouse_id
475
        if warehouseMap.get(current_inventory_snapshot.warehouse_id).state_id == warehouse.state_id:
479
        new_current_inventory_snapshot.item_id = item_id
476
            current_inventory_snapshot.reserved = current_inventory_snapshot.reserved + quantity
480
        new_current_inventory_snapshot.availability = 0
477
            warehouse_id=current_inventory_snapshot.warehouse_id
481
        new_current_inventory_snapshot.reserved = 0
478
            break
-
 
479
        
482
        
480
    else:
-
 
481
        query = CurrentInventorySnapshot.query.filter_by(warehouse_id = warehouse_id, item_id = item_id)
-
 
482
        try:
-
 
483
            new_current_inventory_snapshot = query.one()
-
 
484
        except:
-
 
485
            new_current_inventory_snapshot = CurrentInventorySnapshot()
-
 
486
            new_current_inventory_snapshot.warehouse_id = warehouse_id
-
 
487
            new_current_inventory_snapshot.item_id = item_id
-
 
488
            new_current_inventory_snapshot.availability = 0
-
 
489
            new_current_inventory_snapshot.reserved = 0
-
 
490
            new_current_inventory_snapshot.reserved = new_current_inventory_snapshot.reserved + quantity
483
    new_current_inventory_snapshot.reserved = new_current_inventory_snapshot.reserved + quantity
491
    
484
    
492
    new_reservation = CurrentReservationSnapshot()
485
    new_reservation = CurrentReservationSnapshot()
493
    new_reservation.item_id = item_id
486
    new_reservation.item_id = item_id
494
    new_reservation.warehouse_id = warehouse_id
487
    new_reservation.warehouse_id = warehouse_id
495
    new_reservation.source_id = source_id
488
    new_reservation.source_id = source_id