We'll need to get all the orders per line to count and sum them; prepare it

This commit is contained in:
Jean-Baptiste Bellet
2023-07-10 11:26:25 +02:00
committed by Filipe
parent c134de850c
commit cc26da6560
2 changed files with 11 additions and 11 deletions

View File

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

View File

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