SalesOrder.CloseOrderLine not correctly updating totals on header

We have orders that are coming in externally and code that has been creating those orders has been working well. However, recently the requirement came in to have certain parts have the lines come in as closed/voided from the start as we will not fill those in Epicor but want to see them on the order still for reference. We first attempted just setting voidline = true and openline = false which voids the line but did not adjust totals at the header. Realizing we may also need to simply call the CloseOrderLine method we tried this and it does work better but not perfectly. Now the “Charges” line on the header is correct, as is the “Discount” but the order total still has the voided line calculated in the total. If I simply reopen the line and close it again in the client, it works as expected and the totals recalculate correctly. If I reopen and close the line again in code, the total remains incorrect. I’ve done a trace and the only method being called is CloseOrderLine so I’m not sure what is happening.

We have had some success going through steps to set pricing and quantities to 0 before voiding but it seems like this should be unnecessary since in the client just closing the line works. Has anyone seen this before or know what we’re doing wrong here?

Welcome Rob!

Let me make sure I have the steps correct.

You are bringing in all lines, not voided.
Then calling CloseOrderLine on the ones you don’t want open?

We have tried this two ways - first as an in trans data directive just updating field values with set fields on added row for open/void. We know at this time we want that line voided based on a custom flag on the part record. However, with an added row, just setting the voidline/openline flags doesn’t do anything (other fields set fine, those do not and still go in as open).

When we realized we might have to call CloseOrderLine method separately, we moved that to a standard directive (the other field updates we left in trans) - I’m looping through each line and calling the CloseOrderLine BO on the lines we want closed. For kicks, I also added an update call after even though it wasn’t in the trace to see if it would help.

I think you need to nix the data directives.

How are these orders constructed and gotten in to the system?

They are actually coming in through the multicompany process from another company PO. I did not see any methods to attach to for this process.

To elaborate further, these parts are not physical parts…they are things like subscription fees, etc. They want to leave them on the IC PO so they can use one drop ship entry to receive/ship the entire order rather than drop shipping the other lines and shipping the one separately, but they really don’t want that part to be on the IC sales order that matches. We worked around this for a long time by still having them come over but having price lists at 0 so there was no price or cost issues in the transactions. However, every once in a while a price list gets updated incorrectly. While we are working on that process and training, we were also tasked to find a way get it to work even if pricing was incorrectly set.