예제 #1
0
def test_increase_stock(product_in_stock):
    stock = product_in_stock.variants.first().stock.first()
    stock.quantity = 100
    stock.quantity_allocated = 80
    stock.save()
    increase_stock(stock, 50)
    stock.refresh_from_db()
    assert stock.quantity == 150
    assert stock.quantity_allocated == 80
예제 #2
0
def test_increase_stock(product_in_stock):
    stock = product_in_stock.variants.first().stock.first()
    stock.quantity = 100
    stock.quantity_allocated = 80
    stock.save()
    increase_stock(stock, 50)
    stock.refresh_from_db()
    assert stock.quantity == 150
    assert stock.quantity_allocated == 80
예제 #3
0
def cancel_delivery_group(group):
    """Cancel delivery group and return products to stock."""
    if group.status == GroupStatus.NEW:
        for line in group:
            if line.stock:
                deallocate_stock(line.stock, line.quantity)
    elif group.status == GroupStatus.SHIPPED:
        for line in group:
            if line.stock:
                increase_stock(line.stock, line.quantity)
예제 #4
0
def cancel_delivery_group(group):
    """Cancel delivery group and return products to stock."""
    if group.status == GroupStatus.NEW:
        for line in group:
            if line.stock:
                deallocate_stock(line.stock, line.quantity)
    elif group.status == GroupStatus.SHIPPED:
        for line in group:
            if line.stock:
                increase_stock(line.stock, line.quantity)