Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
4 changes: 4 additions & 0 deletions app/models/state_file_az_intake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,13 @@
#
# Indexes
#
# index_state_file_az_intakes_email_verified (id) WHERE ((email_address IS NOT NULL) AND (email_address_verified_at IS NOT NULL))
# index_state_file_az_intakes_on_created_at (created_at)
# index_state_file_az_intakes_on_email_address (email_address)
# index_state_file_az_intakes_on_hashed_ssn (hashed_ssn)
# index_state_file_az_intakes_on_primary_state_id_id (primary_state_id_id)
# index_state_file_az_intakes_on_spouse_state_id_id (spouse_state_id_id)
# index_state_file_az_intakes_phone_verified (id) WHERE ((phone_number IS NOT NULL) AND (phone_number_verified_at IS NOT NULL))
#
class StateFileAzIntake < StateFileBaseIntake
encrypts :account_number, :routing_number, :raw_direct_file_data, :raw_direct_file_intake_data
Expand Down Expand Up @@ -131,6 +134,7 @@ def qualifying_parents_and_grandparents
end

def disqualifying_df_data_reason
return unless direct_file_data.present?
return :married_filing_separately if direct_file_data.filing_status == 3

w2_states = direct_file_data.parsed_xml.css('W2StateLocalTaxGrp W2StateTaxGrp StateAbbreviationCd')
Expand Down
12 changes: 4 additions & 8 deletions app/models/state_file_base_intake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,13 @@ def self.state_code
delegate :state_code, to: :class

def self.selected_intakes_for_deadline_reminder_soon_notifications
intakes = left_joins(:efile_submissions)
.where(efile_submissions: { id: nil })
.has_verified_contact_info
.where(created_at: Time.current.beginning_of_year..Time.current.end_of_year)

intakes.select { |i| !i.disqualifying_df_data_reason.present? && !i.other_intake_with_same_ssn_has_submission? }
self.where.missing(:efile_submissions)
.has_verified_contact_info
.where(created_at: Time.current.beginning_of_year..Time.current.end_of_year)
end

def self.selected_intakes_for_deadline_reminder_notifications
self.left_joins(:efile_submissions)
.where(efile_submissions: { id: nil })
self.where.missing(:efile_submissions)
.where.not(df_data_imported_at: nil)
.has_verified_contact_info
.select(&:should_be_sent_reminder?)
Expand Down
3 changes: 3 additions & 0 deletions app/models/state_file_id_intake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,13 @@
#
# Indexes
#
# index_state_file_id_intakes_email_verified (id) WHERE ((email_address IS NOT NULL) AND (email_address_verified_at IS NOT NULL))
# index_state_file_id_intakes_on_created_at (created_at)
# index_state_file_id_intakes_on_email_address (email_address)
# index_state_file_id_intakes_on_hashed_ssn (hashed_ssn)
# index_state_file_id_intakes_on_primary_state_id_id (primary_state_id_id)
# index_state_file_id_intakes_on_spouse_state_id_id (spouse_state_id_id)
# index_state_file_id_intakes_phone_verified (id) WHERE ((phone_number IS NOT NULL) AND (phone_number_verified_at IS NOT NULL))
#
class StateFileIdIntake < StateFileBaseIntake
enum donate_grocery_credit: { unfilled: 0, yes: 1, no: 2 }, _prefix: :donate_grocery_credit
Expand Down
4 changes: 4 additions & 0 deletions app/models/state_file_md_intake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,13 @@
#
# Indexes
#
# index_state_file_md_intakes_email_verified (id) WHERE ((email_address IS NOT NULL) AND (email_address_verified_at IS NOT NULL))
# index_state_file_md_intakes_on_created_at (created_at)
# index_state_file_md_intakes_on_email_address (email_address)
# index_state_file_md_intakes_on_hashed_ssn (hashed_ssn)
# index_state_file_md_intakes_on_primary_state_id_id (primary_state_id_id)
# index_state_file_md_intakes_on_spouse_state_id_id (spouse_state_id_id)
# index_state_file_md_intakes_phone_verified (id) WHERE ((phone_number IS NOT NULL) AND (phone_number_verified_at IS NOT NULL))
#
class StateFileMdIntake < StateFileBaseIntake
include MdResidenceCountyConcern
Expand Down Expand Up @@ -141,6 +144,7 @@ class StateFileMdIntake < StateFileBaseIntake

def disqualifying_df_data_reason
return :spouse_nra_html if nra_spouse?
return unless direct_file_data.present?
w2_states = direct_file_data.parsed_xml.css('W2StateLocalTaxGrp W2StateTaxGrp StateAbbreviationCd')
return :has_out_of_state_w2 if w2_states.any? do |state|
(state.text || '').upcase != state_code.upcase
Expand Down
4 changes: 4 additions & 0 deletions app/models/state_file_nc_intake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,12 @@
#
# Indexes
#
# index_state_file_nc_intakes_email_verified (id) WHERE ((email_address IS NOT NULL) AND (email_address_verified_at IS NOT NULL))
# index_state_file_nc_intakes_on_created_at (created_at)
# index_state_file_nc_intakes_on_hashed_ssn (hashed_ssn)
# index_state_file_nc_intakes_on_primary_state_id_id (primary_state_id_id)
# index_state_file_nc_intakes_on_spouse_state_id_id (spouse_state_id_id)
# index_state_file_nc_intakes_phone_verified (id) WHERE ((phone_number IS NOT NULL) AND (phone_number_verified_at IS NOT NULL))
#
class StateFileNcIntake < StateFileBaseIntake
include DateHelper
Expand Down Expand Up @@ -139,6 +142,7 @@ def disaster_relief_county
end

def disqualifying_df_data_reason
return unless direct_file_data.present?
w2_states = direct_file_data.parsed_xml.css('W2StateLocalTaxGrp W2StateTaxGrp StateAbbreviationCd')
:has_out_of_state_w2 if w2_states.any? do |state|
(state.text || '').upcase != state_code.upcase
Expand Down
4 changes: 4 additions & 0 deletions app/models/state_file_nj_intake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,13 @@
#
# Indexes
#
# index_state_file_nj_intakes_email_verified (id) WHERE ((email_address IS NOT NULL) AND (email_address_verified_at IS NOT NULL))
# index_state_file_nj_intakes_on_created_at (created_at)
# index_state_file_nj_intakes_on_email_address (email_address)
# index_state_file_nj_intakes_on_hashed_ssn (hashed_ssn)
# index_state_file_nj_intakes_on_primary_state_id_id (primary_state_id_id)
# index_state_file_nj_intakes_on_spouse_state_id_id (spouse_state_id_id)
# index_state_file_nj_intakes_phone_verified (id) WHERE ((phone_number IS NOT NULL) AND (phone_number_verified_at IS NOT NULL))
#
class StateFileNjIntake < StateFileBaseIntake
self.ignored_columns += ["primary_signature_pin", "spouse_signature_pin"]
Expand Down Expand Up @@ -171,6 +174,7 @@ def calculate_sales_use_tax
end

def disqualifying_df_data_reason
return unless direct_file_data.present?
w2_states = direct_file_data.parsed_xml.css('W2StateLocalTaxGrp W2StateTaxGrp StateAbbreviationCd')
return :has_out_of_state_w2 if w2_states.any? do |state|
!(state.text || '').casecmp(state_code).zero?
Expand Down
1 change: 1 addition & 0 deletions app/models/state_file_ny_intake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ def ach_debit_transaction?
IRC_125_CODES = ['IRC125S', 'IRS125']
YONKERS_CODES = ['YK', 'YON', 'YNK', 'CITYOFYK', 'CTYOFYKR', 'CITYOF YK', 'CTY OF YK']
def disqualifying_df_data_reason
return unless direct_file_data.present?
w2_states = direct_file_data.parsed_xml.css('W2StateLocalTaxGrp W2StateTaxGrp StateAbbreviationCd')
return :has_out_of_state_w2 if w2_states.any? do |state|
(state.text || '').upcase != state_code.upcase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ def self.run

intakes_to_notify.each_slice(BATCH_SIZE) do |batch|
batch.each do |intake|
if (intake.direct_file_data.present? && intake.disqualifying_df_data_reason.present?) || intake.other_intake_with_same_ssn_has_submission?
next
end
StateFile::MessagingService.new(
message: StateFile::AutomatedMessage::DeadlineReminderToday,
intake: intake
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
class AddIndexesForReminderNotifications < ActiveRecord::Migration[7.1]
disable_ddl_transaction!

def change
state_tables = %i[
state_file_az_intakes
state_file_md_intakes
state_file_nj_intakes
state_file_id_intakes
state_file_nc_intakes
]

state_tables.each do |table|
add_index table, :created_at, algorithm: :concurrently

add_index table, :id,
where: "(phone_number IS NOT NULL AND phone_number_verified_at IS NOT NULL)",
name: "index_#{table}_phone_verified",
algorithm: :concurrently

add_index table, :id,
where: "(email_address IS NOT NULL AND email_address_verified_at IS NOT NULL)",
name: "index_#{table}_email_verified",
algorithm: :concurrently
end
end
end
17 changes: 16 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.1].define(version: 2025_09_23_204400) do
ActiveRecord::Schema[7.1].define(version: 2025_09_26_151436) do
# These are extensions that must be enabled in order to support this database
enable_extension "citext"
enable_extension "plpgsql"
Expand Down Expand Up @@ -1941,8 +1941,11 @@
t.string "visitor_id"
t.integer "was_incarcerated", default: 0, null: false
t.integer "withdraw_amount"
t.index ["created_at"], name: "index_state_file_az_intakes_on_created_at"
t.index ["email_address"], name: "index_state_file_az_intakes_on_email_address"
t.index ["hashed_ssn"], name: "index_state_file_az_intakes_on_hashed_ssn"
t.index ["id"], name: "index_state_file_az_intakes_email_verified", where: "((email_address IS NOT NULL) AND (email_address_verified_at IS NOT NULL))"
t.index ["id"], name: "index_state_file_az_intakes_phone_verified", where: "((phone_number IS NOT NULL) AND (phone_number_verified_at IS NOT NULL))"
t.index ["primary_state_id_id"], name: "index_state_file_az_intakes_on_primary_state_id_id"
t.index ["spouse_state_id_id"], name: "index_state_file_az_intakes_on_spouse_state_id_id"
end
Expand Down Expand Up @@ -2088,8 +2091,11 @@
t.decimal "veterans_support_fund_donation", precision: 12, scale: 2
t.string "visitor_id"
t.integer "withdraw_amount"
t.index ["created_at"], name: "index_state_file_id_intakes_on_created_at"
t.index ["email_address"], name: "index_state_file_id_intakes_on_email_address"
t.index ["hashed_ssn"], name: "index_state_file_id_intakes_on_hashed_ssn"
t.index ["id"], name: "index_state_file_id_intakes_email_verified", where: "((email_address IS NOT NULL) AND (email_address_verified_at IS NOT NULL))"
t.index ["id"], name: "index_state_file_id_intakes_phone_verified", where: "((phone_number IS NOT NULL) AND (phone_number_verified_at IS NOT NULL))"
t.index ["primary_state_id_id"], name: "index_state_file_id_intakes_on_primary_state_id_id"
t.index ["spouse_state_id_id"], name: "index_state_file_id_intakes_on_spouse_state_id_id"
end
Expand Down Expand Up @@ -2206,8 +2212,11 @@
t.string "visitor_id"
t.decimal "withdraw_amount", precision: 12, scale: 2
t.string "zip_code"
t.index ["created_at"], name: "index_state_file_md_intakes_on_created_at"
t.index ["email_address"], name: "index_state_file_md_intakes_on_email_address"
t.index ["hashed_ssn"], name: "index_state_file_md_intakes_on_hashed_ssn"
t.index ["id"], name: "index_state_file_md_intakes_email_verified", where: "((email_address IS NOT NULL) AND (email_address_verified_at IS NOT NULL))"
t.index ["id"], name: "index_state_file_md_intakes_phone_verified", where: "((phone_number IS NOT NULL) AND (phone_number_verified_at IS NOT NULL))"
t.index ["primary_state_id_id"], name: "index_state_file_md_intakes_on_primary_state_id_id"
t.index ["spouse_state_id_id"], name: "index_state_file_md_intakes_on_spouse_state_id_id"
end
Expand Down Expand Up @@ -2304,7 +2313,10 @@
t.string "visitor_id"
t.integer "withdraw_amount"
t.string "zip_code"
t.index ["created_at"], name: "index_state_file_nc_intakes_on_created_at"
t.index ["hashed_ssn"], name: "index_state_file_nc_intakes_on_hashed_ssn"
t.index ["id"], name: "index_state_file_nc_intakes_email_verified", where: "((email_address IS NOT NULL) AND (email_address_verified_at IS NOT NULL))"
t.index ["id"], name: "index_state_file_nc_intakes_phone_verified", where: "((phone_number IS NOT NULL) AND (phone_number_verified_at IS NOT NULL))"
t.index ["primary_state_id_id"], name: "index_state_file_nc_intakes_on_primary_state_id_id"
t.index ["spouse_state_id_id"], name: "index_state_file_nc_intakes_on_spouse_state_id_id"
end
Expand Down Expand Up @@ -2461,8 +2473,11 @@
t.datetime "updated_at", null: false
t.string "visitor_id"
t.integer "withdraw_amount"
t.index ["created_at"], name: "index_state_file_nj_intakes_on_created_at"
t.index ["email_address"], name: "index_state_file_nj_intakes_on_email_address"
t.index ["hashed_ssn"], name: "index_state_file_nj_intakes_on_hashed_ssn"
t.index ["id"], name: "index_state_file_nj_intakes_email_verified", where: "((email_address IS NOT NULL) AND (email_address_verified_at IS NOT NULL))"
t.index ["id"], name: "index_state_file_nj_intakes_phone_verified", where: "((phone_number IS NOT NULL) AND (phone_number_verified_at IS NOT NULL))"
t.index ["primary_state_id_id"], name: "index_state_file_nj_intakes_on_primary_state_id_id"
t.index ["spouse_state_id_id"], name: "index_state_file_nj_intakes_on_spouse_state_id_id"
end
Expand Down
3 changes: 3 additions & 0 deletions spec/factories/state_file_az_intakes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,13 @@
#
# Indexes
#
# index_state_file_az_intakes_email_verified (id) WHERE ((email_address IS NOT NULL) AND (email_address_verified_at IS NOT NULL))
# index_state_file_az_intakes_on_created_at (created_at)
# index_state_file_az_intakes_on_email_address (email_address)
# index_state_file_az_intakes_on_hashed_ssn (hashed_ssn)
# index_state_file_az_intakes_on_primary_state_id_id (primary_state_id_id)
# index_state_file_az_intakes_on_spouse_state_id_id (spouse_state_id_id)
# index_state_file_az_intakes_phone_verified (id) WHERE ((phone_number IS NOT NULL) AND (phone_number_verified_at IS NOT NULL))
#
FactoryBot.define do
factory :minimal_state_file_az_intake, class: "StateFileAzIntake"
Expand Down
3 changes: 3 additions & 0 deletions spec/factories/state_file_id_intakes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,13 @@
#
# Indexes
#
# index_state_file_id_intakes_email_verified (id) WHERE ((email_address IS NOT NULL) AND (email_address_verified_at IS NOT NULL))
# index_state_file_id_intakes_on_created_at (created_at)
# index_state_file_id_intakes_on_email_address (email_address)
# index_state_file_id_intakes_on_hashed_ssn (hashed_ssn)
# index_state_file_id_intakes_on_primary_state_id_id (primary_state_id_id)
# index_state_file_id_intakes_on_spouse_state_id_id (spouse_state_id_id)
# index_state_file_id_intakes_phone_verified (id) WHERE ((phone_number IS NOT NULL) AND (phone_number_verified_at IS NOT NULL))
#
FactoryBot.define do
factory :minimal_state_file_id_intake, class: "StateFileIdIntake"
Expand Down
3 changes: 3 additions & 0 deletions spec/factories/state_file_md_intakes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,13 @@
#
# Indexes
#
# index_state_file_md_intakes_email_verified (id) WHERE ((email_address IS NOT NULL) AND (email_address_verified_at IS NOT NULL))
# index_state_file_md_intakes_on_created_at (created_at)
# index_state_file_md_intakes_on_email_address (email_address)
# index_state_file_md_intakes_on_hashed_ssn (hashed_ssn)
# index_state_file_md_intakes_on_primary_state_id_id (primary_state_id_id)
# index_state_file_md_intakes_on_spouse_state_id_id (spouse_state_id_id)
# index_state_file_md_intakes_phone_verified (id) WHERE ((phone_number IS NOT NULL) AND (phone_number_verified_at IS NOT NULL))
#
FactoryBot.define do
factory :state_file_md_intake do
Expand Down
3 changes: 3 additions & 0 deletions spec/factories/state_file_nc_intakes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,12 @@
#
# Indexes
#
# index_state_file_nc_intakes_email_verified (id) WHERE ((email_address IS NOT NULL) AND (email_address_verified_at IS NOT NULL))
# index_state_file_nc_intakes_on_created_at (created_at)
# index_state_file_nc_intakes_on_hashed_ssn (hashed_ssn)
# index_state_file_nc_intakes_on_primary_state_id_id (primary_state_id_id)
# index_state_file_nc_intakes_on_spouse_state_id_id (spouse_state_id_id)
# index_state_file_nc_intakes_phone_verified (id) WHERE ((phone_number IS NOT NULL) AND (phone_number_verified_at IS NOT NULL))
#
FactoryBot.define do
factory :state_file_nc_intake do
Expand Down
3 changes: 3 additions & 0 deletions spec/factories/state_file_nj_intakes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,13 @@
#
# Indexes
#
# index_state_file_nj_intakes_email_verified (id) WHERE ((email_address IS NOT NULL) AND (email_address_verified_at IS NOT NULL))
# index_state_file_nj_intakes_on_created_at (created_at)
# index_state_file_nj_intakes_on_email_address (email_address)
# index_state_file_nj_intakes_on_hashed_ssn (hashed_ssn)
# index_state_file_nj_intakes_on_primary_state_id_id (primary_state_id_id)
# index_state_file_nj_intakes_on_spouse_state_id_id (spouse_state_id_id)
# index_state_file_nj_intakes_phone_verified (id) WHERE ((phone_number IS NOT NULL) AND (phone_number_verified_at IS NOT NULL))
#
FactoryBot.define do
factory :state_file_nj_intake do
Expand Down
3 changes: 3 additions & 0 deletions spec/models/state_file_az_intake_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,13 @@
#
# Indexes
#
# index_state_file_az_intakes_email_verified (id) WHERE ((email_address IS NOT NULL) AND (email_address_verified_at IS NOT NULL))
# index_state_file_az_intakes_on_created_at (created_at)
# index_state_file_az_intakes_on_email_address (email_address)
# index_state_file_az_intakes_on_hashed_ssn (hashed_ssn)
# index_state_file_az_intakes_on_primary_state_id_id (primary_state_id_id)
# index_state_file_az_intakes_on_spouse_state_id_id (spouse_state_id_id)
# index_state_file_az_intakes_phone_verified (id) WHERE ((phone_number IS NOT NULL) AND (phone_number_verified_at IS NOT NULL))
#
require "rails_helper"

Expand Down
Loading
Loading