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

Customer names in reports #5769

Merged
merged 7 commits into from
Aug 27, 2020

Conversation

Matt-Yorkley
Copy link
Contributor

What? Why?

Closes #5054, #5097

  • Adds a new enterprise "Shop Preference" to allow suppliers to view customer names in reports.
  • Conditionally masks relevant customer names based on the new setting

What should we test?

Enterprises can set an "allow customer names" preference in admin enterprise edit page, under "Shop Preferences". The default selection is "disabled".

The following reports need to be tested:

  • Orders and distributors report (one column: Customer name)
  • Bulk Co-op reports (one column: Customer name)
  • Orders and Fulfillment - Order Cycle Customer Totals report (one column: Customer name)
  • Enterprise Fees report
  • Both Packing reports (name and first names are two columns on these ones!)

The test conditions are as follows:

  • The current user manages a supplier that supplied products in some placed orders. The user should not manage the distributor enterprise the orders were placed with.
  • The supplier enterprise has set the enterprise permission "add to order cycle" for a the distributor.
  • The distributor enterprise has the "allow customer names" shop preference disabled.
  • The (supplier enterprise) user looks at the reports listed above, and can not see customer names.
  • The distributor enterprise then sets the "allow customer names" shop preference to enabled.
  • The user managing the supplier can then view the reports listed below, and customer names are visible.

Release notes

Added option for distributors to allow their suppliers to see customer names in reports, for improved packing

@Matt-Yorkley Matt-Yorkley self-assigned this Jul 15, 2020
@Matt-Yorkley Matt-Yorkley force-pushed the customer-names branch 3 times, most recently from 79cb824 to c3ba056 Compare July 16, 2020 08:49
@Matt-Yorkley Matt-Yorkley marked this pull request as ready for review July 16, 2020 09:59
Copy link
Contributor

@luisramos0 luisramos0 left a comment

Choose a reason for hiding this comment

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

All right!

It's a new feature, I think it's better if we get some screenshots of the new config item and of a report with and without names.

I left some comments to refactor some of the code.

The only reason why I am not approving the PR yet is that I think it should be prefers_ not preferred_?

app/serializers/api/admin/enterprise_serializer.rb Outdated Show resolved Hide resolved
app/models/enterprise.rb Outdated Show resolved Hide resolved
config/locales/en.yml Outdated Show resolved Hide resolved
lib/open_food_network/order_and_distributor_report.rb Outdated Show resolved Hide resolved
lib/open_food_network/reports/line_items.rb Outdated Show resolved Hide resolved
spec/lib/open_food_network/packing_report_spec.rb Outdated Show resolved Hide resolved
@Matt-Yorkley
Copy link
Contributor Author

Matt-Yorkley commented Aug 15, 2020

I wanted to do a lot more here, but was told to do the minimum to cover the epic. I've updated and refactored a lot more 👍

Copy link
Contributor

@luisramos0 luisramos0 left a comment

Choose a reason for hiding this comment

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

awesome, thanks Matt. New service 👍
I think I'd still go with prefers_ but now I see it's only for readability.

Copy link
Member

@mkllnk mkllnk left a comment

Choose a reason for hiding this comment

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

I like the extraction into a service. 🌷

@filipefurtad0 filipefurtad0 self-assigned this Aug 27, 2020
@filipefurtad0 filipefurtad0 added pr-staged-fr staging.coopcircuits.fr pr-staged-uk staging.openfoodnetwork.org.uk and removed pr-staged-fr staging.coopcircuits.fr labels Aug 27, 2020
@filipefurtad0
Copy link
Contributor

Hey @Matt-Yorkley ,

Thanks for this new feature! Had a look at the different scenarios in your test notes, and as well on the feature requests from @RachL .

Before staging this PR

  • Created a profile only producer A:

image

image

  • Created product B, with items in stock

  • Set this producer A to act as a supplier to an enterprise, as indicated by the permissions below:
    image

As a hub/enterprise manager C:

  • Verified that the "allow customer names" preference does not exist on the dashboard.
  • Added the product B from the supplier A to an open order cycle

As a customer D:

  • visited the shop from the enterprise C (which sells the produce B from the supplier A)
  • inserted the product B in the cart and checked out.

As Producer A:

  • verified that the name/surname from customer D does not appear in the reports

    Orders and distributors report (one column: Customer name - appears as HIDDEN)

image

Bulk Co-op reports (one column: Customer name - not appearing)

image

Orders and Fulfillment - Order Cycle Customer Totals report (one column: Customer name - not appearing)

image

Enterprise Fees report

image

Both Packing reports (name and first names are two columns on these ones! - appears as HIDDEN)

image

After staging this PR

As a hub/enterprise manager C:

  • Verified that the "allow customer names" preference now exists on the dashboard, and can now be set, and that it's default preference is "disabled":

image

As Producer A:

  • verified that the reports shown above look the same, and still hide the names of customers.

As a hub/enterprise manager C:

  • Enabled the "allow customer names" preference

As Producer A:

  • checked all the reports again - customer names are now visible 🎉

    Orders and distributors report (one column: Customer name is visible, email is hidden)

image

Bulk Co-op reports (one column: Customer name - now appearing)

image

Orders and Fulfillment - Order Cycle Customer Totals report (one column: Customer name - not appearing)

image

Enterprise Fees report - customer name now visible

image

Both Packing reports (name and first names are two columns on these ones! - now appearing)

image

image

Awesome work! Thank you @RachL for inception and @Matt-Yorkley for implementing 💪
Ready to go.

@filipefurtad0 filipefurtad0 removed the pr-staged-uk staging.openfoodnetwork.org.uk label Aug 27, 2020
@sauloperez sauloperez merged commit 2fa8cd5 into openfoodfoundation:master Aug 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

As a hub, I can give my suppliers access to my customers' name and firstname
5 participants