Page 1 of 1

Sales Order Discount Percentage

PostPosted: Fri Aug 14, 2020 5:19 pm
by DannyC
Not sure how to describe this scenario but here goes. I can't duplicate it in Jiwa demo data.
When I enter a discount percentage on a sales order line say, 15% then save the sales order, the discount percentage changes to 15.01.

The line.DefaultPrice = 25.45 which is SellPriceExGST too.
The system setting DiscountPercentDecimalPlaces = 2

In the client database upon saving the disc% changes to 15.01 and is also written to the database SO_Lines.DiscountPercentage as 15.01.
The thing is, when you do the maths it doesn't really matter if the discount percent is 15.00 or 15.01. The line.DiscountedPrice ends up as $21.63 for both.

But in my JiwaDemo database if I set the Default Price of an item to 25.45 and add it to a sales order, then set the disc% to 15, when I save it stays as 15.00. That's is what is expected but doesn't happen like that in the client database.

I've written a plugin to see if the line.DiscountedPrice is different whether the discount percent has no decimals or some. If it'll be the same anyway and therefore makes diddly squat difference to the invoice value, I am writing to the database the ROUND(DiscountPercentage, 0) value, so in this case I'm writing 15.00 to the database.

So now, the SO_Lines.DiscountPercentage value = 15.00
But refreshing the sales order in Jiwa, the Discount Percentage still displays as 15.01.

Q1. What else might be a factor in understanding why the client behaviour is different to my Jiwa demo? I doubt there are any other plugins affecting - I am thinking it's some thing else.

Q2. Why would the sales order display the discount percentage as 15.01 even though the database value is 15.00? At a guess it's because 1-(21.63/25.45) =0.15009823 and that will round to 15.01 but that brings me to Q1 - why wouldn't 15.01 show in my Jiwa demo?

The end result which the client wants is not to have the hundredths but just the whole number as entered.

Both versions are 7.2.1 SR4.

Re: Sales Order Discount Percentage

PostPosted: Fri Aug 14, 2020 5:23 pm
by Scott.Pearce
Let's begin the troubleshooting process by setting DiscountPercentDecimalPlaces = 20 in both databases. Now tell me:

Client Disc % Vs JiwaDemo Disc % BEFORE SAVE
Client Disc % Vs JiwaDemo Disc % AFTER SAVE
Client Disc % Vs JiwaDemo Disc % IN DATABASE

Re: Sales Order Discount Percentage

PostPosted: Fri Aug 14, 2020 5:49 pm
by DannyC
15.00000000000000000000 v 15.00000000000000000000 BEFORE SAVE
15.00982318271119842829 v 15.00000000000000000000 AFTER SAVE
15.000000 v 15.000000 IN DATABASE

EDIT: Re-checked the client db before save. Confirmed its 15.00000000000000000000

Re: Sales Order Discount Percentage

PostPosted: Mon Aug 17, 2020 9:43 am
by Scott.Pearce
What is the value of the system setting "CompensateTaxRounding" in the client db Vs demo db?

Edit: Further thoughts - What is the SellPriceIsIncTax flag in client db vs demo db? Is there a debtor discount coming through that affects things? Also, you could do a SELECT * FROM SO_Lines WHERE InvoiceLineid = 'x' and compare the results from the client db against the demo db - this may provide a clue as to what values are different and thus causing the discount percentage to calculated differently. Even though discount percentage is stored in the database, it is always calculated when a line is added, modified, even read back in.

Re: Sales Order Discount Percentage

PostPosted: Mon Aug 17, 2020 3:07 pm
by DannyC
CompensateTaxRounding = ticked
SellPriceIsIncTax = not ticked

The various prices in the SO_Lines table are the same.

Re: Sales Order Discount Percentage  Topic is solved

PostPosted: Mon Aug 17, 2020 3:10 pm
by Scott.Pearce
So did you have CompensateTaxRounding ticked in the demo data as well?

Re: Sales Order Discount Percentage

PostPosted: Mon Aug 17, 2020 3:50 pm
by DannyC
So did you have CompensateTaxRounding ticked in the demo data as well?


Well, dang. No it wasn't. I guess I'll untick it in the client db too.

Re: Sales Order Discount Percentage

PostPosted: Mon Aug 17, 2020 4:08 pm
by Mike.Sheen
DannyC wrote:Well, dang. No it wasn't. I guess I'll untick it in the client db too.


Or you could turn it on in demo data instead, and they'll reconcile that way as well.