Creating new prices with IPriceDetailService removes decimals



I feel like i'm missing something obvious here. I'm trying to insert a price of 8.12 DKK, but when saving to the database the value changes to 8.00 DKK.

I then create the price using:

var variant = (from method overload - not null)
var currentMarket = ServiceLocator.Current.GetInstance();

var priceValue = new PriceDetailValue {
					CatalogKey = new CatalogKey(AppContext.Current.ApplicationId, variant.Code),
					CustomerPricing = CustomerPricing.AllCustomers,
					MarketId = currentMarket.GetCurrentMarket().MarketId,
					MinQuantity = 1,
					ValidFrom = DateTime.Now,
					ValidUntil = DateTime.Now.AddDays(10),
					UnitPrice = new Money(new decimal(8.12), "DKK")


The market has DKK and EUR as active currencies.

Any help would be greatly appreciated.

Best Regards
Morten Kristensen

Dec 15, 2014 12:35

Oh, and for the record: I'm using EPiServer Commerce 8.5 (build 0)

Dec 15, 2014 12:37


Did you tried with

UnitPrice = new Money(8.12m, "DKK") instead?


Edited, Dec 16, 2014 1:24

No luck - same result with shorthand decimal :o(

The code above is an extract of a Unit Test of the method i use to (dynamically) insert prices. The method containing the code receives a decimal UnitPrice (and Currency string).

Dec 16, 2014 9:01


Can you check if the price stored in database was correct? It should be in PriceDetail table.

The price is stored as Money, which should keep the precision of ten-thousandth. As we have intensive tests in this area then I'm pretty sure that we did it right.



Dec 16, 2014 9:18

The value is inserted as 8.00 DKK in the PriceDetail table.

I'm sure you did it right, but in my case it's not behaving as expected (and yes, Money data type allows 4 decimals, the EPiServer UI/API however supports only 2 decimals in practice - but thats beside the point).
I am however having a hard time debugging from the point of the .Save() of IPriceDetailService.

Dec 16, 2014 9:28


What if you use the Catalog UI to edit prices? Are them saved properly?


Dec 16, 2014 9:40

Yes, the UI saves the prices as expected (entering 8,12 - note the comma) saves the price as 8.12 DKK.

Could it be related to the different decimal mark i'm wondering (even though the actual decimal inserted through the API is 8.12)?

Dec 16, 2014 9:47

Might be - logically it's weird if .NET simply parse 8.12 as 8.0 if the current culture uses , as the decimal parameter - but it won't hurt to test with 8.12, right? ;)



Dec 16, 2014 9:56

Well, the EPiServer Catalog UI changes the price to 8.00 if i enter 8.12 and press enter :o)

I have no clue what to try next though :o/ 

Dec 16, 2014 10:03

It might sound stupid but make sure you don't have custom implementation of IPriceDetailService. The default implentation use ecf_PriceDetail_Save stored procedure, which is quite straighforward and no convert/truncating should happen.

If this issue is serious enough - I suggest to contact our support service for proper investigation. 



Dec 16, 2014 10:25

Nope, I'm not using a custom implementation (but considering doing so - would prefer not to though). The ecf_PriceDetail_Save procedure is used in this case also (tried renaming it to make sure it failed).

I will make some further attempts and contact support service if necessary. Thanks for the effort though Quan - greatly appreciated :o)

Dec 16, 2014 10:51

Oh and by the way, i can resolve the issue by (and this is a temporary workaround):

1. Save the price as described above.
2. Get the price i just created using IPriceDetailService.Get()
3. Invoke new PriceDetailValue(priceJustCreated)
4. Set the price again.
5. Save yet again.

Just in case anyone else needs a workaround.

I'm opening an issue in with support service :o)

Dec 16, 2014 11:02
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.