Skip to content

Commit

Permalink
Better alias for #71
Browse files Browse the repository at this point in the history
  • Loading branch information
lentschi committed Oct 11, 2024
1 parent 30fa5a1 commit aecfa9b
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions app/models/order_article.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ class OrderArticle < ApplicationRecord
scope :belonging_to_open_order, -> { joins(:order).merge(Order.open) }
scope :belonging_to_finished_order, -> { joins(:order).merge(Order.finished) }

# alias for old code which is hard to automatically replace (.price could also refer to ArticleVersion.price)
alias price article_version

before_create :init_from_balancing
after_destroy :update_ordergroup_prices

Expand All @@ -31,12 +34,6 @@ def self.ransackable_associations(_auth_object = nil)
%w[order article]
end

# This method returns either the ArticleVersion or the Article
# The first will be set, when the the order is finished
def price
article_version || article
end

# latest information on available units
def units
return units_received unless units_received.nil?
Expand Down

0 comments on commit aecfa9b

Please sign in to comment.