Skip to content

Commit

Permalink
#46 Update some function names and its references
Browse files Browse the repository at this point in the history
Co-authored-by: GuilhermeBraz <[email protected]>
  • Loading branch information
WeillerFernandes and GuilhermeBraz committed Feb 9, 2022
1 parent 8cac9dc commit 67f2b3b
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 17 deletions.
11 changes: 7 additions & 4 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ def print_percent(rate)

## Dates

def simple_date(date_object, timezone = nil)
# Format date to m/d/Y. Ex: 01/31/2022
def format_date_to_mdY(date_object, timezone = nil)
return '' if date_object.nil?

date_object = date_object.in_time_zone(timezone) if timezone
Expand All @@ -42,11 +43,13 @@ def simple_time(time_object, timezone = nil)
time_object.strftime('%l:%M%P')
end

def readable_date(date_object)
# Format date with complete month name. Ex: "January 31, 2022"
def format_date_with_month_name(date_object)
date_object.strftime('%B %d, %Y')
end

def date_and_time(date_object, timezone = nil)
# Format date to datetime with timezone. Ex: 01/31/2022 11:00PM (+03:00)
def format_date_to_datetime_timezone(date_object, timezone = nil)
date_object = date_object.in_time_zone(timezone) if timezone
date_object.strftime('%m/%d/%Y %I:%M%P (%Z)')
end
Expand All @@ -56,7 +59,7 @@ def us_states
end

# Append a parameter to a URL string
def url_with_param(param, val, url)
def append_param_to_url(param, val, url)
url + (url.include?('?') ? '&' : '?') + param + '=' + val
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
</tr>
<tr>
<td><strong>Recurring Since</strong></td>
<td> <%= simple_date donation.recurring_donation.created_at %></td>
<td> <%= format_date_to_mdY donation.recurring_donation.created_at %></td>
</tr>
<% end %>
Expand Down
6 changes: 3 additions & 3 deletions app/views/donation_mailer/_donation_payment_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
</tr>
<tr>
<td><strong><%= t('donation.date') %></strong></td>
<td><%= date_and_time(charge.try(:created_at) || donation.created_at, donation.nonprofit.timezone) %></td>
</tr>
<td><%= format_date_to_datetime_timezone(charge.try(:created_at) || donation.created_at, donation.nonprofit.timezone) %></td>
</tr>
<% if donation.campaign && donation.campaign.published %>
<tr>
Expand All @@ -47,7 +47,7 @@
</tr>
<tr>
<td><strong><%= t('donation.recurring_since') %></strong></td>
<td> <%= simple_date donation.recurring_donation.created_at %></td>
<td> <%= format_date_to_mdY donation.recurring_donation.created_at %></td>
</tr>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<% if @donation.recurring_donation %>
<p>
<%= t('mailer.donations.donor_direct_debit_notification.recurring_donation_queued_html', nonprofit_name: @nonprofit.name, start_date: simple_date(@donation.recurring_donation.created_at)) %>
<%= t('mailer.donations.donor_direct_debit_notification.recurring_donation_queued_html', nonprofit_name: @nonprofit.name, start_date: format_date_to_mdY(@donation.recurring_donation.created_at)) %>
</p>
<br>
<%else%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<% if @donation.recurring_donation %>
<p>
<%= t('mailer.donations.donor_receipt.recurring_donation_html', nonprofit_name: @nonprofit.name, start_date: simple_date(@donation.recurring_donation.created_at)) %>
<%= t('mailer.donations.donor_receipt.recurring_donation_html', nonprofit_name: @nonprofit.name, start_date: format_date_to_mdY(@donation.recurring_donation.created_at)) %>
</p>
<br>
<%else%>
Expand Down
2 changes: 1 addition & 1 deletion app/views/nonprofit_mailer/_payout_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</tr>
<tr>
<td><strong>Date</strong></td>
<td><%= simple_date(payout.created_at) %></td>
<td><%= format_date_to_mdY(payout.created_at) %></td>
</tr>
<tr>
<td><strong>Bank Account</strong></td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Your invoice for the month of <%= @month_name %> has been paid and the receipt i
</tr>
<tr>
<td><strong>Transaction Date</strong></td>
<td><%= date_and_time(@payment.date, @nonprofit.timezone) %></td>
<td><%= format_date_to_datetime_timezone(@payment.date, @nonprofit.timezone) %></td>
</tr>
<tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<p>We've received a request to update the bank account for receiving donations. Please verify the information below:</p>
<p>New bank account: <strong><%= @bank_account.name %></strong></p>
<p>Date and time of change: <strong><%= date_and_time @bank_account.created_at %></strong></p>
<p>Date and time of change: <strong><%= format_date_to_datetime_timezone @bank_account.created_at %></strong></p>
<p>User who requested change: <strong><%= @bank_account.email %></strong></p>
<p>For security, please confirm your bank account change below:</p>
Expand Down
2 changes: 1 addition & 1 deletion app/views/nonprofits/payouts/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<tbody>
<% @payouts.each do |payout| %>
<tr>
<td><%= simple_date(payout.created_at) %></td>
<td><%= format_date_to_mdY(payout.created_at) %></td>
<td class='table-bigNum'><%= print_currency(payout.net_amount, payout.nonprofit.currency_symbol) %></td>
<td><%= payout.bank_name %></td>
<td>
Expand Down
2 changes: 1 addition & 1 deletion app/views/profiles/_donations.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<td>
<%= link_to(donation.nonprofit.name, donation.nonprofit.url) %>
</td>
<td> <%= simple_date(donation.created_at) %></td>
<td> <%= format_date_to_mdY(donation.created_at) %></td>
<td> <%= GetData.chain(donation.card, :name) %> </td>
</tr>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/profiles/_ongoing_donations.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
</td>
<td>
Since <%= simple_date d.created_at %>
Since <%= format_date_to_mdY d.created_at %>
</td>
<td class='u-centered'>
Expand Down
2 changes: 1 addition & 1 deletion app/views/ticket_mailer/receipt_admin.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<strong><%= @supporter.name || @supporter.email %></strong>
redeemed the following tickets for <strong><a href='<%= Format::Url.concat(root_url, @event.url) %>'><%= @event.name %></a></strong>
on
<%= simple_date @tickets.last.created_at %>.</p><br>
<%= format_date_to_mdY @tickets.last.created_at %>.</p><br>
<%= render 'components/email/supporter_table', supporter: @supporter %>
Expand Down

0 comments on commit 67f2b3b

Please sign in to comment.