Config option for tax rate on shipping

This commit is contained in:
Matt-Yorkley
2014-11-24 03:01:00 +00:00
committed by Rohan Mitchell
parent 371f966f63
commit 623882a2a1
3 changed files with 18 additions and 14 deletions

View File

@@ -1,9 +1,10 @@
Spree::AppConfiguration.class_eval do
# This file decorates the existing preferences file defined by Spree.
# It allows us to add our own global configuration variables, which
# we can allow to be modified in the UI by adding appropriate form
# elements to existing or new configuration pages.
# This file decorates the existing preferences file defined by Spree.
# It allows us to add our own global configuration variables, which
# we can allow to be modified in the UI by adding appropriate form
# elements to existing or new configuration pages.
# Tax Preferences
preference :products_require_tax_category, :boolean, default: false
end
# Tax Preferences
preference :products_require_tax_category, :boolean, default: false
preference :shipping_tax_rate, :decimal, default: 0
end

View File

@@ -0,0 +1,5 @@
/ insert_after "[data-hook='shipment_vat']"
%div.field.align-center{ "data-hook" => "shipping_tax_rate" }
= number_field_tag "preferences[shipping_tax_rate]", Spree::Config[:shipping_tax_rate].to_f, in: 0.0..1.0, step: 0.01
= label_tag nil, t(:shipping_tax_rate)

View File

@@ -30,13 +30,11 @@ module OpenFoodNetwork
shipping_cost = order.adjustments.find_by_label("Shipping").andand.amount
shipping_cost = (shipping_cost == nil) ? 0.0 : shipping_cost
shipping_tax = (Spree::Config[:shipment_inc_vat] && shipping_cost != nil) ? shipping_cost * 0.2 : 0.0
#config option for charging tax on shipping fee or not? exists, need to set rate...
#calculate additional tax for shipping...
#ignore non-shipping adjustments? any potential issues?
#show payment status? other necessary/useful info?
#check which orders are pulled, and which are filtered out... maybe have a dropdown to make it explicit...?
if Spree::Config[:shipment_inc_vat] && shipping_cost != nil
shipping_tax = shipping_cost * Spree::Config[:shipping_tax_rate]
else
shipping_tax = 0.0
end
sales_tax_details << [order.number, order.created_at, totals["items"], totals["items_total"],
totals["taxable_total"], totals["sales_tax"], shipping_cost, shipping_tax, totals["sales_tax"] + shipping_tax,