From 6405c344280a956a80ecfb2d65c9c3ca3ea7c6dd Mon Sep 17 00:00:00 2001 From: Rob H Date: Wed, 29 Apr 2020 21:20:14 +1000 Subject: [PATCH] Add order number and date/time to order cycles customer report --- .../customer_totals_report.rb | 12 +++++++++--- .../customer_totals_report_spec.rb | 16 ++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/lib/open_food_network/orders_and_fulfillments_report/customer_totals_report.rb b/lib/open_food_network/orders_and_fulfillments_report/customer_totals_report.rb index 8225d45eea..16d1a4e163 100644 --- a/lib/open_food_network/orders_and_fulfillments_report/customer_totals_report.rb +++ b/lib/open_food_network/orders_and_fulfillments_report/customer_totals_report.rb @@ -36,7 +36,9 @@ module OpenFoodNetwork I18n.t(:report_header_customer_code), I18n.t(:report_header_tags), I18n.t(:report_header_billing_street), I18n.t(:report_header_billing_street_2), I18n.t(:report_header_billing_city), I18n.t(:report_header_billing_postcode), - I18n.t(:report_header_billing_state)] + I18n.t(:report_header_billing_state), + I18n.t(:report_header_order_number), + I18n.t(:report_header_date)] end # rubocop:enable Metrics/AbcSize # rubocop:enable Metrics/MethodLength @@ -92,7 +94,9 @@ module OpenFoodNetwork proc { |_line_items| "" }, proc { |_line_items| "" }, proc { |_line_items| "" }, - proc { |_line_items| "" } + proc { |_line_items| "" }, + proc { |line_items| line_items.first.order.number }, + proc { |line_items| line_items.first.order.completed_at.strftime("%F %T") }, ] }, { @@ -187,7 +191,9 @@ module OpenFoodNetwork proc { |line_items| line_items.first.order.bill_address.andand.address2 }, proc { |line_items| line_items.first.order.bill_address.andand.city }, proc { |line_items| line_items.first.order.bill_address.andand.zipcode }, - proc { |line_items| line_items.first.order.bill_address.andand.state } + proc { |line_items| line_items.first.order.bill_address.andand.state }, + proc { |line_items| line_items.first.order.number }, + proc { |line_items| line_items.first.order.completed_at.strftime("%F %T") }, ] end # rubocop:enable Metrics/AbcSize diff --git a/spec/lib/open_food_network/orders_and_fulfillments_report/customer_totals_report_spec.rb b/spec/lib/open_food_network/orders_and_fulfillments_report/customer_totals_report_spec.rb index eb2e2f3cc9..628279c260 100644 --- a/spec/lib/open_food_network/orders_and_fulfillments_report/customer_totals_report_spec.rb +++ b/spec/lib/open_food_network/orders_and_fulfillments_report/customer_totals_report_spec.rb @@ -35,6 +35,22 @@ RSpec.describe OpenFoodNetwork::OrdersAndFulfillmentsReport::CustomerTotalsRepor total_field = report_table.last[5] expect(total_field).to eq I18n.t("admin.reports.total") end + + it 'includes the order number and date in item rows' do + order_number_and_date_fields = report_table.first[33..34] + expect(order_number_and_date_fields).to eq([ + order.number, + order.completed_at.strftime("%F %T"), + ]) + end + + it 'includes the order number and date in total rows' do + order_number_and_date_fields = report_table.last[33..34] + expect(order_number_and_date_fields).to eq([ + order.number, + order.completed_at.strftime("%F %T"), + ]) + end end context "loading shipping methods" do