mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
We'll need to get all the orders per line to count and sum them; prepare it
This commit is contained in:
committed by
Filipe
parent
c134de850c
commit
cc26da6560
@@ -15,19 +15,19 @@ module Reporting
|
||||
hub_id: order.distributor_id,
|
||||
shipping_method_id: order.shipping_method&.id,
|
||||
}
|
||||
end.values.map(&:first)
|
||||
end.values
|
||||
end
|
||||
|
||||
def columns
|
||||
{
|
||||
first_name: proc { |order| order.billing_address.firstname },
|
||||
last_name: proc { |order| order.billing_address.lastname },
|
||||
billing_address: proc { |order| order.billing_address.address_and_city },
|
||||
email: proc { |order| order.email },
|
||||
phone: proc { |order| order.billing_address.phone },
|
||||
hub: proc { |order| order.distributor&.name },
|
||||
hub_address: proc { |order| order.distributor&.address&.address_and_city },
|
||||
shipping_method: proc { |order| order.shipping_method&.name },
|
||||
first_name: proc { |orders| orders.first.billing_address.firstname },
|
||||
last_name: proc { |orders| orders.first.billing_address.lastname },
|
||||
billing_address: proc { |orders| orders.first.billing_address.address_and_city },
|
||||
email: proc { |orders| orders.first.email },
|
||||
phone: proc { |orders| orders.first.billing_address.phone },
|
||||
hub: proc { |orders| orders.first.distributor&.name },
|
||||
hub_address: proc { |orders| orders.first.distributor&.address&.address_and_city },
|
||||
shipping_method: proc { |orders| orders.first.shipping_method&.name },
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ module Reporting
|
||||
o = create(:order, distributor: d, bill_address: a)
|
||||
o.shipments << create(:shipment)
|
||||
|
||||
allow(subject).to receive(:query_result).and_return [o]
|
||||
allow(subject).to receive(:query_result).and_return [[o]]
|
||||
expect(subject.table_rows).to eq([[
|
||||
a.firstname, a.lastname,
|
||||
[a.address1, a.address2, a.city].join(" "),
|
||||
@@ -106,7 +106,7 @@ module Reporting
|
||||
end
|
||||
|
||||
it "returns only one row per customer" do
|
||||
expect(subject.query_result).to match_array [o1]
|
||||
expect(subject.query_result).to match_array [[o1, o2]]
|
||||
expect(subject.table_rows.size).to eq(1)
|
||||
expect(subject.table_rows)
|
||||
.to eq([[
|
||||
|
||||
Reference in New Issue
Block a user