We are trying to convert a successfully completed Cart using _orderRepository.SaveAsPurchaseOrder(orderGroup);
We have a number of custom meta fields, such as a Money field which is currently used in a few place but when trying to convert we are getting the following error that seems to be related to our value VatAmount which is the Money field
"Value of VatAmount is £36.03, of type Mediachase.Commerce.Money but should be a System.Decimal or a System.String\r\nParameter name: value"
at Mediachase.MetaDataPlus.Configurator.MetaDataTypes.GetDatabaseValueDecimal(Object value, String metaFieldName)
at Mediachase.MetaDataPlus.MetaObject.GetMetaObjectUpdateParameters(MetaDataContext context)
at Mediachase.MetaDataPlus.MetaObject.AcceptChanges(MetaDataContext context)
at Mediachase.Commerce.Storage.MetaStorageBase.AcceptChanges(MetaDataContext context, Boolean saveSystem)
at EPiServer.Commerce.Order.PurchaseOrderProvider.Save(IPurchaseOrder purchaseOrder)
at EPiServer.Commerce.Order.Internal.SerializableCartProvider.SaveAsPurchaseOrder(ICart cart)
at EPiServer.Commerce.Order.DefaultOrderRepository.SaveAsPurchaseOrder(IOrderGroup orderGroup)
at Redweb.Sja.Commerce.Business.OrderProcessor.DefaultOrderProcessor.CompletedOrderToPurchaseOrder(IOrderGroup orderGroup) in C:\Projects\SJA\Base\Redweb.DotNet.EpiServer.Base\src\Redweb.Sja.Commerce.Business\OrderProcessor\DefaultOrderProcessor.cs:line 253
at Redweb.Sja.Commerce.Business.Basket.DefaultBasketManager.PlaceOrderOnAccount(ICart cart, BasketType basketType) in C:\Projects\SJA\Base\Redweb.DotNet.EpiServer.Base\src\Redweb.Sja.Commerce.Business\Basket\DefaultBasketManager.cs:line 1077
I've checked just before calling it and it looks like this value was on on of the LineItem Extended MetaClass but I can't seem to find anything out about what's going on and it's really causing me some issues.
Can anyone help resolve this?
You can not use Money object in in default Purchase Order as there is no matching MetaField type, you would need to use just the decimal value. If you want the currency as well you would need to add another field for that on the LineItem.
Thanks for the update, I guess that much and have literally just refactored it and am about to test. It's dissapointing, we've found nothing to say you can't use the Money Meta Type and it works for all cart :-(.
It only works for SerilazbleCarts and not the old cart system which is the same as the default purchase order system. There is a money meta field type but that is the money data type in Sql Server.
I think after commerce 12 and the new csr tool on the horizon, creating a custom purchase order provider like the serialzable carts would allow you to do what you want to do and still be able to manage the purchase orders in the user interface
That would be good, I guess the problem is this is our first commerce build so I've only been working with the serialzable carts and wasn't aware at first that the PO wasn't stored the same way until I started digging in to the decompiled source. Thanks again
Thanks Quan, I've just trying to work out a few bits on our first purchase order convert. I've got it working now but at the moment I'm faced with 2 issues
Only just coming to these bits tho
We need your code before saying anything meaningful, it sounds like you might have missed a method call here and there
At the moment we're just following Quicksilver, I may need to re-run the validation methods as there aren't being called after the PO completion at a guess or we aren't setting the right status (currently set to completed as we aren't using the warehouse features), but for the purcahse order I would have thought whatever we had set as the delivery address on the SerializbleCart would be copied automatically in to the PuchaseOrder during the SaveAsPuchaseOrder. I would find it odd that I would have to manually close these over when everything else seems to be being cloned.
I've only just started looking yesterday so hopefully I can nail it, on the plus when I set an address manually in the PO after the totals are calculating correctly for the PO. I think a tricky part is yes there's quick silver to follow but the documentation world seems a bit lacking with how the PO conversion process works. I'll keep plugging along