Line item Placed Price is becoming zero

Vote:
 

Hi All,

I am facing a strange issue with my pruchase orders . 

Placed price is becmong zero for one of the line items in Purchase orders . 

Any suggestion to get ride of this issue will be appreciated. 

Purchase Order LineItems

#155325
Edited, Sep 14, 2016 8:54
Vote:
 

Hi,

Are you running some promotions which give items for free? Is the order form total still correct?

/Q

#155327
Sep 14, 2016 10:00
Vote:
 

Hello Quan,

We are not running any promotions. 

Orderfrom Toal is correct. 

Its not happening all the time . 

Regards

Phani

#155328
Sep 14, 2016 10:13
Vote:
 

Hi,

Do you have any customization on the workflows? 

Can you take a screenshot of the entire order detail (sensetive information can be blurred out, of course)

/Q

#155330
Sep 14, 2016 10:34
Vote:
 

Hello Quan,

Yes, we have some sort of custmisation for caluclation prices 

I have changed the code in OrderGroupActivityBase.Cs

protected Money? GetItemPrice(CatalogEntryDto.CatalogEntryRow entry, LineItem lineItem, CustomerContact customerContact)
{
List<CustomerPricing> customerPricing = new List<CustomerPricing>();
// customerPricing.Add(CustomerPricing.AllCustomers);



customerPricing.Add(new CustomerPricing(CustomerPricing.AllCustomers.PriceTypeId, "RRP"));
customerPricing.Add(new CustomerPricing(CustomerPricing.AllCustomers.PriceTypeId, "SP"));

if (customerContact != null)
{
var userKey = _mapUserKey.ToUserKey(customerContact.UserId);
if (userKey != null && !string.IsNullOrWhiteSpace(userKey.ToString()))
{
customerPricing.Add(new CustomerPricing(CustomerPricing.PriceType.UserName, userKey.ToString()));
}

if (!string.IsNullOrEmpty(customerContact.EffectiveCustomerGroup))
{
//ToDo: Phani Need to Validate the expiry date of Linen Lovers Group
customerPricing.Add(new CustomerPricing(CustomerPricing.PriceType.PriceGroup, customerContact.EffectiveCustomerGroup));
}
}

//To apply the Linen Lover Price
var cartHelper = new CartHelper(Orders.Cart.DefaultName);
var orderForm = cartHelper.Cart.OrderForms.FirstOrDefault();
try
{

if (orderForm != null)
{
var linenNumber = orderForm.GetString("LinenCardNumber");
var isLinenPriceApplicable =Convert.ToBoolean(orderForm.GetBool("IsLinenPriceApplicable"));
if (!string.IsNullOrEmpty(linenNumber) || isLinenPriceApplicable)
{
customerPricing.Add(new CustomerPricing(CustomerPricing.PriceType.PriceGroup, "Linen Lovers Club"));
}
}
}
catch (Exception ex)
{
_log.Error(ex.ToString());
}


IPriceService priceService = ServiceLocator.Current.GetInstance<IPriceService>();

PriceFilter priceFilter = new PriceFilter()
{
Currencies = new List<Currency>() { new Currency(lineItem.Parent.Parent.BillingCurrency) },
Quantity = lineItem.Quantity,
CustomerPricing = customerPricing,
ReturnCustomerPricing = false // just want one value
};
// Get the lowest price among all the prices matching the parameters
IPriceValue priceValue = priceService
.GetPrices(lineItem.Parent.Parent.MarketId, FrameworkContext.Current.CurrentDateTime, new CatalogKey(entry), priceFilter)
.OrderBy(pv => pv.UnitPrice)
.FirstOrDefault();

return priceValue?.UnitPrice;
}



#155331
Edited, Sep 14, 2016 10:42
Vote:
 

The picture is a bit small to my eyes :) 

What price configurations do you have for the free item? My theory is that your GetItemPrice might return 0 in some scenarios.

/Q

#155334
Sep 14, 2016 10:49
Vote:
 

Hi Quan,

Please note in my code I have mentioned the two custom prcing groups 

customerPricing.Add(new CustomerPricing(CustomerPricing.AllCustomers.PriceTypeId, "RRP"));
customerPricing.Add(new CustomerPricing(CustomerPricing.AllCustomers.PriceTypeId, "SP"));
and more over RRP has expiry date after 40 years .  There is no chance  for GetItemPrice(CatalogEntryDto.CatalogEntryRow entry, LineItem lineItem, CustomerContact customerContact) to return zero value.  Moreover other guys did purchase of same item at that secenario price is correct. 
is there any other place in work flows where the item price will be caluculated.

#155336
Sep 14, 2016 11:08
Vote:
 

Hi,

I'm a bit confused now - as you said the orderform total is correct, and I think it's correct in term of:

209.95 + 169.95 + 49.95 = 429.85

Or did you mean the total is "correct" for the missing price?

I missed an important question: Is this order placed in front-end, or is it created directly in Commerce Manager?

/Q

#155337
Sep 14, 2016 11:27
Vote:
 

Hi Quan,

Please find below the order Summary of the above Order. for better understanding . 

Order Form Total is correct , I mean (  209.95 + 169.95 + 49.95 = 429.85)   . 

For some resons the provider id is missing for this order.  It was not created from Commerce Manager. 

#155338
Sep 14, 2016 11:40
Vote:
 

Hi,

It looks like the order is missing a crucial part of information - ProviderId should be "FrontEnd".

The GetItemPrice's return value only takes effect if ProviderId is FrontEnd. So I suppose that the order was created in some other sources (I don't know, front-end or perhaps some third party services?), as the PlacedPrice was set to 0 and then ProviderId missing, your GetItemPrice value (which is supposedly 55.95AUD) was not set during the workflows.

Set the ProviderId to "FrontEnd" then run the workflow ( RecalculatePurchaseOrderWorkflow) should solve the problem. 

Regards,

/Q

#155339
Sep 14, 2016 11:48
Vote:
 

Hi Quan ,

Thanks a lot. 

Is there any way that I can set the Provider Id by default (as a global configuration). 

Becuase I am assigning the provider Id at the time of adding an item to the Cart. 

Do we need to assign the provide Id  only once or every thime while execution of workflows like Cart Validation, CarPreparation and CartCheckout  ?

Regards

Phani 

#155340
Sep 14, 2016 12:15
Vote:
 

Hi,

You don't have to set ProviderId everytime. You just need to set it once before running CartValidate and saving. Something like this:

ch.Cart.ProviderId = "FrontEnd";

ch.RunWorkflow(OrderGroupWorkflowManager.CartValidateWorkflowName);

ch.Cart.AcceptChanges();

/Q

#155341
Sep 14, 2016 12:21
* 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.