magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.56k stars 9.32k forks source link

Admin Dashboard shows wrong period for yearly statistics #29734

Closed norgeindian closed 3 months ago

norgeindian commented 4 years ago

Preconditions (*)

  1. Magento 2.4-develop, 2.3.5-p2

Steps to reproduce (*)

  1. Login to the admin dashboard
  2. Change time period to yearly
  3. Check graph

Expected result (*)

  1. I would expect the shown period to only include the last 12 months

Actual result (*)

![image](https://user-images.githubusercontent.com/11156287/91152880-ce269b00-e6bf-11ea-9da0-fcce983a9d0a.png) More than 12 months are shown. Everything until beginning of 2019 is shown instead of only the period between August 2019 and August 2020. ![image](https://user-images.githubusercontent.com/51681379/91813789-e0628500-ec3b-11ea-85c2-36fa15f615c3.png) Proposed [solution](https://github.com/magento/magento2/issues/29734#issuecomment-682029009) --- Please provide [Severity](https://devdocs.magento.com/guides/v2.3/contributor-guide/contributing.html#backlog) assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes. - [ ] Severity: **S0** _- Affects critical data or functionality and leaves users without workaround._ - [ ] Severity: **S1** _- Affects critical data or functionality and forces users to employ a workaround._ - [ ] Severity: **S2** _- Affects non-critical data or functionality and forces users to employ a workaround._ - [x ] Severity: **S3** _- Affects non-critical data or functionality and does not force users to employ a workaround._ - [ ] Severity: **S4** _- Affects aesthetics, professional look and feel, “quality” or “usability”._
m2-assistant[bot] commented 4 years ago

Hi @norgeindian. Thank you for your report. To help us process this issue please make sure that you provided the following information:

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

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

Please, add a comment to assign the issue: @magento I am working on this


:clock10: You can find the schedule on the Magento Community Calendar page.

:telephone_receiver: The triage of issues 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.

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

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

victortodoran commented 4 years ago

@magento give me 2.4 instance

victortodoran commented 4 years ago

@magento give me 2.4-develop instance

magento-engcom-team commented 4 years ago

Hi @victortodoran. Thank you for your request. I'm working on Magento 2.4-develop instance for you

magento-engcom-team commented 4 years ago

Hi @victortodoran, here is your Magento instance. Admin access: https://i-29734-2-4-develop.instances.magento-community.engineering/admin_39a7 Login: caeaa300 Password: 8ef7cc6790dc Instance will be terminated in up to 3 hours.

m2-assistant[bot] commented 4 years ago

Hi @engcom-Delta. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

magento-engcom-team commented 4 years ago

:white_check_mark: Confirmed by @engcom-Delta Thank you for verifying the issue. Based on the provided information internal tickets MC-37060 were created

Issue Available: @engcom-Delta, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

Blatant commented 4 years ago

Just FYI, I beleive the issue is in the logic at lines 453 to 468 of the file D:\wamp64\www\autoglym2.local\vendor\magento\module-reports\Model\ResourceModel\Order\Collection.php

        case '2y':
            $startMonthDay = explode(
                ',',
                $this->_scopeConfig->getValue(
                    'reports/dashboard/ytd_start',
                    \Magento\Store\Model\ScopeInterface::SCOPE_STORE
                )
            );
            $startMonth = isset($startMonthDay[0]) ? (int)$startMonthDay[0] : 1;
            $startDay = isset($startMonthDay[1]) ? (int)$startMonthDay[1] : 1;
            $dateStart->setDate($dateStart->format('Y'), $startMonth, $startDay);
            //$dateStart->modify('-1 year');
            if ($range == '2y') {
                $dateStart->modify('-1 year');
            }
            break;

Here, I've commented out line 464 to fix it.

The logic being the line 463 $dateStart->setDate($dateStart->format('Y'), $startMonth, $startDay); this sets the date to the current year (with start day configs, pretty meaningless), so for today thats "1-1-2020" assuming defaults

line 464 takes a year off, so thats "1-1-2019" $dateStart->modify('-1 year');

then lines 465 to 467 are if its 2 years to date, take another year off, thats 1-1-2018. if ($range == '2y') { $dateStart->modify('-1 year'); }

So Year to Date YTD and 2 year to date 2YTD are both incorrectly offset by a year. YTD measn you need to start at the beginning of the current year as is calculated in the first statement.

Then a year is taken off, which is where the error is (note I commented it out in the snippet above)

Then the extra year is correctly taken off for the "2y" case.

Good news is, the containing function is public and on a concrete class so it should be easy to write an plugin around the function to correct. Bad news is, this looks like a generic collection used for many reports, I'm not sure if this would impact anything in the actual reporting area of admin....

kaivanshah02 commented 4 years ago

@magento I'm working on it,

m2-assistant[bot] commented 4 years ago

Hi @kaivanshah02! :wave: Thank you for collaboration. Only members of Community Contributors Team are allowed to be assigned to the issue. Please use @magento add to contributors team command to join Contributors team.

kaivanshah02 commented 4 years ago

@magento I'm working on it.

kaivanshah02 commented 4 years ago

@magento add to contributors team

m2-assistant[bot] commented 4 years ago

Hi @kaivanshah02! :wave: Thank you for joining. Please accept team invitation :point_right: here :point_left: and add your comment one more time.

kaivanshah02 commented 4 years ago

@magento I'm working on it.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 14 days if no further activity occurs. Is this issue still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? Thank you for your contributions!

norgeindian commented 3 years ago

@kaivanshah02 , any news regarding this topic?

eBusinessAtlantique commented 3 years ago

Same problem on 2.3.6-p1. I am interested in a solution. Thanks.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 14 days if no further activity occurs. Is this issue still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? Thank you for your contributions!

sprankhub commented 3 years ago

Still relevant AFAIK.

norgeindian commented 3 years ago

Definitely, still no solution here as far as I see.

ThomasT2020 commented 3 years ago

I confirm this is still an issue in 2.3.7-p1

norgeindian commented 3 years ago

It also still appears in 2.4.2-p1

norgeindian commented 3 years ago

Still an issue in 2.4.3-p1

zigojacko commented 2 years ago

Is anyone actually bothering to acknowledge this bug and roll-out a fix?

It was reported over a year ago and is still a present issue in the latest stable release...

norgeindian commented 2 years ago

Still not correct in Magento 2.4.3-p2

norgeindian commented 2 years ago

Any updates regarding this issue?

zigojacko commented 2 years ago

@norgeindian I think Adobe gave up caring about the countless bugs with Magento Open Source edition... 🤷‍♂️

norgeindian commented 2 years ago

Still an issue in 2.4.3-p3

zigojacko commented 2 years ago

@norgeindian we gave up waiting for Magento to fix this themselves and just wrote a module that fixes it as per what @Blatant advised earlier in this thread.

eBusinessAtlantique commented 2 years ago

@Blatant did the right fix. Just needs to be included in M2 next release...

nidhigupta13-ey commented 1 year ago

@magento I am working on this

engcom-Delta commented 3 months ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 3 months ago

Hi @engcom-Delta. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 3 months ago

Hi @engcom-Delta, here is your Magento Instance: https://c636a06a8c812d74973a9e5179ba4e0c.instances-prod.magento-community.engineering Admin access: https://c636a06a8c812d74973a9e5179ba4e0c.instances-prod.magento-community.engineering/admin_061a Login: a7645ec8 Password: 724810383f4a

engcom-Delta commented 3 months ago

Hi @norgeindian,

Thank you for reporting and collaboration. Verified the issue on Magento 2.4-develop and the issue is not reproducible. Kindly refer the screenshots.

Steps to Reproduce

  1. Access Admin

  2. Refresh order report

  3. Navigate back to dashboard

  4. Set sort to YTD , observe current year data is displaying in cart. image

  5. Set sort to 2YTD , observe data is displaying as expected image

Kindly recheck the issue on latest Magento 2.4-develop instance and Please let us know if you are still facing any issue. Thanks.

norgeindian commented 2 months ago

@engcom-Delta , thanks for checking. But as I wrote in the initial description of the issue, I would usually expect the last 12 resp. 24 months to be shown and not all data of the current resp. the current and the last year.