Solved

SOShipmentEntry CreateInvoice override "Base.Document.Current" property null when ran from Process Shipments

  • 22 September 2022
  • 3 replies
  • 201 views

Userlevel 2
Badge +1

I have an override on the SOShipmentEntry CreateInvoice action that works fine when the Prepare Invoice button is pressed on the Shipments screen, but not when it is ran through the Process Shipments screen.  The screenshot below is a simplified version of the override.  The Base.Document.Current.ShipmentNbr field is null and also Base.Transactions.Select() returns no records.  

What am I missing?  I need a reference to the shipment nbr so I can reference back to the order to update some custom fields on the invoice that’s generated.

 

Thanks

Scott

icon

Best answer by Leonardo Justiniano 22 September 2022, 01:27

View original

3 replies

Userlevel 6
Badge +4

Hi @scottstanaland12 

 

You have to consider the adapter parameter. Please look into the original Acumatica function:

protected virtual IEnumerable CreateInvoice(PXAdapter adapter)
{
var shipments = adapter.Get<SOShipment>().ToList();

. . .
}

When the call is made on the Shipment screen or through the processing screen, Acumatica always sends the list through the adapter parameter.

 

 

Userlevel 2
Badge +1

Hi ​​​@Leonardo Justiniano  

Thank you for the quick response.  I will give that a try. 

One question, I was using the method of creating an event handler that fires when the ARInvoice record is inserted in the base method.  I assume the adapter.Get<SOShipment>() call will return all rows that were selected on the processing screen.  Is there a way I can associate the generated invoice with the Shipment Nbr?  

 

 

 

Userlevel 6
Badge +4

@scottstanaland12 

 

Yes, adapter contains all selected SOShipment records, or 1 record in case of the Shipment screen.

About your question, you can create an RowInserted event in a SOInvoiceEntry extension looking at SOOrderShipment table (InvoiceNbr & ShipmentNbr):

namespace PX.Objects.SO
{
public class SOInvoiceEntry_Extension : PXGraphExtension<SOInvoiceEntry>
{
#region Event Handlers
protected void _(Events.RowInserted<ARInvoice> e)
{
PXEntryStatus entryStatus = e.Cache.GetStatus(e.Row);
if (entryStatus == PXEntryStatus.Inserted)
{
// BQL on SOOrderShipment
}
#endregion
}
}

When the invoice is created you can seek the ShipmentNbr based on the e.Row.RefNbr field

The code above runs when the invoice is created.

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