Skip to content

Commit

Permalink
fix: clear deadlines after transition
Browse files Browse the repository at this point in the history
  • Loading branch information
diegosteiner committed Dec 3, 2024
1 parent 390d59e commit 0fd35a4
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/controllers/manage/deadlines_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def edit
end

def update
@booking.set_deadline(deadline_params)
@booking.set_deadline(**deadline_params)
respond_with :manage, @booking, location: manage_booking_path(@booking)
end

Expand Down
1 change: 1 addition & 0 deletions app/domain/booking_states/overdue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def self.to_sym
end

after_transition do |booking|
booking.deadline&.clear
MailTemplate.use(:overdue_notification, booking, to: :tenant, &:autodeliver!)
end

Expand Down
1 change: 1 addition & 0 deletions app/domain/booking_states/payment_overdue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def invoice_type
end

after_transition do |booking|
booking.deadline&.clear
MailTemplate.use(:payment_overdue_notification, booking, to: :tenant, &:autodeliver!)
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/booking.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def editable?
booking_state&.editable || false
end

def set_deadline(params = {})
def set_deadline(**params)
build_deadline if deadline.blank?
deadline.update(armed: true, postponable_for: nil, **params, booking: self)
deadline
Expand Down

0 comments on commit 0fd35a4

Please sign in to comment.