diff --git a/app/models/invoice.rb b/app/models/invoice.rb index a08ea88e5..01ccd2a3d 100644 --- a/app/models/invoice.rb +++ b/app/models/invoice.rb @@ -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 diff --git a/app/views/registrar/invoices/index.haml b/app/views/registrar/invoices/index.haml index a544365ca..6d8e6fa59 100644 --- a/app/views/registrar/invoices/index.haml +++ b/app/views/registrar/invoices/index.haml @@ -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 diff --git a/app/views/registrar/invoices/partials/_details.haml b/app/views/registrar/invoices/partials/_details.haml index 7aac2579a..95f1e5f31 100644 --- a/app/views/registrar/invoices/partials/_details.haml +++ b/app/views/registrar/invoices/partials/_details.haml @@ -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) diff --git a/config/locales/en.yml b/config/locales/en.yml index b67093489..aa9952541 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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' diff --git a/spec/features/registrar/invoices_spec.rb b/spec/features/registrar/invoices_spec.rb index 845a79444..5b777f50d 100644 --- a/spec/features/registrar/invoices_spec.rb +++ b/spec/features/registrar/invoices_spec.rb @@ -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