rutledgek / Rock-Plugins

1 stars 1 forks source link

Batches Doubling #6

Open calvmann opened 4 years ago

calvmann commented 4 years ago

I believe this has started since Rock v11. When downloading transnational batches, the totals are doubled and each transaction shows up twice.

Screen Shot 2020-11-02 at 1 03 24 PM
savecebu commented 3 years ago

I have the same problem. I also go between automatically generated batch names like this: 463801609 to 563. The 563 number is the type of number if we manually add a batch.

JRichmond27 commented 3 years ago

We just updated from Rock 10.3 to 11.4 last week and now we're seeing duplicate transactions on the Transnational Transaction Reconciliation block. I checked the database and the transactions are not duplicated there, so it seems to be a bug that's only related to how the data is displayed.

JRichmond27 commented 3 years ago

After a little digging, it looks like the results of gateway.GetPayments( financialGateway, start, end, out errorMessage ) on line 180 of TransnationalTransactionReconciliation.ascx.cs includes duplicates. Since GetPayments is a Rock function, I'm not sure if this is a plugin issue or a Rock issue.

Another odd observation is that the transactions only seem to be duplicated if the date range is set to multiple days, and the transactions that occur on the start date are never duplicated. So, if the date range was 3/14 to 3/16, then the transactions for 3/15 and 3/16 would be duplicated, but the ones for 3/14 would not be duplicated.

JRichmond27 commented 3 years ago

Not sure if it's the most efficient, but I was able to implement a temporary fix...

In TransnationalTransactionReconciliation.ascx.cs, I implemented an IEqualityComparer for Rock.Financial.Payment and then added .Distinct(PaymentComparer()) to the grouped assignment near line 190.

So this:

var grouped = filtered.OrderByDescending(x => x.SettledDate)
                .GroupBy(x => x.SettledGroupId);

Became this:

var grouped = filtered.OrderByDescending(x => x.SettledDate)
                .Distinct(new PaymentComparer())
                .GroupBy(x => x.SettledGroupId);

So far everything looks good. No more duplicates and we haven't noticed any missing or incorrect data.