Skip to content
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-21513: Change fee selection for text price field on backoffice Event registration Not Creating Correct Financial Items #11380

Merged
merged 2 commits into from
Dec 14, 2017

Conversation

monishdeb
Copy link
Member

@monishdeb monishdeb commented Dec 6, 2017

Overview

Steps to replicate:

  1. Create pending pay later event registration with text field price option say qty 1 x $10
  2. Pending pay later contribution no showing any financial transactions as expected
  3. Edit selections on event registration by changing qty to 3 (i.e. $30)
  4. Pending pay later contribution STILL no showing any financial transactions as expected.
  5. Edit selections on event registration by changing qty to 2 (i.e. $20)
  6. Pending pay later contribution STILL no showing any financial transactions as expected.

Bug: There is only 1 financial item record that refers to previous line-item of $10 amount. However, financial trxn correctly records the surplus $10.
Expected: There should be 3 financial items refers to old line-item and other referers to the changes made in step 3 and 5. Please check the After screenshot.

Before

Only have 1 financial recrods
screen shot 2017-12-08 at 2 55 19 pm

After

screen shot 2017-12-08 at 2 52 21 pm

Technical Details

Added unit test to assert this scenario.


…ent registration Not Creating Correct Financial Items
@eileenmcnaughton
Copy link
Contributor

test this please

@eileenmcnaughton
Copy link
Contributor

@monishdeb I took a look at this but I guess it really is WIP as tests pass with or without the other changes :-)

@monishdeb
Copy link
Member Author

@eileenmcnaughton the fix is complete but need to add comments, above my changes. Also, need to extend added UT, asserting against expected financial records :)

@eileenmcnaughton
Copy link
Contributor

Ah ok - I'm not totally loving the fix - not that it's wrong but just that I'd prefer to take another step towards readability & this is a (slight) step backwards - but I guess given that the same code needs to be touched again for https://issues.civicrm.org/jira/browse/CRM-20676 I could let it through on this one

@eileenmcnaughton
Copy link
Contributor

What do you think about changing Order.create api so that if it receives an id & a line items array it calls 'changeFeeSelections' - that would give us a more robust way to call the function

@monishdeb
Copy link
Member Author

monishdeb commented Dec 7, 2017

Excellent idea, will put some thoughts in this direction and will see what kind of adjustment it needs to call the changeFeeSelections. This fn is already handling some complex cases of membership and event fee-change so that would be cool to use the existing fn for Order APIs.

On otherhand, I knw the patch isn't clean enough, in terms of readbility, so will do whats needed. Also I think getReverseFinancialItemsToRecord name is not appropriate, may be getAdjustedFinancialItemsToRecord ?

@eileenmcnaughton
Copy link
Contributor

I feel like the issue with the code (which is not caused by this patch) is that it still mixes up processes for no obvious reason - ie. the recordAdjustedAmt function should probably do all the financial trxn / financial item changes rather than some & some being in the parent function.

Also, I tried changing from one option value to an option value Plus a text value & that got wierder. I support further changes going into the rc in this area (I think 4.7.29 is cut)

@monishdeb
Copy link
Member Author

@eileenmcnaughton I agree. I think we should first resolve all the issues on 1st round. Then on 2nd round we need to adjust Order API to use changeFeeSelections fn. And in 3rd around we need to refactor the fn to move all the financial trxn / financial item changes to recordAdjustedAmt fn. What do you think?

This PR is ready for review!

@monishdeb monishdeb changed the title [WIP] CRM-21513: Change fee selection for text price field on backoffice Event registration Not Creating Correct Financial Items CRM-21513: Change fee selection for text price field on backoffice Event registration Not Creating Correct Financial Items Dec 8, 2017
@eileenmcnaughton
Copy link
Contributor

I'm merging this because after testing & code review I agree it takes us forwards, & locks it in with a test. I'm still not convinced we have all the issues in this code resolved / covered by tests - but I think we should merge this & then move onto trying to replicate https://issues.civicrm.org/jira/browse/CRM-21414 & https://issues.civicrm.org/jira/browse/CRM-20676

@eileenmcnaughton eileenmcnaughton merged commit 03b9e33 into civicrm:master Dec 14, 2017
@monishdeb monishdeb deleted the CRM-21513 branch December 17, 2017 13:17
sluc23 pushed a commit to ixiam/civicrm-core that referenced this pull request Jan 10, 2018
CRM-21513: Change fee selection for text price field on backoffice Event registration Not Creating Correct Financial Items
@vakeesan26
Copy link

when we doing change selection and then record payment it is creating two completed financial transactions. which is affecting the Accounting Batch.
1
2
3

@eileenmcnaughton
Copy link
Contributor

let's track that in gitlab https://lab.civicrm.org/dev/core/issues/309

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants