From 3ed6aea9abed3de941c3b93823929e0a128f2b59 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Wed, 6 Feb 2019 16:43:29 +0000 Subject: [PATCH] Add line items adjustments (order.price_adjustments) to the order edit page so that user is aware of adjustments included in the price like for example tax rates This change happens in spree v2.2 together with other changes (like adding the, not yet available in v2.0, shipment_adjustments this way). See commit for more details: https://github.com/spree/spree/commit/636d87dd77bb6db35fa053caf769474c60e0898b --- app/views/spree/admin/orders/_form.html.haml | 19 ++----------------- .../admin/orders/_form/_adjustments.html.haml | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 17 deletions(-) create mode 100644 app/views/spree/admin/orders/_form/_adjustments.html.haml diff --git a/app/views/spree/admin/orders/_form.html.haml b/app/views/spree/admin/orders/_form.html.haml index cc846d50f68..1b3c17a72f6 100644 --- a/app/views/spree/admin/orders/_form.html.haml +++ b/app/views/spree/admin/orders/_form.html.haml @@ -4,23 +4,8 @@ = render :partial => "spree/admin/orders/shipment", :collection => @order.shipments, :locals => { :order => order } - - if order.adjustments.eligible.exists? - %fieldset.no-border-bottom - %legend= Spree.t('adjustments') - %table - %thead - %th= Spree.t('name') - %th= Spree.t('amount') - %tbody#order-charges.with-border{"data-hook" => "order_details_adjustments"} - - order.adjustments.eligible.each do |adjustment| - - next if ((adjustment.originator_type == 'Spree::TaxRate') and (adjustment.amount == 0)) || adjustment.originator_type == 'Spree::ShippingMethod' - %tr.total - %td - %strong - = adjustment.label - \: - %td.total.align-center - %span= adjustment.display_amount + = render :partial => "spree/admin/orders/_form/adjustments", :locals => { :adjustments => @order.price_adjustments, :order => order, :title => Spree.t(:line_item_adjustments)} + = render :partial => "spree/admin/orders/_form/adjustments", :locals => { :adjustments => @order.adjustments, :order => order, :title => Spree.t(:order_adjustments)} - if order.line_items.exists? %fieldset#order-total.no-border-bottom{"data-hook" => "order_details_total"} diff --git a/app/views/spree/admin/orders/_form/_adjustments.html.haml b/app/views/spree/admin/orders/_form/_adjustments.html.haml new file mode 100644 index 00000000000..27cb0af79e3 --- /dev/null +++ b/app/views/spree/admin/orders/_form/_adjustments.html.haml @@ -0,0 +1,14 @@ +- if adjustments.present? + %fieldset.no-border-bottom + %legend= title + %table> + %thead + %th= Spree.t('name') + %th= Spree.t('amount') + %tbody#order-charges.with-border + - adjustments.each do |adjustment| + - if (adjustment.originator_type != 'Spree::ShippingMethod') && !(adjustment.originator_type == 'Spree::TaxRate' && adjustment.amount == 0) + %tr.total + %td.strong= adjustment.label + ":" + %td.total.align-center + %span= Spree::Money.new(adjustment.amount)