Skip to content

Commit

Permalink
Add line items adjustments (order.price_adjustments) to the order edi…
Browse files Browse the repository at this point in the history
…t 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: spree/spree@636d87d
  • Loading branch information
luisramos0 committed Feb 7, 2019
1 parent d598831 commit 3ed6aea
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
19 changes: 2 additions & 17 deletions app/views/spree/admin/orders/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand Down
14 changes: 14 additions & 0 deletions app/views/spree/admin/orders/_form/_adjustments.html.haml
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 3ed6aea

Please sign in to comment.