Show real balance in invoices view

This commit is contained in:
Martin Lensment 2015-04-15 14:00:18 +03:00
parent 8768c0e1d6
commit 99aecc476f
5 changed files with 14 additions and 3 deletions

View file

@ -13,6 +13,11 @@ class Invoice < ActiveRecord::Base
account_activity.present?
end
def paid_at
# TODO: Cache this?
account_activity.try(:bank_transaction).try(:paid_at)
end
def to_s
I18n.t('invoice_no', no: id)
end

View file

@ -7,7 +7,7 @@
= link_to(t('add_deposit'), new_registrar_deposit_path, class: 'btn btn-default')
%hr
= t('your_current_credit_account_balance_is', balance: 1000.0)
= t('your_current_account_balance_is', balance: current_user.registrar.cash_account.balance)
%h1= t('invoices')
%hr

View file

@ -7,6 +7,12 @@
%dt= t('due_date')
%dd= l(@invoice.due_date)
%dt= t('paid_at')
- if @invoice.paid_at
%dd= l(@invoice.paid_at)
- else
%dd{class: 'text-danger'}= t('unpaid')
%dt= t('payment_term')
%dd= t(@invoice.payment_term)

View file

@ -652,7 +652,7 @@ en:
prepayment: 'Prepayment'
vat: 'VAT (%{vat_prc}%)'
unpaid: 'Unpaid'
your_current_credit_account_balance_is: 'Your current credit account balance is %{balance} EUR'
your_current_account_balance_is: 'Your current account balance is %{balance} EUR'
billing: 'Billing'
your_account: 'Your account'
pay_by_bank_link: 'Pay by bank link'

View file

@ -24,7 +24,7 @@ feature 'Invoices', type: :feature do
click_link 'Billing'
current_path.should == '/registrar/invoices'
page.should have_text('Your current credit account balance is')
page.should have_text('Your current account balance is')
end
it 'should get domains index page' do