diff --git a/app/models/transaction.rb b/app/models/transaction.rb index 8525157a..f3e2269b 100644 --- a/app/models/transaction.rb +++ b/app/models/transaction.rb @@ -22,7 +22,11 @@ def time end def signed_amount(account) - sign = from_account == account ? '-' : '+' + sign = negative?(account) ? '-' : '+' "#{sign}#{amount}" end + + def negative?(account) + from_account == account + end end diff --git a/app/views/transactions_mailer/transaction_notification.html.erb b/app/views/transactions_mailer/transaction_notification.html.erb index e0b543d6..2f7dab4b 100644 --- a/app/views/transactions_mailer/transaction_notification.html.erb +++ b/app/views/transactions_mailer/transaction_notification.html.erb @@ -1,21 +1,108 @@ -

New transaction was added in <%= @account.name %>!

-

About transation:

-

Amount: <%= @transaction.signed_amount(@account) %>

-

Description: <%= @transaction.description %>

-

Current balance: <%= @account.balance %>

-
-

Last 5 transactions:

- - - - - - - <% @transactions.each do |transaction|%> +
+

Transaction added to <%= @account.name %>

+
+
+ Amount: + <%= @transaction.signed_amount(@account) %> +
+ Description: <%= @transaction.description %> + Current balance: <%= @account.balance %> +
+

Last 5 transactions:

+
DateAmountDescription
- - - + + + - <% end %> -
<%= transaction.date %><%= transaction.signed_amount(@account) %><%= transaction.description %>DateAmountDescription
+ <% @transactions.each do |transaction|%> + + <%= transaction.date %> + <%= transaction.signed_amount(@account) %> + <%= transaction.description %> + + <% end %> + + <%= link_to "See More details", account_url(@account) %> + + +