Search code examples
c#acumaticaacumatica-kb

How to modify the Create Prepayment action/button on Purchase Order?


I've successfully modified the process when a AP Bill is created by the action Create AP Bill on the Purchase Order page, but i need to do the same when the user wants to create a Prepayment.

To modify the creation of the AP Bill from the Purchase Order I just created a delegate and the new InvoicePOOrder function. But since the Prepayment is a Popup of the Prepayment screen it seems like it doesn't works the same way. I've searched through the code for the correct method to no avail. The only portion I find is on the CodeRepository.xml file.

    public PXAction<POOrder> createPrepayment;

    [PXUIField(DisplayName = "Create Prepayment Request", MapEnableRights = PXCacheRights.Select,
        MapViewRights = PXCacheRights.Select, Visible = true)]
    [PXButton(OnClosingPopup = PXSpecialButtonType.Cancel)]
    public virtual void CreatePrepayment()
    {
        if (Base.Document.Current != null)
        {
            Base.Save.Press();
            var target = PXGraph.CreateInstance<APInvoiceEntry>();
            var prepaymentExt = target.GetExtension<APInvoiceEntryExt.Prepayments>();
            prepaymentExt.AddPOOrderProc(Base.Document.Current, true);

            throw new PXPopupRedirectException(target, "New Prepayment", true);
        }
    }

Is there anyway to access it directly on my customization or do I need to modify the xml to accomplish what I need?


Solution

  • Create Prepayment action is declared on Prepayment graph extension in PX.Objects.PO.GraphExtensions.POOrderEntryExt namespace.

    You need to create a secondary graph extension, and override CreatePrepayment action there.

    public class PrepaymentExt : PXGraphExtension<Prepayments, POOrderEntry> {}
    

    If you need to do the same thing on the "Popup", what is actually an APInvoiceEntry graph in the background, you can extend that graph or it's Prepayment extension in the same way.