Misc Line for Surcharge on Sales Order

We are looking to add a misc line charge for a surcharge per order that is customer specific

Is anyone doing this or know if there is something in the Customer Record that allows for a surge charge to be automatically added to each of their orders

We are only wanting to do this per certain customer not across the board

Perhaps there is a non-code way to do this, but one suggestion here would be a BPM that fires when the customer ID is filled in and then programmatically add the service charge. I don’t have a snippet handy for a header level charge but here is one for a line level charge that worked pretty easily.

// Create a reference to the SalesOrder BO so we can use its methods
var svc = ServiceRenderer.GetService<SalesOrderSvcContract>(Db);

// Grab the MiscChrg record we will be adding
var miscChrg = Db.MiscChrg.Where(m => m.Company == company && m.MiscCode  == "MyMiscCharge").First();

var orderDtls = ttOrderDtl.Where(d => d.RowMod == "U" || d.RowMod == "A");                   
var ts = (Erp.Tablesets.SalesOrderTableset)ds;
string company = Session.CompanyID;

foreach (var orderDtl in orderDtls) {
    svc.GetNewOrderMsc(ref ts, orderDtl.OrderNum, orderDtl.OrderLine);
    ttOrderMsc.Last().MiscCode = "MyMiscCharge";
    ttOrderMsc.Last().Description = miscChrg.Description;
    ttOrderMsc.Last().Type = miscChrg.Type;
    ttOrderMsc.Last().FreqCode = miscChrg.FreqCode;
    ttOrderMsc.Last().Percentage = miscChrg.Percentage;
    ttOrderMsc.Last().MiscAmt = miscChrg.MiscAmt;
    svc.ChangeMiscPercent(ref ts, "OrderMsc");
}

Thank you we are going to move forward with the specs for the BPM

image007.jpg

2 Likes

@JMH6271 Were you able to create the BPM? If so, would you be willing to share it? I have been asked to create Misc lines at the OrderHed level based on the Customer ID, but keep running into errors.

Thanks,
Melissa

Hi Melissa

We have not completed it yet since we are tied up with our year end but will gladly share it when done.

What errors are you receiving?

Jeanne

My main issue is that I can get it to create a misc line at the order head but every time I hit the refresh button it disappears. I am not sure how to get it to stay.

Attached is a copy of my BPM, if you have time to look at it.
OHMiscCharge.bpm (35.9 KB)

Hi Melissa, that sounds like a missing SO service update method call. Are you calling the Update method after adding the misc charge? or maybe you are not setting the record’s rowmod = “A”?

On any case, try adding something like:

  newOrderMsc.RowMod = "A";
  soSvc.Update(ref ts);

Thank you for the suggestion, to be honest my C# knowledge is non-existent. I tried to add the Invoke BO Method widget at the end referencing SalesOrder.MasterUpdate, but the system times out and forcibly closes the application.

Not sure if it is an issue for you, but keep in mind that the OrderMsc table is used for header and line misc charges. It differentiates them by using LineNum = 0 for header charges.

Thanks, @ckrusen. I believe that I have all that setup correctly within my BPM. I can get the misc line to create at the header level (before I added the Invoke BO Method SalesOrder.MasterUpdate), it just won’t save it and I am unsure of how to get it to save.

I see this message in the Event Viewer and several more relating to w3wp.exe, after triggering the save on the Sales Order- “An unhandled Microsoft .NET Framework exception occurred in w3wp.exe [11836]. Just-In-Time debugging this exception failed with the following error”

Attached is an updated version of my BPM with the Invoke BO Method Sales Order.MasterUpdate.

OHMiscCharge.bpm (42.4 KB)

I don’t have access to 10.2.500, so I can’t see what is in that BPM.

Can you post some screen shots, and any code blocks?

I hope this helps. Let me know if there is something else you may need. I appreciate all the help.

As a no-coder myself, I will say it is very possible to do just about anything using Epicor Functions and BPMs.

I don’t see anywhere in this post where you started with a trace, and that’s step zero. Also, BPMs work fine, but I LOVE using Functions as they help isolate, well, you know, the separate functional areas of your project.

I could be way off here…

But in the following:

The “added row” is referring to a row that was added, which initiated the Update. And not the row you are adding with the call to GetNewOHOrderMsc.

The above Set Field widget (as you have it configured) will only set the MiscCode to FUEL, of an OrderMsc record that was added to this order. And not one added in the BPM, but one added that caused the Update to fire.

Thank you for the information, I will let you know how it goes.