diff --git a/app/components/modals/pay_invoice/component.html.erb b/app/components/modals/pay_invoice/component.html.erb
index 52304f730..346d0e754 100644
--- a/app/components/modals/pay_invoice/component.html.erb
+++ b/app/components/modals/pay_invoice/component.html.erb
@@ -24,7 +24,7 @@
<%= turbo_frame_tag "invoice_information" do %>
- <%= render partial: 'invoices/invoice_information', locals: { invoice: @invoice } %>
+ <%= component 'modals/pay_invoice/invoice_information', invoice: @invoice %>
<% end %>
diff --git a/app/components/modals/pay_invoice/component.rb b/app/components/modals/pay_invoice/component.rb
index 443445d4a..c64f8c8a9 100644
--- a/app/components/modals/pay_invoice/component.rb
+++ b/app/components/modals/pay_invoice/component.rb
@@ -8,44 +8,6 @@ def initialize(invoice:)
@invoice = invoice
end
-
- def current_billing_profile
- params[:billing_profile_id].presence || invoice.billing_profile_id
- end
-
- def invoice_issuer
- Setting.find_by(code: 'invoice_issuer').retrieve
- end
-
- def issuer_for
- @invoice.address
- end
-
- def invoice_issuer_address
- Setting.find_by(code: 'invoice_issuer_address').retrieve
- end
-
- def invoice_issuer_reg_no
- Setting.find_by(code: 'invoice_issuer_reg_no').retrieve
- end
-
- def invoice_issuer_vat_number
- Setting.find_by(code: 'invoice_issuer_vat_number').retrieve
- end
-
- def billing_profile_dropdown_properties
- {
- attribute: :billing_profile_id,
- enum: billing_profiles = BillingProfile.where(user_id: invoice.user_id).collect do |b|
- [b.name, b.id, { 'data-vat-rate' => b.vat_rate }]
- end,
- first_options: {},
- second_options: {
- class: billing_profiles.size == 1 ? 'disabled' : '',
- data: { action: 'change->invoice-autotax-counterr#updateTax', invoice_autotax_counter_target: 'dropdown'}
- }
- }
- end
end
end
end
\ No newline at end of file
diff --git a/app/views/invoices/_invoice_information.html.erb b/app/components/modals/pay_invoice/invoice_information/component.html.erb
similarity index 81%
rename from app/views/invoices/_invoice_information.html.erb
rename to app/components/modals/pay_invoice/invoice_information/component.html.erb
index 61a4b1ff0..b19af1eae 100644
--- a/app/views/invoices/_invoice_information.html.erb
+++ b/app/components/modals/pay_invoice/invoice_information/component.html.erb
@@ -2,11 +2,11 @@
- <%= form_with model: invoice, url: invoice_path(invoice.uuid), data: { controller: 'form--debounce', action: 'change->form--debounce#search', form__debounce_target: 'form' } do |f| %>
+ <%= form_with model: @invoice, url: invoice_path(@invoice.uuid), data: { controller: 'form--debounce', action: 'change->form--debounce#search', form__debounce_target: 'form' } do |f| %>
<%= component 'common/form/label', form: f, attribute: :billing_profile_id, title: t('billing_profiles_name') %>
<%= component 'common/form/dropdown_input', form: f, attribute: :billing_profile_id,
- enum: options_for_select(BillingProfile.where(user_id: invoice.user_id).pluck(:name, :id), params[:billing_profile_id].presence || invoice.billing_profile_id),
+ enum: options_for_select(BillingProfile.where(user_id: @invoice.user_id).pluck(:name, :id), params[:billing_profile_id].presence || @invoice.billing_profile_id),
first_options: { include_blank: false } %>
<% end %>
@@ -54,7 +54,7 @@
- <% invoice.items.each_with_index do |item, index| %>
+ <% @invoice.items.each_with_index do |item, index| %>
<%= index + 1 %> |
<%= I18n.t('invoice_items.name',
@@ -67,21 +67,21 @@
|
2 |
- <%= t('invoices.vat_amount') %> <%= number_to_percentage(invoice.vat_rate * 100, precision: 0) %> |
- <%= t('offers.price_in_currency', price: invoice.vat) %> |
+ <%= t('invoices.vat_amount') %> <%= number_to_percentage(@invoice.vat_rate * 100, precision: 0) %> |
+ <%= t('offers.price_in_currency', price: @invoice.vat) %> |
3 |
<%= t('invoices.total') %> |
- <%= t('offers.price_in_currency', price: invoice.total + (invoice.enable_deposit? ? invoice.deposit : 0.0)) %> |
+ <%= t('offers.price_in_currency', price: @invoice.total + (@invoice.enable_deposit? ? @invoice.deposit : 0.0)) %> |
- <% if invoice.enable_deposit? %>
+ <% if @invoice.enable_deposit? %>
4 |
<%= t('invoices.deposit') %> |
- <%= t('offers.price_in_currency', price: invoice.deposit) %> |
+ <%= t('offers.price_in_currency', price: @invoice.deposit) %> |
<% end %>
@@ -89,7 +89,7 @@
<%= t('invoices.show.total_amount') %> |
- <%= t('offers.price_in_currency', price: invoice.total) %> |
+ <%= t('offers.price_in_currency', price: @invoice.total) %> |
diff --git a/app/components/modals/pay_invoice/invoice_information/component.rb b/app/components/modals/pay_invoice/invoice_information/component.rb
new file mode 100644
index 000000000..a80d1d2a0
--- /dev/null
+++ b/app/components/modals/pay_invoice/invoice_information/component.rb
@@ -0,0 +1,15 @@
+module Modals
+ module PayInvoice
+ module InvoiceInformation
+ class Component < ApplicationViewComponent
+ attr_reader :invoice
+
+ def initialize(invoice:)
+ super
+
+ @invoice = invoice
+ end
+ end
+ end
+ end
+end
diff --git a/app/controllers/invoices_controller.rb b/app/controllers/invoices_controller.rb
index 437e64495..340743849 100644
--- a/app/controllers/invoices_controller.rb
+++ b/app/controllers/invoices_controller.rb
@@ -12,8 +12,9 @@ def update
if update_predicate
format.turbo_stream do
render turbo_stream: [
- turbo_stream.update('invoice_information', partial: 'invoices/invoice_information', locals: { invoice: @invoice }),
- turbo_stream.toast(t(:updated), position: "right", background: 'linear-gradient(to right, #11998e, #38ef7d)')
+ turbo_stream.update('invoice_information',
+ Modals::PayInvoice::InvoiceInformation::Component.new(invoice: @invoice)),
+ turbo_stream.toast(t(:updated), position: "right", background: 'linear-gradient(to right, #11998e, #38ef7d)')
]
end