12_generate_custom_csv_file #58
3 changed files with 14 additions and 7 deletions
|
@ -28,6 +28,6 @@
|
||||||
%th
|
%th
|
||||||
- FinancialTransactionClass.sorted.each do |c|
|
- FinancialTransactionClass.sorted.each do |c|
|
||||||
- name = FinancialTransactionClass.has_multiple_classes ? c.display : heading_helper(Ordergroup, :account_balance)
|
- name = FinancialTransactionClass.has_multiple_classes ? c.display : heading_helper(Ordergroup, :account_balance)
|
||||||
%th.numeric= format_currency @total_balances[c.id]
|
%th.numeric{:id => "total_balance#{c.id}"}= format_currency @total_balances[c.id]
|
||||||
%th.numeric
|
%th.numeric#total_balance_sum
|
||||||
= format_currency @total_balances.values.reduce(:+)
|
= format_currency @total_balances.values.reduce(:+)
|
|
@ -3,24 +3,30 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Finance::OrdergroupsController do
|
describe Finance::OrdergroupsController do
|
||||||
|
include ActionView::Helpers::NumberHelper
|
||||||
|
render_views
|
||||||
|
|
||||||
let(:user) { create(:user, :role_finance, :role_orders, :ordergroup) }
|
let(:user) { create(:user, :role_finance, :role_orders, :ordergroup) }
|
||||||
let(:fin_trans_type1) { create(:financial_transaction_type) }
|
let(:fin_trans_type1) { create(:financial_transaction_type) }
|
||||||
let(:fin_trans_type2) { create(:financial_transaction_type) }
|
let(:fin_trans_type2) { create(:financial_transaction_type) }
|
||||||
let(:fin_trans1) do
|
let(:fin_trans1) do
|
||||||
create(:financial_transaction,
|
create(:financial_transaction,
|
||||||
user: user,
|
user: user,
|
||||||
|
amount: 100,
|
||||||
ordergroup: user.ordergroup,
|
ordergroup: user.ordergroup,
|
||||||
financial_transaction_type: fin_trans_type1)
|
financial_transaction_type: fin_trans_type1)
|
||||||
end
|
end
|
||||||
let(:fin_trans2) do
|
let(:fin_trans2) do
|
||||||
create(:financial_transaction,
|
create(:financial_transaction,
|
||||||
user: user,
|
user: user,
|
||||||
|
amount: 200,
|
||||||
ordergroup: user.ordergroup,
|
ordergroup: user.ordergroup,
|
||||||
financial_transaction_type: fin_trans_type1)
|
financial_transaction_type: fin_trans_type1)
|
||||||
end
|
end
|
||||||
let(:fin_trans3) do
|
let(:fin_trans3) do
|
||||||
create(:financial_transaction,
|
create(:financial_transaction,
|
||||||
user: user,
|
user: user,
|
||||||
|
amount: 42.23,
|
||||||
ordergroup: user.ordergroup,
|
ordergroup: user.ordergroup,
|
||||||
financial_transaction_type: fin_trans_type2)
|
financial_transaction_type: fin_trans_type2)
|
||||||
end
|
end
|
||||||
|
@ -37,14 +43,15 @@ describe Finance::OrdergroupsController do
|
||||||
it 'renders index page' do
|
it 'renders index page' do
|
||||||
get_with_defaults :index
|
get_with_defaults :index
|
||||||
expect(response).to have_http_status(:success)
|
expect(response).to have_http_status(:success)
|
||||||
expect(response).to render_template('finance/ordergroups/index')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'calculates total balance sums correctly' do
|
it 'calculates total balance sums correctly' do
|
||||||
get_with_defaults :index
|
get_with_defaults :index
|
||||||
expect(assigns(:total_balances).size).to eq(2)
|
expect(response).to have_http_status(:success)
|
||||||
expect(assigns(:total_balances)[fin_trans_type1.id]).to eq(fin_trans1.amount + fin_trans2.amount)
|
|
||||||
expect(assigns(:total_balances)[fin_trans_type2.id]).to eq(fin_trans3.amount)
|
assert_select "#total_balance#{fin_trans_type1.id}", number_to_currency(300)
|
||||||
|
assert_select "#total_balance#{fin_trans_type2.id}", number_to_currency(42.23)
|
||||||
|
assert_select '#total_balance_sum', number_to_currency(342.23)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue