-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[Behat] Fix base currency step semantics #6791
Conversation
@@ -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 |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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"
?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not exactly 🌮
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$currencyCode = $currencyCode ?: $this->defaultCurrencyCode;
Which of these two is correct |
4a0272b
to
d5a7426
Compare
@michalmarcinkowski both are ok, but |
I would vote for |
d5a7426
to
7981e8d
Compare
7981e8d
to
7c20c56
Compare
{ | ||
$currencyCode = $currencyCode ?: self::DEFAULT_CURRENCY_CODE; |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this?
Thanks Mateusz! Please apply my comments in a separate PR. |
…cy-step [Behat] Fix base currency step semantics
According to upcoming changes with currencies, it will be more appropriate to have base currency set in channel creation step (
United States
channel has obviouslyUSD
base currency).