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

Fix creditmemo tax calculation bug when using multiple discounts #88

Closed
wants to merge 2 commits into from

Conversation

seansan
Copy link
Contributor

@seansan seansan commented May 18, 2016

Fix creditmemo tax calculation bug when using multiple discounts

Needs code review and additional testing

But this has been tested in production and solved our errors with creditmemo calculation missing value

Replace

        $creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $subtotal);
        $creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseSubtotal);

with 

        $creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $subtotalInclTax);
        $creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseSubtotalInclTax);
@LeeSaferite
Copy link
Contributor

Can you give a detail description of the problem and how this code solves the issue?
Looking at the code I see what appears to be dead code. The changes in the collectTotals method seem to just be removing the 'tax' total collector.

@seansan
Copy link
Contributor Author

seansan commented May 19, 2016

When adding several product types and utilizing several (more than 1) discount code the credit memo calculation is not correct.

Before the fix the order value is 184,40 and credit memo is 181,41
After the the fix the order value is 184,40 and credit memo is 184,40

So in essence it seems to solves an tax issue when utilizing cart discounts

@colinmollenhour
Copy link
Member

Does this merge cleanly with 1.9.3.0?

@tmotyl tmotyl changed the base branch from 1.9.2.4 to 1.9.3.x March 15, 2017 13:42
@tmotyl
Copy link
Contributor

tmotyl commented Mar 15, 2017

I've changed the base to 1.9.3.x, however a confirmation is needed whether the bug occures in 1.9.3 still.

public function collectTotals()
{
foreach ($this->getConfig()->getTotalModels() as $model) {
public function collectTotals()
Copy link
Contributor

Choose a reason for hiding this comment

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

whitespace issue here (space)

{
$models = $this->getConfig()->getTotalModels();
$res = array();
$i=0;
Copy link
Contributor

Choose a reason for hiding this comment

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

whitespaces

$i=0;
$discount = 0;
foreach ($models as $name =>$model) {
if ($name=='discount') $discount = $i;
Copy link
Contributor

Choose a reason for hiding this comment

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

whitespaces around == needed, and please wrap $discount = $i; with brackets {}

$discount = 0;
foreach ($models as $name =>$model) {
if ($name=='discount') $discount = $i;
if ($name=='tax') {
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

@tmotyl
Copy link
Contributor

tmotyl commented Mar 22, 2017

@seansan can you improve the pull request and confirm that the issue still exists?

@seansan
Copy link
Contributor Author

seansan commented Mar 22, 2017

Feel free to change pull. But more importantly there needs to be more than 1 test ....

@tmotyl
Copy link
Contributor

tmotyl commented Mar 22, 2017

@seansan I have no access to this branch, probably you forgot to select a checkbox like "allow contributors to edit..." when making pull request

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.

None yet

5 participants