Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2315 bug declinebydefaultat field is incorrectly being set #9861

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def days_left_to_respond
end

def decline_by_default_date
@decline_by_default_date ||= @application_form.application_choices.offer.map(&:decline_by_default_at).min
@decline_by_default_date ||= CycleTimetable.decline_by_default_date(@application_form.recruitment_cycle_year)
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ def header_component_class
ApplicationHeaderComponents::RespondComponent
elsif awaiting_decision_but_cannot_respond?
ApplicationHeaderComponents::AwaitingDecisionCannotRespondComponent
elsif offer_will_be_declined_by_default?
ApplicationHeaderComponents::OfferWillBeDeclinedByDefaultComponent
elsif offer_waiting_for_candidate_response?
ApplicationHeaderComponents::OfferAwaitingCandidateResponseComponent
elsif deferred_offer?
ApplicationHeaderComponents::DeferredOfferComponent
end
Expand All @@ -52,7 +52,7 @@ def show_inset_text?
deferred_offer? ||
awaiting_decision_but_cannot_respond? ||
set_up_interview? ||
offer_will_be_declined_by_default?
offer_waiting_for_candidate_response?
end

def respond_to_application?
Expand All @@ -75,8 +75,8 @@ def waiting_for_interview?
provider_can_respond && application_choice.interviewing?
end

def offer_will_be_declined_by_default?
application_choice.offer? && application_choice.decline_by_default_at.present?
def offer_waiting_for_candidate_response?
application_choice.offer?
end

private
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module ProviderInterface
module ApplicationHeaderComponents
class OfferWillBeDeclinedByDefaultComponent < ApplicationChoiceHeaderComponent
class OfferAwaitingCandidateResponseComponent < ApplicationChoiceHeaderComponent
def offer_text
days = application_choice.days_since_offered

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def rows
application_number_row,
status_row,
offer_made_at_row,
decline_by_default_at_row,
course_candidate_applied_for_row,
course_offered_by_provider_row,
course_row,
Expand Down Expand Up @@ -51,12 +50,6 @@ def offer_made_at_row
{ key: 'Offer made at', value: application_choice.offered_at.to_fs(:govuk_date_and_time) }
end

def decline_by_default_at_row
return unless application_choice.offer?

{ key: 'Decline by default at', value: application_choice.decline_by_default_at.to_fs(:govuk_date_and_time) } if application_choice.decline_by_default_at
end

def course_candidate_applied_for_row
return unless application_choice.different_offer?

Expand Down
6 changes: 0 additions & 6 deletions app/exports/application_choices_export.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ custom_columns:
description: Date the application choice was rejected by default
example: 2020-11-01T00:00:00+00:00

decline_by_default_at:
type: string
format: date-time
description: Date the application choice was declined by default
example: 2020-11-01T00:00:00+00:00

decision:
type: string
description: Application choice decision
Expand Down
12 changes: 0 additions & 12 deletions app/exports/candidate_journey_tracking_export.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,6 @@ custom_columns:
description: Date the provider gave an offer
example: 2020-11-01T00:00:00+00:00

dbd_date:
type: string
format: date-time
description: Date the application choice will be declined by default
example: 2020-11-01T00:00:00+00:00

dbd_reminder_sent:
type: string
format: date-time
description: Date the earliest DBD reminder email was sent
example: 2020-11-01T00:00:00+00:00

candidate_decision:
type: string
format: date-time
Expand Down
10 changes: 1 addition & 9 deletions app/lib/time_limit_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,7 @@ def self.stale_application_rules
end

def self.rules
{
reject_by_default: stale_application_rules,
decline_by_default: [
Rule.new(nil, nil, 10),
],
chase_candidate_before_dbd: [
Rule.new(nil, nil, 5),
],
}
{ reject_by_default: stale_application_rules }
end

private_constant 'Rule'
Expand Down
23 changes: 0 additions & 23 deletions app/mailers/candidate_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -216,29 +216,6 @@ def offer_50_day(application_choice)
)
end

def declined_by_default(application_form)
@declined_courses = application_form.application_choices.select(&:declined_by_default?)
@declined_course_names = @declined_courses.map { |application_choice| "#{application_choice.current_course_option.course.name_and_code} at #{application_choice.current_course_option.course.provider.name}" }
@candidate_magic_link = candidate_magic_link(application_form.candidate)

if application_form.ended_without_success? && application_form.application_choices.any?(&:rejected?)
template_name = :declined_by_default_with_rejections
subject = I18n.t!('candidate_mailer.decline_by_default_last_course_choice.subject', count: @declined_courses.size)
elsif application_form.ended_without_success?
template_name = :declined_by_default_without_rejections
subject = I18n.t!('candidate_mailer.decline_by_default_last_course_choice.subject', count: @declined_courses.size)
else
template_name = :declined_by_default
subject = I18n.t!('candidate_mailer.declined_by_default.subject', count: @declined_courses.size)
end

email_for_candidate(
application_form,
subject:,
template_name:,
)
end

def conditions_statuses_changed(application_choice, met_conditions, pending_conditions, previously_met_conditions)
@application_choice = application_choice
course = application_choice.current_course_option.course
Expand Down
7 changes: 0 additions & 7 deletions app/models/application_choice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,6 @@ def recruitment_cycle
current_course.recruitment_cycle_year
end

def days_until_decline_by_default
dbd = decline_by_default_at
if offer? && dbd && dbd > Time.zone.now
((dbd - Time.zone.now) / 1.day).floor
end
end

delegate :course_not_available?, to: :course_option
delegate :withdrawn?, to: :course, prefix: true
delegate :submitted_at, to: :application_form, allow_nil: true, prefix: true
Expand Down
4 changes: 0 additions & 4 deletions app/models/application_dates.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,4 @@ def submitted_at
def reject_by_default_at
@application_form.application_choices.first&.reject_by_default_at
end

def decline_by_default_at
@application_form.first_not_declined_application_choice.decline_by_default_at
end
end
6 changes: 0 additions & 6 deletions app/models/application_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,6 @@ def awaiting_provider_decisions?
application_choices.decision_pending.any?
end

def first_not_declined_application_choice
application_choices
.where.not(decline_by_default_at: nil)
.first
end

def qualification_in_subject(level, subject)
if subject.to_s == ApplicationQualification::SCIENCE
# A Science GCSE may have any one of the following subject variants
Expand Down
27 changes: 0 additions & 27 deletions app/services/data_migrations/remove_dbd_from_current_cycle.rb

This file was deleted.

This file was deleted.

2 changes: 0 additions & 2 deletions app/services/make_offer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ def save!
course_option,
other_fields: { offered_at: Time.zone.now },
)

SetDeclineByDefaultToEndOfCycle.new(application_choice: application_choice).call
end

CancelUpcomingInterviews.new(
Expand Down
22 changes: 0 additions & 22 deletions app/services/reinstate_declined_offer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,11 @@ def initialize(course_choice:, zendesk_ticket:)
end

def save!
reset_all_dbd

@course_choice.update!(
status: 'offer',
declined_at: nil,
decline_by_default_at: set_dbd_value,
withdrawn_or_declined_for_candidate_by_provider: nil,
audit_comment: "Reinstate offer Zendesk request: #{@zendesk_ticket}",
)
end

private

def reset_all_dbd
choices_to_reset.each do |choice|
choice.update!(
decline_by_default_at: set_dbd_value,
audit_comment: "DBD reset due to a reinstated offer on application choice #{@course_choice.id} from ticket: #{@zendesk_ticket}",
)
end
end

def choices_to_reset
@course_choice.self_and_siblings.where(status: 'offer').where.not(id: @course_choice.id)
end

def set_dbd_value
TimeLimitCalculator.new(rule: :decline_by_default, effective_date: Time.zone.now).call[:time_in_future]
end
end
13 changes: 0 additions & 13 deletions app/services/set_decline_by_default_to_end_of_cycle.rb

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def application_choices(export_options = {})
course_code: choice.course.code,
sent_to_provider_at: choice.sent_to_provider_at,
reject_by_default_at: choice.reject_by_default_at,
decline_by_default_at: choice.decline_by_default_at,
decision: decision_interpretation(choice:),
decided_at: choice.offered_at || choice.rejected_at,
offer_response: offer_response_interpretation(choice:),
Expand Down
10 changes: 0 additions & 10 deletions app/services/support_interface/candidate_journey_tracker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ def initialize(application_choice)
application_rbd
provider_decision
offer_made
dbd_date
dbd_reminder_sent
candidate_decision
offer_declined
offer_accepted
Expand Down Expand Up @@ -90,14 +88,6 @@ def offer_made
@application_choice.offered_at
end

def dbd_date
@application_choice.decline_by_default_at
end

def dbd_reminder_sent
earliest_application_chaser_sent(:candidate_decision_request)
end

def candidate_decision
@application_choice.accepted_at || @application_choice.declined_at
end
Expand Down
5 changes: 0 additions & 5 deletions app/views/candidate_mailer/declined_by_default.text.erb

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
<li>the candidate has not accepted any other offers</li>
</ul>
<p class="govuk-body">In order to reinstate the offer you must first contact the provider to confirm that they agree to this.</p>
<p class="govuk-body">By reinstating the offer, the DBD deadline for this offer (and any other offers) will be reset to 10 working days.</p>
<p class="govuk-body">Once the offer has been reinstated, please email the candidate using the macro.</p>
<p class="govuk-body">There are separate macros if the request was made after 5 working days or if the candidate has already accepted another offer.</p>

Expand Down
1 change: 0 additions & 1 deletion config/locales/application_states.yml
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,6 @@ en:
by: system
description: The candidate has to respond within 10 working days, otherwise the system will decline the offer.
emails:
- candidate_mailer-declined_by_default
- provider_mailer-declined_by_default

offer-withdraw_offer:
Expand Down
8 changes: 0 additions & 8 deletions config/locales/emails/candidate_mailer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,6 @@ en:
We emailed the referee using this address: %{referee_email}
feedback_received_for_application_rejected_by_default:
subject: "Feedback on your application for %{provider_name}"
declined_by_default:
subject:
one: Application withdrawn automatically
other: Applications withdrawn automatically
decline_by_default_last_course_choice:
subject:
one: "You did not respond to your offer: next steps"
other: "You did not respond to your offers: next steps"
application_rejected:
subject: Update on your application
application_withdrawn_on_request:
Expand Down
5 changes: 2 additions & 3 deletions docs/support_playbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -362,13 +362,12 @@ To rollback a providers offer do the following:

- Set the status of the application choice back to `awaiting_provider_decision``
- set `offer_at` back to `nil`
- Set `decline_by_default_at` back to `nil`
- Add the Zendesk ticket URL as the `audit_comment`

E.G

```
ApplicationForm.find(ID).application_choices.find(id).update(status: 'awaiting_provider_decision', offered_at: nil, decline_by_default_at: nil, audit_comment: ZENDESK_URL)
ApplicationForm.find(ID).application_choices.find(id).update(status: 'awaiting_provider_decision', offered_at: nil, audit_comment: ZENDESK_URL)
```

### Make or change offer
Expand Down Expand Up @@ -497,7 +496,7 @@ It can happen that a candidate started training but forgot to accept the offer i
Update [ApplicationChoice](../app/models/application_choice.rb) to `recruited`.

```ruby
ApplicationChoice.find(_id).update!(status: :recruited, decline_by_default_at: nil, audit_comment: "ZENDESK_URL")
ApplicationChoice.find(_id).update!(status: :recruited, audit_comment: "ZENDESK_URL")
```

## Delete an account / application
Expand Down
Loading
Loading