Try our conversational search powered by Generative AI!

Error Converting To PO (11.8.2) with custom meta fields

Vote:
 

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 Mediachase.Commerce.Orders.LineItem.AcceptChanges()
   at Mediachase.Commerce.Storage.MetaStorageCollectionBase`1.AcceptChanges()
   at Mediachase.Commerce.Orders.OrderForm.AcceptChanges()
   at Mediachase.Commerce.Storage.MetaStorageCollectionBase`1.AcceptChanges()
   at Mediachase.Commerce.Orders.OrderGroup.AcceptChanges()
   at Mediachase.Commerce.Orders.PurchaseOrder.AcceptChanges()
   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?

#189976
Edited, Mar 28, 2018 15:52
Vote:
 

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.

#189982
Mar 28, 2018 17:55
Vote:
 

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 :-(. 

#189983
Mar 28, 2018 17:58
Vote:
 

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

#189984
Mar 28, 2018 18:07
Vote:
 

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

#189985
Mar 28, 2018 18:10
Vote:
 
<p>Note that for IOrderGroup already has Currency (and for OrderGroup, it's BillingCurrency). All other amounts in the order should be in decimal only as you already have the currency order-wise.</p> <p>Well, it's possible that you have more than one currencies per order, but the scenario seems unlikely.&nbsp;</p>
#189992
Mar 28, 2018 20:52
Vote:
 

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

  1. The billing address isn't being copied over
  2. The inventory says "Assigned" in the PO but the inventory is the same in the catalogue.

Only just coming to these bits tho

#190009
Mar 29, 2018 10:08
Vote:
 

We need your code before saying anything meaningful, it sounds like you might have missed a method call here and there

#190010
Mar 29, 2018 10:36
Vote:
 

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

#190011
Mar 29, 2018 10:44
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.