Discount percentage is inconsistent: should it be 0--1, or 0--100?

Create issue
Issue #1371 open
Philip White created an issue

Satchmo's administrative interface has this to say about Discount Percentage: "Percents are given in whole numbers, and can be up to 100%."

So I enter 20. The discount appears to work correctly on the site.

Yet satchmo.log produces a dozen of these lines for every pageload: {{{ #!logfile

product.utils WARNING Correcting discount percentage, should be less than 1, is 20.00 }}}

I am running Satchmo tip on Python 2.7.2.

Comments (4)

  1. Hynek Cernoch

    This is probably a potentionally dangereous consequence of some old backward compatibility fix. (in product.utils.calc_discounted_by_percentage and product.templatetags.satchmo_discounts.discount_ratio)

    These functions convert discounts between 2% and 100% to the ratio between 0.02 and 1.00. The value 1% is very problematic. If a seller wants to give a discount 1%, it is interpreted the same as 100% and the result price would be zero!!

    Fortunately the code looks it is related only to:
    1) templatetags in satchmo_discounts
    2) javascript for product variations
    Everything related to Order totals and payment looks correct.

    I do not know an easy fix because I remember that I read something from a seller who expects discount 100% for himself be useful. However it is better to fix it, because it is easier to explain to some very very VIP customer that he will see somewhere 1% discount but he get finally 100%, than do it for many unknown users on the contrary total more expensive then items. It can be argued that discount 1% is not much frequent and much motivating but IMHO it should be fixed. Unfortunately, it would require to analyze also a code for free shipping (100% discount?) which is a common practice for big orders.

  2. Philip White reporter

    I don't understand why 1% is interpreted as 100%... seems like whether you allow a discount of 0--1 or 0--100, all cases are covered without doing any adjustments.

    Either way, it seems to me that my issue is more about the inconsistency of percentage-as-a-real vs percentage-as-an-integer rather than any corner case like you describe.

  3. Hynek Cernoch

    Read the code of calc_discounted_by_percentage (only 9 lines) which produces that warning and compare it with apply_percentage (only 7 nonempty lines). You will understand what I wrote and that you pointed to a more serious inconsistency problem for %1 and 100% discount, not only that warning.

    The function requires percentage 0 - 100%, but for calc_discounted_by_percentage is the parameter percentage=0.01 .. 1.00 the same as 1 .. 100 and it is problem whether the boundary 1 should mean 1% or 100% because either conversion is unacceptable.

    How to reproduce the error

    • Create a discount with percentage 2%, select "localhost", "active", "automatic", "all products", "apply the discount above to shipping", start 2011-01-01, end 2015-12-31 and other arbitrary meaningful values.
    • Display any product (/percent/neat-book/) and verify that you see price discounted by 2%
    • Change the discount to 1 %.
    • You will see the discounted price 0.00, also it is discounted by 100%. Everething in the cart is also with bad discount. Only the final order is calculated correctly.
  4. Log in to comment