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

[Behat] Fix base currency step semantics #6791

Merged

Conversation

Zales0123
Copy link
Member

@Zales0123 Zales0123 commented Nov 21, 2016

Q A
Bug fix? yes
New feature? no
BC breaks? no
Related tickets #6766
License MIT

According to upcoming changes with currencies, it will be more appropriate to have base currency set in channel creation step (United States channel has obviously USD base currency).

@@ -11,7 +11,7 @@ Feature: Viewing details of an order
And the store operates on a channel named "Web"
And that channel allows to shop using the "USD" currency
And that channel allows to shop using the "GBP" currency with exchange rate 3.0
And that channel uses the "USD" currency by default
And that channel uses the "USD" currency as base
Copy link
Member

Choose a reason for hiding this comment

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

I would change a whole sentence... And that channel operates on "USD" currency?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not exactly, as channel can operate on many currencies, but it has only one base currency. Maybe sth like And that channel's base currency is "USD"?

Copy link
Member

Choose a reason for hiding this comment

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

Not exactly. Channel will operate only on a one currency, but prices can be shown in different for your convenience. I would stay with And that channel operates on "USD" currency

Copy link
Member Author

Choose a reason for hiding this comment

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

Not exactly. Channel will operate only on a one currency, but for now it can operate on many of them. So for now this sentence would be incorrect.

Copy link
Contributor

Choose a reason for hiding this comment

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

Not exactly 🌮

Copy link
Member

@lchrusciel lchrusciel Nov 21, 2016

Choose a reason for hiding this comment

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

Not exactly. Channel can operate only on a one currency from the beginning. If we want to be so semantical strict, the sentence should be And that channel base display currency is "USD". Anyway, with your last argument there is no point in changing it now, because this sentence will be for 100% incorrect in one/two days.

Copy link
Member Author

Choose a reason for hiding this comment

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

Not exactly. There is a concept of baseCurrency on Channel entity and it will not be deleted in the nearest (or further) future. So the sentence And that channel's base currency is "USD" is 100% correct now and in the future. And that channel uses the "USD" currency by default is not 100% correct neither now nor in the future, IMO the same with And that channel operates on "USD" currency. channel's base currency is not open to interpretation, it's exactly what we do with channel (especially as it's the setup step).

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, so after internal brainstorm we decided to merge this step with step that creates channel to have And the store operates on a channel named "Web" in "USD" currency - that will be suitable for further pricing changes (however destroys our beautiful argument 😢 ).

And that channel allows to shop using "EUR" and "GBP" currencies
And that channel uses the "EUR" currency as base
And the store operates on another channel named "Web-GB"
Copy link
Contributor

Choose a reason for hiding this comment

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

... another channel named "Web-GB" in currency "GBP"

And that channel allows to shop using "EUR" and "GBP" currencies
And that channel uses the "EUR" currency by default
And the store operates on another channel named "Web-GB"
Copy link
Contributor

Choose a reason for hiding this comment

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

... another channel named "Web-GB" **in "GBP" currency

*/
public function itUsesTheCurrencyByDefault(ChannelInterface $channel, $currencyCode)
public function itUsesTheCurrencyAsBase(ChannelInterface $channel, $currencyCode)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be removed.

@@ -8,10 +8,9 @@ Feature: Viewing details of an order
Given the store ships to "British Virgin Islands"
And the store has a zone "English" with code "EN"
And this zone has the "British Virgin Islands" country member
And the store operates on a channel named "Web"
And the store operates on a channel named "Web" in currency "USD"
And that channel allows to shop using the "USD" currency
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it still needed?

@@ -8,10 +8,9 @@ Feature: Seeing prices recalculated by exchange rate on order summary
Given the store ships to "British Virgin Islands"
And the store has a zone "English" with code "EN"
And this zone has the "British Virgin Islands" country member
And the store operates on a channel named "Web"
And the store operates on a channel named "Web" in currency "USD"
And that channel allows to shop using the "USD" currency
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 etc.

{
if (null === $currencyCode) {
Copy link
Contributor

Choose a reason for hiding this comment

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

$currencyCode = $currencyCode ?: self::DEFAULT_CURRENCY_CODE;

{
if (null === $currencyCode) {
Copy link
Contributor

Choose a reason for hiding this comment

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

$currencyCode = $currencyCode ?: $this->defaultCurrencyCode;

@michalmarcinkowski
Copy link
Contributor

Which of these two is correct ... in currency "USD" or ... in "USD" currency? /cc @TheMadeleine

@Zales0123 Zales0123 force-pushed the fix-base-channel-currency-step branch from 4a0272b to d5a7426 Compare November 21, 2016 15:50
@CoderMaggie
Copy link
Member

@michalmarcinkowski both are ok, but in "USD" currency sounds better imo.

@michalmarcinkowski
Copy link
Contributor

I would vote for in "USD" currency also. @Zales0123 could you correct it? :)

@Zales0123 Zales0123 force-pushed the fix-base-channel-currency-step branch from d5a7426 to 7981e8d Compare November 22, 2016 07:29
@Zales0123 Zales0123 force-pushed the fix-base-channel-currency-step branch from 7981e8d to 7c20c56 Compare November 22, 2016 09:31
{
$currencyCode = $currencyCode ?: self::DEFAULT_CURRENCY_CODE;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can always use USD in this case, it's "The United States" channel, so the currency is pretty much known and immutable :) In Default channel it makes sense, but for this specific factory it doesn't IMO.

$order->setLocaleCode((null !== $localeCode) ? $localeCode : $this->sharedStorage->get('locale')->getCode());

$currencyCode = $currencyCode ? $currencyCode : $this->sharedStorage->get('currency')->getCode();
$currencyCode = $currencyCode ? $currencyCode : $order->getChannel()->getBaseCurrency()->getCode();
Copy link
Contributor

Choose a reason for hiding this comment

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

The order should be always created with base currency of the channel in which it was placed. We should not allow to pass other value here.


$this->sharedStorage->setClipboard($defaultData);
$this->sharedStorage->set('channel', $defaultData['channel']);
$this->currencyStorage->set($defaultData['channel'], $defaultData['currency']->getCode());
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this?

@michalmarcinkowski michalmarcinkowski merged commit 46f179e into Sylius:master Nov 22, 2016
@michalmarcinkowski
Copy link
Contributor

Thanks Mateusz! Please apply my comments in a separate PR.

pamil pushed a commit to pamil/Sylius that referenced this pull request May 7, 2019
…cy-step

[Behat] Fix base currency step semantics
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants