mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-02 21:57:17 +00:00
Update DB schema to store updatable weight on items sold
This commit is contained in:
17
app/controllers/spree/api/line_items_controller_decorator.rb
Normal file
17
app/controllers/spree/api/line_items_controller_decorator.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
Spree::Api::LineItemsController.class_eval do
|
||||
after_filter :apply_enterprise_fees, :only => :update
|
||||
|
||||
def apply_enterprise_fees
|
||||
authorize! :read, order
|
||||
order.update_distribution_charge!
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
#when we update a line item the .update_distribution_charge! is called
|
||||
# order.should_receive .update_distribution_charge!
|
||||
# check fails when absent
|
||||
|
||||
# in order model check that .update_distribution_charge! is properly tested.
|
||||
# think through use cases - existing completed order
|
||||
# currently likely just used to complete orders so add test case that works on a completed order
|
||||
5
db/migrate/20150305004846_add_weight_to_line_items.rb
Normal file
5
db/migrate/20150305004846_add_weight_to_line_items.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddWeightToLineItems < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :spree_line_items, :unit_value, :decimal, :precision => 8, :scale => 2
|
||||
end
|
||||
end
|
||||
@@ -549,6 +549,7 @@ ActiveRecord::Schema.define(:version => 20150424025907) do
|
||||
t.string "currency"
|
||||
t.decimal "distribution_fee", :precision => 10, :scale => 2
|
||||
t.string "shipping_method_name"
|
||||
t.decimal "unit_value", :precision => 8, :scale => 2
|
||||
end
|
||||
|
||||
add_index "spree_line_items", ["order_id"], :name => "index_line_items_on_order_id"
|
||||
|
||||
Reference in New Issue
Block a user