Skip to content

Commit 650d513

Browse files
committed
Merge remote-tracking branch 'origin/main' into FYST-2263-create-oct-21-df-reminder-notification
2 parents b60fb90 + 762aab3 commit 650d513

File tree

10 files changed

+246
-3
lines changed

10 files changed

+246
-3
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
module StateFile::AutomatedMessage
2+
class OctoberTransferReminder < BaseAutomatedMessage
3+
4+
def self.after_transition_notification?
5+
false
6+
end
7+
8+
def self.send_only_once?
9+
true
10+
end
11+
12+
def self.name
13+
'messages.state_file.october_transfer_reminder'.freeze
14+
end
15+
16+
def sms_body(**args)
17+
I18n.t("messages.state_file.october_transfer_reminder.sms", **args)
18+
end
19+
20+
def email_subject(**args)
21+
I18n.t("messages.state_file.october_transfer_reminder.email.subject", **args)
22+
end
23+
24+
def email_body(**args)
25+
I18n.t("messages.state_file.october_transfer_reminder.email.body", **args)
26+
end
27+
end
28+
end

app/models/state_file_base_intake.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,26 @@ def self.selected_intakes_for_deadline_reminder_notifications
9292
.select(&:should_be_sent_reminder?)
9393
end
9494

95+
def self.selected_intakes_for_first_deadline_reminder_notification
96+
self.where(df_data_imported_at: nil)
97+
.has_verified_contact_info
98+
.where(created_at: Time.current.beginning_of_year..Time.current.end_of_year)
99+
.select(&:send_october_transfer_reminder?)
100+
end
101+
102+
def send_october_transfer_reminder?
103+
received_message_recently = if message_tracker.present?
104+
message_tracker.values.compact.any? do |time_msg_sent|
105+
next false if time_msg_sent.blank?
106+
Time.parse(time_msg_sent.to_s) > 24.hours.ago
107+
end
108+
else
109+
false
110+
end
111+
112+
!received_message_recently && !other_intake_with_same_ssn_has_submission?
113+
end
114+
95115
def should_be_sent_reminder?
96116
received_reminder_recently = if message_tracker.present? && message_tracker["messages.state_file.finish_return"]
97117
finish_return_msg_sent_time = Time.parse(message_tracker["messages.state_file.finish_return"])
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module StateFile
2+
class OctoberTransferReminderService
3+
BATCH_SIZE = 100
4+
5+
def self.run
6+
intakes_to_notify = []
7+
StateFile::StateInformationService.state_intake_classes.excluding(StateFileNyIntake).each do |class_object|
8+
intakes_to_notify += class_object.selected_intakes_for_first_deadline_reminder_notification
9+
end
10+
11+
intakes_to_notify.each_slice(BATCH_SIZE) do |batch|
12+
batch.each do |intake|
13+
StateFile::MessagingService.new(
14+
message: StateFile::AutomatedMessage::OctoberTransferReminder,
15+
intake: intake
16+
).send_message
17+
end
18+
end
19+
end
20+
end
21+
end

app/views/signups/new.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<div class="slab slab--banner">
44
<div class="grid">
55
<div class="grid__item">
6-
<strong><%= t('.banner') %></strong>
6+
<strong><%= t('.banner', year: app_time.year) %></strong>
77
</div>
88
</div>
99
</div>

config/locales/en.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1732,6 +1732,28 @@ en:
17321732
The FileYourStateTaxes team
17331733
subject: Remember to finish your state tax return
17341734
sms: "Hi %{primary_first_name} - You started a state tax return with FileYourStateTaxes but have not finished. \n\nGo to http://www.fileyourstatetaxes.org/en/login-options to finish them today. The last day to submit your state tax return is October 22.\n\nIf you have already filed using another service, no action is required.\n\nNeed help? Email us at [email protected]\n\nBest,\nThe FileYourStateTaxes team\n"
1735+
october_transfer_reminder:
1736+
email:
1737+
body: |
1738+
Hi!
1739+
1740+
It looks like you created an account with <a target="_blank" rel="noopener nofollow" href="https://www.fileyourstatetaxes.org/">FileYourStateTaxes</a> but haven't transferred your federal return information from IRS Direct File. If you want to file your state return with us, please do so before October 22nd.
1741+
1742+
It's easy! Get started now at <a target="_blank" rel="noopener nofollow" href="https://www.fileyourstatetaxes.org/en/login-options">www.fileyourstatetaxes.org/en/login-options</a>.
1743+
1744+
Need help? Reply to this email.
1745+
1746+
Best,
1747+
The FileYourStateTaxes team
1748+
subject: Remember to start your state tax return
1749+
sms: |
1750+
Hi!
1751+
1752+
It looks like you created an account with FileYourStateTaxes but haven't transferred your federal return information from IRS Direct File. If you want to file your state return with us please do so before October 22nd.
1753+
1754+
It's easy! Get started now at http://www.fileyourstatetaxes.org/en/login-options .
1755+
1756+
Need help? Email us at [email protected]
17351757
post_deadline_reminder:
17361758
email:
17371759
body: |-
@@ -2208,7 +2230,7 @@ en:
22082230
signups:
22092231
flash_notice: Thank you! You will receive a notification when we open.
22102232
new:
2211-
banner: New intakes for GetYourRefund have closed for 2023. Please come back in January to file next year.
2233+
banner: New intakes for GetYourRefund have closed for %{year}. Please come back in January to file next year.
22122234
header: We'd love to work with you next year to help you file your taxes for free!
22132235
opt_in_message:
22142236
01_intro: 'Note: Providing your phone number means you have opted in to the following in order to use the GetYourRefund service:'

config/locales/es.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1713,6 +1713,20 @@ es:
17131713
body: "Hola %{primary_first_name},\n\nTodavía no has enviado tu declaración de impuestos estatales. \n\nCompleta tu declaración hoy visitando <a target=\"_blank\" rel=\"noopener nofollow\" href=\"http://www.fileyourstatetaxes.org/es/login-options\">www.fileyourstatetaxes.org/es/login-options</a>. El último día para enviar tu declaración estatal es el 22 de octubre.\n\nSi ya presentaste tu declaración usando otro servicio, no necesitas hacer nada.\n\n¿Necesitas ayuda? Responde a este correo electrónico.\n\nAtentamente,\nEl equipo de FileYourStateTaxes\n"
17141714
subject: Recuerda terminar tu declaración de impuestos estatales
17151715
sms: "Hola %{primary_first_name} - Aún no has enviado tu declaración de impuestos estatales.\n\nCompleta tu declaración hoy en http://www.fileyourstatetaxes.org/es/login-options . El último día para enviar tu declaración estatal es el 22 de octubre. \n\nSi ya presentaste tu declaración usando otro servicio, no necesitas hacer nada.\n\n¿Necesitas ayuda? Envíanos un email a [email protected].\n\nAtentamente,\nEl equipo de FileYourStateTaxes\n"
1716+
october_transfer_reminder:
1717+
email:
1718+
body: "¡Hola! \n\nAl parecer creaste una cuenta con <a target=\"_blank\" rel=\"noopener nofollow\" href=\"https://www.fileyourstatetaxes.org/\">FileYourStateTaxes</a>, pero aún no has transferido la información de tu declaración federal desde IRS Direct File. Si deseas presentar tu declaración estatal con nosotros, hazlo antes del 22 de octubre.\n\n¡Es fácil! Comienza ahora en <a target=\"_blank\" rel=\"noopener nofollow\" href=\"https://www.fileyourstatetaxes.org/es/login-options\">www.fileyourstatetaxes.org/es/login-options</a>.\n\n¿Necesitas ayuda? Responde a este correo electrónico.\n\nAtentamente, El equipo de FileYourStateTaxes\n"
1719+
subject: Recuerda comenzar tu declaración de impuestos estatales
1720+
sms: |
1721+
¡Hola!
1722+
1723+
Al parecer creaste una cuenta con FileYourStateTaxes, pero aún no has transferido la información de tu declaración federal desde IRS Direct File. Si deseas presentar tu declaración estatal con nosotros, hazlo antes del 22 de octubre.
1724+
1725+
Es fácil! Comienza en http://www.fileyourstatetaxes.org/es/login-options .
1726+
1727+
¿Necesitas ayuda? Envíanos un email a [email protected].
1728+
1729+
Atentamente, El equipo de FileYourStateTaxes
17161730
post_deadline_reminder:
17171731
email:
17181732
body: |-
@@ -2185,7 +2199,7 @@ es:
21852199
signups:
21862200
flash_notice: "¡Gracias! Recibirás una notificación cuando abramos."
21872201
new:
2188-
banner: Se cerraron nuevas inscripciones para GetYourRefund para 2023. Vuelva en enero para presentar la solicitud el próximo año.
2202+
banner: Se cerraron nuevas inscripciones para GetYourRefund para %{year}. Vuelva en enero para presentar la solicitud el próximo año.
21892203
header: "¡Nos daría mucho gusto trabajar con usted y ayudarle gratuitamente a declarar sus impuestos!"
21902204
opt_in_message:
21912205
01_intro: 'Aviso: Proporcionar su número de teléfono significa que usted ha optado por lo siguiente para usar el servicio GetYourRefund:'

crontab

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@
1515
0 21 27 10 * bundle exec rake users:suspend_non_admins
1616
0 18 21 10 * bundle exec rake state_file:send_deadline_reminder_tomorrow
1717
0 18 22 10 * bundle exec rake state_file:send_deadline_reminder_today
18+
0 18 16 10 * bundle exec rake state_file:send_october_transfer_reminder

lib/tasks/state_file.rake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ namespace :state_file do
3535
StateFile::SendMarketingEmailService.run
3636
end
3737

38+
task send_october_transfer_reminder: :environment do
39+
return unless DateTime.now.year == 2025
40+
StateFile::OctoberTransferReminderService.run
41+
end
42+
3843
task backfill_intake_submission_pdfs: :environment do
3944
batch_size = 5
4045
intake_types = StateFile::StateInformationService.state_intake_classes

spec/models/state_file_base_intake_spec.rb

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,107 @@
681681
end
682682
end
683683

684+
describe ".selected_intakes_for_first_deadline_reminder_notification" do
685+
let!(:az_intake_with_email_notifications_and_df_import) {
686+
create :state_file_az_intake,
687+
df_data_imported_at: 2.minutes.ago,
688+
email_address: '[email protected]',
689+
email_address_verified_at: 5.minutes.ago,
690+
email_notification_opt_in: 1
691+
}
692+
let!(:az_intake_with_email_notifications_and_df_import_from_last_year) {
693+
create :state_file_az_intake,
694+
df_data_imported_at: 2.minutes.ago,
695+
email_address: '[email protected]',
696+
email_address_verified_at: 5.minutes.ago,
697+
email_notification_opt_in: 1,
698+
created_at: 1.year.ago
699+
}
700+
let!(:az_intake_with_email_notifications_without_df_import) {
701+
create :state_file_az_intake,
702+
df_data_imported_at: nil,
703+
email_address: '[email protected]',
704+
email_address_verified_at: 5.minutes.ago,
705+
email_notification_opt_in: 1,
706+
message_tracker: { "messages.state_file.welcome" => 2.days.ago.utc.strftime("%Y-%m-%d %H:%M:%S UTC") }
707+
}
708+
let!(:az_intake_with_recent_message) {
709+
create :state_file_az_intake,
710+
df_data_imported_at: nil,
711+
email_address: '[email protected]',
712+
email_address_verified_at: 5.minutes.ago,
713+
email_notification_opt_in: 1,
714+
message_tracker: { "messages.state_file.welcome" => DateTime.now.utc.strftime("%Y-%m-%d %H:%M:%S UTC") }
715+
}
716+
let!(:az_intake_with_text_notifications_and_df_import) {
717+
create :state_file_az_intake,
718+
df_data_imported_at: 2.minutes.ago,
719+
phone_number: "+15551115511",
720+
sms_notification_opt_in: 1,
721+
phone_number_verified_at: 5.minutes.ago
722+
}
723+
let!(:az_intake_with_unverified_text_notifications_and_df_import) {
724+
create :state_file_az_intake,
725+
df_data_imported_at: 2.minutes.ago,
726+
phone_number: "+15551115511",
727+
sms_notification_opt_in: "yes",
728+
email_address: '[email protected]',
729+
email_address_verified_at: 5.minutes.ago,
730+
email_notification_opt_in: "no"
731+
}
732+
let!(:az_intake_submitted) {
733+
create :state_file_az_intake,
734+
df_data_imported_at: 2.minutes.ago,
735+
email_address: '[email protected]',
736+
email_address_verified_at: 5.minutes.ago,
737+
email_notification_opt_in: 1
738+
}
739+
let!(:efile_submission) { create :efile_submission, :for_state, data_source: az_intake_submitted }
740+
741+
let!(:az_intake_has_disqualifying_df_data) {
742+
create :state_file_az_intake,
743+
filing_status: :married_filing_separately,
744+
email_address: "[email protected]",
745+
email_address_verified_at: 1.hour.ago,
746+
email_notification_opt_in: 1,
747+
df_data_imported_at: 2.minutes.ago
748+
}
749+
750+
let!(:az_intake_submitted_ssn_duplicate) {
751+
create :state_file_az_intake,
752+
email_address: "[email protected]",
753+
email_address_verified_at: 1.hour.ago,
754+
email_notification_opt_in: 1,
755+
phone_number: nil,
756+
df_data_imported_at: 2.minutes.ago,
757+
hashed_ssn: "111443333"
758+
}
759+
let!(:az_intake_submitted_ssn_duplicate_1) {
760+
create :state_file_az_intake,
761+
email_address: "[email protected]",
762+
email_address_verified_at: 1.hour.ago,
763+
email_notification_opt_in: 1,
764+
phone_number: nil,
765+
df_data_imported_at: 2.minutes.ago,
766+
hashed_ssn: "111443333"
767+
}
768+
let!(:efile_submission_for_duplicate) { create :efile_submission, :for_state, data_source: az_intake_submitted_ssn_duplicate }
769+
770+
before do
771+
allow(Flipper).to receive(:enabled?).and_call_original
772+
allow(Flipper).to receive(:enabled?).with(:prevent_duplicate_ssn_messaging).and_return(true)
773+
774+
allow_any_instance_of(StateFileAzIntake).to receive(:should_be_sent_reminder?).and_return(true)
775+
end
776+
777+
it "returns only current-year intakes without df data that have no other messages within the past 24 hours and have no disqualifying/duplicate-with-submission issues" do
778+
results = StateFileAzIntake.selected_intakes_for_first_deadline_reminder_notification
779+
780+
expect(results).to match_array([az_intake_with_email_notifications_without_df_import])
781+
end
782+
end
783+
784+
684785
describe "#should_be_sent_reminder?" do
685786
let(:message_tracker) { nil }
686787
let(:intake) { create :state_file_az_intake, message_tracker: message_tracker }
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# frozen_string_literal: true
2+
require 'rails_helper'
3+
4+
describe 'state_file:october_transfer_reminder' do
5+
before(:all) do
6+
Rake.application.rake_require "tasks/state_file"
7+
end
8+
9+
around do |example|
10+
Timecop.freeze(DateTime.parse("2-12-2025")) do
11+
example.run
12+
end
13+
end
14+
15+
it 'sends messages via appropriate contact method to intakes without submissions, with or without df data that is not disqualifying' do
16+
az_intake_to_notify = create(:state_file_az_intake)
17+
az_intake_to_not_notify = create(:state_file_az_intake)
18+
nc_intake = create(:state_file_nc_intake)
19+
allow(StateFileAzIntake).to receive(:selected_intakes_for_first_deadline_reminder_notification).and_return([az_intake_to_notify])
20+
allow(StateFileNcIntake).to receive(:selected_intakes_for_first_deadline_reminder_notification).and_return([nc_intake])
21+
messaging_service = spy('StateFile::MessagingService')
22+
allow(StateFile::MessagingService).to receive(:new).and_return(messaging_service)
23+
24+
Rake::Task['state_file:send_october_transfer_reminder'].execute
25+
26+
expect(StateFile::MessagingService).to have_received(:new).exactly(2).times
27+
expect(StateFile::MessagingService).to have_received(:new).with(message: StateFile::AutomatedMessage::OctoberTransferReminder, intake: az_intake_to_notify)
28+
expect(StateFile::MessagingService).to have_received(:new).with(message: StateFile::AutomatedMessage::OctoberTransferReminder, intake: nc_intake)
29+
expect(StateFile::MessagingService).to_not have_received(:new).with(message: StateFile::AutomatedMessage::OctoberTransferReminder, intake: az_intake_to_not_notify)
30+
end
31+
end

0 commit comments

Comments
 (0)