#95 Discount not deducting correct amount

v3.56
wont-fix
nobody
None
3
2014-08-10
2014-01-17
Robert Malsbury
No

The Line and/or possibly the total discount functions are not returning a accurate value.

If I ring up a item for 20.00 then add a 10% discount it works fine and takes off 2.00 for a discounted price of 18.00.

If I ring up a item for 19.99 and then add a 10% discount. Instead of deducting 1.99 off the price and returning the new price of 18.00, it deducts 2.00 off the price and the new price is 17.99.

I have checked the script.totaldiscount and it contains the line that is supposed to fix this problem that I have seen in other posts on http://sourceforge.net/p/unicentaopos/bugs/54/

To reproduce
Scan item for 19.99
Add discount % of 10 (script.linediscount or script.totaldiscount)
program takes off 2.00 instead of 1.99

import com.openbravo.format.Formats;
import com.openbravo.pos.ticket.TicketLineInfo;
import com.openbravo.pos.ticket.TicketProductInfo; 

discountrate = 1 - (sales.getInputValue() / 100.0);

index = sales.getSelectedIndex();
if (index >= 0) {
    if (ticket.getTotal() > 0.0 && discountrate > 0.0) {

        sdiscount = Formats.PERCENT.formatValue((1-discountrate));

for (int number= 0; number < ticket.getLinesCount(); number++) {

    line = ticket.getLine(number);
        ticket.setLine(number,
            new TicketLineInfo(
                    line.getProductID(),
                    line.getProductName() + " -" + sdiscount,
                    line.getProductTaxCategoryID(),
                    line.getMultiply(),
                    (double)Math.round(line.getPrice() * discountrate * 100) / 100,
                    line.getTaxInfo()));
    }  
} else {  
    java.awt.Toolkit.getDefaultToolkit().beep();  
}
} else {
    java.awt.Toolkit.getDefaultToolkit().beep();
}

Discussion

  • uniCenta
    uniCenta
    2014-07-31

    • status: open --> wont-fix