Wrong taxed_discount_saved and taxed price before discount if DEFAULT_VIEW_TAX = true and discount

Issue #1315 new
Former user created an issue

I found 2 bugs in satchmo code:

  1. Fist one is in function taxed_discount_saved from satchmo/apps/product/templatetags/satchmo_discounts.py

In case you use DEFAULT_VIEW_TAX = true, function taxed_discount_saved will show wrong value. It is because there is used product.unit_price (which is price without tax) minus taxed_discount_price (discounted price include tax)

Wrong code: {{{ price = product.unit_price }}}

should be replaced by: {{{ price = taxed_discount_price(product, "") }}}

So final correct code of function is: {{{ def taxed_discount_saved(product, discount): """Returns the amount saved by the discount, after applying taxes."""

if discount and discount.valid_for_product(product):
    #price = product.unit_price #fixed by Qk
    price = taxed_discount_price(product, "")
    discounted = taxed_discount_price(product, discount)
    saved = price - discounted
    cents = Decimal("0.01")
    return saved.quantize(cents)
    return Decimal('0.00')

register.filter('taxed_discount_saved', taxed_discount_saved) }}}

  1. Second bug is in satchmo/apps/satchmo_store/shop/templates/shop/cart.html template and is similar to previous bug. Line:

{{{ {% if sale %}<td align="center">{{ cartitem.product.unit_price|currency }}</td>{% endif %} }}}

should return price before discount, but in case DEFAULT_VIEW_TAX = true it doesn't work correctly because it shows price without tax and all other prices are include tax

Corrected line is: {{{ {% if sale %}<td align="center">{{ cartitem.product|discount_price:""|currency }}</td>{% endif %} }}}

Comments (0)

  1. Log in to comment