本文整理汇总了Python中shuup_tests.utils.basketish_order_source.BasketishOrderSource.get_total_tax_amount方法的典型用法代码示例。如果您正苦于以下问题:Python BasketishOrderSource.get_total_tax_amount方法的具体用法?Python BasketishOrderSource.get_total_tax_amount怎么用?Python BasketishOrderSource.get_total_tax_amount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shuup_tests.utils.basketish_order_source.BasketishOrderSource
的用法示例。
在下文中一共展示了BasketishOrderSource.get_total_tax_amount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_broken_order
# 需要导入模块: from shuup_tests.utils.basketish_order_source import BasketishOrderSource [as 别名]
# 或者: from shuup_tests.utils.basketish_order_source.BasketishOrderSource import get_total_tax_amount [as 别名]
def test_broken_order(admin_user):
"""
"""
quantities = [44, 23, 65]
expected = sum(quantities) * 50
expected_based_on = expected / 1.5
# Shuup is calculating taxes per line so there will be some "errors"
expected_based_on = ensure_decimal_places(Decimal("%s" % (expected_based_on + 0.01)))
shop = get_default_shop()
supplier = get_default_supplier()
product1 = create_product("simple-test-product1", shop, supplier, 50)
product2 = create_product("simple-test-product2", shop, supplier, 50)
product3 = create_product("simple-test-product3", shop, supplier, 50)
tax = get_default_tax()
source = BasketishOrderSource(get_default_shop())
billing_address = get_address(country="US")
shipping_address = get_address(name="Test street", country="US")
source.status = get_initial_order_status()
source.billing_address = billing_address
source.shipping_address = shipping_address
source.customer = create_random_person()
source.payment_method = get_default_payment_method()
source.shipping_method = get_default_shipping_method()
source.add_line(
type=OrderLineType.PRODUCT,
product=product1,
supplier=get_default_supplier(),
quantity=quantities[0],
base_unit_price=source.create_price(50),
)
source.add_line(
type=OrderLineType.PRODUCT,
product=product2,
supplier=get_default_supplier(),
quantity=quantities[1],
base_unit_price=source.create_price(50),
)
source.add_line(
type=OrderLineType.PRODUCT,
product=product3,
supplier=get_default_supplier(),
quantity=quantities[2],
base_unit_price=source.create_price(50),
)
currency = "EUR"
summary = source.get_tax_summary()
assert len(summary) == 1
summary = summary[0]
assert summary.taxful == Money(expected, "EUR")
assert summary.based_on == Money(expected_based_on, "EUR")
# originally non-rounded value
assert bankers_round(source.get_total_tax_amount()) == summary.tax_amount
assert source.taxless_total_price.value == expected_based_on
assert summary.taxful.value == source.taxful_total_price.value
assert summary.tax_amount == Money(bankers_round(source.taxful_total_price.value - source.taxless_total_price.value), currency)
assert summary.taxful == summary.raw_based_on + summary.tax_amount
assert summary.tax_rate == tax.rate
assert summary.taxful.value == (summary.based_on + summary.tax_amount).value - Decimal("%s" % 0.01)
# create order from basket
creator = OrderCreator()
order = creator.create_order(source)
assert order.taxless_total_price.value == expected_based_on
# originally non-rounded value
assert bankers_round(order.get_total_tax_amount()) == summary.tax_amount