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

MC-23915: Wrong currency symbol in creditmemo_grid & sales_order_view > creditmemo grid for subtotal & Shipping and Handling fee #31553

Merged
merged 6 commits into from
Jan 20, 2021

Conversation

engcom-Echo
Copy link
Contributor

Description (*)

Related Pull Requests

Fixed Issues (if relevant)

  1. Fixes Wrong currency symbol in creditmemo_grid & sales_order_view > creditmemo grid for subtotal & Shipping and Handling fee #22662

Manual testing scenarios (*)

See : #22662

Questions or comments

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

… > creditmemo grid for subtotal & Shipping and Handling fee
@m2-assistant
Copy link

m2-assistant bot commented Jan 5, 2021

Hi @engcom-Echo. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names. Allowed build names are:

  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE,
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests

You can find more information about the builds here

ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review.

For more details, please, review the Magento Contributor Guide documentation.

⚠️ According to the Magento Contribution requirements, all Pull Requests must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@m2-community-project m2-community-project bot added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label Jan 5, 2021
@engcom-Echo
Copy link
Contributor Author

@magento run all tests

/**
* @var OrderRepositoryInterface
*/
private $order;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
private $order;
private $orderRepository;

Comment on lines 75 to 77
$currencyCode = isset($item['order_currency_code'])
? $item['order_currency_code']
: $this->order->get($item['order_id'])->getOrderCurrencyCode();
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Looks like here we can use ?? here
Suggested change
$currencyCode = isset($item['order_currency_code'])
? $item['order_currency_code']
: $this->order->get($item['order_id'])->getOrderCurrencyCode();
$currencyCode = $item['order_currency_code'] ?? $this->order->get($item['order_id'])->getOrderCurrencyCode();
  1. Loading objects in the loop is a really heavy operation and not recommended. Can we load all needed orders at once? Or maybe we can do that when preparing dataSource?

Copy link
Contributor Author

@engcom-Echo engcom-Echo Jan 6, 2021

Choose a reason for hiding this comment

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

  1. Thanks.
  2. Will do

) {
$this->priceFormatter = $priceFormatter;
$this->currency = $currency ?: \Magento\Framework\App\ObjectManager::getInstance()
->create(Currency::class);
$this->order = $order ?: \Magento\Framework\App\ObjectManager::getInstance()
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
$this->order = $order ?: \Magento\Framework\App\ObjectManager::getInstance()
$this->orderRepository = $orderRepository ?? \Magento\Framework\App\ObjectManager::getInstance()

/**
* @var OrderRepositoryInterface|MockObject
*/
protected $orderMock;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
protected $orderMock;
private $orderRepositoryMock;

… > creditmemo grid for subtotal & Shipping and Handling fee
@m2-community-project m2-community-project bot moved this from Changes Requested to Review in Progress in High Priority Pull Requests Dashboard Jan 6, 2021
@engcom-Echo
Copy link
Contributor Author

@magento run all tests

Copy link
Contributor

@ihor-sviziev ihor-sviziev left a comment

Choose a reason for hiding this comment

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

I still believe we can iterate all the orders and get all needed info with a single request instead of loading each order in the loop. Please update the solution

/**
* @var OrderRepositoryInterface|MockObject
*/
private $orderRepository;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
private $orderRepository;
private $orderRepositoryMock;

[
'currency' => $this->currencyMock,
'context' => $contextMock,
'order' => $this->orderRepository,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
'order' => $this->orderRepository,
'orderRepository' => $this->orderRepositoryMock,

Comment on lines 71 to 76
public function testPrepareDataSource(
$itemName,
$oldItemValue,
$newItemValue,
$orderCurrencyCode
): void {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public function testPrepareDataSource(
$itemName,
$oldItemValue,
$newItemValue,
$orderCurrencyCode
): void {
public function testPrepareDataSource(
string $itemName,
string $oldItemValue,
string $newItemValue,
?string $orderCurrencyCode
): void {

@m2-community-project m2-community-project bot moved this from Review in Progress to Changes Requested in High Priority Pull Requests Dashboard Jan 6, 2021
… > creditmemo grid for subtotal & Shipping and Handling fee
@dmitriyprime
Copy link
Contributor

@magento i am working on it

@zakdma
Copy link
Contributor

zakdma commented Jan 19, 2021

@magento-engcom-team
Copy link
Contributor

@zakdma, an error occurred during the Pull Request import.

@magento-engcom-team
Copy link
Contributor

@zakdma the branch with code successfully imported intomagento-tsg/magento2ce repository. Branch name: imported-magento-magento2-31553.

@engcom-Bravo
Copy link
Contributor

✔️ QA Passed

Manual testing scenario

  1. From Admin Panel, go to Stores - All Stores and create a second Website, Store, Store View
  2. Go to Stores - Configuration and change the Scope for the previously created second Store View
  3. Go to General - Currency Setup and add Ukrainian Hryvnia to Allowed Currencies
  4. Change the Default Display Currency to Ukrainian Hryvnia. Save Config
  5. Go to Stores - Currency Rates and set 2 for UAH. Save Currency Rates
  6. Create an order from the second Store, where the currency is UAH
  7. From Admin Panel, go to Sales - Orders. Create an Invoice for the previously created order
  8. Create a Credit Memo for the previously created order
  9. Open Orders Grid.
  10. Click Columns and check Subtotal and Shipping and Handling
  11. Observe the Currency symbol in Grand Total (Base), Subtotal and Shipping and Handling columns
    The currency symbol is Dollar $
    dollar
  12. Go to Sales - Credit Memos grid and observe Currency symbol in Refund, Subtotal and Shipping and Handling columns
    The currency symbol is Dollar $
    cr_m_dollar

AFTER applying changes provided in the PR the Currency symbol in the Credit Memo grid is displayed correctly
after

after2

@engcom-Bravo engcom-Bravo moved this from Testing in Progress to Extended Testing (optional) in High Priority Pull Requests Dashboard Jan 19, 2021
@engcom-Bravo engcom-Bravo added the QA: Added to Regression Scope Scenario was analysed and added to Regression Testing Scope label Jan 19, 2021
@m2-community-project m2-community-project bot moved this from Extended Testing (optional) to Ready for Testing in High Priority Pull Requests Dashboard Jan 19, 2021
@engcom-Bravo engcom-Bravo moved this from Ready for Testing to Extended Testing (optional) in High Priority Pull Requests Dashboard Jan 19, 2021
@magento-engcom-team magento-engcom-team merged commit 43a568e into magento:2.4-develop Jan 20, 2021
@m2-assistant
Copy link

m2-assistant bot commented Jan 20, 2021

Hi @engcom-Echo, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Frontend Auto-Tests: Covered All changes in Pull Request is covered by auto-tests Award: bug fix Award: test coverage Component: Sales Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: accept Progress: extended testing QA: Added to Regression Scope Scenario was analysed and added to Regression Testing Scope Release Line: 2.4 Type: Bug Fix
Projects
None yet
7 participants