Skip to main content

Hello Everyone,

We are working with 23 R1 build version 23.106.0055.

We have a scenario where we need to get the Invoice Status and Released flag status when we are releasing the invoice.

On releasing the invoice, the status will change form Balanced to Open. But when we are trying to get the value in Base.Document.Current.Status, we are getting the status as Balanced.

At the same time on Invoice Release action, the Released flag will also set to true but when we are trying to access this value we are getting this as false only.

On creating invoice directly:

  • On Save action, under Persist method, we observed that Released flag is false.
  • On Invoice release, Persist method triggering 2 times first time Released flag is false and when it triggered second time Released flag is true.

On Creating Invoice through Sales Order:

  • On prepare invoice it triggered and release is false.
  • On Release invoice it triggered once and release is false.

We also verified with ARInvoice_RowPersisting and ARInvoice_RowPersisted events but the behavior is the same and we are not getting Released flag as true and Status as Open.

Sample code:

public class SOInvoiceEntry_Extension : PXGraphExtension<PX.Objects.SO.SOInvoiceEntry>
{
PXOverride]
public void Persist(Action del)
{

del();

if (Base.Document.Current?.Released == true && Base.Document.Current.Status == "Open")
{

}
}
}

Can you please review and suggested the best possible way to achieve this.

 

Thank you!

Hi @rakeshe45 
 

Please try with the below code,

public class SOInvoiceEntry_Extension : PXGraphExtension<SOInvoiceEntry>
{
    PXOverride]
    public void ReleaseInvoiceProc(List<ARRegister> list, bool isMassProcess, Action<List<ARRegister>, bool> baseMethod)
    {
        // Custom logic before the release (optional)
        PXTrace.WriteInformation("Before ReleaseInvoiceProc");

        // Call the original method (ReleaseInvoiceProcImpl)
        baseMethod(list, isMassProcess);

        // Custom logic after the release
        AfterInvoiceReleased(list);
    }

    private void AfterInvoiceReleased(List<ARRegister> invoices)
    {
        foreach (var invoice in invoices)
        {
            // Custom logic to run after the invoice release process is completed
            PXTrace.WriteInformation($"SO Invoice {invoice.RefNbr} has been released.");

            // Example: throw an exception or perform further processing
            if (invoice.Released == true)
            {
                throw new PXException($"SO Invoice {invoice.RefNbr} has been successfully released.");
            }
        }
    }
}
 


Hello @rakeshe45 ,

 

The RELEASE operation executes in its own thread. The SO Invoice graph uses ARDocumentRelease.ReleaseDoc() method to release the current invoice. Extend the “ReleaseInvoice” method available in the ARDocumentRelease graph if you are wanted to do some post operations after release.

Also, I would look at the below response from @Dmitrii Naumov .

https://stackoverflow.com/questions/67794689/how-do-i-get-a-hook-into-the-acumatica-ar-document-release

 

Hope this helps!


Reply