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

Only display Supplier column in Order Cycle Report email if there is more than one supplier #11798

Conversation

cillian
Copy link
Contributor

@cillian cillian commented Nov 10, 2023

What? Why?

Note, the failing test on this branch is one that is failing on the master branch.

What should we test?

  1. Create an order cycle with orders containing products from more than one supplier. Click the Notify producers button and check that the Order Cycle Report email contains a 'Supplier' column.
  2. Create an order cycle with orders containing products from only one supplier. Click the Notify producers button and check that the Order Cycle Report email does not contain a 'Supplier' column.

Release notes

Changelog Category (reviewers may add a label for the release notes):

  • User facing changes
  • API changes (V0, V1, DFC or Webhook)
  • Technical changes only
  • Feature toggled

Comment on lines +41 to +43
- if @distributors_pickup_times.many?
%td
#{raw(line_items.first.product.supplier.name)}
Copy link
Member

Choose a reason for hiding this comment

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

Not related to this PR but I'm wondering why the name is raw here. It looks like it got copied from the text template without knowing that it's introducing a security issue. A supplier could inject HTML in the name.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This will be addressed here #11801

Copy link
Collaborator

@rioug rioug left a comment

Choose a reason for hiding this comment

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

Nice one 👍

@filipefurtad0 filipefurtad0 self-assigned this Nov 16, 2023
@filipefurtad0 filipefurtad0 added the pr-staged-uk staging.openfoodnetwork.org.uk label Nov 16, 2023
@filipefurtad0
Copy link
Contributor

Hey @cillian,

Below a summary of my findings:

  1. OC with multiple suppliers: the supplier column is removed, which is great, but the indentation for the summary row is a bit off, which compromises readability
    image

  2. OC with one supplier only: we find the same issue with the summary row indentation, but also, when grouping the orders by customer(* please see side note below), we can see that the supplier column is still there:
    image

I'm a bit hesitant to merge this one: it would remove the column in most cases, but perhaps best to fix the summary row indentation before shipping?

Also, would be great if we could remove the Suppliers column from the table which groups orders by customer.

Would it be ok to address these two points, within this PR? The alternative would be to split this and create separate issues, but perhaps it is doable. Please let me know what you think.

Moving back to in dev.

  • Side note: after some head-scratching, I've found out how to enable this option: this can be done on the Customer names on reports option, on the dashboard:

image

@filipefurtad0 filipefurtad0 removed the pr-staged-uk staging.openfoodnetwork.org.uk label Nov 16, 2023
…er of columns in totals row by one too to keep columns aligned
…orders grouped by customer part of the order cycle report
@cillian cillian force-pushed the conditional-supplier-column-in-order-cycle-report branch from 98c27b0 to b96110e Compare November 30, 2023 20:32
@cillian
Copy link
Contributor Author

cillian commented Nov 30, 2023

@filipefurtad0 Thanks, that's fixed now, I should have spotted that.

Before

order-cycle-report-before

After

order-cycle-report-after

Before (with customers)

order-cycle-report-with-customers-before

After (with customers)

order-cycle-report-with-customers-after

@drummer83 drummer83 self-assigned this Dec 6, 2023
@drummer83 drummer83 added the pr-staged-au staging.openfoodnetwork.org.au label Dec 6, 2023
@drummer83
Copy link
Contributor

Hi @cillian,
ooof, this was a hard one to crack. 😆
First of all a big Thank you to @filipefurtad0 for laying the ground with his testing notes above. 💚

Regarding Filipe's findings

  1. Incorrect indentation of summary rows.
  2. Hide Suppliers column for the list grouped by customers as well.

Those are both fixed now, as we can see here:
grafik

HOWEVER

I think there is another misunderstanding underlying here.
To make the Suppliers column useful I tried to find a test setup with two different suppliers actually being listed in that column. But I couldn't, no matter what... So I looked at the code to understand how this column is filled and I came across distributors_pickup_times. This was a hint towards distributors and I set up an order cycle with two distributors. Looking at the notification email then made me realize what the original idea of this email might have been:
grafik

In this email

  • the supplier can see where his/her products have been sold (the list of different distributors),
  • the supplier can see how many items of each product in total have been sold (8 pieces in the example above),
  • BUT the supplier cannot see how many items of each product need to be delivered to which distributor - that would make sense, right?
  • The supplier column is always containing just one value, because as @audez mentioned in the issue the email is always sent to just one producer.

Conclusion

  • I think this email would make much more sense if instead of the suppliers the distributors were listed as a column instead.
  • It still makes sense to only display this column, if there are more than one distributors involved.

I may be totally wrong, but this is my conclusion for today.

I think we can safely merge this because it is an improvement.
We might consider replacing the supplier column with the distributor column.

What do you think, Cillian? Does this make sense?
@openfoodfoundation/train-drivers-product-owners Any comments about the history of this email maybe?

I will add the feedback needed label for now until we know how to move on.

Thanks again! 🙏

@drummer83 drummer83 added feedback-needed and removed pr-staged-au staging.openfoodnetwork.org.au labels Dec 6, 2023
@cillian
Copy link
Contributor Author

cillian commented Dec 8, 2023

Hi @drummer83 Nice catch, yes I think displaying the distributor makes more sense.

One other thing I noticed, I think the same product can be sold for multiple distributors (not 100% sure about this e.g. maybe my local data not setup correctly). So I was wondering if there is multiple distributors do we need to show a list for each distributor like in this following example? This would show people the total amount of each product for each distributor, which could be for multiple customers. Note, the potatoes quantity is 2 because it was sold at multiple distributors.

order-cycle-report-multiple-distributors

And here is an example with just one distributor:

order-cycle-report-single-distributor

@RachL
Copy link
Contributor

RachL commented Dec 8, 2023

I think the same product can be sold for multiple distributor

Yes! In FR, distributors are often just a pickup places so some managers can have OC with over 10 distributors 🙈

Any comments about the history of this email maybe?

No idea! maybe @kirstenalarsen has some hints? But I concur that it would make sense to display distributors when there are more than one. I think this could be open as a new papercut straight in main repo 👍

@drummer83
Copy link
Contributor

drummer83 commented Dec 10, 2023

Thanks, @cillian!
Your examples look great to me! Makes perfect sense.

I will merge this one and open a new issue to remove the supplier column and add the tables per distributor in the way you showed in your comment! ➡️ #11916

Thanks - amazing work! 🙏

@drummer83 drummer83 merged commit cdb7312 into openfoodfoundation:master Dec 10, 2023
54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Remove the "supplier" column from the order cycle notifications email
6 participants