Merge pull request #1243 from internetee/issue-e-invoice-along-with-invoice

Issue e invoice along with invoice
This commit is contained in:
Timo Võhmar 2019-06-28 17:50:39 +03:00 committed by GitHub
commit b5af793305
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 19 additions and 7 deletions

View file

@ -17,7 +17,7 @@ GIT
GIT
remote: https://github.com/internetee/e_invoice.git
revision: 60084e2035dae0a8bce6eda960f8f5a64c4da604
revision: 917318bd546322408b83567745375c998619c926
branch: master
specs:
e_invoice (0.1.0)

View file

@ -69,6 +69,7 @@ class Invoice
i.vat_amount = invoice.vat_amount
i.total = invoice.total
i.currency = invoice.currency
i.delivery_channel = %i[internet_bank portal]
end
EInvoice::EInvoice.new(date: Time.zone.today, invoice: e_invoice_invoice)

View file

@ -53,7 +53,7 @@ class Registrar < ActiveRecord::Base
def issue_prepayment_invoice(amount, description = nil)
vat_rate = ::Invoice::VatRateCalculator.new(registrar: self).calculate
invoices.create!(
invoice = invoices.create!(
issue_date: Time.zone.today,
due_date: (Time.zone.now + Setting.days_to_keep_invoices_active.days).to_date,
description: description,
@ -95,6 +95,11 @@ class Registrar < ActiveRecord::Base
}
]
)
e_invoice = invoice.to_e_invoice
e_invoice.deliver
invoice
end
def cash_account

View file

@ -17,10 +17,7 @@ namespace :registrars do
next if reload_pending || !threshold_reached
Registrar.transaction do
invoice = registrar.issue_prepayment_invoice(reload_amount)
e_invoice = invoice.to_e_invoice
e_invoice.deliver
registrar.issue_prepayment_invoice(reload_amount)
registrar.settings['balance_auto_reload']['pending'] = true
registrar.save!
end

View file

@ -93,6 +93,14 @@ class RegistrarTest < ActiveSupport::TestCase
Setting.days_to_keep_invoices_active = @original_days_to_keep_invoices_active_setting
end
def test_issues_e_invoice_along_with_invoice
EInvoice::Providers::TestProvider.deliveries.clear
@registrar.issue_prepayment_invoice(100)
assert_equal 1, EInvoice::Providers::TestProvider.deliveries.count
end
def test_invalid_without_address_street
registrar = valid_registrar
registrar.address_street = ''

View file

@ -5,7 +5,6 @@ class ReloadBalanceTaskTest < ActiveSupport::TestCase
setup do
@registrar = registrars(:bestnames)
EInvoice.provider = EInvoice::Providers::TestProvider.new
end
def test_issues_invoice_when_auto_reload_is_enabled_and_threshold_reached

View file

@ -26,6 +26,8 @@ end
CompanyRegister::Client = CompanyRegisterClientStub
EInvoice.provider = EInvoice::Providers::TestProvider.new
class ActiveSupport::TestCase
include FactoryBot::Syntax::Methods