diff --git a/app/controllers/manage/deadlines_controller.rb b/app/controllers/manage/deadlines_controller.rb index 1fd2a1ad5..e9811d52a 100644 --- a/app/controllers/manage/deadlines_controller.rb +++ b/app/controllers/manage/deadlines_controller.rb @@ -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 diff --git a/app/domain/booking_states/overdue.rb b/app/domain/booking_states/overdue.rb index 78ad5e7c5..a4a3e69c9 100644 --- a/app/domain/booking_states/overdue.rb +++ b/app/domain/booking_states/overdue.rb @@ -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 diff --git a/app/domain/booking_states/payment_overdue.rb b/app/domain/booking_states/payment_overdue.rb index b5a582c77..cb67425ac 100644 --- a/app/domain/booking_states/payment_overdue.rb +++ b/app/domain/booking_states/payment_overdue.rb @@ -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 diff --git a/app/models/booking.rb b/app/models/booking.rb index d5d22ddcf..049148e25 100644 --- a/app/models/booking.rb +++ b/app/models/booking.rb @@ -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