Skip to content
This repository has been archived by the owner on Jul 24, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1197 from YaleSTC/1121_returned_overdue
Browse files Browse the repository at this point in the history
[1121] view returned overdue
  • Loading branch information
squidgetx committed Jun 8, 2015
2 parents 0653874 + f013b36 commit 4c63b83
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 8 deletions.
6 changes: 3 additions & 3 deletions app/controllers/reservations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ def set_filter

f = (can? :manage, Reservation) ? :upcoming : :reserved

@filters = [:reserved, :checked_out, :overdue, :returned, :upcoming,
:requested, :approved_requests, :denied]
@filters << :missed unless AppConfig.check(:res_exp_time)
@filters = [:reserved, :checked_out, :overdue, :returned, :returned_overdue,
:upcoming, :requested, :approved_requests, :denied]
@filters << :missed unless AppConfig.first.res_exp_time

# if filter in session set it
if session[:filter]
Expand Down
9 changes: 8 additions & 1 deletion app/models/reservation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,14 @@ def time_checked_out
end

def late_fee
equipment_model.late_fee.to_f
if checked_in
end_date = checked_in.to_date
else
end_date = Time.zone.today
end
fee = equipment_model.late_fee * (end_date - due_date)
fee = 0 if fee < 0
fee
end

def reserver
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Notes: <%= markdown(@overdue_checked_in.notes) %>
<% end %>

<p>The late fee is <%= number_to_currency(@overdue_checked_in.equipment_model.late_fee) %> per day, for a total of <%= number_to_currency(((@overdue_checked_in.checked_in.to_date - @overdue_checked_in.due_date )).to_i*(@overdue_checked_in.equipment_model.late_fee))%>
<p>The late fee is <%= number_to_currency(@overdue_checked_in.equipment_model.late_fee) %> per day, for a total of <%= number_to_currency(@overdue_checked_in.late_fee) %>
</p>

<br />
2 changes: 1 addition & 1 deletion app/views/reservations/_check_in_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<footer>
<p>
This equipment is <strong class="error">overdue.</strong><br />
At a fee of <%= number_to_currency(reservation.late_fee) %> / day, the renter owes <strong><%= number_to_currency(reservation.late_fee * (Time.zone.today - reservation.due_date).to_i) %></strong> total.
At a fee of <%= number_to_currency(reservation.equipment_model.late_fee) %> / day, the renter owes <strong><%= number_to_currency(reservation.late_fee) %></strong> total.
</p>
</footer>

Expand Down
2 changes: 1 addition & 1 deletion app/views/reservations/_check_out_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<footer>
<p>
This equipment is <strong>due back on <%= reservation.due_date.to_s(:long) %>.</strong><br />
An overdue return will incur a combined late fee of <strong><%= number_to_currency(reservation.late_fee) %> / day.</strong>
An overdue return will incur a combined late fee of <strong><%= number_to_currency(reservation.equipment_model.late_fee) %> / day.</strong>
</p>
</footer>
</div>
Expand Down
1 change: 1 addition & 0 deletions app/views/reservations/_index_nav.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<%= render partial: 'index_nav_tab', locals: {filter: :missed, text: 'Missed'} %>
<% end %>
<%= render partial: 'index_nav_tab', locals: {filter: :returned, text: 'Returned'} %>
<%= render partial: 'index_nav_tab', locals: {filter: :returned_overdue, text: 'Returned Overdue'} %>
<%= render partial: 'index_nav_tab', locals: {filter: :approved_requests, text: 'Approved'} %>
<%= render partial: 'index_nav_tab', locals: {filter: :denied, text: 'Denied'} %>
</ul>
Expand Down
6 changes: 6 additions & 0 deletions app/views/reservations/_reservations_list.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
<th>Item</th>
<th>Start Date</th>
<th>Due Date</th>
<% if @filter == :overdue || @filter == :returned_overdue %>
<th>Late Fee</th>
<% end %>
</tr>
</thead>
<tbody>
Expand Down Expand Up @@ -38,6 +41,9 @@
</td>
<td><%= reservation.start_date.to_s(:long) %></td>
<td><%= reservation.due_date.to_s(:long) %></td>
<% if @filter == :overdue || @filter == :returned_overdue %>
<td><%= number_to_currency reservation.late_fee %></td>
<% end %>
</tr>
<% end %>
</tbody>
Expand Down
2 changes: 1 addition & 1 deletion app/views/user_mailer/_returned_overdue.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<p>This is a receipt for your late equipment return. </p>

<% if @reservation.equipment_model.late_fee > 0 %>
<p>Your late fee is <%= number_to_currency(@reservation.equipment_model.late_fee) %> per day, for a total of <%= number_to_currency(((@reservation.checked_in.to_date - @reservation.due_date)).to_i*(@reservation.equipment_model.late_fee))%>
<p>Your late fee is <%= number_to_currency(@reservation.equipment_model.late_fee) %> per day, for a total of <%= number_to_currency(@reservation.late_fee) %>
</p>
<% end %>

0 comments on commit 4c63b83

Please sign in to comment.