Skip to content

Commit

Permalink
Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
embarnard committed Apr 22, 2024
1 parent 922141a commit 03d505f
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 18 deletions.
26 changes: 26 additions & 0 deletions app/controllers/application_controller.rb
Expand Up @@ -413,6 +413,32 @@ def before_state_file_launch?
end
helper_method :before_state_file_launch?

def withdrawal_date_deadline
case params[:us_state]
when 'ny'
Rails.configuration.state_file_withdrawal_date_deadline_ny
else
# Arizona's withdrawal date deadline is the same as the end-new-intakes date which is set in PDT,
# if this was during daylight-savings, it would be different except in the Navajo Nation
Rails.configuration.state_file_end_of_new_intakes
end
end
helper_method :withdrawal_date_deadline

def before_withdrawal_date_deadline?
app_time < withdrawal_date_deadline
end
helper_method :before_withdrawal_date_deadline?

def post_deadline_withdrawal_date
if params[:us_state] == 'ny'
app_time.in_time_zone('America/New_York')
else
app_time.in_time_zone('America/Phoenix')
end
end
helper_method :post_deadline_withdrawal_date

private

def locale
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/session_toggles_controller.rb
Expand Up @@ -23,8 +23,9 @@ def index
service_url: url_for(host: MultiTenantService.new(:statefile).host, controller: :session_toggles),
times: [
SessionToggleTime.new(name: 'Start of open intake', property: :state_file_start_of_open_intake),
SessionToggleTime.new(name: 'End of New intake', property: :state_file_end_of_new_intakes),
SessionToggleTime.new(name: 'End of In Progress Intakes', property: :state_file_end_of_in_progress_intakes),
SessionToggleTime.new(name: 'Withdrawal date deadline for New York', property: :state_file_withdrawal_date_deadline_ny),
SessionToggleTime.new(name: 'End of new intakes', property: :state_file_end_of_new_intakes),
SessionToggleTime.new(name: 'End of in-progress intakes', property: :state_file_end_of_in_progress_intakes),
]
},
{
Expand Down
Expand Up @@ -34,7 +34,6 @@ def pay_mail_online_text
end
helper_method :pay_mail_online_text


private

def card_postscript; end
Expand Down
31 changes: 21 additions & 10 deletions app/forms/state_file/taxes_owed_form.rb
Expand Up @@ -10,11 +10,15 @@ class TaxesOwedForm < TaxRefundForm
:withdraw_amount

set_attributes_for :confirmation, :routing_number_confirmation, :account_number_confirmation
set_attributes_for :date, :date_electronic_withdrawal_month, :date_electronic_withdrawal_year, :date_electronic_withdrawal_day
set_attributes_for :date,
:date_electronic_withdrawal_month,
:date_electronic_withdrawal_year,
:date_electronic_withdrawal_day,
:post_deadline_withdrawal_date

with_options unless: -> { payment_or_deposit_type == "mail" } do
# validate :date_electronic_withdrawal_is_valid_date
# validate :withdrawal_date_before_deadline, if: -> { date_electronic_withdrawal.present? }
validate :date_electronic_withdrawal_is_valid_date
validate :withdrawal_date_before_deadline, if: -> { date_electronic_withdrawal.present? && !post_deadline_withdrawal_date.present? }
validates :withdraw_amount, presence: true, numericality: { greater_than: 0 }
validate :withdraw_amount_higher_than_owed?
end
Expand All @@ -37,11 +41,22 @@ def self.existing_attributes(intake)
private

def date_electronic_withdrawal
Time.now.in_time_zone('Eastern Time (US & Canada)').to_date
if post_deadline_withdrawal_date.present?
post_deadline_withdrawal_date
else
parse_date_params(date_electronic_withdrawal_year, date_electronic_withdrawal_month, date_electronic_withdrawal_day)
end
end

def date_electronic_withdrawal_is_valid_date
valid_text_date(Time.now.year.to_s, Time.now.month.to_s, Time.now.day.to_s, :date_electronic_withdrawal)
if post_deadline_withdrawal_date.present?
Date.parse(post_deadline_withdrawal_date)
else
valid_text_date(date_electronic_withdrawal_year,
date_electronic_withdrawal_month,
date_electronic_withdrawal_day,
:date_electronic_withdrawal)
end
end

def withdraw_amount_higher_than_owed?
Expand All @@ -55,13 +70,9 @@ def withdraw_amount_higher_than_owed?
end

def withdrawal_date_before_deadline
unless date_electronic_withdrawal.between?(DateTime.current.to_date, withdrawal_date_deadline)
unless date_electronic_withdrawal.between?(DateTime.current.to_date, withdrawal_date_deadline) || post_deadline_withdrawal_date.present?
self.errors.add(:date_electronic_withdrawal, I18n.t("forms.errors.taxes_owed.withdrawal_date_deadline", year: withdrawal_date_deadline.year))
end
end

def withdrawal_date_deadline
DateTime.parse("April 15th, #{MultiTenantService.new(:statefile).current_tax_year + 1}")
end
end
end
6 changes: 5 additions & 1 deletion app/views/shared/_environment_warning.html.erb
Expand Up @@ -16,7 +16,11 @@
<div class="grid">
<div class="grid__item">
<strong>Active Session Toggles:</strong>
<div><%= session[:session_toggles] %></div>
<div><%= session[:session_toggles] %> UTC</div>
<% if state_file? %>
<div><%= app_time.in_time_zone('America/New_York').strftime("%A %m-%d-%Y %l:%M%P") %> EST</div>
<div><%= app_time.in_time_zone('America/Phoenix').strftime("%A %m-%d-%Y %l:%M%P") %> MST</div>
<% end %>
</div>
</div>
</div>
Expand Down
24 changes: 22 additions & 2 deletions app/views/state_file/questions/tax_refund/_bank_details.html.erb
Expand Up @@ -4,7 +4,21 @@
<div class="form-group-tight">
<% if owe_taxes %>
<%= form.cfa_input_field(:withdraw_amount, t('.withdraw_amount', owed_amount: taxes_owed), classes: ["form-width--long"]) %>
<% if before_withdrawal_date_deadline? %>
<div class="date-select">
<% year = MultiTenantService.new(:statefile).current_tax_year + 1 %>
<%= form.cfa_date_select(
:date_electronic_withdrawal,
t(".date_withdraw_text"),
options: {
start_year: year,
end_year: year,
}
) %>
</div>
<% else %>
<%= form.hidden_field :post_deadline_withdrawal_date, value: post_deadline_withdrawal_date %>
<% end %>
<% end %>
<%= form.cfa_input_field(:bank_name, t("views.questions.bank_details.bank_name"), classes: ["form-width--long"]) %>
Expand All @@ -23,5 +37,11 @@
<%= form.cfa_input_field(:account_number_confirmation, t(".confirm_account_number"), classes: ["form-width--long", "disablepaste", "disablecopy"]) %>
</div>
<p><strong><%= t(".disclaimer") %></strong></p>
<p><strong><%= t(".after-deadline-default-withdrawl-info") %></strong></p>
<% if owe_taxes && !before_withdrawal_date_deadline? %>
<p>
<%= t(".after_deadline_default_withdrawal_info",
with_drawal_deadline_date: I18n.l(withdrawal_date_deadline.to_date, format: :medium, locale: locale),
with_drawal_deadline_year: withdrawal_date_deadline.year) %>
</p>
<% end %>
</div>
1 change: 1 addition & 0 deletions config/application.rb
Expand Up @@ -108,6 +108,7 @@ class Application < Rails::Application
# StateFile
config.state_file_start_of_open_intake = Time.find_zone('America/New_York').parse('2024-02-08 09:00:00')
config.state_file_end_of_new_intakes = Time.find_zone('America/Los_Angeles').parse('2024-04-15 23:59:59')
config.state_file_withdrawal_date_deadline_ny = Time.find_zone('America/New_York').parse('2024-04-15 23:59:59')
config.state_file_end_of_in_progress_intakes = Time.find_zone('America/Los_Angeles').parse('2024-04-25 23:59:59')

config.allow_magic_verification_code = (Rails.env.demo? || Rails.env.development? || Rails.env.heroku?)
Expand Down
2 changes: 1 addition & 1 deletion config/locales/en.yml
Expand Up @@ -2667,7 +2667,7 @@ en:
tax_refund:
bank_details:
account_number: Account Number
after-deadline-default-withdrawl-info: Because you are submitting your return on or after April 15, 2024, the state will withdraw your payment as soon as they process your return.
after_deadline_default_withdrawal_info: Because you are submitting your return on or after %{with_drawal_deadline_date}, %{with_drawal_deadline_year}, the state will withdraw your payment as soon as they process your return.
bank_title: 'Please provide your bank details:'
confirm_account_number: Confirm Account Number
confirm_routing_number: Confirm Routing Number
Expand Down
2 changes: 1 addition & 1 deletion config/locales/es.yml
Expand Up @@ -2647,7 +2647,7 @@ es:
tax_refund:
bank_details:
account_number: Número de cuenta
after-deadline-default-withdrawl-info: Debido al hecho de que estás enviando tu declaración el 15 de abril o después, el estado retirará tu pago tan pronto como se procese tu declaración.
after_deadline_default_withdrawal_info: Debido al hecho de que estás enviando tu declaración el %{with_drawal_deadline_date}, %{with_drawal_deadline_year} o después, el estado retirará tu pago tan pronto como se procese tu declaración.
bank_title: 'Comparte los detalles de tu cuenta bancaria:'
confirm_account_number: Confirma el número de cuenta
confirm_routing_number: Confirma el número de ruta bancaria (routing number)
Expand Down
21 changes: 21 additions & 0 deletions spec/controllers/application_controller_spec.rb
Expand Up @@ -1408,6 +1408,27 @@ def index
end
end

describe "#withdrawal_date_deadline" do
let(:state) { "ny" }
before { @params = { us_state: state } }

context "for a New York return" do
it "returns the NY withdrawal date deadline" do
get :index, params: @params
expect(subject.withdrawal_date_deadline).to eq Rails.configuration.state_file_withdrawal_date_deadline_ny
end
end

context "for an Arizona return" do
let(:state) { "az" }

it "returns the AZ withdrawal date deadline" do
get :index, params: @params
expect(subject.withdrawal_date_deadline).to eq Rails.configuration.state_file_end_of_new_intakes
end
end
end

context "when receiving invalid requests from robots" do
before do
allow(DatadogApi).to receive(:increment)
Expand Down

0 comments on commit 03d505f

Please sign in to comment.