当前位置: 首页>>代码示例>>Python>>正文


Python OrderLine.unit_price方法代码示例

本文整理汇总了Python中shoop.core.models.OrderLine.unit_price方法的典型用法代码示例。如果您正苦于以下问题:Python OrderLine.unit_price方法的具体用法?Python OrderLine.unit_price怎么用?Python OrderLine.unit_price使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在shoop.core.models.OrderLine的用法示例。


在下文中一共展示了OrderLine.unit_price方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_order_with_product

# 需要导入模块: from shoop.core.models import OrderLine [as 别名]
# 或者: from shoop.core.models.OrderLine import unit_price [as 别名]
def create_order_with_product(product, supplier, quantity, taxless_unit_price, tax_rate=0, n_lines=1):
    order = create_empty_order()
    order.full_clean()
    order.save()
    for x in range(n_lines):
        product_order_line = OrderLine(order=order)
        update_order_line_from_product(request=None, order_line=product_order_line, product=product, quantity=quantity,
                                       supplier=supplier)
        product_order_line.unit_price = TaxlessPrice(taxless_unit_price)
        product_order_line.save()
        product_order_line.taxes.add(
            OrderLineTax.from_tax(get_test_tax(tax_rate), product_order_line.taxless_total_price)
        )
    assert order.get_product_ids_and_quantities()[product.pk] == (quantity * n_lines), "Things got added"
    return order
开发者ID:charn,项目名称:shoop,代码行数:17,代码来源:factories.py

示例2: create_order

# 需要导入模块: from shoop.core.models import OrderLine [as 别名]
# 或者: from shoop.core.models.OrderLine import unit_price [as 别名]
def create_order(request, creator, customer, product):
    billing_address = get_address()
    shipping_address = get_address(name="Shippy Doge")
    shipping_address.save()
    order = Order(
        creator=creator,
        customer=customer,
        shop=get_default_shop(),
        payment_method=get_default_payment_method(),
        shipping_method=get_default_shipping_method(),
        billing_address=billing_address,
        shipping_address=shipping_address,
        order_date=now(),
        status=get_initial_order_status()
    )
    order.full_clean()
    order.save()
    supplier = get_default_supplier()
    product_order_line = OrderLine(order=order)
    update_order_line_from_product(order_line=product_order_line, product=product, request=request, quantity=5, supplier=supplier)
    product_order_line.unit_price = TaxlessPrice(100)
    assert product_order_line.taxful_total_price.amount > 0
    product_order_line.save()
    product_order_line.taxes.add(OrderLineTax.from_tax(get_default_tax(), product_order_line.taxless_total_price))

    discount_order_line = OrderLine(order=order, quantity=1, type=OrderLineType.OTHER)
    discount_order_line.total_discount = TaxfulPrice(30)
    assert discount_order_line.taxful_total_discount.amount == 30
    assert discount_order_line.taxful_total_price.amount == -30
    assert discount_order_line.taxful_unit_price.amount == 0
    discount_order_line.save()

    order.cache_prices()
    order.check_all_verified()
    order.save()
    base_amount = 5 * 100
    tax_value = get_default_tax().calculate_amount(base_amount)
    assert order.taxful_total_price == base_amount + tax_value - 30, "Math works"

    shipment = order.create_shipment_of_all_products(supplier=supplier)
    assert shipment.total_products == 5, "All products were shipped"
    assert shipment.weight == product.net_weight * 5, "Gravity works"
    assert not order.get_unshipped_products(), "Nothing was left in the warehouse"

    order.create_payment(order.taxful_total_price)
    assert order.is_paid()
    assert Order.objects.paid().filter(pk=order.pk).exists(), "It was paid! Honestly!"
开发者ID:charn,项目名称:shoop,代码行数:49,代码来源:test_basic_order.py

示例3: test_line_discount_more

# 需要导入模块: from shoop.core.models import OrderLine [as 别名]
# 或者: from shoop.core.models.OrderLine import unit_price [as 别名]
def test_line_discount_more():
    order = create_empty_order()
    order.save()
    ol = OrderLine(order=order, type=OrderLineType.OTHER)
    ol.quantity = 5
    ol.unit_price = TaxlessPrice(30)
    ol.total_discount = TaxlessPrice(50)
    ol.save()
    assert ol.taxless_unit_price == TaxlessPrice(30)
    assert ol.taxless_total_discount == TaxlessPrice(50)
    assert ol.taxless_total_price == TaxlessPrice(5 * 30 - 50)
    ol.taxes.add(OrderLineTax.from_tax(get_default_tax(), ol.taxless_total_price))
    assert ol.taxless_total_discount == TaxlessPrice(50)
    assert ol.taxful_total_discount == TaxfulPrice(75)
    assert ol.taxless_total_price == TaxlessPrice(100)
    assert ol.taxful_total_price == TaxfulPrice(150)
    assert ol.taxless_unit_price == TaxlessPrice(30)
    assert ol.taxful_unit_price == TaxfulPrice(45)
开发者ID:charn,项目名称:shoop,代码行数:20,代码来源:test_orders.py

示例4: test_line_discount

# 需要导入模块: from shoop.core.models import OrderLine [as 别名]
# 或者: from shoop.core.models.OrderLine import unit_price [as 别名]
def test_line_discount():
    order = create_empty_order()
    order.save()
    ol = OrderLine(
        order=order,
        type=OrderLineType.OTHER,
        quantity=5,
        text="Thing"
    )
    ol.total_discount = TaxlessPrice(50)
    ol.unit_price = TaxlessPrice(40)
    ol.save()
    ol.taxes.add(OrderLineTax.from_tax(get_default_tax(), ol.taxless_total_price))
    assert ol.taxless_total_discount == TaxlessPrice(50)
    assert ol.taxful_total_discount == TaxfulPrice(75)
    assert ol.taxless_total_price == TaxlessPrice(150)
    assert ol.taxful_total_price == TaxfulPrice(150 + 75)
    assert ol.taxless_unit_price == TaxlessPrice(40)
    assert ol.taxful_unit_price == TaxfulPrice(60)
    assert "Thing" in six.text_type(ol)
开发者ID:charn,项目名称:shoop,代码行数:22,代码来源:test_orders.py

示例5: source_line_to_order_lines

# 需要导入模块: from shoop.core.models import OrderLine [as 别名]
# 或者: from shoop.core.models.OrderLine import unit_price [as 别名]
    def source_line_to_order_lines(self, order, source_line):
        """
        Convert a SourceLine into one or more OrderLines (yield them)
        :param order: The order
        :param source_line: The SourceLine
        """
        order_line = OrderLine(order=order)
        product = source_line.product
        quantity = Decimal(source_line.quantity)
        if product:
            order_line.product = product
            if product.sales_unit:
                quantized_quantity = bankers_round(quantity, product.sales_unit.decimals)
                if quantized_quantity != quantity:
                    raise ValueError("Sales unit decimal conversion causes precision loss!")
        else:
            order_line.product = None

        def text(value):
            return force_text(value) if value is not None else ""

        order_line.quantity = quantity
        order_line.supplier = source_line.supplier
        order_line.sku = text(source_line.sku)
        order_line.text = (text(source_line.text))[:192]
        if source_line.unit_price:
            order_line.unit_price = source_line.unit_price
        if source_line.total_discount:
            order_line.total_discount = source_line.total_discount
        order_line.type = (source_line.type if source_line.type is not None
                           else OrderLineType.OTHER)
        order_line.accounting_identifier = text(source_line.accounting_identifier)
        order_line.require_verification = bool(source_line.require_verification)
        order_line.verified = False
        order_line.source_line = source_line
        self._check_orderability(order_line)

        yield order_line

        for child_order_line in self.create_package_children(order_line):
            yield child_order_line
开发者ID:charn,项目名称:shoop,代码行数:43,代码来源:creator.py


注:本文中的shoop.core.models.OrderLine.unit_price方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。