SalesforceFoundation / NPSP

The current version of the Salesforce.org Nonprofit Success Pack
http://www.salesforce.org/nonprofit/nonprofit-success-pack/
BSD 3-Clause "New" or "Revised" License
14 stars 3 forks source link

Recurring Donation's Number of Paid Installments Not Recalculated When Opportunity Goes from Won to Lost #4866

Closed jesslopez-sf closed 4 years ago

jesslopez-sf commented 4 years ago

With legacy rollups enabled, a Recurring Donation's Number of Paid Installments field is incorrect when a child Opportunity's Stage moves from Closed Won to Closed Lost.

Workaround: Switch to Customizable Rollups. This switches that field to a rollup and is calculated correctly in this situation.

Root Cause

When legacy rollups are enabled, we calculate the npe03Total_Paid_Installmentsc only when an Opportunity is updated and it is Closed and Won. This occurs in RD_RecurringDonations.cls on line 253.

else if (isClosed == true && isWon == true) {
   rd.npe03__Last_Payment_Date__c = (date) obj.get('MaxDate');

   //convert rollup total to RD's currency
   if (RLLP_OppRollup_UTIL.isMultiCurrency()) {
      rd.npe03__Paid_Amount__c = UTIL_CurrencyConversion.convertFromCorporateUsingStandardRates((String) rd.get(RDCurrencyField), (Decimal) obj.get('Total'));
   } else {
      rd.npe03__Paid_Amount__c = (Decimal) obj.get('Total');
   }
      rd.npe03__Total_Paid_Installments__c = (Integer) obj.get('oppcount');
      updateMap.put(rdid, rd);
}

Steps to Repeat

Test 1:

  1. Make sure that Customizable Rollups are turned OFF in NPSP Settings → Donations → Customizable Rollups.
  2. Create Contact
  3. Create Recurring Donation (Name = Test 1; Open-Ended Status = Open; Contact = your new Contact; Amount = 100; Installment Period = Monthly)
  4. Switch first two Opportunities’ Stages to Closed Won
  5. Confirm that Number of Paid Installments field on Recurring Donation is 2.
  6. Edit one of the Opportunities’ Stages to Closed Lost.
  7. Confirm that Number of Paid Installments remains at 2 (Expected Value = 1).

Test 2:

  1. Turn on Customizable Rollups in NPSP Settings → Donations → Customizable Rollups.
  2. Create Recurring Donation (Name = Test 2; Open-Ended Status = Open; Contact = your new Contact; Amount = 200; Installment Period = Monthly)
  3. Switch first two Opportunities’ Stages to Closed Won
  4. Confirm that Number of Paid Installments field on Recurring Donation is 2.
  5. Edit one of the Opportunities’ Stages to Closed Lost.
  6. Confirm that Number of Paid Installments is reset to 1.
jesslopez-sf commented 4 years ago

**lurch: add

LurchTheButler commented 4 years ago

Tracking W-037954

mpusto commented 4 years ago

We are almost ready to release new RD features and will not be fixing this bug in the old RD code.