Esempio n. 1
0
def taxed_discount_line_total(cartitem, discount):
    """Returns the discounted line total for this cart item with taxes included."""
    price = discount_line_total(cartitem, discount)
    taxer = satchmo_tax._get_taxprocessor()
    price = price + taxer.by_price(cartitem.product.taxClass, price)
    
    return price
Esempio n. 2
0
def taxed_discount_price(product, discount):
    """Returns the product price with the discount applied, and taxes included.
    
    Ex: product|discount_price:sale
    """
    price = discount_price(product, discount)
    taxer = satchmo_tax._get_taxprocessor()
    price = price + taxer.by_price(product.taxClass, price)
Esempio n. 3
0
def _get_shipping_choices(request,
                          paymentmodule,
                          cart,
                          contact,
                          default_view_tax=False):
    """Iterate through legal shipping modules, building the list for display to the user.

    Returns the shipping choices list, along with a dictionary of shipping choices, useful
    for building javascript that operates on shipping choices.
    """
    shipping_options = []
    shipping_dict = {}

    if not cart.is_shippable:
        methods = [
            shipping_method_by_key('NoShipping'),
        ]
    else:
        methods = shipping_methods()

    valid_methods = []
    for method in methods:
        method.calculate(cart, contact)
        if method.valid():
            valid_methods.append((method, method.cost()))

    # sort methods by cost
    valid_methods.sort(key=lambda method_cost: int(method_cost[1]))

    for method, shipcost in valid_methods:
        template = lookup_template(paymentmodule, 'shipping_options.html')
        t = loader.get_template(template)
        shipping_tax = None
        taxed_shipping_price = None
        if config_value('TAX', 'TAX_SHIPPING'):
            shipping_tax = config_value('TAX', 'TAX_CLASS')
            taxer = _get_taxprocessor(request)
            total = shipcost + taxer.by_price(shipping_tax, shipcost)
            taxed_shipping_price = money_format(total)

        data = {
            'amount': shipcost,
            'description': method.description(),
            'method': method.method(),
            'expected_delivery': method.expectedDelivery(),
            'default_view_tax': default_view_tax,
            'shipping_tax': shipping_tax,
            'taxed_shipping_price': taxed_shipping_price
        }

        if hasattr(method, 'shipping_discount'):
            data['discount'] = method.shipping_discount()

        c = RequestContext(request, data)
        shipping_options.append((method.id, t.render(c)))
        shipping_dict[method.id] = shipcost

    return shipping_options, shipping_dict
Esempio n. 4
0
def _get_shipping_choices(request,
                          paymentmodule,
                          cart,
                          contact,
                          default_view_tax=False):
    """Iterate through legal shipping modules, building the list for display to the user.

    Returns the shipping choices list, along with a dictionary of shipping choices, useful
    for building javascript that operates on shipping choices.
    """
    shipping_options = []
    shipping_dict = {}

    if not cart.is_shippable:
        methods = [shipping_method_by_key("NoShipping")]
    else:
        methods = shipping_methods()

    valid_methods = []
    for method in methods:
        method.calculate(cart, contact)
        if method.valid():
            valid_methods.append((method, method.cost()))

    # sort methods by cost
    valid_methods.sort(key=lambda method_cost: int(method_cost[1]))

    for method, shipcost in valid_methods:
        template = lookup_template(paymentmodule, "shipping_options.html")
        t = loader.get_template(template)
        shipping_tax = None
        taxed_shipping_price = None
        if config_value("TAX", "TAX_SHIPPING"):
            shipping_tax = config_value("TAX", "TAX_CLASS")
            taxer = _get_taxprocessor(request)
            total = shipcost + taxer.by_price(shipping_tax, shipcost)

            currency_code = currency_for_request(request)
            taxed_shipping_price = money_format(total, currency_code)

        data = {
            "amount": shipcost,
            "description": method.description(),
            "method": method.method(),
            "expected_delivery": method.expectedDelivery(),
            "default_view_tax": default_view_tax,
            "shipping_tax": shipping_tax,
            "taxed_shipping_price": taxed_shipping_price,
        }

        if hasattr(method, "shipping_discount"):
            data["discount"] = method.shipping_discount()

        shipping_options.append((method.id, t.render(data)))
        shipping_dict[method.id] = shipcost

    return shipping_options, shipping_dict
Esempio n. 5
0
def _get_shipping_choices(
    request, paymentmodule, cart, contact, default_view_tax=False
):
    """Iterate through legal shipping modules, building the list for display to the user.

    Returns the shipping choices list, along with a dictionary of shipping choices, useful
    for building javascript that operates on shipping choices.
    """
    shipping_options = []
    shipping_dict = {}

    if not cart.is_shippable:
        methods = [shipping_method_by_key("NoShipping")]
    else:
        methods = shipping_methods()

    valid_methods = []
    for method in methods:
        method.calculate(cart, contact)
        if method.valid():
            valid_methods.append((method, method.cost()))

    # sort methods by cost
    valid_methods.sort(key=lambda method_cost: int(method_cost[1]))

    for method, shipcost in valid_methods:
        template = lookup_template(paymentmodule, "shipping_options.html")
        t = loader.get_template(template)
        shipping_tax = None
        taxed_shipping_price = None
        if config_value("TAX", "TAX_SHIPPING"):
            shipping_tax = config_value("TAX", "TAX_CLASS")
            taxer = _get_taxprocessor(request)
            total = shipcost + taxer.by_price(shipping_tax, shipcost)

            currency_code = currency_for_request(request)
            taxed_shipping_price = money_format(total, currency_code)

        data = {
            "amount": shipcost,
            "description": method.description(),
            "method": method.method(),
            "expected_delivery": method.expectedDelivery(),
            "default_view_tax": default_view_tax,
            "shipping_tax": shipping_tax,
            "taxed_shipping_price": taxed_shipping_price,
        }

        if hasattr(method, "shipping_discount"):
            data["discount"] = method.shipping_discount()

        shipping_options.append((method.id, t.render(data)))
        shipping_dict[method.id] = shipcost

    return shipping_options, shipping_dict
Esempio n. 6
0
def _get_shipping_choices(request, paymentmodule, cart, contact, default_view_tax=False):
    """Iterate through legal shipping modules, building the list for display to the user.

    Returns the shipping choices list, along with a dictionary of shipping choices, useful
    for building javascript that operates on shipping choices.
    """
    shipping_options = []
    shipping_dict = {}

    if not cart.is_shippable:
        methods = [shipping_method_by_key('NoShipping'), ]
    else:
        methods = shipping_methods()

    valid_methods = []
    for method in methods:
        method.calculate(cart, contact)
        if method.valid():
            valid_methods.append((method, method.cost()))

    # sort methods by cost
    valid_methods.sort(key=lambda method_cost: int(method_cost[1]))

    for method, shipcost in valid_methods:
        template = lookup_template(paymentmodule, 'shipping_options.html')
        t = loader.get_template(template)
        shipping_tax = None
        taxed_shipping_price = None
        if config_value('TAX', 'TAX_SHIPPING'):
            shipping_tax = config_value('TAX', 'TAX_CLASS')
            taxer = _get_taxprocessor(request)
            total = shipcost + taxer.by_price(shipping_tax, shipcost)
            taxed_shipping_price = money_format(total)

        data = {
            'amount': shipcost,
            'description': method.description(),
            'method': method.method(),
            'expected_delivery': method.expectedDelivery(),
            'default_view_tax': default_view_tax,
            'shipping_tax': shipping_tax,
            'taxed_shipping_price': taxed_shipping_price
        }

        if hasattr(method, 'shipping_discount'):
            data['discount'] = method.shipping_discount()

        c = RequestContext(request, data)
        shipping_options.append((method.id, t.render(c)))
        shipping_dict[method.id] = shipcost

    return shipping_options, shipping_dict
Esempio n. 7
0
def taxed_sale_price(product):
    """Returns the product unit price with the best auto discount applied and taxes included."""
    taxer = satchmo_tax._get_taxprocessor()
    price = sale_price(product)
    price = price + taxer.by_price(product.taxClass, price)
    return price