Counter Sale Invoice BPM

I’m trying to calculate a few UD fields when Invoices are created.
I’ve got a function that takes Company and InvoiceNum as input params.

I trigger the function in each of these scenarios:

  • Standard Shipments (ARInvoice.GetShipmentsConsolidated, Method Directive)
  • Drop Shipments (ARInvoice.GetDropShipments, Method Directive)
  • RMAs (ARInvoice.GetRMACredits, Method Directive)
  • Miscellanious Invoices (Kinetic layer event)

But how could I do this for Counter Sales? A soon a I process the counter sale, the invoice gets posted (and locked).
I was getting away with running the function After SalesOrder.ProcessCounterSaleUsingOrderLinesInDatabase, but that was before implementing tax connect.
Now I’m getting an error “Tax Service records are committed. Update not allowed.”

Whats another trigger point I could use for this scenario? Where the Invoice has been created (including all lines), but not yet posted.

You might need to make this a DATA BPM, and have the BPM check to see what kind of invoice it is before it gets created an posted.

Thanks Shuwy, I appreciate the feedback!

I’m trying a Data directivite now, but I’m still getting the same error, “Tax Service records are committed. Update not allowed.”

I’ve got an In-Transaction Data Directive on InvcHead.Update.

It uses this query condition to check for and only grab “Counter Sales”
It also checks for InvcHead.Posted has been changed to True. Maybe this condition is the problem? I was hoping I was getting the InvcHead BEFORE the Posted change was applied in the database.

Maybe the data directive needs to be on InvcDtl?
I’m trying that next…

Or maybe I can’t use a function in one of these in-transaction data directives?
I’m triggering it like this currently:

var InvcHead = (from item in ttInvcHead select item).FirstOrDefault();  
var InvcNum64 = Convert.ToInt64(InvcHead.InvoiceNum);  
this.InvokeFunction("InvoiceFunctions", "CalcPricingFields", InvcHead.Company, InvcNum64);

Do i have to put code right in the data directive and use a transaction scope or dbContext?