[REF] Move calls to CRM_Core_BAO_FinancialTrxn::createDeferredTrxn back to the calling functions. #15641
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Code -re-arrangment
Before
Harder to see what is happening in updateFinancialAccount function
After
Easier to see what is happening in updateFinancialAccount function
Technical Details
Although this seems like we are increasing duplication - by having more calls to one line of code I feel like
we are better off moving it back to the calling functions as there is 'preparatory wrangling' that also belongs
in the calling functions - notably in changeFinancialType.
I believe we should be able to get to the point where the updateFinancialAccounts funcgtion does not
need to receive context as a parameter because all the context specific stuff will be done in the calling functions
and it will have a clear objective - which I have finally realised is creating the financial transaction
and the financial items - however in some cases it is called twice to do a reversal followed by a line item
and I believe the calling functions could be cleaned up a lot more by 'returning' code to them as
passing by reference leaves us very unclear as to what is happening to them at each point in the process.
Comments