mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-04-07 07:36:58 +00:00
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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user