mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Merge pull request #13187 from chahmedejaz/task/13127-add-shipment-state-to-oc-customer-totals-report
Add shipment state to OC customer totals report
This commit is contained in:
@@ -67,6 +67,7 @@ module Reporting
|
||||
order_number: proc { |line_items| line_items.first.order.number },
|
||||
date: proc { |line_items| line_items.first.order.completed_at.strftime("%F %T") },
|
||||
final_weight_volume: proc { |line_items| line_items.sum(&:final_weight_volume) },
|
||||
shipment_state: proc { |line_items| line_items.first.order.shipment_state },
|
||||
}
|
||||
end
|
||||
# rubocop:enable Metrics/AbcSize
|
||||
@@ -107,7 +108,7 @@ module Reporting
|
||||
def default_params
|
||||
super.merge(
|
||||
{
|
||||
fields_to_hide: %i[final_weight_volume voucher_label voucher_amount]
|
||||
fields_to_hide: %i[final_weight_volume voucher_label voucher_amount shipment_state]
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
@@ -68,6 +68,15 @@ RSpec.describe Reporting::Reports::OrdersAndFulfillment::OrderCycleCustomerTotal
|
||||
expect(report.rows.second.quantity).to eq "TOTAL"
|
||||
expect(report.rows.second.date).to eq order.completed_at.strftime("%F %T")
|
||||
end
|
||||
|
||||
context "shipment state" do
|
||||
# by default, shipment state is hidden, so make fields_to_hide empty for this test
|
||||
let(:params) { { q: search_params, fields_to_hide: [] } }
|
||||
|
||||
it 'includes the shipment state' do
|
||||
expect(report.rows.first.shipment_state).to eq order.shipment_state
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "loading shipping methods" do
|
||||
@@ -155,6 +164,7 @@ RSpec.describe Reporting::Reports::OrdersAndFulfillment::OrderCycleCustomerTotal
|
||||
final_weight_volume
|
||||
voucher_label
|
||||
voucher_amount
|
||||
shipment_state
|
||||
],
|
||||
q: {
|
||||
completed_at_gt: 1.month.ago.beginning_of_day,
|
||||
|
||||
Reference in New Issue
Block a user