mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-12 18:36:49 +00:00
Compare commits
3 Commits
RachL-patc
...
v3.5.14
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2e8ebacce3 | ||
|
|
6f35e4e662 | ||
|
|
2341494555 |
@@ -2,16 +2,18 @@ module Spree
|
||||
module Admin
|
||||
class AdjustmentsController < ::Admin::ResourceController
|
||||
belongs_to 'spree/order', find_by: :number
|
||||
destroy.after :reload_order
|
||||
|
||||
prepend_before_action :set_included_tax, only: [:create, :update]
|
||||
before_action :set_order_id, only: [:create, :update]
|
||||
after_action :update_order, only: [:create, :update, :destroy]
|
||||
before_action :set_default_tax_rate, only: :edit
|
||||
before_action :enable_updates, only: :update
|
||||
|
||||
private
|
||||
|
||||
def reload_order
|
||||
def update_order
|
||||
@order.reload
|
||||
@order.update!
|
||||
end
|
||||
|
||||
def collection
|
||||
@@ -22,6 +24,10 @@ module Spree
|
||||
parent.all_adjustments.eligible.find(params[:id])
|
||||
end
|
||||
|
||||
def set_order_id
|
||||
@adjustment.order_id = parent.id
|
||||
end
|
||||
|
||||
# Choose a default tax rate to show on the edit form. The adjustment stores its included
|
||||
# tax in dollars, but doesn't store the source of the tax (ie. TaxRate that generated it).
|
||||
# We guess which tax rate here, choosing:
|
||||
|
||||
5
db/migrate/20210312095840_add_index_to_adjustments.rb
Normal file
5
db/migrate/20210312095840_add_index_to_adjustments.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddIndexToAdjustments < ActiveRecord::Migration
|
||||
def change
|
||||
add_index :spree_adjustments, :order_id
|
||||
end
|
||||
end
|
||||
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20210216203057) do
|
||||
ActiveRecord::Schema.define(version: 20210312095840) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
@@ -399,6 +399,7 @@ ActiveRecord::Schema.define(version: 20210216203057) do
|
||||
end
|
||||
|
||||
add_index "spree_adjustments", ["adjustable_id"], name: "index_adjustments_on_order_id", using: :btree
|
||||
add_index "spree_adjustments", ["order_id"], name: "index_spree_adjustments_on_order_id", using: :btree
|
||||
|
||||
create_table "spree_assets", force: :cascade do |t|
|
||||
t.integer "viewable_id"
|
||||
|
||||
@@ -21,6 +21,9 @@ module Spree
|
||||
expect(a.label).to eq('Testing included tax')
|
||||
expect(a.amount).to eq(110)
|
||||
expect(a.included_tax).to eq(0)
|
||||
expect(a.order_id).to eq(order.id)
|
||||
|
||||
expect(order.reload.total).to eq 110
|
||||
end
|
||||
|
||||
it "calculates included tax when a tax rate is provided" do
|
||||
@@ -31,6 +34,9 @@ module Spree
|
||||
expect(a.label).to eq('Testing included tax')
|
||||
expect(a.amount).to eq(110)
|
||||
expect(a.included_tax).to eq(10)
|
||||
expect(a.order_id).to eq(order.id)
|
||||
|
||||
expect(order.reload.total).to eq 110
|
||||
end
|
||||
end
|
||||
|
||||
@@ -47,6 +53,9 @@ module Spree
|
||||
expect(a.label).to eq('Testing included tax')
|
||||
expect(a.amount).to eq(110)
|
||||
expect(a.included_tax).to eq(0)
|
||||
expect(a.order_id).to eq(order.id)
|
||||
|
||||
expect(order.reload.total).to eq 110
|
||||
end
|
||||
|
||||
it "calculates included tax when a tax rate is provided" do
|
||||
@@ -57,6 +66,9 @@ module Spree
|
||||
expect(a.label).to eq('Testing included tax')
|
||||
expect(a.amount).to eq(110)
|
||||
expect(a.included_tax).to eq(10)
|
||||
expect(a.order_id).to eq(order.id)
|
||||
|
||||
expect(order.reload.total).to eq 110
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user