Saleslogix Web Client v8.1 Sales Order Total Not Calculating Correctly

We recently received a complaint from a client that the Sales Order total field is not using the extended price of the products.  instead it is summing the Price field with does not allow for correct totals if the user adjusts a price or changes the quantity.

 

This used to work up through SalesLogix v8.0

 

I have submitted as a ticket to Saleslogix (8010146679).

 

It seems they have monkeyed with these business rules.  Not sure if it was because of the ERP sync they threw in there.

 

Pre 8.1
public static double GetAdjustedPrice(ISalesOrder salesOrder)
{
    double num = 0.0;
    double num2 = 0.0;
    foreach (ISalesOrderItem item in salesOrder.SalesOrderItems)
    {
        num += item.Price.Value * ((int) item.Quantity.Value);
        if (item.Discount.HasValue)
        {
            num2 += (item.Price.Value * ((int) item.Quantity.Value)) * (1.0 – item.Discount.Value);
        }
        else
        {
            num2 += item.Price.Value;
        }
    }
    return num2;
}

New in 8.1
public static double GetAdjustedPrice(ISalesOrder salesOrder)
{
    double num = 0.0;
    foreach (ISalesOrderItem item in salesOrder.SalesOrderItems)
    {
        double num2 = (item.Price.HasValue && (item.Price.Value > 0.0)) ? item.Price.Value : ((item.CalculatedPrice.HasValue && (item.CalculatedPrice.Value > 0M)) ? ((double) item.CalculatedPrice.Value) : 0.0);
        num += num2;
    }
    return num;
}

Should be:
public static double GetAdjustedPrice(ISalesOrder salesOrder)
{
    double num = 0.0;
    foreach (ISalesOrderItem item in salesOrder.SalesOrderItems)
    {
        double num2 = (item.ExtendedPrice.HasValue  ? item.ExtendedPrice.Value : 0.0);
        num += num2;
    }
    return num;
}

Since these are in the compiled SalesLogix assemblies, it is a no go for fixing these directly.  However, you can create your own void result SalesOrder entity business rule of:

            double num = 0.0;
            foreach (ISalesOrderItem item in salesorder.SalesOrderItems)
            {
                double num2 = (item.ExtendedPrice.HasValue  ? item.ExtendedPrice.Value : 0.0);
                num += num2;
            }
           
            salesorder.OrderTotal=num;
                       
            double? discount = salesorder.Discount;
            num -= num * (discount.HasValue ? discount.GetValueOrDefault() : 0.0);
            double? tax = salesorder.Tax;
            num += num * (tax.HasValue ? tax.GetValueOrDefault() : 0.0);
            double? freight = salesorder.Freight;
            salesorder.GrandTotal = (num + (freight.HasValue ? freight.GetValueOrDefault() : 0.0));

Then you can add a post execute event to the salesorderitem’s entity events for OnAfterUpdate, OnAfterInsert, OnAfterDelete of:

    salesorderitem.SalesOrder.FXSetOrderTotal();
    salesorderitem.SalesOrder.Save(); 

 

The OnAfterDelete should be this:
        if (((salesorderitem != null) && (salesorderitem.SalesOrder != null)) && (salesorderitem.SalesOrder.SalesOrderItems != null))
        {
                    salesorderitem.SalesOrder.FXSetOrderTotal();
        }

 

You also will need to add a similar cust post execute event to the sales order entity’s OnBeforeUpdate event:

    salesorder.FXSetOrderTotal();

ABOUT THE AUTHOR

Kris Halsrud

Kris Halsrud is a Senior Analyst / Developer for Customer FX Corporation.

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter

Join our mailing list to receive the latest Infor CRM (Saleslogix) and Creatio (bpm'online) news and product updates!

You have Successfully Subscribed!