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

[Currency] Exchange rate refactor #6846

Merged

Conversation

lchrusciel
Copy link
Member

@lchrusciel lchrusciel commented Nov 24, 2016

Q A
Bug fix? yes
New feature? yes
BC breaks? yes
Related tickets partially #6641
License MIT

Based on #6820

@michalmarcinkowski michalmarcinkowski added BC Break PRs introducing BC breaks (do not even try to merge). Bug Fix labels Nov 24, 2016
@lchrusciel lchrusciel changed the title [Currency] Exchange rate refactor [WIP] [Currency] Exchange rate refactor Nov 24, 2016
}

return (int) round($amount * $currency->getExchangeRate());
return (int) round($amount * $exchangeRate->getRatio());
Copy link
Contributor

Choose a reason for hiding this comment

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

We have two cases here:

  1. Ratio for source -> target (multiply)
  2. Ratio for target -> source (divide)
if ($exchangeRate->getSourceCurrency()->getCode() === $sourceCurrencyCode) {
    return (int) round(amount * $exchangeRate->getRatio());
}

return (int) round(amount / $exchangeRate->getRatio());

This should be covered by Behat.

{
if (isset($this->cache[$code])) {
return $this->cache[$code];
$cacheIndex = $sourceCode . $targetCode;
Copy link
Contributor

Choose a reason for hiding this comment

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

$cacheIndex = sprintf('%s-%s', $sourceCode, $targetCode);

@lchrusciel lchrusciel changed the title [WIP] [Currency] Exchange rate refactor [Currency] Exchange rate refactor Nov 24, 2016
@lchrusciel lchrusciel changed the title [Currency] Exchange rate refactor [WIP] [Currency] Exchange rate refactor Nov 24, 2016
@lchrusciel lchrusciel force-pushed the exchange-rate-refactor branch 6 times, most recently from 6c893c8 to 215f832 Compare November 25, 2016 08:44
@lchrusciel lchrusciel changed the title [WIP] [Currency] Exchange rate refactor [Currency] Exchange rate refactor Nov 25, 2016
@michalmarcinkowski michalmarcinkowski merged commit a1cd23a into Sylius:currency-party Nov 25, 2016
@michalmarcinkowski
Copy link
Contributor

Well done! Getting closer to party 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BC Break PRs introducing BC breaks (do not even try to merge).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants