Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

Purchase Order's Line Item Quantity displayed in Commerce Manager UI is different from the database quantity.

Vote:
 

EPiServer Commerce Manager: v9.15

I have strange scenario wherein a purchase order with single line item is displaying a quantity of 1 in the Order Details tab > Line Items in Commerce Manager. 

In the database, that same line item has a quantity of 2. The correct quantity (i.e. we expect) is 1.

(I've used the ID of the said line item displayed on Commerce Manager Order Details tab and queried it against the [dbo].[LineItem] table).

We have custom reports that are pulling from the Order Form > Line Items via stored procedures and, as expected, the reports which, as you may expect, displays 2 as the quantity, thus, creating confusion to our clients. 

At this point, I'm not sure where Commerce Manager is pulling the quantity information from. Are there any other database tables I should check this or alternatives?

 

FYI: I've thought it's just caching so I've restarted the site and recycled the site application pool several times, but, to no avail.

Further Info (in case it helps):

The purchase order only has one order form which contains only a single item.

Before the cart got saved as purchase order (on the checkout), the quantity in the cart was updated from 2 to 1. All of the cart's logs point to having quantity of 1 until the payment and checkout phases.

Our site is hosted on load balanced servers.

 

#187060
Jan 11, 2018 3:03
Vote:
 

The underlying structure is a bit complicated. The lineitems belong to the orderform, and they are distributed to shipments via a collection of index-quantity map.

In your case I suspect the lineitem has quantity of 2, but the shipment containing it only has 1 distributed. another quantity is now "orphan".

It can be fixed like this

shipment.RemoveLineItemIndex(0);

shipment.AddLineItemIndex(0, 2);

shipment.AcceptChanges();

#187061
Jan 11, 2018 3:41
Vote:
 

Thank you for the quick reply, Quan Mai. 

I would need to manually edit that purchase order then based on your suggestions above.

I do have follow-up question, though.

As you mentioned: 

> "In your case I suspect the lineitem has quantity of 2, but the shipment containing it only has 1 distributed. another quantity is now "orphan"."

What normally causes the "orphan-ing of the shipment? Is it an issue on the index-quantity mapping?

I need to understand if it's somewhere in our code that caused this -- and if we need to add aditional steps in order to prevent this strange issue.

As I've mentioned, this only happened in only one purchase order.

#187063
Jan 11, 2018 4:28
Vote:
 

The main cause is usually an incorrect AddLineItemIndex call. If you only have one shipment, it might make senses to call the overload without the quantity parameter (which will add all quantity to the shipment)

#187071
Jan 11, 2018 10:01
* 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.