-
-
Notifications
You must be signed in to change notification settings - Fork 825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CRM-20750: Incorrect financial trxn entries when payment instrument i… #10920
Conversation
c6217fa
to
9c79280
Compare
test this please |
…s changed on backoffice Contribution edit form added unit test CRM-20750, fixed db entries ---------------------------------------- * CRM-20750: Incorrect financial trxn entries when payment instrument is changed on backoffice Contribution edit form https://issues.civicrm.org/jira/browse/CRM-20750
9c79280
to
793fb67
Compare
On trying to investigate why a test change was required in the original PR I came to the following conclusions: 1) the test function was causing problems by being hard to read. As a result it was too easy to see it as 'accounts magic' - I started a cleanup here 2) Once I understood what was being tested & failing I concluded the change in the PR was in fact wrong as it was putting a negative entry against the new financial account rather than the original one.
793fb67
to
b0e806f
Compare
Change logic for determinig paymentInstrumentChange to look at whether ['payment_instrument_id'] isset. If not it has not been passed by the calling function and by definition the calling function is not attempting to change it
@monishdeb can you review this as a proposed replacement for #10539 - note that your commit is more-or-less-yours with some refactoring added but my 2 are logic changes from yours. |
@eileenmcnaughton I agree with the final patch. Thanks a lot :) Tested on my local, working fine : Should I merge it then? |
} | ||
elseif ((!CRM_Utils_System::isNull($params['payment_instrument_id']) && | ||
!CRM_Utils_System::isNull($params['prevContribution']->payment_instrument_id)) && | ||
$params['contribution']->payment_instrument_id != $params['prevContribution']->payment_instrument_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checking non null value for payment_instrument_id from $params['payment_instrument_id'] and $params['prevContribution']->payment_instrument_id, but in next line comparing payment_instrument from
$params['contribution']->payment_instrument_id
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sunilpawar we are still comparing payment_instrument_id
of 'contribution' and 'prevContribution' respectively. On which line we are comparing the payment_instrument_id
with name payment_instrument
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@monishdeb can we connect Skype? i already send skype request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was something well spotted by @sunilpawar & this should be merged
#10980
In pr civicrm#10920 @sunilpawar spotted this error
Get changes from civicrm#10920 with additional changes for recurring payment.
In pr civicrm#10920 @sunilpawar spotted this error
Get changes from civicrm#10920 with additional changes for recurring payment.
Get changes from civicrm#10920 with additional changes for recurring payment.
Get changes from civicrm#10920 with additional changes for recurring payment.
Get changes from civicrm#10920 with additional changes for recurring payment.
@monishdeb this is the portion of #10539 that I understand. Mostly I have removed the whitespace changes & the test changes (as opposed to the additional test). I expect this to fail & the reason for the test changes to become clearer to me.
Note that I did a further extraction of self::isPaymentInstrumentChange for readability.
In general I feel fairly good about test coverage of the function being changed & most of your change is just tidying up code (unscattering & moving to a function).
There is a change in here that is not spelt out - when altering a check number 2 transactions will no longer be created (a negative & a positive one). Much as I passionately agree with that change I think it needs to be spelt out in the spec & if Joe agrees to it I believe some documentation needs to be updated
https://issues.civicrm.org/jira/browse/CRM-20750
Overview
Fix to incorrect financial items created when editing a payment through the back office contribution form
Before
After altering the credit card details are incorrectly assigned to the reversal entry
[https://issues.civicrm.org/jira/secure/attachment/61870/Screen%20Shot%202017-06-20%20at%205.35.02%20PM.png]
After
Reversal entry is 'clean' of the details from the new transaction. Code readability improved & unit test added
Technical Details
Comments
This is a reviewers commit of #10539
I have done an extraction and made changes to the test. I have not changed what the test tests, which was my concern in the first commit before review.
Notable changes
elseif ((!CRM_Utils_System::isNull($params['contribution']->payment_instrument_id) ||
to
& switched && rather than || in the logic. This was causing a test failure which was changed in the original PR by changes to the test. However, I felt that the logic in fact was wrong, rather than the test. We should check if there is an attempt to change the payment_instrument_id (as represented by the $params array) rather than whether the $params['contribution'] has one.
Unfortunately I think I might be personally guilty of having added $params['contribution'] to the $params array in about 4.2 as a hack to get some data onto the form :-(