2019-07-30 21:29:24 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-25 18:23:59 +00:00
|
|
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
2018-03-25 17:30:42 +00:00
|
|
|
object @payment => :data
|
|
|
|
|
|
|
|
attributes :gross_amount, :towards, :net_amount, :fee_total, :id, :date, :refund_total, :kind
|
|
|
|
|
|
|
|
node(:consider_donation_anonymous) do |p|
|
2019-07-30 21:29:24 +00:00
|
|
|
d_anonymous = p.donation.nil? ? false : p.donation.anonymous
|
2018-03-25 17:30:42 +00:00
|
|
|
|
2019-07-30 21:29:24 +00:00
|
|
|
!!d_anonymous || !!p.supporter.anonymous
|
2018-03-25 17:30:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
child :charge do
|
2019-07-30 21:29:24 +00:00
|
|
|
attributes :created_at, :id, :status
|
2018-03-25 17:30:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
child :donation, object_root: false do
|
2019-07-30 21:29:24 +00:00
|
|
|
attributes :designation, :dedication, :origin_url, :id, :comment
|
2018-03-25 17:30:42 +00:00
|
|
|
|
|
|
|
child :campaign, object_root: false do
|
2019-07-30 21:29:24 +00:00
|
|
|
attributes :name, :url, :id
|
2018-03-25 17:30:42 +00:00
|
|
|
end
|
|
|
|
|
2019-07-30 21:29:24 +00:00
|
|
|
node(:campaign_gift) { |d| { name: d.campaign_gifts.any? ? d.campaign_gifts.last.campaign_gift_option.name : nil } }
|
2018-03-25 17:30:42 +00:00
|
|
|
|
|
|
|
child :event, object_root: false do
|
2018-10-01 21:14:51 +00:00
|
|
|
attributes :name, :url, :id
|
2018-03-25 17:30:42 +00:00
|
|
|
end
|
|
|
|
|
2019-07-30 21:29:24 +00:00
|
|
|
child :recurring_donation, object_root: false do
|
|
|
|
attributes :interval, :time_unit, :created_at
|
|
|
|
end
|
2018-03-25 17:30:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
child :dispute, object_root: false do
|
|
|
|
attributes :id, :status, :reason
|
|
|
|
end
|
|
|
|
|
|
|
|
child :refund do
|
2019-07-30 21:29:24 +00:00
|
|
|
attributes :reason, :comment, :disbursed
|
2018-03-25 17:30:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
child :offsite_payment do
|
2019-07-30 21:29:24 +00:00
|
|
|
attributes :check_number, :kind
|
2018-03-25 17:30:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
node(:ticket) do |payment|
|
2019-02-22 22:13:41 +00:00
|
|
|
event = payment&.tickets&.last&.event
|
2018-03-25 17:30:42 +00:00
|
|
|
h = {
|
2019-07-30 21:29:24 +00:00
|
|
|
event: { name: event&.name, url: event&.url, id: event&.id },
|
|
|
|
levels: payment.tickets.map { |t| "#{GetData.chain(t.ticket_level, :name)} (#{t.quantity}x)" }.join(', '),
|
|
|
|
discount: payment.tickets.map { |t| t.event_discount ? "#{t.event_discount.name} (#{t.event_discount.percent}%)" : nil }.compact.join(', ')
|
2018-03-25 17:30:42 +00:00
|
|
|
}
|
|
|
|
event ? h : nil
|
|
|
|
end
|
|
|
|
|
|
|
|
child :tickets, object_root: false do
|
2019-07-30 21:29:24 +00:00
|
|
|
attributes :id
|
2018-03-25 17:30:42 +00:00
|
|
|
|
2019-07-30 21:29:24 +00:00
|
|
|
child :ticket_level do
|
|
|
|
attributes :name
|
|
|
|
end
|
2018-03-25 17:30:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
child :supporter do
|
2019-07-30 21:29:24 +00:00
|
|
|
attributes :name, :email, :city, :state_code, :address, :zip_code, :phone, :id, :country
|
2018-03-25 17:30:42 +00:00
|
|
|
end
|
2018-10-01 21:14:51 +00:00
|
|
|
|
|
|
|
child :nonprofit do
|
2019-07-30 21:29:24 +00:00
|
|
|
attributes :id
|
2018-10-01 21:14:51 +00:00
|
|
|
end
|