Add form field to set tax when creating adjustment on order. Display tax included in adjustments on order interface.

This commit is contained in:
Rohan Mitchell
2015-11-04 10:44:33 +11:00
parent 6476ce6ba9
commit d794981ecf
6 changed files with 45 additions and 0 deletions

View File

@@ -24,6 +24,10 @@ module Spree
update_attributes! included_tax: tax.round(2)
end
def display_included_tax
Spree::Money.new(included_tax, { :currency => currency })
end
def has_tax?
included_tax > 0
end

View File

@@ -0,0 +1,9 @@
/ replace_contents "[data-hook='adjustment_row']"
%td.align-center.created_at= pretty_time(adjustment.created_at)
%td.align-center.label= adjustment.label
%td.align-center.amount= adjustment.display_amount.to_html
%td.align-center.included-tax= adjustment.display_included_tax.to_html
%td.actions
= link_to_edit adjustment, no_text: true
= link_to_delete adjustment, no_text: true

View File

@@ -0,0 +1,8 @@
/ replace_contents "[data-hook='adjustmment_head']"
%tr
%th= "#{t('spree.date')}/#{t('spree.time')}"
%th= t(:description)
%th= t(:amount)
%th= t(:included_tax)
%th.actions

View File

@@ -0,0 +1,6 @@
/ replace_contents "[data-hook='admin_adjustment_form_fields']"
- if @adjustment.new_record?
= render 'new_form', f: f
- else
= render 'edit_form', f: f

View File

@@ -0,0 +1,17 @@
.row
.alpha.three.columns
= f.field_container :amount do
= f.label :amount, raw(t(:amount) + content_tag(:span, " *", :class => "required"))
= text_field :adjustment, :amount, :class => 'fullwidth'
= f.error_message_on :amount
.omega.three.columns
= f.field_container :tax_rate_id do
= f.label :tax_rate_id, t(:tax)
= select_tag :tax_rate_id, options_from_collection_for_select(Spree::TaxRate.all, :id, :name), prompt: t(:none), class: 'fullwidth'
= f.error_message_on :tax_rate_id
.row
.alpha.omega.twelve.columns
= f.field_container :label do
= f.label :label, raw(t(:description) + content_tag(:span, " *", :class => "required"))
= text_field :adjustment, :label, :class => 'fullwidth'
= f.error_message_on :label

View File

@@ -38,3 +38,4 @@ en:
footer_about_url: "About URL"
footer_tos_url: "Terms of Service URL"
invoice: "Invoice"
included_tax: "Included tax"