mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Fix orders and fulfillment reports
Plus specs
This commit is contained in:
@@ -15,7 +15,7 @@ module Reporting
|
||||
@orders ||= search_orders
|
||||
end
|
||||
|
||||
def list(line_item_includes = [variant: [product: :supplier]])
|
||||
def list(line_item_includes = [variant: [:supplier, :product]])
|
||||
line_items = order_permissions.visible_line_items.in_orders(orders.result)
|
||||
.order("supplier.name", "product.name", "variant.display_name")
|
||||
|
||||
|
||||
@@ -49,11 +49,11 @@ module Reporting
|
||||
end
|
||||
|
||||
def supplier_name
|
||||
proc { |line_items| line_items.first.variant.product.supplier.name }
|
||||
proc { |line_items| line_items.first.variant.supplier.name }
|
||||
end
|
||||
|
||||
def supplier_charges_sales_tax?
|
||||
proc { |line_items| line_items.first.variant.product.supplier.charges_sales_tax }
|
||||
proc { |line_items| line_items.first.variant.supplier.charges_sales_tax }
|
||||
end
|
||||
|
||||
def product_name
|
||||
|
||||
@@ -93,7 +93,7 @@ module Reporting
|
||||
end
|
||||
|
||||
def line_item_includes
|
||||
[{ variant: { product: :supplier },
|
||||
[{ variant: [:product, :supplier],
|
||||
order: [:bill_address, :ship_address, :order_cycle, :adjustments, :payments,
|
||||
:user, :distributor, :shipments] }]
|
||||
end
|
||||
|
||||
@@ -40,7 +40,7 @@ module Reporting
|
||||
:adjustments,
|
||||
{ shipments: { shipping_rates: :shipping_method } }
|
||||
],
|
||||
variant: { product: :supplier }
|
||||
variant: [:product, :supplier]
|
||||
}]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -42,7 +42,7 @@ module Reporting
|
||||
end
|
||||
|
||||
def line_item_includes
|
||||
[{ variant: { product: :supplier } }]
|
||||
[{ variant: [:supplier, :product] }]
|
||||
end
|
||||
|
||||
def query_result
|
||||
|
||||
@@ -41,7 +41,7 @@ module Reporting
|
||||
|
||||
def line_item_includes
|
||||
[{ order: :distributor,
|
||||
variant: { product: :supplier } }]
|
||||
variant: [:product, :supplier] }]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -29,7 +29,7 @@ RSpec.describe Reporting::Reports::OrdersAndFulfillment::OrderCycleCustomerTotal
|
||||
distributor:,
|
||||
completed_at: order_date,
|
||||
).tap do |order|
|
||||
order.line_items[0].product.supplier.update(name: "Apple Farmer")
|
||||
order.line_items[0].variant.supplier.update(name: "Apple Farmer")
|
||||
order.line_items[0].product.update(name: "Apples")
|
||||
order.line_items[0].variant.update(sku: "APP")
|
||||
end
|
||||
|
||||
@@ -30,7 +30,7 @@ module Reporting
|
||||
distributor_name_field = report_table.first[0]
|
||||
expect(distributor_name_field).to eq distributor.name
|
||||
|
||||
supplier = order.line_items.first.variant.product.supplier
|
||||
supplier = order.line_items.first.variant.supplier
|
||||
supplier_name_field = report_table.first[1]
|
||||
expect(supplier_name_field).to eq supplier.name
|
||||
end
|
||||
|
||||
@@ -27,7 +27,7 @@ module Reporting
|
||||
end
|
||||
|
||||
it "has a variant row under the distributor" do
|
||||
supplier = order.line_items.first.variant.product.supplier
|
||||
supplier = order.line_items.first.variant.supplier
|
||||
expect(report.rows.first.producer).to eq supplier.name
|
||||
expect(report.rows.first.hub).to eq distributor.name
|
||||
end
|
||||
|
||||
@@ -9,7 +9,7 @@ RSpec.describe Reporting::Reports::OrdersAndFulfillment::OrderCycleSupplierTotal
|
||||
create(:completed_order_with_totals, line_items_count: 1, distributor:)
|
||||
end
|
||||
let!(:supplier) do
|
||||
order.line_items.first.variant.product.supplier
|
||||
order.line_items.first.variant.supplier
|
||||
end
|
||||
let(:current_user) { distributor.owner }
|
||||
let(:params) { { display_summary_row: false, fields_to_hide: [] } }
|
||||
|
||||
Reference in New Issue
Block a user