mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Test for invoice payment button #2733
This commit is contained in:
parent
e722da3ed8
commit
268fa47909
5 changed files with 59 additions and 2 deletions
|
@ -16,7 +16,10 @@ class Admin::BankStatementsController < AdminController
|
|||
end
|
||||
|
||||
def new
|
||||
@bank_statement = BankStatement.new
|
||||
@bank_statement = BankStatement.new(
|
||||
bank_code: Setting.registry_bank_code,
|
||||
iban: Setting.registry_iban
|
||||
)
|
||||
@invoice = Invoice.find_by(id: params[:invoice_id])
|
||||
@bank_transaction = @bank_statement.bank_transactions.build(
|
||||
description: @invoice.to_s,
|
||||
|
@ -78,7 +81,7 @@ class Admin::BankStatementsController < AdminController
|
|||
|
||||
def bank_statement_params
|
||||
params.require(:bank_statement).permit(:th6_file, :bank_code, :iban, bank_transactions_attributes: [
|
||||
:description, :sum, :reference_no, :paid_at
|
||||
:description, :sum, :currency, :reference_no, :paid_at
|
||||
])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -29,6 +29,10 @@
|
|||
= x.label :sum, class: 'col-md-4 control-label required'
|
||||
.col-md-8
|
||||
= x.text_field(:sum, class: 'form-control', required: true)
|
||||
.form-group
|
||||
= x.label :currency, class: 'col-md-4 control-label required'
|
||||
.col-md-8
|
||||
= x.text_field(:currency, class: 'form-control', required: true, readonly: true)
|
||||
.form-group
|
||||
= x.label :reference_no, class: 'col-md-4 control-label required'
|
||||
.col-md-8
|
||||
|
|
|
@ -71,6 +71,7 @@
|
|||
= render 'setting_row', var: :registry_vat_no
|
||||
= render 'setting_row', var: :registry_vat_prc
|
||||
= render 'setting_row', var: :registry_bank
|
||||
= render 'setting_row', var: :registry_bank_code
|
||||
= render 'setting_row', var: :registry_iban
|
||||
= render 'setting_row', var: :registry_swift
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ if con.present? && con.table_exists?('settings')
|
|||
Setting.save_default(:registry_vat_prc, 0.2)
|
||||
Setting.save_default(:registry_iban, 'EE557700771000598731')
|
||||
Setting.save_default(:registry_bank, 'LHV Pank')
|
||||
Setting.save_default(:registry_bank_code, '689')
|
||||
Setting.save_default(:registry_swift, 'LHVBEE22')
|
||||
Setting.save_default(:registry_invoice_contact, 'Martti Õigus')
|
||||
end
|
||||
|
|
|
@ -59,4 +59,52 @@ feature 'Invoice', type: :feature do
|
|||
response_headers['Content-Type'].should == 'application/pdf'
|
||||
response_headers['Content-Disposition'].should == "attachment; filename=\"#{@invoice.pdf_name}\""
|
||||
end
|
||||
|
||||
it 'should create bankt statement and transaction for invoice' do
|
||||
r = Fabricate(:registrar, reference_no: 'RF7086666663')
|
||||
invoice = r.issue_prepayment_invoice(200, 'add some money')
|
||||
|
||||
visit '/admin/invoices'
|
||||
click_link invoice.to_s
|
||||
|
||||
page.should have_content('Unpaid')
|
||||
|
||||
click_link 'Payment received'
|
||||
|
||||
paid_at = Time.zone.now
|
||||
find_field('Bank code').value.should == '689'
|
||||
find_field('Iban').value.should == 'EE557700771000598731'
|
||||
find_field('Description').value.should == invoice.to_s
|
||||
find_field('Sum').value.should == invoice.sum.to_s
|
||||
find_field('Currency').value.should == 'EUR'
|
||||
find_field('Reference no').value.should == invoice.reference_no
|
||||
find_field('Paid at').value.should == paid_at.to_date.to_s
|
||||
|
||||
click_button 'Save'
|
||||
|
||||
page.should have_content('Record created')
|
||||
page.should have_content('689')
|
||||
page.should have_content('EE557700771000598731')
|
||||
page.should have_content('Not binded', count: 2)
|
||||
page.should have_content(invoice.sum.to_s)
|
||||
page.should have_content('EUR')
|
||||
|
||||
click_link 'Bind invoices'
|
||||
|
||||
page.should have_content('Invoices were fully binded')
|
||||
page.should have_content('Fully binded')
|
||||
page.should have_content('Binded')
|
||||
|
||||
click_link I18n.l(paid_at, format: :date_long)
|
||||
|
||||
page.should have_content('Binded')
|
||||
page.should have_content(invoice.to_s)
|
||||
page.should have_content(invoice.sum.to_s)
|
||||
page.should have_content(invoice.reference_no)
|
||||
page.should have_content(I18n.l(paid_at, format: :date_long))
|
||||
|
||||
click_link(invoice.to_s)
|
||||
page.should_not have_content('Unpaid')
|
||||
page.should_not have_content('Payment received')
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue