Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decimals error? #165

Open
trouble2 opened this issue Mar 15, 2021 · 18 comments
Open

Decimals error? #165

trouble2 opened this issue Mar 15, 2021 · 18 comments
Labels

Comments

@trouble2
Copy link

I've entered 12,50 euro for some option, however in the cart it shows as 125,00.
In the totals it is calculating with the good value however:
So could something be wrong in:
@NBrightBuyUtils.FormatToStoreCurrency(nbiOpt.GetXmlPropertyDouble("option/optvalcost"))
image

@leedavi
Copy link
Collaborator

leedavi commented Mar 15, 2021

Yes, looks like a display issue with the option price. As a workaround for now I think you might be able to change the display format in the cart list template.

@leedavi leedavi added the bug label Mar 15, 2021
@trouble2
Copy link
Author

And how would I do that?

@leedavi
Copy link
Collaborator

leedavi commented Mar 15, 2021

not sure of the code off the top of my head.... but change...

@NBrightBuyUtils.FormatToStoreCurrency(nbiOpt.GetXmlPropertyDouble("option/optvalcost"))

to something like this...

@nbiOpt.GetXmlPropertyDouble("option/optvalcost").ToString("C0")

Currency should be kept in a Decimal, legacy code has it as a double and it causes a lot of issues and time to get it correctly formatted. But there are lots of formatting options https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings?redirectedfrom=MSDN#CFormatString

In OpenStore we have to support many currency formats, including the french who have a format "5,89" and decide to enter in the keypad "5.89". We've had to do some JS and code to help these situations. Maybe we're missing something on the money input field.

@trouble2
Copy link
Author

Nope, that didn't solve it, there is def. something in the code that needs fixing, this is on the productdetail page:

image

And this is on the cartlist template:
image

So whenever the amount is a whole number, like 35 everything is ok, when the amount is something like 12,50 it will show 125
Tried several things:
@nbiOpt.GetXmlPropertyDouble("option/optvalcost").ToString()
@nbiOpt.GetXmlProperty("option/optvalcost").ToString()
@nbiOpt.GetXmlPropertyDouble("option/optvalcost").ToString("F2")
@nbiOpt.GetXmlPropertyDouble("option/optvalcost").ToString("F")
@nbiOpt.GetXmlPropertyDouble("option/optvalcost").ToString("C0")

@trouble2
Copy link
Author

trouble2 commented Mar 16, 2021

The xml is correct though, and the calculations on the total also.
So it is something in the GetXMLProperty (Double) I guess....

<optionvalues optionid="I35OCtZf"> <genxml> <files /> <hidden> <optionid>I35OCtZf</optionid> <optionvalueid>JMgf8npJ</optionvalueid> </hidden> <textbox> <txtaddedcost datatype="double">12.5</txtaddedcost> </textbox> <checkbox /> <dropdownlist /> <checkboxlist /> <radiobuttonlist /> </genxml> </optionvalues> <optionvalues optionid="lifbDOnk"> <genxml> <files /> <hidden> <optionid>lifbDOnk</optionid> <optionvalueid>DListlLm</optionvalueid> </hidden> <textbox> <txtaddedcost datatype="double">35</txtaddedcost> </textbox> <checkbox /> <dropdownlist /> <checkboxlist /> <radiobuttonlist /> </genxml> </optionvalues>

@leedavi
Copy link
Collaborator

leedavi commented Mar 16, 2021

Here is my dev system... look OK???
image

The is the default ClassicAjax Theme.

@leedavi
Copy link
Collaborator

leedavi commented Mar 16, 2021

image

@trouble2
Copy link
Author

Ok...so what could it be then? Is it the same code:
@nbiOpt.GetXmlPropertyDouble("option/optvalcost")

Could it be some culture setting in DNN or something?

@leedavi
Copy link
Collaborator

leedavi commented Mar 16, 2021

This is in French... maybe something to do with language. try a test system in French and see if it works.

@leedavi
Copy link
Collaborator

leedavi commented Mar 16, 2021

I think it is this...

        @if (@product.Options.Count >= 1)
        {
            <div class="options">@ProductOptions(product)</div>
        }

Not what you are formatting with.

@trouble2
Copy link
Author

trouble2 commented Mar 16, 2021

Yes, that is the part on the detailpage which is working fine.
But I mean in cartlist which displays the 125 instead of 12,50

@NBrightBuyUtils.FormatToStoreCurrency(nbiOpt.GetXmlPropertyDouble("option/optvalcost"))

@trouble2
Copy link
Author

trouble2 commented Mar 16, 2021

Hmm....when I look in the order it shows this:
<option>
<optid>FUTRWNRq</optid>
<optvalueid>True</optvalueid>
<optname>Verwijderingsbijdrage accu</optname>
<optvalcost datatype="double">125</optvalcost>
<optvaltext />
<optvaltotal datatype="double">12.5</optvaltotal>
</option>

@trouble2
Copy link
Author

See the difference between optvalcost and optvaltotal

@leedavi
Copy link
Collaborator

leedavi commented Mar 16, 2021

Ah!! Sorry, your using OpenStore v3 (NBrightBuy), I only just noticed. Sorry we have stopped development on this. I'm unsure of the fix, look at OpenStore for a solution, it seems to work in there. https://github.com/openstore-ecommerce/OpenStore

@trouble2
Copy link
Author

Nope , we're using 4.1.4

@leedavi
Copy link
Collaborator

leedavi commented Mar 17, 2021

OK. Here you put it on the v3 of OpenStore. You should use this forum.

https://github.com/openstore-ecommerce/OpenStore/discussions

But never mind. The answer I put above is still valid if you use v4. Have a look at the default templates and see what the difference is.

@trouble2
Copy link
Author

Yes, well did you see the xml?
So when I change:
@NBrightBuyUtils.FormatToStoreCurrency((nbiOpt.GetXmlPropertyDouble("option/optvalcost")))

to
@NBrightBuyUtils.FormatToStoreCurrency((nbiOpt.GetXmlPropertyDouble("option/optvaltotal")))

it shows the correct 12,50 instead of 125

@leedavi
Copy link
Collaborator

leedavi commented Mar 21, 2021

Sorry, missed the email.

OK, so you think it should be "optvaltotal" for all templates? It's strange it works for me.

        <option>
          <optid>QEdTFc3V</optid>
          <optvalueid>True</optvalueid>
          <optname>2222222222</optname>
          <optvalcost datatype="double">2.3</optvalcost>
          <optvaltext>qqqq</optvaltext>
          <optvaltotal datatype="double">2.3</optvaltotal>
        </option>

I cannot remember the code for this changing for a long time.
What version is OpenStore ?
Did you import the data?
Try a few other tests and see if you can re-create the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants