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

UPS Shipment Tracking: Show "Delivered On" only when package has actually been delivered #29080

Merged
merged 2 commits into from
Sep 23, 2020

Conversation

danbtl
Copy link
Contributor

@danbtl danbtl commented Jul 11, 2020

Description (*)

The UPS Tracking API returns the activity status code "D" for delivered packages. The delivery properties of the tracking object should only be set if we see this status code. Otherwise packages that are still in transit show as delivered, incorrectly.

Consider the following extract of a UPS tracking API response:

...
    <Package>
      <TrackingNumber>*REMOVED*</TrackingNumber>
      <DeliveryIndicator>N</DeliveryIndicator>
      <Activity>
        <ActivityLocation>
          <Address>
            <City>Secaucus</City>
            <StateProvinceCode>NJ</StateProvinceCode>
            <CountryCode>US</CountryCode>
          </Address>
        </ActivityLocation>
        <Status>
          <StatusType>
            <Code>I</Code>
            <Description>Departed from Facility</Description>
          </StatusType>
          <StatusCode>
            <Code>DP</Code>
          </StatusCode>
        </Status>
        <Date>20200711</Date>
        <Time>034100</Time>
        <GMTDate>2020-07-11</GMTDate>
        <GMTTime>07:41:00</GMTTime>
        <GMTOffset>-04:00</GMTOffset>
        <NextScheduleActivity>
          <Date>2020-07-15</Date>
          <Time>235900</Time>
        </NextScheduleActivity>
      </Activity>
      <Activity>
        <ActivityLocation>
          <Address>
            <City>New York</City>
            <StateProvinceCode>NY</StateProvinceCode>
            <CountryCode>US</CountryCode>
          </Address>
        </ActivityLocation>
        <Status>
          <StatusType>
            <Code>I</Code>
            <Description>Origin Scan</Description>
          </StatusType>
          <StatusCode>
            <Code>OR</Code>
          </StatusCode>
        </Status>
        <Date>20200710</Date>
        <Time>202339</Time>
        <GMTDate>2020-07-11</GMTDate>
        <GMTTime>00:23:39</GMTTime>
        <GMTOffset>-04:00</GMTOffset>
      </Activity>
...

In this case, the package is still in transit. However, because the check for the DeliveryStatus is missing, the package would incorrectly show as delivered in Magento, and display the date/time of the first activity as Delivered On.

Related Pull Requests

None

Fixed Issues (if relevant)

Couldn't find any open issues related to this.

Manual testing scenarios (*)

You will need a valid UPS tracking number and UPS API keys to test this.

Questions or comments

Let me know if you need samples of the UPS tracking API response.

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)

Resolved issues:

  1. resolves [Issue] UPS Shipment Tracking: Show "Delivered On" only when package has actually been delivered #29659: UPS Shipment Tracking: Show "Delivered On" only when package has actually been delivered

@m2-assistant
Copy link

m2-assistant bot commented Jul 11, 2020

Hi @danbtl. 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

@danbtl
Copy link
Contributor Author

danbtl commented Jul 13, 2020

@magento run all tests

1 similar comment
@danbtl
Copy link
Contributor Author

danbtl commented Jul 27, 2020

@magento run all tests

@danbtl
Copy link
Contributor Author

danbtl commented Jul 27, 2020

@joni-jones Could you please have a look at this PR? Let me know if you need additional information.

@joni-jones
Copy link
Contributor

Hi @danbtl, thanks for pointing your attention to this issue. I'm not sure how familiar you are with tracking functionality, so let me provide some context. The idea, that a customer or merchant can see all package transition history for a specific shipment, basically the same what almost all carriers provide - when a package left a shipping facility, current transit destination, delivery status, etc. So not only when a package was delivered.

The current logic is the following, the latest (XML nodes follow from latest to earlier update order) tracking information will be represented as shipment status and previous - as shipment activities. For instance, if a package in transit then the status will be In Transit, and activities like Label Created, Shipped, Out for Delivery, etc - will be represented as activities.

The proposed changes will break this logic because if the latest status is not Delivered then we will just lose the information about the current status.

However, because the check for the DeliveryStatus is missing, the package would incorrectly show as delivered in Magento, and display the date/time of the first activity as Delivered On.

I think the problem, not in the logic for UPS carrier itself but in the label for status https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Shipping/Block/DataProviders/Tracking/DeliveryDateTitle.php#L25. The label says Delivered On but it should be something like Current Status or Status Updated.

@danbtl
Copy link
Contributor Author

danbtl commented Aug 5, 2020

Hi @joni-jones, thank you for reviewing this issue. I spent some time to look into this a bit further.

You're right, my proposed patch will hide the "Delivered on" row for packages that are still in transit. Like you mentioned, the real problem is that the label "Delivered On" is incorrect, and it should really say "Status on" or something similar (at least while the package is still in transit).

The FedEx provider contains a plugin that changes this label:

public function afterGetTitle(Subject $subject, $result, Status $trackingStatus)
{
if ($trackingStatus->getCarrier() === Carrier::CODE) {
$result = __('Expected Delivery:');
}
return $result;
}

I could add a similar plugin to the UPS module that simply changes the label using the same afterGetTitle mechanism. What do you think?

@sidolov sidolov added Priority: P3 May be fixed according to the position in the backlog. Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround. labels Aug 18, 2020
@sidolov
Copy link
Contributor

sidolov commented Aug 18, 2020

@magento create issue

@danbtl
Copy link
Contributor Author

danbtl commented Aug 20, 2020

@joni-jones I updated the PR. I added a plugin to change the Delivered On title to Status Updated On for the UPS carrier. This is using the same plugin mechanism that is used by the FedEx module.
Let me know your thoughts.

@ghost ghost moved this from Pending Review to Ready for Testing in Pull Requests Dashboard Aug 20, 2020
@ghost ghost assigned VladimirZaets Aug 20, 2020
@VladimirZaets
Copy link
Contributor

@magento run all tests

@magento-engcom-team
Copy link
Contributor

Hi @VladimirZaets, thank you for the review.
ENGCOM-8045 has been created to process this Pull Request
✳️ @VladimirZaets, could you please add one of the following labels to the Pull Request?

Label Description
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests
Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests
Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests

@magento-engcom-team
Copy link
Contributor

@danbtl thank you for contributing. Please accept Community Contributors team invitation here to gain extended permissions for this repository.

@danbtl
Copy link
Contributor Author

danbtl commented Aug 24, 2020

@VladimirZaets Thank you for reviewing this. This is my first Magento PR. Is there anything else I should do to get this merged?

@ghost
Copy link

ghost commented Aug 24, 2020 via email

@engcom-Delta engcom-Delta self-assigned this Sep 10, 2020
@engcom-Delta engcom-Delta moved this from Ready for Testing to Testing in Progress in Pull Requests Dashboard Sep 10, 2020
@engcom-Delta
Copy link
Contributor

@magento give me test instance

@magento-deployment-service
Copy link

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

@magento-deployment-service
Copy link

@engcom-Delta
Copy link
Contributor

@magento give me test instance

@magento-deployment-service
Copy link

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

@magento-deployment-service
Copy link

@engcom-Delta
Copy link
Contributor

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

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

@engcom-Delta
Copy link
Contributor

✔️ QA passed
Result:
Before:
#29080Main

✔️ After:
ShippingTrack

@engcom-Delta engcom-Delta added the QA: Added to Regression Scope Scenario was analysed and added to Regression Testing Scope label Sep 22, 2020
@engcom-Delta
Copy link
Contributor

Note: Automation tests are passed

@engcom-Delta engcom-Delta moved this from Testing in Progress to Merge in Progress in Pull Requests Dashboard Sep 22, 2020
magento-engcom-team pushed a commit that referenced this pull request Sep 23, 2020
@magento-engcom-team magento-engcom-team merged commit bfeeb17 into magento:2.4-develop Sep 23, 2020
@m2-assistant
Copy link

m2-assistant bot commented Sep 23, 2020

Hi @danbtl, 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.

@ghost ghost moved this from Merge in Progress to Recently Merged in Pull Requests Dashboard Sep 23, 2020
@sidolov sidolov added the Auto-Tests: Covered All changes in Pull Request is covered by auto-tests label Sep 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests Component: Ups Priority: P3 May be fixed according to the position in the backlog. Progress: accept QA: Added to Regression Scope Scenario was analysed and added to Regression Testing Scope Release Line: 2.4 Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround.
Projects
Pull Requests Dashboard
  
Recently Merged
Development

Successfully merging this pull request may close these issues.

[Issue] UPS Shipment Tracking: Show "Delivered On" only when package has actually been delivered
6 participants