Split dedications up in the export

This commit is contained in:
Eric Schultz 2018-10-25 16:56:02 -05:00 committed by Eric Schultz
parent 68aa5b1f53
commit 3d704cd876
2 changed files with 19 additions and 2 deletions

View file

@ -335,6 +335,11 @@ module QueryPayments
}
end
def self.get_dedication_or_empty(*path)
"json_extract_path_text(coalesce(nullif(trim(both from donations.dedication), ''), '{}')::json, #{path.map{|i| "'#{i}'"}.join(',')})"
end
def self.export_selects
["to_char(payments.date::timestamptz, 'YYYY-MM-DD HH24:MI:SS TZ') AS date",
'(payments.gross_amount / 100.0)::money::text AS gross_amount',
@ -344,7 +349,13 @@ module QueryPayments
.concat(QuerySupporters.supporter_export_selections)
.concat([
"coalesce(donations.designation, 'None') AS designation",
'donations.dedication AS "Honorarium/Memorium"',
"#{get_dedication_or_empty('type')}::text AS \"Dedication Type\"",
"#{get_dedication_or_empty('name')}::text AS \"Dedicated To: Name\"",
"#{get_dedication_or_empty('supporter_id')}::text AS \"Dedicated To: Supporter ID\"",
"#{get_dedication_or_empty('contact', 'email')}::text AS \"Dedicated To: Email\"",
"#{get_dedication_or_empty('contact', "phone")}::text AS \"Dedicated To: Phone\"",
"#{get_dedication_or_empty( "contact", "address")}::text AS \"Dedicated To: Address\"",
"#{get_dedication_or_empty( "note")}::text AS \"Dedicated To: Note\"",
'donations.anonymous',
'donations.comment',
"coalesce(nullif(campaigns_for_export.name, ''), 'None') AS campaign",

View file

@ -1,7 +1,13 @@
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
module MockHelpers
def self.payment_export_headers()
["Date",'Gross Amount', 'Fee Total', 'Net Amount','Type', 'Last Name', 'First Name','Full Name', 'Organization', 'Email', 'Phone', 'Address', 'City', 'State', 'Postal Code', 'Country', 'Anonymous?', 'Supporter Id', 'Designation', 'Honorarium/Memorium', 'Anonymous','Comment','Campaign', 'Campaign Gift Level', 'Event Name', 'Payment', 'Check Number', 'Donation Note']
["Date",'Gross Amount', 'Fee Total', 'Net Amount','Type', 'Last Name', 'First Name','Full Name', 'Organization', 'Email', 'Phone', 'Address', 'City', 'State', 'Postal Code', 'Country', 'Anonymous?', 'Supporter Id', 'Designation', "Dedication Type",
"Dedicated To: Name",
"Dedicated To: Supporter Id",
"Dedicated To: Email",
"Dedicated To: Phone",
"Dedicated To: Address",
"Dedicated To: Note", 'Anonymous','Comment','Campaign', 'Campaign Gift Level', 'Event Name', 'Payment', 'Check Number', 'Donation Note']
end
def self.recurring_donation_export_headers()