DavidAJohn / PhotoPortfolio

Personal photo portfolio .NET web application which implements a Blazor and Tailwind CSS user interface with a MongoDb database, and includes integration with Stripe Checkout and Prodigi Print API
0 stars 1 forks source link

Checkout Success total decimal points #56

Closed DavidAJohn closed 1 year ago

DavidAJohn commented 1 year ago

The Checkout Success page is showing the order total to three decimal places (ie. £30.000).

Obviously, it should always be just two decimal places.

DavidAJohn commented 1 year ago

For the recent test orders I created, the ItemsCost and the TotalCost have both been stored in the database with three decimal places. The Shipping Cost is still being stored with two, despite all of them being the same Decimal128 type.

So there are two issues:

First, the database should be storing costs with two decimal places. Why has that suddenly stopped happening?

Second, pages that display costs need to check that only two decimal places are shown, regardless of what's stored in the database.

DavidAJohn commented 1 year ago

It's difficult to say where the extra decimal place has come from. It's not the Mongo drivers, because they were last updated in early June 2023 and I have several test orders created after that which don't have the third decimal place.

Regardless, I think it needs a belt and braces approach:

We're never going to lose anything in the rounding, because the costs are only ever returned in a Prodigi quote to two decimal places anyway.