From 2c8107b870e2b2f9dba2e422563ee768c479557b Mon Sep 17 00:00:00 2001 From: Sergei Tsoganov Date: Tue, 3 Oct 2023 13:07:52 +0300 Subject: [PATCH 1/2] Added balance support for e_invoice data --- .../api/v1/e_invoice/e_invoice_controller.rb | 5 +++++ app/services/e_invoice_generator.rb | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/v1/e_invoice/e_invoice_controller.rb b/app/controllers/api/v1/e_invoice/e_invoice_controller.rb index ee76555..717a2f1 100644 --- a/app/controllers/api/v1/e_invoice/e_invoice_controller.rb +++ b/app/controllers/api/v1/e_invoice/e_invoice_controller.rb @@ -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], } diff --git a/app/services/e_invoice_generator.rb b/app/services/e_invoice_generator.rb index 519b7b3..0974818 100644 --- a/app/services/e_invoice_generator.rb +++ b/app/services/e_invoice_generator.rb @@ -1,6 +1,8 @@ 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) @@ -8,6 +10,11 @@ def initialize(e_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] @@ -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) From fa94887847273316265d1062aa083d4a167c54d4 Mon Sep 17 00:00:00 2001 From: Sergei Tsoganov Date: Tue, 3 Oct 2023 14:17:09 +0300 Subject: [PATCH 2/2] Updated e_invoice gem --- Gemfile | 4 ++-- Gemfile.lock | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Gemfile b/Gemfile index 055925b..8c2d33a 100644 --- a/Gemfile +++ b/Gemfile @@ -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' diff --git a/Gemfile.lock b/Gemfile.lock index e7d486c..f9b0403 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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 @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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)