Solved

How to 'slightly' modify SOOrderEntry.InvoiceOrder?

  • 10 October 2022
  • 3 replies
  • 69 views

Userlevel 7
Badge +5

On SOOrderEntry.cs we have the ‘Prepare Invoice’ PXAction. I’d like to add a new PXAction that allows me to run the same functionality as the InvoiceOrder method but I want to add some additional criteria to the selection of the SOLine records so I can invoice a sub-set of the details.

I suspect that I have to PXOverride the InvoiceOrder method within my customization but, here’s the challenge, I would like to leave the regular ‘Prepare Invoice’ functionality alone.

So do I have to try to copy all of the underlying code for my button or is there a way that my PXAction can do some magic ‘temporarily replace the InvoiceOrder function with this code until I’m done and then swap back in the regular InvoiceOrder function’ coding?

icon

Best answer by Django 11 October 2022, 01:38

View original

3 replies

Userlevel 5
Badge +2

@ddunn Try using a flag to condition the execution of the additional logic you would like to add when overriding the InvoiceOrder method as follows:

 

public class yourExtension : PXCacheExtension<SOOrderEntry>{
public bool runCustomCode = false;

public void delegate InvoiceOrderDelegate(Dictionary<string, object> parameters, IEnumerable<SOOrder> list, InvoiceList created, bool isMassProcess, PXQuickProcess.ActionFlow quickProcessFlow);

[PXOverride]
public void InvoiceOrder(Dictionary<string, object> parameters, IEnumerable<SOOrder> list, InvoiceList created, bool isMassProcess, PXQuickProcess.ActionFlow quickProcessFlow, InvoiceOrderDelegate baseMethod){

baseMethod(parameters, list, crated, isMassProcess, quickProcessFlow);
if(runCustomCode){
//yor code
}

}

[PXButton]
public void YourButton(){
try{
runCustomCode = true;
Base.InvoiceOrder(...);
}
finally{
runCustomCode = false;
}
}

 

Userlevel 7
Badge +5

I’ve tried that but the value of runCustomCode seems to be false. I think that’s because the code within PrepareInvoice (which calls InvoiceOrders which calls InvoiceOrder) creates a new graph of SOOrderEntry and that doesn’t have the variable that I need - the graph extension does. I might not have investigated enough but decided to head in a different direction.

What I ended up doing, because there isn’t much code, was to create my own PXAction and then copy the code for PrepareInvoice, InvoiceOrders, and InvoiceOrder and then added my own logic within the InvoiceOrder code. It won’t be hard to upgrade as I haven’t done much so I’m not too worried.

I would like the code used to select the detail lines to be turned into a method so that it can be overridden all by itself if any of the Acumatica developers have some extra time. ;)

Userlevel 7
Badge

Thank you for sharing your solution with the community @ddunn !

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved