I have some code in the system that checks orders line by line and puts an order/customer on credit hold based on certain criteria set in other fields.
For customers with certain job payment terms and multiple projects and jobs with different credit terms entering orders can take a while as things are being checked line by line. It doesn’t affect all customers and only seems to get really bad on customers that order frequently as it is running through a credit check process against the customer and their open invoices and jobs each line entered.
Is there a way to streamline this process or replace the current rowmod usage? Checking orders line by line worked for us at first when Epicor didn’t have as much data in it when we launched but with more and more jobs in the system it can take minutes to input a few lines. Here’s a small example of code used in this process:
There is code like this throughout and mostly uses RowMod == “A” || RowMod == “U” to check if any changes are made to the order that will increase amounts so that orders cannot have extra lines added to them after they are released. This particular bulk of code is a little over 1100 lines (the department had requests for many, many different scenarios to be checked against) so forgive me for not posting it in it’s entirety.
You could definitely streamline this, there are 3 calls in a row which almost do the same thing here (check there is a row, check there is a row with condition, get said row)
You could try just doing this:
var hed = ttOrderHed.Where(h => h.Updated() || h.Added()).FirstOrDefault();
Now you just check the hed != null and start processing it
I also did not write this code and am tasked with going through it and cleaning it up as there were some issues with the code itself and not passing through the right variables which I have already fixed.
So at first glance I am little confused about their initial intention. So far, all I see is the getting of records direct from the Db and storing those values. Judging by their liberal use of inline funcs and dynamics, they are probably better programmers than I, I prefer to keep it simple.
If it were me, instead of all that fancy look ups in the Db, I’d instanciate a BO and simply do a GetByID(OrderNum). This will get the head and all of the detail records like they are doing in one single call. At that point, if necessary, you can grab the data from your dataset and assign to those variables as they are doing.
Here is an example of instanciating a BO in a BPM
SO =Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.SalesOrderSvcContract>(Db);
///then you can do
SalesOrderDataSet soDs = SO.GetByID(idhere);
//the entire structure is in ds now, head, details, etc
That is something I will have to try implementing although I am not too sure of how I am going to cleanly implement it as there are many lines of code written in the old way and references throughout. Rewriting the whole thing might be better at this point which is something I would have hoped to avoid.