Skip to content

Commit

Permalink
fix checkout
Browse files Browse the repository at this point in the history
  • Loading branch information
nabeta committed Jan 19, 2025
1 parent 25c9b4c commit 9ce2a59
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions app/models/concerns/enju_circulation/enju_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,10 @@ def available_for_checkout?

def checkout!(user)
Item.transaction do
if user_reservation(user)
unless user_reservation.state_machine.in_state?(:completed)
user_reservation.checked_out_at = Time.zone.now
user_reservation.state_machine.transition_to!(:completed)
end
reserve = user_reservation(user)
if reserve && reserve.state_machine.not_in_state?(:completed)
reserve.checked_out_at = Time.zone.now
reserve.state_machine.transition_to!(:completed)
end

update!(circulation_status: CirculationStatus.find_by(name: 'On Loan'))
Expand Down

0 comments on commit 9ce2a59

Please sign in to comment.