Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 2 additions & 17 deletions app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -287,30 +287,15 @@ def create_bulk_payment
return
end

person_id = params[:person_id].presence
organization_id = params[:organization_id].presence

if organization_id.present? && person_id.blank?
payer_type = "Organization"
elsif person_id.present? && organization_id.blank?
payer_type = "Person"
elsif person_id.present? && organization_id.present?
payer_type = params[:payer_type].presence || "Organization"
else
person_id = submission.person_id
payer_type = "Person"
end

payment = submission.build_payment(
person_id: person_id,
organization_id: organization_id,
payer_type: payer_type,
amount_cents: (params[:amount_dollars].to_d * 100).to_i,
currency: params[:currency].presence || "usd",
type: payment_type,
check_number: params[:check_number].presence,
memo: params[:memo].presence
)
payment.payer_sgid = params[:payer_sgid]
payment.additional_designation_sgid = params[:additional_designation_sgid]

if payment.save
@payment = payment
Expand Down
29 changes: 12 additions & 17 deletions app/views/events/_bulk_payment_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,24 @@
</div>
</div>

<div class="grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-3 mt-4">
<div class="grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2 mt-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Who is paying?</label>
<%= select_tag :payer_type,
options_for_select(Payment::PAYER_TYPES, "Organization"),
<label class="block text-sm font-medium text-gray-700 mb-1">Payer</label>
<%= select_tag :payer_sgid, nil,
prompt: "Search people and organizations",
required: true,
data: { controller: "remote-select", remote_select_model_value: "person_or_organization" },
class: "bg-white w-full rounded-lg border border-gray-300 px-3 py-2 text-sm shadow-sm focus:border-blue-500 focus:ring-1 focus:ring-blue-500" %>
<p class="text-xs text-gray-500 mt-1">Whose account is the money coming from?</p>
</div>

<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Person</label>
<%= select_tag :person_id, nil,
prompt: "Search for a person",
data: { controller: "remote-select", remote_select_model_value: "person" },
class: "bg-white w-full rounded-lg border border-gray-300 px-3 py-2 text-sm shadow-sm" %>
</div>

<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Organization</label>
<%= select_tag :organization_id, nil,
prompt: "Search for an organization",
data: { controller: "remote-select", remote_select_model_value: "organization" },
class: "bg-white w-full rounded-lg border border-gray-300 px-3 py-2 text-sm shadow-sm" %>
<label class="block text-sm font-medium text-gray-700 mb-1">Additional designation</label>
<%= select_tag :additional_designation_sgid, nil,
prompt: "Search people and organizations",
include_blank: true,
data: { controller: "remote-select", remote_select_model_value: "person_or_organization" },
class: "bg-white w-full rounded-lg border border-gray-300 px-3 py-2 text-sm shadow-sm focus:border-blue-500 focus:ring-1 focus:ring-blue-500" %>
</div>
</div>

Expand Down