0

Good day,

Every vendor and customer will be linked to an Employee that is responsible for them.

I need to add an extra filter on the "Calculate Overdue Charges" Page, AR507000, this will be linking back to the customers and only showing the Employees enter image description here

What is the current place to add the code to add this extra filter? Does anyone have an example or article I can find more info on?

I did figure out how to do this but I am not sure if is the best way

JvD
  • 473
  • 3
  • 18

1 Answers1

0

First, find the method that does the calculation/Filter in mycase it is CalculateFinancialCharges

2de add your logic under the normal baseMethod and remove needed items using Remove(item);

 public delegate void CalculateFinancialChargesDelegate(ARFinChargesApplyParameters filter);
                [PXOverride]
                public void CalculateFinancialCharges(ARFinChargesApplyParameters filter, CalculateFinancialChargesDelegate baseMethod)
                {
               
                    baseMethod(filter);
                
                    try
                    {
                        ARFinChargesApplyParameters curARFinChargesApplyParameters = this.Base.Filter.Current;
                        ARFinChargesApplyParametersExt curARFinChargesApplyParametersExt = curARFinChargesApplyParameters.GetExtension<ARFinChargesApplyParametersExt>();
        
                        if (!string.IsNullOrWhiteSpace(curARFinChargesApplyParametersExt.UsrEmployeeID))
                        {
        
                            foreach (ARFinChargesDetails item in this.Base.ARFinChargeRecords.Cache.Inserted)
                            {
                                BAccount bAccount = PXSelect<Customer,
                                    Where<Customer.bAccountID, Equal<Required<ARFinChargesDetails.customerID>>>>.
                                    Select(Base, item.CustomerID);
                                BAccountExt bAccountExt = bAccount.GetExtension<BAccountExt>();
        
                                if (bAccountExt.UsrEmployeeID != curARFinChargesApplyParametersExt.UsrEmployeeID)
                                {

                                    this.Base.ARFinChargeRecords.Cache.Remove(item);
                                }
        
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                       PXTrace.WriteError(ex);
            
                    }
        
    }
JvD
  • 473
  • 3
  • 18