Skip to content

Commit

Permalink
Merge pull request #1137 from sul-dlss/1135-bill-dates
Browse files Browse the repository at this point in the history
Guard against missing bill dates. Fixes #1135
  • Loading branch information
jcoyne authored Jun 25, 2024
2 parents 2c07993 + 4169346 commit 324ae3e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
8 changes: 5 additions & 3 deletions app/models/folio/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ def nice_status
record.dig('feeFine', 'feeFineType')
end

# dateCreated on the account is often null, so we use the first action date
# dateCreated on the account is often null, so we often fall back on the first action date
def bill_date
return if record['actions'].none?
@bill_date ||= begin
value = record['dateCreated'] || record.dig('metadata', 'createdDate') || record.dig('actions', 0, 'dateAction')

Time.zone.parse(record.dig('actions', 0, 'dateAction'))
Time.zone.parse(value) if value
end
end

# dateUpdated on the account is often null, so we use the last action date if closed
Expand Down
4 changes: 4 additions & 0 deletions app/services/folio_graphql_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ def patron_info(patron_uuid)
id
userId
remaining
dateCreated
amount
loanId
loan {
Expand All @@ -272,6 +273,9 @@ def patron_info(patron_uuid)
dateAction
typeAction
}
metadata {
createdDate
}
paymentStatus {
name
}
Expand Down
6 changes: 4 additions & 2 deletions app/views/fines/_fine.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
<dt class="col-3 offset-1 col-md-2 offset-md-2">Borrower:</dt>
<dd class="col-8"><%= patron.group.member_name(fine.patron_key) || patron.display_name %></dd>
<% end %>
<dt class="col-3 offset-1 col-md-2 offset-md-2">Billed:</dt>
<dd class="col-8"><%= l(fine.bill_date, format: :short) %></dd>
<% if fine.bill_date %>
<dt class="col-3 offset-1 col-md-2 offset-md-2">Billed:</dt>
<dd class="col-8"><%= l(fine.bill_date, format: :short) %></dd>
<% end %>
<dt class="col-3 offset-1 col-md-2 offset-md-2"><%= nice_status_fee_label(fine.nice_status) %>:</dt>
<dd class="col-8"><%= number_to_currency(fine.fee) %></dd>
<dt class="col-3 offset-1 col-md-2 offset-md-2">Source:</dt>
Expand Down

0 comments on commit 324ae3e

Please sign in to comment.