Пример #1
0
def test_restock_fulfilled_order_lines(fulfilled_order):
    line_1 = fulfilled_order.lines.first()
    line_2 = fulfilled_order.lines.last()
    stock_1_quantity_allocated_before = line_1.variant.quantity_allocated
    stock_2_quantity_allocated_before = line_2.variant.quantity_allocated
    stock_1_quantity_before = line_1.variant.quantity
    stock_2_quantity_before = line_2.variant.quantity

    restock_order_lines(fulfilled_order)

    line_1.variant.refresh_from_db()
    line_2.variant.refresh_from_db()
    assert line_1.variant.quantity_allocated == stock_1_quantity_allocated_before
    assert line_2.variant.quantity_allocated == stock_2_quantity_allocated_before
    assert line_1.variant.quantity == stock_1_quantity_before + line_1.quantity
    assert line_2.variant.quantity == stock_2_quantity_before + line_2.quantity
Пример #2
0
def test_restock_fulfilled_order_lines(fulfilled_order):
    line_1 = fulfilled_order.lines.first()
    line_2 = fulfilled_order.lines.last()
    stock_1_quantity_allocated_before = line_1.variant.quantity_allocated
    stock_2_quantity_allocated_before = line_2.variant.quantity_allocated
    stock_1_quantity_before = line_1.variant.quantity
    stock_2_quantity_before = line_2.variant.quantity

    restock_order_lines(fulfilled_order)

    line_1.variant.refresh_from_db()
    line_2.variant.refresh_from_db()
    assert line_1.variant.quantity_allocated == stock_1_quantity_allocated_before
    assert line_2.variant.quantity_allocated == stock_2_quantity_allocated_before
    assert line_1.variant.quantity == stock_1_quantity_before + line_1.quantity
    assert line_2.variant.quantity == stock_2_quantity_before + line_2.quantity
Пример #3
0
def test_restock_fulfilled_order_lines(fulfilled_order):
    line_1 = fulfilled_order.lines.first()
    line_2 = fulfilled_order.lines.last()
    stock_1 = Stock.objects.get(product_variant=line_1.variant)
    stock_2 = Stock.objects.get(product_variant=line_2.variant)
    stock_1_quantity_allocated_before = stock_1.quantity_allocated
    stock_2_quantity_allocated_before = stock_2.quantity_allocated
    stock_1_quantity_before = stock_1.quantity
    stock_2_quantity_before = stock_2.quantity

    restock_order_lines(fulfilled_order)

    stock_1.refresh_from_db()
    stock_2.refresh_from_db()
    assert stock_1.quantity_allocated == stock_1_quantity_allocated_before
    assert stock_2.quantity_allocated == stock_2_quantity_allocated_before
    assert stock_1.quantity == stock_1_quantity_before + line_1.quantity
    assert stock_2.quantity == stock_2_quantity_before + line_2.quantity
Пример #4
0
def test_restock_order_lines(order_with_lines, track_inventory):

    order = order_with_lines
    line_1 = order.lines.first()
    line_2 = order.lines.last()

    line_1.variant.track_inventory = track_inventory
    line_2.variant.track_inventory = track_inventory

    line_1.variant.save()
    line_2.variant.save()
    stock_1 = Stock.objects.get(product_variant=line_1.variant)
    stock_2 = Stock.objects.get(product_variant=line_2.variant)

    stock_1_quantity_allocated_before = get_quantity_allocated_for_stock(stock_1)
    stock_2_quantity_allocated_before = get_quantity_allocated_for_stock(stock_2)

    stock_1_quantity_before = stock_1.quantity
    stock_2_quantity_before = stock_2.quantity

    restock_order_lines(order)

    stock_1.refresh_from_db()
    stock_2.refresh_from_db()

    if track_inventory:
        assert get_quantity_allocated_for_stock(stock_1) == (
            stock_1_quantity_allocated_before - line_1.quantity
        )
        assert get_quantity_allocated_for_stock(stock_2) == (
            stock_2_quantity_allocated_before - line_2.quantity
        )
    else:
        assert get_quantity_allocated_for_stock(stock_1) == (
            stock_1_quantity_allocated_before
        )
        assert get_quantity_allocated_for_stock(stock_2) == (
            stock_2_quantity_allocated_before
        )

    assert stock_1.quantity == stock_1_quantity_before
    assert stock_2.quantity == stock_2_quantity_before
    assert line_1.quantity_fulfilled == 0
    assert line_2.quantity_fulfilled == 0
Пример #5
0
def test_restock_order_lines(order_with_lines_and_stock):
    order = order_with_lines_and_stock
    line_1 = order.lines.first()
    line_2 = order.lines.last()
    stock_1_quantity_allocated_before = line_1.stock.quantity_allocated
    stock_2_quantity_allocated_before = line_2.stock.quantity_allocated
    stock_1_quantity_before = line_1.stock.quantity
    stock_2_quantity_before = line_2.stock.quantity

    restock_order_lines(order)

    line_1.stock.refresh_from_db()
    line_2.stock.refresh_from_db()
    assert line_1.stock.quantity_allocated == (
        stock_1_quantity_allocated_before - line_1.quantity)
    assert line_2.stock.quantity_allocated == (
        stock_2_quantity_allocated_before - line_2.quantity)
    assert line_1.stock.quantity == stock_1_quantity_before
    assert line_2.stock.quantity == stock_2_quantity_before
    assert line_1.quantity_fulfilled == 0
    assert line_2.quantity_fulfilled == 0
Пример #6
0
def test_restock_order_lines(order_with_lines):
    order = order_with_lines
    line_1 = order.lines.first()
    line_2 = order.lines.last()
    stock_1_quantity_allocated_before = line_1.variant.quantity_allocated
    stock_2_quantity_allocated_before = line_2.variant.quantity_allocated
    stock_1_quantity_before = line_1.variant.quantity
    stock_2_quantity_before = line_2.variant.quantity

    restock_order_lines(order)

    line_1.variant.refresh_from_db()
    line_2.variant.refresh_from_db()
    assert line_1.variant.quantity_allocated == (
        stock_1_quantity_allocated_before - line_1.quantity)
    assert line_2.variant.quantity_allocated == (
        stock_2_quantity_allocated_before - line_2.quantity)
    assert line_1.variant.quantity == stock_1_quantity_before
    assert line_2.variant.quantity == stock_2_quantity_before
    assert line_1.quantity_fulfilled == 0
    assert line_2.quantity_fulfilled == 0
def test_restock_order_lines(order_with_lines, track_inventory):

    order = order_with_lines
    line_1 = order.lines.first()
    line_2 = order.lines.last()

    line_1.variant.track_inventory = track_inventory
    line_2.variant.track_inventory = track_inventory

    line_1.variant.save()
    line_2.variant.save()

    stock_1_quantity_allocated_before = line_1.variant.quantity_allocated
    stock_2_quantity_allocated_before = line_2.variant.quantity_allocated

    stock_1_quantity_before = line_1.variant.quantity
    stock_2_quantity_before = line_2.variant.quantity

    restock_order_lines(order)

    line_1.variant.refresh_from_db()
    line_2.variant.refresh_from_db()

    if track_inventory:
        assert line_1.variant.quantity_allocated == (
            stock_1_quantity_allocated_before - line_1.quantity)
        assert line_2.variant.quantity_allocated == (
            stock_2_quantity_allocated_before - line_2.quantity)
    else:
        assert line_1.variant.quantity_allocated == (
            stock_1_quantity_allocated_before)
        assert line_2.variant.quantity_allocated == (
            stock_2_quantity_allocated_before)

    assert line_1.variant.quantity == stock_1_quantity_before
    assert line_2.variant.quantity == stock_2_quantity_before
    assert line_1.quantity_fulfilled == 0
    assert line_2.quantity_fulfilled == 0
Пример #8
0
def test_restock_order_lines(order_with_lines, track_inventory):

    order = order_with_lines
    line_1 = order.lines.first()
    line_2 = order.lines.last()

    line_1.variant.track_inventory = track_inventory
    line_2.variant.track_inventory = track_inventory

    line_1.variant.save()
    line_2.variant.save()

    stock_1_quantity_allocated_before = line_1.variant.quantity_allocated
    stock_2_quantity_allocated_before = line_2.variant.quantity_allocated

    stock_1_quantity_before = line_1.variant.quantity
    stock_2_quantity_before = line_2.variant.quantity

    restock_order_lines(order)

    line_1.variant.refresh_from_db()
    line_2.variant.refresh_from_db()

    if track_inventory:
        assert line_1.variant.quantity_allocated == (
            stock_1_quantity_allocated_before - line_1.quantity)
        assert line_2.variant.quantity_allocated == (
            stock_2_quantity_allocated_before - line_2.quantity)
    else:
        assert line_1.variant.quantity_allocated == (
            stock_1_quantity_allocated_before)
        assert line_2.variant.quantity_allocated == (
            stock_2_quantity_allocated_before)

    assert line_1.variant.quantity == stock_1_quantity_before
    assert line_2.variant.quantity == stock_2_quantity_before
    assert line_1.quantity_fulfilled == 0
    assert line_2.quantity_fulfilled == 0