Page MenuHomePhabricator

Bug with new Recurring Financial Types
Closed, ResolvedPublic

Description

The new financial types Recurring Gift and Recurring Gift - Cash are working.

However, I'm finding some recurring gifts that are being coded as Recurring Gift when they are actually not the first gift in a donor's recurring gift series. CID 5822008

Event Timeline

Restricted Application added a subscriber: Aklapper. ยท View Herald TranscriptSep 8 2023, 2:12 PM
AKanji-WMF subscribed.

@NNichols we'll have a look at this in our sprint this week.

Damilare subscribed.

Change 963428 had a related patch set uploaded (by Eileen; author: Eileen):

[wikimedia/fundraising/crm@master] Add unit test check to trace wrong types on recurring contributions

https://gerrit.wikimedia.org/r/963428

Change 963428 merged by jenkins-bot:

[wikimedia/fundraising/crm@master] Fix recurring contributions being given wrong type on subsequent

https://gerrit.wikimedia.org/r/963428

Just noting that these 2 queries should run 'clean' (return 0 results)

SELECT count(*)
FROM
  civicrm_contribution a
    -- join to previous contributions with the same contribution recur id which happened before the given one
    LEFT JOIN civicrm_contribution c2 ON c2.contribution_recur_id = a.contribution_recur_id AND
                                         c2.receive_date < a.receive_date
    LEFT JOIN `civicrm_value_1_gift_data_7` Gift_Data
    ON a.id = Gift_Data.entity_id

WHERE `a`.`receive_date` > "20230701000000"
  AND `a`.`contribution_recur_id` > 0
  -- financial type not already of recurring type
  AND `a`.`financial_type_id` NOT IN (31)
  AND `a`.`is_test` = 0
  AND c2.id IS NULL
LIMIT 5000;

SELECT count(*)
  FROM
  civicrm_contribution a
    -- join to previous contributions with the same contribution recur id which happened before the given one
    LEFT JOIN civicrm_contribution c2 ON c2.contribution_recur_id = a.contribution_recur_id
    AND c2.receive_date < a.receive_date
    LEFT JOIN `civicrm_value_1_gift_data_7` Gift_Data
    ON a.id = Gift_Data.entity_id

WHERE `a`.`receive_date` > "20230701000000"
  AND `a`.`contribution_recur_id` > 0
  -- financial type not already of recurring type
  AND `a`.`financial_type_id` NOT IN (32)
  AND `a`.`is_test` = 0
  AND c2.id IS NOT NULL
LIMIT 5000;

This query is not running clean

SELECT count(*)
FROM
  civicrm_contribution a
    -- join to previous contributions with the same contribution recur id which happened before the given one
    LEFT JOIN civicrm_contribution c2 ON c2.contribution_recur_id = a.contribution_recur_id AND
                                         c2.receive_date < a.receive_date
    LEFT JOIN `civicrm_value_1_gift_data_7` Gift_Data
    ON a.id = Gift_Data.entity_id

WHERE `a`.`receive_date` > "20230701000000"
  AND `a`.`contribution_recur_id` > 0
  -- financial type not already of recurring type
  AND `a`.`financial_type_id` NOT IN (31)
  AND `a`.`is_test` = 0
  AND c2.id IS NULL
LIMIT 5000;

Because we appear to still be creating new adyen with the incorrect financial type (ie first in series has 'Recurring Gift Cash' not 'Recurring Gift'

So it seems that with a contact like

https://civicrm.wikimedia.org/civicrm/contact/view?reset=1&cid=2560914&selectedChild=contribute the $104 record is the first , kinda, but the the $25 is the first one that is attached to the recurring. I have put up a patch that gives the second one the financial type to denote it as the first

I'm not 100% clear on the whole flow

Pushed up a patch to run the upgrade once more as 1550 still to do (seems like no new ones have happened since 26 Oct so hopefully this will be the end of it)

both queries ran clean - I think this is done!

Eileenmcnaughton set Final Story Points to 4.