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:
Konrad
2025-03-04 20:25:44 +01:00
committed by GitHub
2 changed files with 12 additions and 1 deletions

View File

@@ -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

View File

@@ -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,