We have a situation where duplicate payment captures are appearing in the detail rows of the Capture Payments screen (AR511500). If I leave the standard process alone and run the capture process the first row of the three that I have highlighted will be captured and then the following two will generate an error message because the Payment has already been captured. So then the user will hit Process All and have to wade through a number of errors that are not really errors at all and I would like to avoid that.

I’d like to be able to adjust the filter or override the filter logic so that any records with a Reference Nbr value that were already included in the list are left off of the list.
Alternatively, if I can pre-select the unique Reference Nbr values, that would work, too. I need the solution to be able to run through a schedule.
Or if I can get the Process routine to check the status of the Payment entry before it tries to initiate the credit card capture, that would be fine, too.
I decided to try pre-selecting the records that I wanted to process so I created a graph extension of the ARPaymentsAutoProcessing graph and tried to re-write the ardocumentlist. That shows an error on the foreach line: “Unable to cast object of type 'PX.Objects.AR.ARPaymentInfo' to type 'PX.Data.PXResult`1[PX.Objects.AR.ARPaymentInfo]'.”
In addition, (if I debug the process) res contains the entire list of ARRegister records instead of the two that would normally appear on the screen. So it seems like the filter isn’t being respected.
public class ARPaymentsAutoProcessing_Extension : PXGraphExtension<ARPaymentsAutoProcessing>
{
public static bool IsActive()
{ return true; }
protected virtual IEnumerable ardocumentlist()
{
PXView sel = new PXView(Base, true, Base.ARDocumentList.View.BqlSelect);
int totalRow = 0;
int startRow = PXView.StartRow;
List<object> res = sel.Select(PXView.Currents, PXView.Parameters,
PXView.Searches, PXView.SortColumns, PXView.Descendings,
PXView.Filters, ref startRow, PXView.MaximumRows, ref totalRow);
var refNbrList = new List<string>();
foreach (PXResult<ARPaymentInfo> row in res) //ERROR HERE
{
ARPaymentInfo paymentInfo = (ARPaymentInfo)row;
if ( !refNbrList.Contains(paymentInfo.RefNbr))
{
paymentInfo.Selected = true;
Base.ARDocumentList.Cache.Update(paymentInfo);
refNbrList.Add(paymentInfo.RefNbr);
}
}
return res;
}
}