From 0a8676ec97ce1504e09aae298b49a2a524b9c973 Mon Sep 17 00:00:00 2001 From: Auninda Date: Wed, 11 May 2016 16:02:43 +0600 Subject: [PATCH] The transaction template page is updated to hide summed up amounts if they contain mixed currency values. --- views/projects/transactions.html.erb | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/views/projects/transactions.html.erb b/views/projects/transactions.html.erb index 27b53b0a..fa4f2df9 100755 --- a/views/projects/transactions.html.erb +++ b/views/projects/transactions.html.erb @@ -71,8 +71,11 @@ title: Development Tracker
-
<%= Money.new(project['aggregations']['activity_children']['incoming_funds_value'].to_f.round(0)*100, project['aggregations']['activity_children']['incoming_funds_currency']).format(:no_cents_if_whole => true,:sign_before_symbol => false)%> -
+ <%mixedCurrencyExists = transactions.select {|group| group['transaction_type']['code'] == '1' }.sort{ |a,b| b['transaction_date'] <=> a['transaction_date'] } %> + <% if mixedCurrencyExists.uniq{|m| m['currency']['code']}.count == 1%> +
<%= Money.new(project['aggregations']['activity_children']['incoming_funds_value'].to_f.round(0)*100, project['aggregations']['activity_children']['incoming_funds_currency']).format(:no_cents_if_whole => true,:sign_before_symbol => false)%> +
+ <%end%>
@@ -122,8 +125,11 @@ title: Development Tracker
-
<%= Money.new(project['aggregations']['activity_children']['commitment_value'].to_f.round(0)*100, project['aggregations']['activity_children']['commitment_currency']).format(:no_cents_if_whole => true,:sign_before_symbol => false)%> + <%mixedCurrencyExists = transactions.select {|group| group['transaction_type']['code'] == '2' }.sort{ |a,b| b['transaction_date'] <=> a['transaction_date'] } %> + <% if mixedCurrencyExists.uniq{|m| m['currency']['code']}.count == 1%> +
<%= Money.new(project['aggregations']['activity_children']['commitment_value'].to_f.round(0)*100, project['aggregations']['activity_children']['commitment_currency']).format(:no_cents_if_whole => true,:sign_before_symbol => false)%>
+ <%end%>
@@ -171,8 +177,11 @@ title: Development Tracker
-
<%= Money.new(project['aggregations']['activity_children']['disbursement_value'].to_f.round(0)*100, project['aggregations']['activity_children']['disbursement_currency']).format(:no_cents_if_whole => true,:sign_before_symbol => false)%> + <%mixedCurrencyExists = transactions.select {|group| group['transaction_type']['code'] == '3' }.sort{ |a,b| b['transaction_date'] <=> a['transaction_date'] } %> + <% if mixedCurrencyExists.uniq{|m| m['currency']['code']}.count == 1%> +
<%= Money.new(project['aggregations']['activity_children']['disbursement_value'].to_f.round(0)*100, project['aggregations']['activity_children']['disbursement_currency']).format(:no_cents_if_whole => true,:sign_before_symbol => false)%>
+ <%end%>
@@ -223,8 +232,11 @@ title: Development Tracker
-
<%= Money.new(project['aggregations']['activity_children']['expenditure_value'].to_f.round(0)*100, project['aggregations']['activity_children']['expenditure_currency']).format(:no_cents_if_whole => true,:sign_before_symbol => false)%> -
+ <%mixedCurrencyExists = transactions.select {|group| group['transaction_type']['code'] == '4' }.sort{ |a,b| b['transaction_date'] <=> a['transaction_date'] } %> + <% if mixedCurrencyExists.uniq{|m| m['currency']['code']}.count == 1%> +
<%= Money.new(project['aggregations']['activity_children']['expenditure_value'].to_f.round(0)*100, project['aggregations']['activity_children']['expenditure_currency']).format(:no_cents_if_whole => true,:sign_before_symbol => false)%> +
+ <%end%>