Skip to content

Commit

Permalink
Merge pull request #5916 from mamhoff/move-line-item-actions-to-legac…
Browse files Browse the repository at this point in the history
…y-promotions

Move Line Item Actions to solidus_legacy_promotions
tvdeyen authored Nov 14, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents b1a3796 + d339e84 commit 79b0511
Showing 5 changed files with 17 additions and 13 deletions.
3 changes: 0 additions & 3 deletions core/app/models/spree/line_item.rb
Original file line number Diff line number Diff line change
@@ -19,9 +19,6 @@ class LineItem < Spree::Base
has_many :adjustments, as: :adjustable, inverse_of: :adjustable, dependent: :destroy
has_many :inventory_units, inverse_of: :line_item

has_many :line_item_actions, dependent: :destroy
has_many :actions, through: :line_item_actions

before_validation :normalize_quantity
before_validation :set_required_attributes

10 changes: 0 additions & 10 deletions core/db/migrate/20160101010000_solidus_one_four.rb
Original file line number Diff line number Diff line change
@@ -197,16 +197,6 @@ def up
t.index ["variant_id"], name: "index_inventory_units_on_variant_id"
end

create_table "spree_line_item_actions", force: :cascade do |t|
t.integer "line_item_id", null: false
t.integer "action_id", null: false
t.integer "quantity", default: 0
t.datetime "created_at", precision: 6
t.datetime "updated_at", precision: 6
t.index ["action_id"], name: "index_spree_line_item_actions_on_action_id"
t.index ["line_item_id"], name: "index_spree_line_item_actions_on_line_item_id"
end

create_table "spree_line_items", force: :cascade do |t|
t.integer "variant_id"
t.integer "order_id"
Original file line number Diff line number Diff line change
@@ -2,6 +2,11 @@

module SolidusLegacyPromotions
module SpreeLineItemDecorator
def self.prepended(base)
base.has_many :line_item_actions, dependent: :destroy
base.has_many :actions, through: :line_item_actions
end

def total_before_tax
amount + adjustments.select { |value| !value.tax? && value.eligible? }.sum(&:amount)
end
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -122,5 +122,17 @@ def up
t.index ["starts_at"], name: "index_spree_promotions_on_starts_at"
end
end

unless table_exists?(:spree_line_item_actions)
create_table "spree_line_item_actions", force: :cascade do |t|
t.integer "line_item_id", null: false
t.integer "action_id", null: false
t.integer "quantity", default: 0
t.datetime "created_at", precision: 6
t.datetime "updated_at", precision: 6
t.index ["action_id"], name: "index_spree_line_item_actions_on_action_id"
t.index ["line_item_id"], name: "index_spree_line_item_actions_on_line_item_id"
end
end
end
end

0 comments on commit 79b0511

Please sign in to comment.