Skip to content

Commit

Permalink
Merge pull request #1041 from sul-dlss/payment-aliases
Browse files Browse the repository at this point in the history
Remove Symphony::Payment method aliases and use Folio::Account method names
  • Loading branch information
cbeer authored Feb 12, 2024
2 parents a4b9971 + 7ccaf3b commit e16b14e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 34 deletions.
6 changes: 3 additions & 3 deletions app/assets/javascripts/listSort.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ $(document).on('turbolinks:load ajax:loaded', function(){

var paymentOptions = {
valueNames: [
{ name: 'bill_description', attr: 'data-sort-bill_description' },
{ name: 'item_title', attr: 'data-sort-item_title' },
{ name: 'nice_status', attr: 'data-sort-nice_status' },
{ name: 'title', attr: 'data-sort-title' },
{ name: 'payment_date', attr: 'data-sort-payment_date' },
{ name: 'bill_amount', attr: 'data-sort-bill_amount'},
{ name: 'fee', attr: 'data-sort-fee'},
],
};

Expand Down
15 changes: 3 additions & 12 deletions app/models/folio/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ def sort_key(key)
sort_key = case key
when :payment_date
[payment_sort_key, title, nice_status]
when :item_title
when :title
[title, payment_sort_key, nice_status]
when :bill_amount
when :fee
[fee, payment_sort_key, title, nice_status]
when :bill_description
when :nice_status
[nice_status, payment_sort_key, title]
end

Expand All @@ -126,15 +126,6 @@ def payment_amount
UNPAID_STATUSES.include?(status) ? 0 : fee
end

# Methods on Symphony::Payment
# TODO: remove these after migration and consolidate method names
alias resolution status
alias bill_description nice_status
alias nice_bill_description nice_status
alias item_title title
alias paid_fee? closed?
alias bill_amount fee

private

def record_location
Expand Down
18 changes: 9 additions & 9 deletions app/views/payments/_payment.html.erb
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<li class="list-group-item">
<div class="row d-flex flex-wrap position-relative">
<div class="d-flex flex-row flex-grow-1 justify-content-start w-100 row col-md-12 col-lg-6">
<div class="col-4 col-md-4 order-md-first bill_description" data-sort-bill_description="<%= h payment.sort_key(:bill_description) %>" >
<%= payment.nice_bill_description %>
<div class="col-4 col-md-4 order-md-first nice_status" data-sort-nice_status="<%= h payment.sort_key(:nice_status) %>" >
<%= payment.nice_status %>
</div>

<div class="col-3 col-md-4 order-first order-sm-first bill_amount" data-sort-bill_amount="<%= h payment.sort_key(:bill_amount) %>">
<%= number_to_currency(payment.bill_amount) %>
<div class="col-3 col-md-4 order-first order-sm-first fee" data-sort-fee="<%= h payment.sort_key(:fee) %>">
<%= number_to_currency(payment.fee) %>
</div>

<div class="col-5 col-md-4 text-right text-md-left payment_date" data-sort-payment_date="<%= h payment.sort_key(:payment_date) %>" >
<%= l(payment.payment_date, format: :short) %>
</div>
</div>
<div class="d-flex flex-grow-1 flex-column flex-md-row w-75 row col-md-12 col-lg-6 item_title" data-sort-item_title="<%= h payment.sort_key(:item_title) %>">
<h3 class="col-md-10 clamp-3 record-title list-item-title"><%= payment.item_title %></h3>
<div class="d-flex flex-grow-1 flex-column flex-md-row w-75 row col-md-12 col-lg-6 title" data-sort-title="<%= h payment.sort_key(:title) %>">
<h3 class="col-md-10 clamp-3 record-title list-item-title"><%= payment.title %></h3>
</div>
<div>
<button class="btn collapsed stretched-link position-static" type="button" data-toggle="collapse" data-target="#collapseDetails-<%= payment.key.parameterize %>" aria-expanded="false" aria-controls="collapseDetails-<%= payment.key.parameterize %>">
Expand All @@ -26,15 +26,15 @@
<div class="collapse" id="collapseDetails-<%= payment.key.parameterize %>">
<dl class="row justify-content-center">
<dt class="col-3 offset-1 col-md-2 offset-md-2">Resolution:</dt>
<dd class="col-8"><%= payment.resolution %></dd>
<dd class="col-8"><%= payment.status %></dd>
<dt class="col-3 offset-1 col-md-2 offset-md-2">Billed:</dt>
<dd class="col-8"><%= l(payment.bill_date, format: :short) %></dd>
<dt class="col-3 offset-1 col-md-2 offset-md-2">Resolved:</dt>
<dd class="col-8"><%= l(payment.payment_date, format: :short) %></dd>
<dt class="col-3 offset-1 col-md-2 offset-md-2">Amount billed:</dt>
<dd class="col-8"><%= number_to_currency(payment.bill_amount) %></dd>
<dd class="col-8"><%= number_to_currency(payment.fee) %></dd>
<dt class="col-3 offset-1 col-md-2 offset-md-2">Amount paid:</dt>
<% if payment.paid_fee? %>
<% if payment.closed? %>
<dd class="col-8"><%= number_to_currency(payment.payment_amount) %></dd>
<% else %>
<dd class="col-8">$0.00</dd>
Expand Down
12 changes: 6 additions & 6 deletions app/views/payments/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
</a>

<ul class="dropdown-menu" aria-labelledby="dropdownMenuLink">
<li class="dropdown-item" data-sort="bill_description">Reason</li>
<li class="dropdown-item" data-sort="nice_status">Reason</li>
<li class="dropdown-item active" data-sort="payment_date">Date paid</li>
<li class="dropdown-item" data-sort="item_title">Title</li>
<li class="dropdown-item" data-sort="bill_amount">Amount</li>
<li class="dropdown-item" data-sort="title">Title</li>
<li class="dropdown-item" data-sort="fee">Amount</li>
</ul>
</div>
</div>
Expand All @@ -23,12 +23,12 @@
<% if @payments.any? %>
<div class="d-none d-md-flex row font-weight-bold list-header">
<div class="row col-md-12 col-lg-6">
<div class="col-md-4" data-sort="bill_description">Reason</div>
<div class="col-md-4" data-sort="bill_amount">Amount</div>
<div class="col-md-4" data-sort="nice_status">Reason</div>
<div class="col-md-4" data-sort="fee">Amount</div>
<div class="col-md-4 active" data-sort="payment_date">Paid on</div>
</div>
<div class="row col-md-12 col-lg-6">
<div class="col-md-7" data-sort="item_title">Title</div>
<div class="col-md-7" data-sort="title">Title</div>
</div>
</div>

Expand Down
8 changes: 4 additions & 4 deletions spec/features/payments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
expect(page).to have_css('li h3',
text: 'Aspects of twentieth century art : Picasso - Important paintings, ' \
'watercolours, and new linocuts.')
expect(page).to have_css('li .bill_description', text: 'Lost item fee')
expect(page).to have_css('li .nice_status', text: 'Lost item fee')
end
end

Expand All @@ -53,13 +53,13 @@

within '#payments' do
expect(page).to have_css('.dropdown-toggle', text: 'Sort (Date paid)')
find('[data-sort="bill_description"]').click
find('[data-sort="nice_status"]').click

expect(page).to have_css('.dropdown-toggle', text: 'Sort (Reason)')
expect(page).to have_css('.active[data-sort="bill_description"]', count: 2, visible: :all)
expect(page).to have_css('.active[data-sort="nice_status"]', count: 2, visible: :all)

within(first('ul.payments li')) do
expect(page).to have_css('.bill_description', text: 'Damaged material')
expect(page).to have_css('.nice_status', text: 'Damaged material')
end
end
end
Expand Down

0 comments on commit e16b14e

Please sign in to comment.