diff --git a/app/queries/expenses/total_query.rb b/app/queries/expenses/total_query.rb index 677dc30..09bf30b 100644 --- a/app/queries/expenses/total_query.rb +++ b/app/queries/expenses/total_query.rb @@ -15,6 +15,8 @@ module Expenses expense_summary.variable, expense_summary.variable_count, expense_summary.total_count, + guest_count.confirmed as confirmed_guests, + guest_count.projected as projected_guests, expense_summary.fixed + expense_summary.variable * guest_count.confirmed as total, expense_summary.fixed + expense_summary.variable * guest_count.projected as max_projected, (expense_summary.fixed + expense_summary.variable * guest_count.confirmed) / guest_count.confirmed as per_person diff --git a/spec/queries/expenses/total_query_spec.rb b/spec/queries/expenses/total_query_spec.rb index 7510e17..9e32716 100644 --- a/spec/queries/expenses/total_query_spec.rb +++ b/spec/queries/expenses/total_query_spec.rb @@ -23,6 +23,8 @@ module Expenses expect(response["total_count"]).to be_zero expect(response["max_projected"]).to be_zero expect(response["per_person"]).to be_zero + expect(response["confirmed_guests"]).to eq(2) + expect(response["projected_guests"]).to eq(2 + 4 + 5) end end @@ -41,6 +43,8 @@ module Expenses expect(response["total_count"]).to eq(2) expect(response["max_projected"]).to eq(300) expect(response["per_person"]).to eq(150) + expect(response["confirmed_guests"]).to eq(2) + expect(response["projected_guests"]).to eq(2 + 4 + 5) end end @@ -58,6 +62,8 @@ module Expenses expect(response["total"]).to eq(2*300) expect(response["total_count"]).to eq(2) expect(response["max_projected"]).to eq(11*300) + expect(response["confirmed_guests"]).to eq(2) + expect(response["projected_guests"]).to eq(2 + 4 + 5) end end @@ -77,6 +83,8 @@ module Expenses expect(response["total_count"]).to eq(3) expect(response["max_projected"]).to eq(100 + 200 + 11*50) expect(response["per_person"]).to eq(200) + expect(response["confirmed_guests"]).to eq(2) + expect(response["projected_guests"]).to eq(2 + 4 + 5) end end end