Add campaign_id to export

This commit is contained in:
Eric Schultz 2019-01-22 11:34:54 -06:00 committed by Eric Schultz
parent bcb84d2aab
commit 22ea10c65e
2 changed files with 19 additions and 0 deletions

View file

@ -14,7 +14,21 @@ module QueryDonations
].concat(QuerySupporters.supporter_export_selections)
.concat([
"supporters.id AS \"Supporter ID\"",
<<<<<<< HEAD
])
=======
]).concat([
"coalesce(donations.designation, 'None') AS designation",
"#{QueryPayments.get_dedication_or_empty('type')}::text AS \"Dedication Type\"",
"#{QueryPayments.get_dedication_or_empty('name')}::text AS \"Dedicated To: Name\"",
"#{QueryPayments.get_dedication_or_empty('supporter_id')}::text AS \"Dedicated To: Supporter ID\"",
"#{QueryPayments.get_dedication_or_empty('contact', 'email')}::text AS \"Dedicated To: Email\"",
"#{QueryPayments.get_dedication_or_empty('contact', "phone")}::text AS \"Dedicated To: Phone\"",
"#{QueryPayments.get_dedication_or_empty( "contact", "address")}::text AS \"Dedicated To: Address\"",
"#{QueryPayments.get_dedication_or_empty( "note")}::text AS \"Dedicated To: Note\"",
"donations.campaign_id AS \"Campaign Id\""
])
>>>>>>> 5c0d16c0b... Add campaign_id to export
).from(:donations)
.join(:supporters, "supporters.id=donations.supporter_id")
.left_outer_join(:campaign_gifts, "campaign_gifts.donation_id=donations.id")

View file

@ -45,6 +45,11 @@ describe QueryDonations do
expect(export.map{|i| i['Amount']}).to match_array(['$10.00', '$20.00', '$40.00', '$80.00'])
end
it 'includes the campaign ids' do
export = vector_to_hash(campaign_export)
expect(export.map{|i| i['Campaign Id']}).to match_array([campaign.id, campaign.id, campaign_child.id, campaign_child_2.id])
end
end
## move to common area