Coming soon: Your brand new Help Center & Community! Get a sneak-peek here

GetDiscountPercent() on QuoteAlternative gives wrong decimal precision?

Hi, 

I've got a weird case where I use the QuoteAgent to get the discount perfent given on a quotealternative. The problem is that the DiscountPercent method on the QuoteAlternative gives wrong decimal precision - but only in production, not in test.

I'm using CRMScript, but assume I would have gotten same issue had I used same classes/methods via C#.

The problem can be visualized using this CRMScript:

Integer quoteAlternativeId = 341;

NSQuoteAgent qa;
NSQuoteAlternative alt = qa.GetQuoteAlternative(quoteAlternativeId);
printLine("From NSQuoteAlternative: " + alt.GetDiscountPercent().toString(8));

SearchEngine se;
se.addField("QuoteAlternative.DiscountPercent");
se.addCriteria("QuoteAlternative.quotealternative_id", "equals", quoteAlternativeId.toString());
for (se.execute(); !se.eof(); se.next())
  printLine("From SearchEngine: " + se.getField("QuoteAlternative.DiscountPercent"));

When I use the GetDiscountPercent on the NSQuoteAlternative I get one answer, and if I look up the value in the database directly using SearchEngine I get different answer:

The weird thing is that in the TEST environment I get the correct precision when using same script.

What could cause GetDiscountPercent to round off the discount like that? Is there a setting somewhere for this?

 

RE: GetDiscountPercent() on QuoteAlternative gives wrong decimal precision?

Both Test and Prod is using version SuperOffice 8.2 Build Release82_C-2018.03.09-05.

Af: Frode Lillerud 1. nov 2018

RE: GetDiscountPercent() on QuoteAlternative gives wrong decimal precision?

Hello Frode,

Are you maybe using a Custom Quote Connector which isn't there in TEST? Tried your example on both our own PROD and TEST, both return discount without rounding (it is version 8.4 R2 though...)

Af: David Hollegien 1. nov 2018

RE: GetDiscountPercent() on QuoteAlternative gives wrong decimal precision?

Hi David, I've doublechecked now, but they are not using any custom Quote connector. I thought that perhaps an old SuperOffice connector could be left behind from an upgrade, but no, everything is standard.

Af: Frode Lillerud 2. nov 2018

RE: GetDiscountPercent() on QuoteAlternative gives wrong decimal precision?

Just a thought...
Might it be ToString() ?
/conrad

Af: Conrad Weyns 2. nov 2018

RE: GetDiscountPercent() on QuoteAlternative gives wrong decimal precision?

Hi Conrad,

no, the .toString(8) is correct. That is CRMScript for getting a float as string with 8 decimals. The same script works fine when copied over to the test-environment, so the problem is with the environment somewhere...

Af: Frode Lillerud 3. nov 2018