[REF] Clean up handling of financial_type_id override
authoreileen <emcnaughton@wikimedia.org>
Sat, 1 Aug 2020 20:45:13 +0000 (08:45 +1200)
committereileen <emcnaughton@wikimedia.org>
Mon, 3 Aug 2020 01:35:58 +0000 (13:35 +1200)
commitfa839a6825d6e6bea4005b5a7d1420260c6ecd31
tree1474e83bb202ee570782a17ba6a81ca842302a29
parent486e4f90ab2e4decff64d87898d4378915605b2e
[REF] Clean up handling of financial_type_id override

Currently we use the primaryContributionID to determine whether the templateContribution will
have more than one line item & unset the parameter. It makes much more sense to do evaluations
on how many line items the template contribution will have when we have loaded it's line items.

The logic is that the financial_type_id can be overriden either by editing the recurring contribution
(which you are permitted to do if only one line item exists) or by passing it in via input (which
is ignored if there is more than one line item.

This change ensures the input parameter reaches repeatTrannsaction - which is the appropriate
place to determine whether to apply it.

It removes one of 2 places that refers to primaryContributionID. The other is also inappropriate
as it is basically used to look up the line items to see the number of terms for the membership. However,
we already know that for any repeat transactions as we have already loaded the line items. In
completeOrder the line items are that of the contribution being saved.

We could pass the saved contribution id into this function as a quick way to eliminate the primaryContributionID
or we could just determine num_terms rather than primaryContributionID earlier on
CRM/Contribute/BAO/Contribution.php
CRM/Contribute/BAO/ContributionRecur.php
tests/phpunit/CRM/Event/Form/Task/ParticipantStatusTest.php [new file with mode: 0644]
tests/phpunit/CiviTest/CiviUnitTestCase.php
tests/phpunit/api/v3/ContributionTest.php