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

[wip] CRM-19585, added function to Calculate Tax for each item when Financi… #9685

Closed
wants to merge 2 commits into from

Conversation

pradpnayak
Copy link
Contributor

…al Type is changed.


* @param int $contributionId
*
*/
public static function calculateTaxAfterChangeInFinancialTypeForLineItems($lineItem, $contributionId) {
Copy link
Member

Choose a reason for hiding this comment

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

I think this method name and its description are confusing. Usually, the method name should describe what it does and not when it should be executed. It says it calculates the Tax after the Financial Type is changed, but looking at the code, it looks like it can do the calculation anytime, even if the Financial Type hasn't been changed.

Copy link
Contributor

@JoeMurray JoeMurray Mar 13, 2017

Choose a reason for hiding this comment

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

Pradeep, there is merit in @davialexandre comment, but the code at some level needs to be either reversing out financial_items for both the line_item and its tax and posting new entries (I think that is the spec at https://wiki.civicrm.org/confluence/display/CRM/CiviAccounts+Data+Flow but Confluence is down at the moment) or maybe (I don't think so) creating a difference transaction for financial_line_item for both line item and tax. Could you respond to his comment? Thx.

* Calculate Tax for each item when Financial Type is changed.
*
* @param array $lineItem
*
Copy link
Member

Choose a reason for hiding this comment

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

no need to this empty line here

Copy link
Contributor

@JoeMurray JoeMurray Mar 13, 2017

Choose a reason for hiding this comment

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

https://www.drupal.org/node/1354#functions suggests a blank line between args and no blank line after last one.

* @param array $lineItem
*
* @param int $contributionId
*
Copy link
Member

Choose a reason for hiding this comment

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

no need for this empty line here

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, https://www.drupal.org/node/1354#functions suggests a blank line between args and no blank line after last one.

*
* @param int $contributionId
*
*/
Copy link
Member

Choose a reason for hiding this comment

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

Missing @return

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed. Partially fixed in updated PR.

@@ -5457,4 +5457,25 @@ public static function createProportionalFinancialEntries($entityParams, $lineIt
}
}

/**
* Calculate Tax for each item when Financial Type is changed.
*
Copy link
Member

Choose a reason for hiding this comment

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

It would be nice to add the logic of the calculation to the method description. Otherwise, we have to read the code in order to understand what is going on

Copy link
Contributor

Choose a reason for hiding this comment

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

This function is just repeatedly calling a different function that does the calculation. I don't think it should be documenting details that is not responsible for.

/**
* Calculate Tax for each item when Financial Type is changed.
*
* @param array $lineItem
Copy link
Member

Choose a reason for hiding this comment

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

It would be nice to know what are the values expected in this $lineItem array

Copy link
Contributor

Choose a reason for hiding this comment

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

explained in updated PR

* @param int $contributionId
*
*/
public static function calculateTaxAfterChangeInFinancialTypeForLineItems($lineItem, $contributionId) {
Copy link
Member

Choose a reason for hiding this comment

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

What about adding tests to this new method?

Copy link
Contributor

Choose a reason for hiding this comment

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

Pradeep, you should respond to each comment indicating if you accept it or provide reason(s) for disagreeing. In this case, indicate that you have added a test in updated PR.

…al Type is changed.

----------------------------------------
* CRM-19585: Sales tax issue
  https://issues.civicrm.org/jira/browse/CRM-19585
----------------------------------------
* CRM-19585: Sales tax issue
  https://issues.civicrm.org/jira/browse/CRM-19585
@Edzelopez
Copy link
Contributor

Jenkins, test this please

@pradpnayak
Copy link
Contributor Author

jenkins, retest this please

Copy link
Contributor

@eileenmcnaughton eileenmcnaughton left a comment

Choose a reason for hiding this comment

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

Same comments as the others. Can we get some context on this so it can be reviewed

@eileenmcnaughton eileenmcnaughton changed the title CRM-19585, added function to Calculate Tax for each item when Financi… [wip] CRM-19585, added function to Calculate Tax for each item when Financi… Mar 10, 2017
@eileenmcnaughton
Copy link
Contributor

setting to WIP, needs it's own ticket & steps to replicate the problem this is trying to solve

* @param int $contributionId
* the id of the contribution
*
* @return array
Copy link
Contributor

Choose a reason for hiding this comment

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

This is incorrect. Could you indicate the data type and precision of the returned contribution total tax amount.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the input @JoeMurray - I hadn't gone down to the code level on these PRs yet, because I wanted to start from an understanding of what they are trying to fix

@JoeMurray
Copy link
Contributor

I agree with need for issue and context.

@JoeMurray
Copy link
Contributor

Pradeep, in general, please respond to each comment separately indicating if you have accepted or why not. Although comments become dated when you submit a new PR, everyone needs to manage the feedback to track if everything has been fixed or not; hence the need for individual replies rather than an updated PR and silence on the comments.

@colemanw
Copy link
Member

@pradpnayak could you please rebase this and also merge in the branch CRM-19585-8 to this PR because they are similar enough to be combined into one PR.

@monishdeb
Copy link
Member

@colemanw I have closed in favor of #10172 after rebase

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.

8 participants