コード例 #1
0
def add_product_to_order(order,
                         supplier,
                         product,
                         quantity,
                         taxless_base_unit_price,
                         tax_rate=0,
                         pricing_context=None):
    if not pricing_context:
        pricing_context = _get_pricing_context(order.shop, order.customer)
    product_order_line = OrderLine(order=order)
    update_order_line_from_product(pricing_context,
                                   order_line=product_order_line,
                                   product=product,
                                   quantity=quantity,
                                   supplier=supplier)
    base_unit_price = order.shop.create_price(taxless_base_unit_price)
    if order.prices_include_tax:
        base_unit_price *= (1 + tax_rate)
    product_order_line.base_unit_price = order.shop.create_price(
        base_unit_price)
    product_order_line.save()

    taxes = [get_test_tax(tax_rate)]
    price = quantity * base_unit_price
    taxed_price = stacked_value_added_taxes(price, taxes)
    order_line_tax = OrderLineTax.from_tax(
        taxes[0],
        taxed_price.taxless.amount,
        order_line=product_order_line,
    )
    order_line_tax.save(
    )  # Save order line tax before linking to order_line.taxes
    product_order_line.taxes.add(order_line_tax)
コード例 #2
0
 def get_taxed_price(self, context, price, tax_class):
     taxes = []
     if context.postal_code == "92602":
         taxes = [
             # Based on data from TaxJar
             get_tax("CA", "California", rate="0.065"),
             get_tax("CA-OC", "Orange County", rate="0.01"),
             get_tax("CA-OC-IR", "Irvine", rate="0.00"),
             get_tax("CA-OC-IR-DS", "District tax", rate="0.005"),
         ]
     return stacked_value_added_taxes(price, taxes)
コード例 #3
0
ファイル: test_tax_system.py プロジェクト: ruqaiya/shuup
 def get_taxed_price(self, context, price, tax_class):
     taxes = []
     if context.postal_code == "92602":
         taxes = [
             # Based on data from TaxJar
             get_tax("CA", "California", rate="0.065"),
             get_tax("CA-OC", "Orange County", rate="0.01"),
             get_tax("CA-OC-IR", "Irvine", rate="0.00"),
             get_tax("CA-OC-IR-DS", "District tax", rate="0.005"),
         ]
     return stacked_value_added_taxes(price, taxes)
コード例 #4
0
ファイル: factories.py プロジェクト: suutari-ai/shuup
def add_product_to_order(order, supplier, product, quantity, taxless_base_unit_price, tax_rate=0, pricing_context=None):
    if not pricing_context:
        pricing_context = _get_pricing_context(order.shop, order.customer)
    product_order_line = OrderLine(order=order)
    update_order_line_from_product(pricing_context,
                                   order_line=product_order_line,
                                   product=product, quantity=quantity,
                                   supplier=supplier)
    base_unit_price = order.shop.create_price(taxless_base_unit_price)
    if order.prices_include_tax:
        base_unit_price *= (1 + tax_rate)
    product_order_line.base_unit_price = order.shop.create_price(base_unit_price)
    product_order_line.save()

    taxes = [get_test_tax(tax_rate)]
    price = quantity * base_unit_price
    taxed_price = stacked_value_added_taxes(price, taxes)
    order_line_tax = OrderLineTax.from_tax(
        taxes[0],
        taxed_price.taxless.amount,
        order_line=product_order_line,
    )
    order_line_tax.save()  # Save order line tax before linking to order_line.taxes
    product_order_line.taxes.add(order_line_tax)