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

[ready-for-review]CRM-20193, Draw currency from better table on Batch Transaction form #9930

Merged
merged 3 commits into from
Mar 7, 2017

Conversation

pradpnayak
Copy link
Contributor

@pradpnayak pradpnayak commented Mar 5, 2017

…financial_trxn table and have name field table alias

----------------------------------------
* CRM-20193: Draw currency from better table on Batch Transaction form
  https://issues.civicrm.org/jira/browse/CRM-20193
…the LEFT JOIN

----------------------------------------
* CRM-20193: Draw currency from better table on Batch Transaction form
  https://issues.civicrm.org/jira/browse/CRM-20193
----------------------------------------
* CRM-20193: Draw currency from better table on Batch Transaction form
  https://issues.civicrm.org/jira/browse/CRM-20193
@@ -648,10 +648,11 @@ public static function getBatchFinancialItems($entityID, $returnValues, $notPres
}

$from = "civicrm_financial_trxn
LEFT JOIN civicrm_entity_financial_trxn ON civicrm_entity_financial_trxn.financial_trxn_id = civicrm_financial_trxn.id
INNER JOIN civicrm_entity_financial_trxn ON civicrm_entity_financial_trxn.financial_trxn_id = civicrm_financial_trxn.id
INNER JOIN civicrm_contribution ON (civicrm_contribution.id = civicrm_entity_financial_trxn.entity_id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pradpnayak is there much of an issue here switching from LEFT to INNER JOIN?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggested these changes because the LEFT JOINs were misleading given https://github.com/civicrm/civicrm-core/pull/9930/files#diff-4edf3d9f312c7543c00ef7d38bf21044L726 which forces the existence of a record in both of these tables.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy with that explanation, That makes sense, Just thought worth posing the question

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, how does that tie in with

"This is relevant as the form is intended to allow financial data from other types of financial information as well eg grants, general journal entries. While these have entries in the civicrm_financial_trxn table, they don't have related civicrm_contributions, and a currency is still required."

I feel like that INNER JOIN would exclude them from being pulled in. I read that as a bad thing - but perhaps it is a good thing?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So to me, this was a code cleanup for maintainability.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK - I've worked through the clean up & it all makes sense, and is just clean-up as opposed to functionality change, as you say, except for the removal of

AND civicrm_entity_batch.entity_table = 'civicrm_financial_trxn'

which I'm still not clear about the reason for

@eileenmcnaughton eileenmcnaughton changed the title [ready-for-core-team-to-review]CRM-20193, Draw currency from better table on Batch Transaction form [ready-for-review]CRM-20193, Draw currency from better table on Batch Transaction form Mar 5, 2017
@eileenmcnaughton
Copy link
Contributor

I just removed the core team part, since anyone could be the reviewer. You should still specify core-team if you are funding core team to do the review

if (!$notPresent) {
$where = " ( civicrm_entity_batch.batch_id = {$entityID}
AND civicrm_entity_batch.entity_table = 'civicrm_financial_trxn'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So why did this line get removed

Copy link
Contributor Author

@pradpnayak pradpnayak Mar 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, but as a left join not an INNER join, so removing that will remove the criteria

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Joe pointed out that this line is redundant because the line about is from the same table, & hence the left join would mean the left join would filter out the id & it would be NULL not = $entityID

@@ -722,24 +723,15 @@ public static function getBatchFinancialItems($entityID, $returnValues, $notPres
}
if (!empty($query->_where[0])) {
$where = implode(' AND ', $query->_where[0]) .
" AND civicrm_entity_batch.batch_id IS NULL
AND civicrm_entity_financial_trxn.entity_table = 'civicrm_contribution'";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK - this line is redundant due to inner join above

@eileenmcnaughton eileenmcnaughton merged commit 7166f0c into civicrm:master Mar 7, 2017
@pradpnayak pradpnayak deleted the CRM-20193 branch March 15, 2017 11:42
monishdeb pushed a commit to monishdeb/civicrm-core that referenced this pull request May 2, 2017
[ready-for-review]CRM-20193, Draw currency from better table on Batch Transaction form
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.

5 participants