Merge pull request #13160 from chahmedejaz/task/13097-add-columns-in-packing-reports

Add shipping method and shipment state to packing reports
This commit is contained in:
Filipe
2025-02-20 19:49:03 -06:00
committed by GitHub
11 changed files with 81 additions and 15 deletions

View File

@@ -40,6 +40,16 @@ module Reporting
def joins_order_bill_address
reflect query.join(association(Spree::Order, :bill_address, bill_address_alias))
end
def joins_selected_shipping_methods
reflect query.
join(association(Spree::Order, :shipments)).
join(association(Spree::Shipment, :shipping_rates)).
join(shipping_method_table).on(
shipping_method_table[:id].eq(shipping_rate_table[:shipping_method_id]).
and(shipping_rate_table[:selected].eq(true))
)
end
end
end
end

View File

@@ -42,6 +42,18 @@ module Reporting
def shipping_category_table
Spree::ShippingCategory.arel_table
end
def shipping_method_table
Spree::ShippingMethod.arel_table
end
def shipping_rate_table
Spree::ShippingRate.arel_table
end
def shipment_table
Spree::Shipment.arel_table
end
end
end
end

View File

@@ -20,6 +20,7 @@ module Reporting
joins_variant_product.
joins_variant_supplier.
joins_variant_shipping_category.
joins_selected_shipping_methods.
selecting(select_fields).
ordered_by(ordering_fields)
end
@@ -30,7 +31,7 @@ module Reporting
def default_params
# Prevent breaking change in this report by hidding new columns by default
{ fields_to_hide: ["phone", "price"],
{ fields_to_hide: ["phone", "price", "shipment_state", "shipping_method"],
q: { order_completed_at_gt: 1.month.ago.beginning_of_day,
order_completed_at_lt: 1.day.from_now.beginning_of_day } }
end
@@ -54,6 +55,8 @@ module Reporting
depth: line_item_table[:depth],
quantity: line_item_table[:quantity],
price: (line_item_table[:quantity] * line_item_table[:price]),
shipment_state: order_table[:shipment_state],
shipping_method: shipping_method_table[:name],
temp_controlled: shipping_category_table[:temperature_controlled],
}
end

View File

@@ -7,7 +7,8 @@ module Reporting
def table_columns
Struct.new(:keys).new(
[:hub, :customer_code, :first_name, :last_name, :phone, :supplier, :product,
:variant, :weight, :height, :width, :depth, :quantity, :price, :temp_controlled]
:variant, :weight, :height, :width, :depth, :quantity, :price, :temp_controlled,
:shipment_state, :shipping_method]
)
end

View File

@@ -7,7 +7,8 @@ module Reporting
def table_columns
Struct.new(:keys).new(
[:hub, :supplier, :product, :variant, :customer_code, :first_name,
:last_name, :phone, :quantity, :price, :temp_controlled]
:last_name, :phone, :quantity, :price, :temp_controlled, :shipment_state,
:shipping_method]
)
end

View File

@@ -7,7 +7,8 @@ module Reporting
def table_columns
Struct.new(:keys).new(
[:hub, :supplier, :customer_code, :first_name, :last_name, :phone,
:product, :variant, :quantity, :price, :temp_controlled]
:product, :variant, :quantity, :price, :temp_controlled, :shipment_state,
:shipping_method]
)
end