diff --git a/app/helpers/spree/orders_helper.rb b/app/helpers/spree/orders_helper.rb index d3d1a155c1..60786f9609 100644 --- a/app/helpers/spree/orders_helper.rb +++ b/app/helpers/spree/orders_helper.rb @@ -45,5 +45,9 @@ module Spree shop: current_distributor.name, oc_close: l(current_order_cycle.orders_close_at, format: "%A, %b %d, %Y @ %H:%M")) end + + def format_unit_price(unit_price) + "#{Spree::Money.new(unit_price[:amount]).to_html} / #{unit_price[:unit]}" + end end end diff --git a/app/models/invoice/data_presenter/line_item.rb b/app/models/invoice/data_presenter/line_item.rb index 2b55cca925..f69faa7523 100644 --- a/app/models/invoice/data_presenter/line_item.rb +++ b/app/models/invoice/data_presenter/line_item.rb @@ -4,7 +4,7 @@ class Invoice class DataPresenter class LineItem < Invoice::DataPresenter::Base attributes :id, :added_tax, :currency, :included_tax, :price_with_adjustments, :quantity, - :variant_id, :unit_price_price_and_unit, :unit_presentation, + :variant_id, :unit_price, :unit_presentation, :enterprise_fee_additional_tax, :enterprise_fee_included_tax attributes_with_presenter :variant invoice_generation_attributes :added_tax, :included_tax, :price_with_adjustments, diff --git a/app/models/spree/line_item.rb b/app/models/spree/line_item.rb index 2d9444e18d..38dcacc3f9 100644 --- a/app/models/spree/line_item.rb +++ b/app/models/spree/line_item.rb @@ -234,10 +234,13 @@ module Spree final_weight_volume / quantity end - def unit_price_price_and_unit - unit_price = UnitPrice.new(variant) - Spree::Money.new(price_with_adjustments / unit_price.denominator).to_html + - " / ".html_safe + unit_price.unit + def unit_price + unit = UnitPrice.new(variant).unit + amount = price_with_adjustments / UnitPrice.new(variant).denominator + { + amount:, + unit:, + } end def scoper diff --git a/app/serializers/invoice/line_item_serializer.rb b/app/serializers/invoice/line_item_serializer.rb index 50e566850d..5896b06fea 100644 --- a/app/serializers/invoice/line_item_serializer.rb +++ b/app/serializers/invoice/line_item_serializer.rb @@ -3,7 +3,7 @@ class Invoice class LineItemSerializer < ActiveModel::Serializer attributes :id, :added_tax, :currency, :included_tax, :price_with_adjustments, :quantity, - :variant_id, :unit_price_price_and_unit, :unit_presentation, + :variant_id, :unit_price, :unit_presentation, :enterprise_fee_additional_tax, :enterprise_fee_included_tax has_one :variant, serializer: Invoice::VariantSerializer diff --git a/app/views/spree/admin/orders/_invoice/_line_item_name.html.haml b/app/views/spree/admin/orders/_invoice/_line_item_name.html.haml index 37dc28e3a1..04ef1f4c75 100644 --- a/app/views/spree/admin/orders/_invoice/_line_item_name.html.haml +++ b/app/views/spree/admin/orders/_invoice/_line_item_name.html.haml @@ -2,5 +2,6 @@ = line_item.variant.product.name - unless line_item.variant.product.name.include? line_item.name_to_display %span= "- #{line_item.name_to_display}" -- if line_item.unit_price_price_and_unit - = raw("(#{line_item.unit_price_price_and_unit})") +- if line_item.unit_price + = raw("(#{format_unit_price(line_item.unit_price)})") + diff --git a/app/views/spree/orders/_bought.html.haml b/app/views/spree/orders/_bought.html.haml index ed96d2fe00..2e6a69420a 100644 --- a/app/views/spree/orders/_bought.html.haml +++ b/app/views/spree/orders/_bought.html.haml @@ -24,7 +24,7 @@ = line_item.single_display_amount_with_adjustments.to_html %br %span.unit-price - = line_item.unit_price_price_and_unit + = format_unit_price(line_item.unit_price) %td.text-center.cart-item-quantity = line_item.quantity %td.cart-item-total.text-right diff --git a/app/views/spree/orders/_line_item.html.haml b/app/views/spree/orders/_line_item.html.haml index 14aac9d689..7d8011134d 100644 --- a/app/views/spree/orders/_line_item.html.haml +++ b/app/views/spree/orders/_line_item.html.haml @@ -22,7 +22,7 @@ = line_item.single_display_amount_with_adjustments.to_html %br %span.unit-price - = line_item.unit_price_price_and_unit + = format_unit_price(line_item.unit_price) %td.text-center.cart-item-quantity - finalized_quantity = @order.completed? ? line_item.quantity : 0 = item_form.number_field :quantity,