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] Refactoring of display currency feature #6820

Conversation

lchrusciel
Copy link
Member

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

@michalmarcinkowski michalmarcinkowski added BC Break PRs introducing BC breaks (do not even try to merge). Bug Fix labels Nov 22, 2016
@lchrusciel lchrusciel changed the title [WIP] [Currency] Exchange rate can into shop [WIP] [Currency] Refactoring of display currency feature Nov 22, 2016
@lchrusciel lchrusciel force-pushed the exchange-rate-can-into-shop branch 2 times, most recently from ddccf91 to 5250160 Compare November 23, 2016 10:35
@lchrusciel lchrusciel changed the title [WIP] [Currency] Refactoring of display currency feature [Currency] Refactoring of display currency feature Nov 23, 2016
@@ -5,17 +5,16 @@ Feature: Viewing details of an order
I want to be able to view details of my placed order
Copy link
Contributor

@michalmarcinkowski michalmarcinkowski Nov 24, 2016

Choose a reason for hiding this comment

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

This feature isn't good, we should have a feature "Order is always placed in a base currency of a channel" and then in the scenario:

  1. Browse shop in a different than base currency
  2. Place order through UI
  3. Verify than order amounts are in a base 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.

We have such a scenario in checkout

Given I have added 2 products "The Pug Mug" to the cart
When I switch to the "EUR" currency
Then grand total value should be "€13.63"
And grand total value in base currency should be "$14.00"
Copy link
Contributor

Choose a reason for hiding this comment

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

We should also assert the value of a single item, to show the rounding issue.

@@ -14,13 +14,12 @@ Feature: Modifying a customer's shipping address of an order with a different cu
And the store has "DHL" shipping method with "$20.00" fee within the "EN" zone
Copy link
Contributor

@michalmarcinkowski michalmarcinkowski Nov 24, 2016

Choose a reason for hiding this comment

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

This feature can be removed. We don't have exchange rate on the order anymore, and we always display the amounts from database in admin, so there is no possibility to break something when changing exchange rate.

Then I should see the order "#00000666" with total "£40.00"

@ui
Scenario: Seeing multiple orders in different currencies
Copy link
Contributor

Choose a reason for hiding this comment

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

We should have such scenario, but use 2 channels with different base currencies.

Copy link
Member Author

Choose a reason for hiding this comment

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

@@ -9,7 +10,7 @@
{{ payment.method }}
</div>
<p>
{{ payment.amount|sylius_price(payment.order.currencyCode) }}
{{ money.convertAndFormat(payment.amount) }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if we should convert the value here, the customer will be charged in a base currency anyway /cc @pjedrzejewski

Copy link
Member Author

Choose a reason for hiding this comment

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

Of course not.

@michalmarcinkowski
Copy link
Contributor

Looks good! 👍 Rebase needed.

@lchrusciel lchrusciel force-pushed the exchange-rate-can-into-shop branch 2 times, most recently from 26f1ea5 to 92f8b3b Compare November 24, 2016 09:37
As a Visitor
I want to see every cash amount in my chosen currency
I want to see rounded every cash amount in my chosen currency
Copy link
Contributor

Choose a reason for hiding this comment

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

Changing display currency of the cart
and
I want to see every cash amount rounded to my chosen currency
or something alike

Scenario: Changing the currency of my cart
Given I have product "The Pug Mug" in the cart
When I switch to the "EUR" currency
Then grand total value should be "€6.82"
Copy link
Contributor

Choose a reason for hiding this comment

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

the grand total... same below

*/
public function myBaseCartTotalShouldBe($total)
{
$this->summaryPage->open();
Copy link
Contributor

Choose a reason for hiding this comment

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

add an empty line below

@lchrusciel lchrusciel force-pushed the exchange-rate-can-into-shop branch 3 times, most recently from e26edcd to 6f39136 Compare November 24, 2016 13:37
@michalmarcinkowski
Copy link
Contributor

Rebase needed :)

@lchrusciel
Copy link
Member Author

@michalmarcinkowski done

And that channel allows to shop using the "CAD" currency with exchange rate 3.0
And the store ships to "United States"
And the store has a zone "United States" with code "US"
And this zone has the "United States" country member
Copy link
Contributor

Choose a reason for hiding this comment

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

We should use DefaultUnitedStatesChannelFactory and then the 3 steps above won't be necessary.

Copy link
Member Author

Choose a reason for hiding this comment

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

This test is turned of, it can be adjusted later on.

And the store has a product "Angel T-Shirt" priced at "$20.00"
And I am a logged in customer

# This test should pass, but refactoring of context would be needed to fulfill requirements. Because refactoring is postponed this test will be turned on later
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the issue?

Copy link
Member Author

Choose a reason for hiding this comment

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

I need to process whole checkout and then access a show page of an order. Both of them have specifyEmail method. There is no point in creating order programmatically.

{% macro convertAndFormat(amount) %}
{% import _self as macro %}

{{ macro.format(amount|sylius_convert_money(shopperContext.currencyCode), shopperContext.currencyCode) }}
Copy link
Contributor

Choose a reason for hiding this comment

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

We should use shopperContext.channel.baseCurrency as a base 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.

Already done

@michalmarcinkowski michalmarcinkowski merged commit c61ae06 into Sylius:currency-party Nov 25, 2016
@michalmarcinkowski
Copy link
Contributor

Great work! Please apply my comments in a separate PR.

@lchrusciel lchrusciel deleted the exchange-rate-can-into-shop branch November 25, 2016 07:33
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

3 participants