connect 2022 banner tablet connect 2022 banner mobile

How to Create a Transportation Management System Rate Engine in Dynamics 365 Finance and Operations

By Taylor Valnes | July 26, 2019

The other day I had to create a new Transportation Management System (TMS) Rate Engine in Dynamics 365 Finance and Operations so that the weight could be included in the calculation of a rate. The math desired was to add a multiplier on the standard rate calculation where the weight of the shipment would be divided by a divisor (set as a parameter on the rate engine) and then multiplied by the rate.

For example: Rate per mile: $1, Mileage: 100, Weight: 100, Divisor on new rate engine: 25. The math would work out to be (100/25) * 1 * 100 = $400.

While that is a simplistic example, the point remains that the desire was to utilize the weight.

While following the link for Create a new transportation management engine was helpful as to the actual creation of the class, what I found was that to utilize the mileage point we needed to do various changes. The first thing is we want is for our class to extend the MileageRateEngine class, this is what will allow for the calculated rate to be added to the form. Without that we were able to see the calculated rate when debugging, but that rate would not transfer to the form.

As far as the code to actually do the math using the rate engine, you'd extend the rate method and execute the following code in addition to the standard mileage engine code:

decimal num = BaseRateEngine.RetrieveRate(tMSRateBase, tMSRateBaseDetail, (tMSFwkMileageHelperResponse.parmMiles() * tMSRateBaseDetail.Rate) / StringExtensions.ToDecimal(tMSRateBaseDetail.Dimension1));
            //get shipment/load weight
            decimal wght = XDocExtensions.SumDown(shipment, ElementXmlConstants.Weight);
            // multiply ton-miles rate by wght of the load
            num = num* wght;
            //   XElement re = shipment.RetrieveOrCreateRatingEntity(this.RatingDto);
            xElement.AddRate(TmsRateType.Rate, num);

Happy calculating! If you have any questions about TMS in Dynamics 365 for Finance and Operations, let us know if we can help!

Start the Conversation

It’s our mission to help clients win. We’d love to talk to you about the right business solutions to help you achieve your goals.

Subscribe To Our Blog

Sign up to get periodic updates on the latest posts.

Thank you for subscribing!