Skip to content

Commit

Permalink
Merge pull request #91 from internetee/add-balance-to-e-invoices
Browse files Browse the repository at this point in the history
Added balance support for e_invoice data
  • Loading branch information
vohmar authored Oct 4, 2023
2 parents 697fafe + fa94887 commit 35cb4be
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ gem 'pdfkit'
gem 'money'
gem 'countries', :require => 'countries/global'

#payment features
gem 'e_invoice', github: 'internetee/e_invoice', branch: :master
# payment features
gem 'e_invoice', github: 'internetee/e_invoice', branch: 'master'
gem 'directo', github: 'internetee/directo', branch: 'master'
gem 'lhv', github: 'internetee/lhv', branch: 'master'

Expand Down
18 changes: 9 additions & 9 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ GIT

GIT
remote: https://github.com/internetee/e_invoice.git
revision: 9f850465697a2448a31ebddb83c1be5a5a9be3d2
revision: 0930cadeb00ed3d1e13d80065a6c743e374e14bc
branch: master
specs:
e_invoice (0.1.3)
e_invoice (0.1.5)
builder (~> 3.2)
nokogiri
savon
Expand Down Expand Up @@ -94,7 +94,7 @@ GEM
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
addressable (2.8.1)
addressable (2.8.5)
public_suffix (>= 2.0.2, < 6.0)
airbrussh (1.4.1)
sshkit (>= 1.6.1, != 1.7.0)
Expand Down Expand Up @@ -221,12 +221,12 @@ GEM
net-smtp
marcel (1.0.2)
method_source (1.0.0)
mini_mime (1.1.2)
mini_mime (1.1.5)
minitest (5.19.0)
money (6.16.0)
i18n (>= 0.6.4, <= 2)
msgpack (1.6.0)
net-imap (0.3.6)
net-imap (0.3.7)
date
net-protocol
net-pop (0.1.2)
Expand All @@ -235,7 +235,7 @@ GEM
timeout
net-scp (4.0.0)
net-ssh (>= 2.6.5, < 8.0.0)
net-smtp (0.3.3)
net-smtp (0.4.0)
net-protocol
net-ssh (7.0.1)
nio4r (2.5.9)
Expand All @@ -251,7 +251,7 @@ GEM
pg_search (2.3.6)
activerecord (>= 5.2)
activesupport (>= 5.2)
public_suffix (5.0.1)
public_suffix (5.0.3)
puma (6.1.0)
nio4r (~> 2.0)
racc (1.7.1)
Expand Down Expand Up @@ -296,7 +296,7 @@ GEM
redis-client (0.12.1)
connection_pool
regexp_parser (2.7.0)
rexml (3.2.5)
rexml (3.2.6)
rspec-core (3.12.1)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.2)
Expand Down Expand Up @@ -370,7 +370,7 @@ GEM
strong_migrations (1.4.2)
activerecord (>= 5.2)
thor (1.2.2)
timeout (0.3.2)
timeout (0.4.0)
turbo-rails (1.3.3)
actionpack (>= 6.0.0)
activejob (>= 6.0.0)
Expand Down
5 changes: 5 additions & 0 deletions app/controllers/api/v1/e_invoice/e_invoice_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ def create
buyer_e_invoice_iban: invoice_params[:buyer_e_invoice_iban],
seller_country_code: invoice_params[:seller_country_code],
buyer_country_code: invoice_params[:buyer_country_code],
balance_date: invoice_params[:balance_date],
balance_begin: invoice_params[:balance_begin],
inbound: invoice_params[:inbound],
outbound: invoice_params[:outbound],
balance_end: invoice_params[:balance_end],
initiator: invoice_params[:initiator],
}

Expand Down
15 changes: 14 additions & 1 deletion app/services/e_invoice_generator.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
class EInvoiceGenerator
attr_reader :invoice, :payable, :items, :buyer_billing_email,
:buyer_e_invoice_iban, :invoice_subtotal, :invoice_vat_amount,
:buyer_e_invoice_iban, :invoice_subtotal, :invoice_balance_date,
:invoice_balance_begin, :invoice_inbound, :invoice_outbound,
:invoice_balance_end, :invoice_vat_amount,
:seller_country_code, :buyer_country_code, :e_invoice_data

def initialize(e_invoice_data)
@invoice = e_invoice_data[:invoice_data]
@payable = e_invoice_data[:payable]
@invoice_subtotal = e_invoice_data[:invoice_subtotal]
@invoice_vat_amount = e_invoice_data[:vat_amount]
@invoice_balance_date = e_invoice_data[:balance_date]
@invoice_balance_begin = e_invoice_data[:balance_begin]
@invoice_inbound = e_invoice_data[:inbound]
@invoice_outbound = e_invoice_data[:outbound]
@invoice_balance_end = e_invoice_data[:balance_end]
@items = e_invoice_data[:invoice_items]
@buyer_billing_email = e_invoice_data[:buyer_billing_email]
@buyer_e_invoice_iban = e_invoice_data[:buyer_e_invoice_iban]
Expand Down Expand Up @@ -71,10 +78,16 @@ def generate
i.subtotal = invoice_subtotal
i.vat_amount = invoice_vat_amount
i.total = invoice[:total]
i.total_to_pay = invoice[:total_to_pay]
i.currency = invoice[:currency]
i.delivery_channel = %i[internet_bank portal]
i.payable = payable
i.monthly_invoice = invoice[:monthly_invoice]
i.balance_date = invoice_balance_date
i.balance_begin = invoice_balance_begin
i.inbound = invoice_inbound
i.outbound = invoice_outbound
i.balance_end = invoice_balance_end
end

EInvoice::EInvoice.new(date: Time.zone.today, invoice: e_invoice_invoice)
Expand Down

0 comments on commit 35cb4be

Please sign in to comment.