From a44f24ad438a14280735a1f0039f79a72a06ec98 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Tue, 9 May 2023 13:29:44 +0100 Subject: [PATCH] Remove prefixes from invoice data representation so it conforms to the same interface as order --- app/models/invoice/data_presenter.rb | 6 +++--- .../spree/admin/orders/_invoice/_order_note.html.haml | 2 +- app/views/spree/admin/orders/invoice3.html.haml | 8 ++++---- app/views/spree/admin/orders/invoice4.html.haml | 8 ++++---- spec/services/invoice_data_generator_spec.rb | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/models/invoice/data_presenter.rb b/app/models/invoice/data_presenter.rb index 4d0118a4d3..beccdd9549 100644 --- a/app/models/invoice/data_presenter.rb +++ b/app/models/invoice/data_presenter.rb @@ -11,8 +11,8 @@ class Invoice extend Invoice::DataPresenterAttributes attributes :additional_tax_total, :currency, :included_tax_total, :payment_total, - :shipping_method_id, :state, :total - attributes :number, :note, :special_instructions, prefix: :order + :shipping_method_id, :state, :total, :number, :note, :special_instructions + attributes_with_presenter :bill_address, :customer, :distributor, :ship_address, :shipping_method, :order_cycle @@ -26,7 +26,7 @@ class Invoice :shipping_method_id, :sorted_line_items, :total # if any of the following attributes is updated, the latest invoice should be updated - invoice_update_attributes :order_note, :order_special_instructions, :state, + invoice_update_attributes :note, :special_instructions, :state, :all_eligible_adjustments, :payments def initialize(invoice) diff --git a/app/views/spree/admin/orders/_invoice/_order_note.html.haml b/app/views/spree/admin/orders/_invoice/_order_note.html.haml index f6a478faf3..f1a5b3a6cc 100644 --- a/app/views/spree/admin/orders/_invoice/_order_note.html.haml +++ b/app/views/spree/admin/orders/_invoice/_order_note.html.haml @@ -1,4 +1,4 @@ %p.callout{style: "margin-top: 30px"} %strong= t :additional_information %p{style: "margin: 5px"} - = @invoice_presenter.order_note \ No newline at end of file + = @invoice_presenter.note \ No newline at end of file diff --git a/app/views/spree/admin/orders/invoice3.html.haml b/app/views/spree/admin/orders/invoice3.html.haml index 461cc422ad..0397e769c0 100644 --- a/app/views/spree/admin/orders/invoice3.html.haml +++ b/app/views/spree/admin/orders/invoice3.html.haml @@ -11,7 +11,7 @@ %td{ :align => "left" } %h4 = "#{t('spree.admin.orders.invoice.tax_invoice')}: " - = "#{@invoice_presenter.order_number}" + = "#{@invoice_presenter.number}" %td{width: "10%" }   %td{ :align => "right" } @@ -63,11 +63,11 @@ = @invoice_presenter.ship_address.full_address %br = @invoice_presenter.ship_address.phone - - if @invoice_presenter.order_special_instructions.present? + - if @invoice_presenter.special_instructions.present? %br %br %strong= t :customer_instructions - = @invoice_presenter.order_special_instructions + = @invoice_presenter.special_instructions = render 'spree/admin/orders/invoice_table3' @@ -78,5 +78,5 @@ = render 'spree/admin/orders/_invoice/payment' -- if @invoice_presenter.order_note.present? +- if @invoice_presenter.note.present? = render partial: 'spree/admin/orders/_invoice/order_note' diff --git a/app/views/spree/admin/orders/invoice4.html.haml b/app/views/spree/admin/orders/invoice4.html.haml index 47f689c1c6..00859bac64 100644 --- a/app/views/spree/admin/orders/invoice4.html.haml +++ b/app/views/spree/admin/orders/invoice4.html.haml @@ -51,7 +51,7 @@ = l @invoice_presenter.order_completed_at.to_date %br = t :order_number - = @invoice_presenter.order_number + = @invoice_presenter.number %td{ :align => "right" } = t :invoice_billing_address %br @@ -75,12 +75,12 @@ = render 'spree/admin/orders/invoice_table4' -- if @invoice_presenter.order_special_instructions.present? +- if @invoice_presenter.special_instructions.present? %p.callout %strong = t :customer_instructions %p - %em= @invoice_presenter.order_special_instructions + %em= @invoice_presenter.special_instructions %p   @@ -90,5 +90,5 @@ = render 'spree/admin/orders/_invoice/payment' -- if @invoice_presenter.order_note.present? +- if @invoice_presenter.note.present? = render partial: 'spree/admin/orders/_invoice/order_note' diff --git a/spec/services/invoice_data_generator_spec.rb b/spec/services/invoice_data_generator_spec.rb index bedbcb7c93..cc014cc312 100644 --- a/spec/services/invoice_data_generator_spec.rb +++ b/spec/services/invoice_data_generator_spec.rb @@ -22,7 +22,7 @@ describe InvoiceDataGenerator do new_note = "This is an updated note" order.update!(note: new_note) - expect(new_invoice_presenter.order_note).to eq(new_note) + expect(new_invoice_presenter.note).to eq(new_note) end end