Solved

Need help finding the method to override on the ARPrintInvoices graph


Userlevel 6
Badge +3

On the Print Invoices and Memos screen, I want to override the email process.  I want to intercept the process where the invoice is being emailed and remove the PDF invoice from the email and add a custom PDF invoice that has been uploaded manually instead.

The first step to try to do this is to find the delegate method to override when the processor is run.

I am looking at the source code for the ARPrintInvoices graph for that screen.  I don’t see anywhere in that code where the process gets called.  I looked for other files in the PX.Objects.AR repository and I don’t see anything like “ARPrintInvoicesProcess” etc.

Can anyone help me find the place in the code where I can override the processing delegate?  I think there are some cases in Acumatica where you don’t have access to certain code, but I’m hoping it is just because I don’t know where to find it.

 

icon

Best answer by Dmitrii Naumov 13 March 2023, 19:45

View original

12 replies

Userlevel 7
Badge +6

@Joe Schmucker could you specify the report on the notification template?

Userlevel 6
Badge +3

@iqraharrison48 The only code I can find on this screen is the graph from the code repository.  I don’t know which report is being used from that screen to create the invoice.

I just looked at the ARInvoiceEntry graph and found this code.  I am going to guess that this is the same process to generate the invoice and email it if you do it from that graph as might be used on the screen I am trying to override.  I *think* that the report used is AR641000.  

When I drill into the ReportNotificationGenerator, I found that this class is in the PX.Objects.EP namespace.  I found public class ReportNotificationGenerator in the NotificationSender.cs file.

I don’t see any public virtual methods in that code that I can override.

 

Userlevel 6
Badge +3

I just did a debug session on the Print Invoices and Memos screen and it didn’t hit the public ReportNotificationGenerator(string reportId, IReportLoaderService reportLoader, IReportDataBinder reportDataBinder) method in the ReportNotificationGenerator class.  So, I don’t think that gets me any closer.

Userlevel 7
Badge +6

@Joe Schmucker i’m not 100% sure what code it would be but i did have a follow up question, is there a reason the custom invoice isn’t set up in acumatica? is it possible to replace the existing invoice template so that when the invoice is sent out via email, it is using the correct invoice from the beginning which could eliminate the need to intercept before it goes out?

 

Userlevel 6
Badge +3

@iqraharrison48 The customer uses a different application (not Acumatica) to create their PDF invoices.  They manually upload their PDF invoices into Acumatica.  They create invoices in Acumatica with no details.  The details are provided on the PDF from the outside application.  

The goal for me is to allow them to use the Print Invoices and Memos screen to bulk send invoices to their customers.  But we do not want to use the invoice generated by Acumatica.  We want to substitute the PDF they uploaded instead.

My thought is to override the process to delete the attachment created by Acumatica and add the PDF they uploaded manually.

Userlevel 7
Badge +6

@Joe Schmucker i believe emails go out based on how the business event is set up otherwise you can manually process them using the “email pending processing screen” 

you could set up a separate notification template for this customer and set the emails to go out manually which would give you the ability to review the email and attach any PDFs as needed and then manually push it through.  it can also be set up to send after hours which would give your staff time to upload the correct PDF.  

Userlevel 6
Badge +3

@iqraharrison48 I just debugged and found that the processor is hitting this action on the ARInvoiceEntry graph

At least I found a spot in the code that is being called.  Maybe this helps you help me?  😊

Userlevel 6
Badge +3

@iqraharrison48 Thanks for the tips.  I will investigate that as an option with the customer and see if that may be an option.  

Userlevel 7
Badge +6

@Joe Schmucker i wish I had more coding experience but it’s slim to none over here 😅 

 

@Dmitrii Naumov is this something you could help with? 

Userlevel 7
Badge +5

Hi @Joe Schmucker 

This is indeed the place that is being invoked from ‘Print Invoices and Memos’ screen. 

You can find those actions by checking workflow actions for AR301000 screen as shown below:

 

I think you can override the code as shown below:

[PXButton, PXUIField(DisplayName = "Email", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
[ARMigrationModeDependentActionRestriction(
restrictInMigrationMode: false,
restrictForRegularDocumentInMigrationMode: true,
restrictForUnreleasedMigratedDocumentInNormalMode: true)]
[PXOverride]
public virtual IEnumerable EmailInvoice(
PXAdapter adapter,
[PXString]
string notificationCD = null) {
foreach (ARInvoice doc in adapter.Get().RowCast<ARInvoice>())
{
//get ID of file attachment
Guid fileID = PXNoteAttribute.GetFileNotes(Base.Document.Cache, doc).First();

Dictionary<string, string> parameters = new Dictionary<string, string>
{
["DocType"] = doc.DocType,
["RefNbr"] = doc.RefNbr
};
Activity.SendNotification(ARNotificationSource.Customer,
notificationCD, // may want to change the notification CD as weel, if needed
doc.BranchID, parameters, adapter.MassProcess,
// add it to the notification
new List<Guid?> { fileID });
}

return adapter.Get();
}

 

Userlevel 6
Badge +3

@Dmitrii Naumov That is fantastic.  I didn’t realize I could [PXOverride] an action!

When I put that code into my extension, I do get a couple reference errors but I will try to remedy them.

Where did you get that code for the action?  Is that something only available to Acumatica?  If I can find it in the code repository, that may help me to find this type of code in the future.  I did a search in the entire solution for “public virtual IEnumerable EmailInvoice” but I did not find any results.

Thank you!

 

Userlevel 7
Badge +5

@Joe Schmucker I mostly copypasted it from the ARInvoiceEntry.Notification which is called from original EmailInvoice

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