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

Add Vouchers to OC Customer Total Report #11999

Conversation

chahmedejaz
Copy link
Collaborator

@chahmedejaz chahmedejaz commented Jan 3, 2024

⚠️ ALL dev, code review, product and testing etc should use the Clockify code 11922

What? Why?

What should we test?

  • Run /admin/reports/orders_and_fulfillment/order_cycle_customer_totals-
  • By default, columns "vouchers amount" and "voucher label" would not be displayed
  • When displayed, see they show the correct data for orders with vouchers on total line
  • If summary/total row are not displayed, but the column is selected, then the behavior should be the same as the behavor we have currently under the "comments" column: the column show up empty (not the best behavior, but it's out of scope to improve this here)

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

def initialize(name:, options:, selected:)
# @param id [String] uniquely identifies the MultipleCheckedSelect (mcs) field. '_mcs_field' will be appended
def initialize(id:, name:, options:, selected:)
@id = "#{id}_mcs_field"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

adding id to the mcs field, it would make it easier to test and identify each field uniquely in case we use multiple mcs on a page

Copy link
Member

Choose a reason for hiding this comment

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

If we use multiple fields, they should have different labels.

@chahmedejaz chahmedejaz marked this pull request as ready for review January 3, 2024 11:07
@chahmedejaz chahmedejaz changed the title Task/11923 add vouchers to oc customer total report Add Vouchers to OC Customer Total Report Jan 3, 2024
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 job ! I left a few note but nothing blocking.

end

def voucher_amount(order)
return '' unless voucher_applicable?(order)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am wondering if actually need this check ?

If I am not mistaken (order.total - order.pre_discount_total).abs would return 0 if no voucher has been applied to the order.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, but for consistency between voucher label vs amount's empty state, I added this check to return empty strings as their empty state value. Thanks. :)

@@ -27,5 +27,5 @@
.row
.alpha.two.columns= label_tag nil, t(:report_columns)
.omega.fourteen.columns
= render MultipleCheckedSelectComponent.new(name: "fields_to_show", options: @report.available_headers, selected: @rendering_options.options[:fields_to_show])
= render MultipleCheckedSelectComponent.new(id: 'fields_to_show', name: "fields_to_show", options: @report.available_headers, selected: @rendering_options.options[:fields_to_show])
Copy link
Member

Choose a reason for hiding this comment

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

Needing to change the code just to test it can be a code smell. And system specs should test form the perspective of the user which can't know DOM ids. It's better to click on something visible. I'll add a commit to show you an alternative.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll make sure to keep that in mind. Thanks :)

chahmedejaz and others added 2 commits January 4, 2024 12:53
…mer_totals.rb

Co-authored-by: Gaetan Craig-Riou <40413322+rioug@users.noreply.github.com>
@drummer83 drummer83 self-assigned this Jan 9, 2024
@drummer83 drummer83 added the pr-staged-au staging.openfoodnetwork.org.au label Jan 9, 2024
@drummer83
Copy link
Contributor

Hi @chahmedejaz,
Thank you so much for working on this!

After staging the PR I could see the new columns, which were inactive (hidden) by default. ✔️
image

The numbers I checked are correct. I also compared them to the numbers of the order details page. ✔️
image

Comparing the report before and after the PR showed no difference - apart from the new columns, of course. ✔️

I think this one is ready to go! Excellent! 🎉
Merging! 🚀

@drummer83 drummer83 merged commit 7c33c97 into openfoodfoundation:master Jan 9, 2024
52 checks passed
@drummer83 drummer83 removed the pr-staged-au staging.openfoodnetwork.org.au label Jan 9, 2024
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.

[Vouchers] Add vouchers to OC customer total report
4 participants