2

We are having a requirement to pass other than shipping address to external tax calculation method to compute tax. I am storing the address in a simple custom table and it is selected in the sales order and the same is copied into sales invoice for calculating the Tax.

The GetAddress is overridden to pass the custom address to the Avalar and this was working fine in Acumatica 2018, but the same is not working in Acumatica 2019.

In 2019, I have tried to override GetAddress function on

public class SOOrderEntryExternalTax_Extension : PXGraphExtension<SOOrderEntryExternalTax, SOOrderEntry>
{
    #region Event Handlers
    [PXOverride]
    public IAddressBase GetToAddress(SOOrder order, Func<SOOrder, IAddressBase> methodBase)
    {
        var shipAddress = methodBase(order);
        if (shipAddress != null)
        {
            CYBProjectDataNameSpace.CYB_PROJECTS CYBProject = PXSelectorAttribute.Select<SOOrderExt.usrProjectId>(Base.Document.Cache, order) as CYBProjectDataNameSpace.CYB_PROJECTS;
            //shipAddress.AddressLine1 = CYBProject.Cyb_address;
            shipAddress.AddressLine2 = "";
            shipAddress.AddressLine3 = "";
            shipAddress.City = CYBProject.Cyb_pcity;
            shipAddress.State = CYBProject.Cyb_pstate;
            shipAddress.PostalCode = CYBProject.Cyb_pzcode;
            shipAddress.CountryID = CYBProject.Cyb_pcountry;
        }

        return shipAddress;
    }

    #endregion
}

In ARInvoice

[PXOverride]
    public IAddressBase GetToAddress(ARInvoice invoice, Func<ARInvoice, IAddressBase> methodBase)
    {
        var shipAddress = methodBase(invoice);
        if (shipAddress != null)
        {
            CYBProjectDataNameSpace.CYB_PROJECTS CYBProject = PXSelectorAttribute.Select<ARRegisterExt.usrProjectId>(Base.Document.Cache, invoice) as CYBProjectDataNameSpace.CYB_PROJECTS;
            if (CYBProject != null)
            {
                //shipAddress.AddressLine1 = CYBProject.Cyb_address;
                shipAddress.AddressLine2 = "";
                shipAddress.AddressLine3 = "";
                shipAddress.City = CYBProject.Cyb_pcity;
                shipAddress.State = CYBProject.Cyb_pstate;
                shipAddress.PostalCode = CYBProject.Cyb_pzcode;
                shipAddress.CountryID = CYBProject.Cyb_pcountry;
            }
        }

        return shipAddress;
    }





    #endregion
}

The customization code is not working.

How to fix the issue?

1 Answers1

2

Logic for external tax is defined within the ExternalTax graph extension. The graph extension is utilized by derived classes for each module, such as ARInvoiceEntryExternalTax for AR. To override the methods relating to taxes you will need to create a 2nd order Graph extension, tested samples shown below. Be aware there are additional GetToAddress(...) methods not shown in your question that require the document details DAC as a parameter.

 public class ARInvoiceEntryExtension : PXGraphExtension<ARInvoiceEntryExternalTax, ARInvoiceEntry>
    {
        [PXOverride]
        public virtual IAddressBase GetToAddress(ARInvoice invoice, Func<ARInvoice, IAddressBase> del)
        {
            return del(invoice);
        }

        [PXOverride]
        public virtual IAddressBase GetAddress(ARInvoice invoice, ARTran tran, Func<ARInvoice, ARTran, IAddressBase> del)
        {
            return del(invoice, tran);
        }
    }

    public class SOOrderEntryExtension : PXGraphExtension<SOOrderEntryExternalTax, SOOrderEntry>
    {
        [PXOverride]
        public virtual IAddressBase GetToAddress(SOOrder order, Func<SOOrder, IAddressBase> del)
        {
            return del(order);
        }

        [PXOverride]
        public virtual IAddressBase GetToAddress(SOOrder order, SOLine line, Func<SOOrder, SOLine, IAddressBase> del)
        {
            return del(order, line);
        }
    }
Joshua Van Hoesen
  • 1,684
  • 15
  • 30