Removed acts_as_paranoid. Implemented own version.
This commit is contained in:
parent
8bafb3f4b2
commit
07581b7ecf
25 changed files with 93 additions and 57 deletions
|
|
@ -1,10 +1,9 @@
|
|||
# encoding: utf-8
|
||||
class StockArticle < Article
|
||||
acts_as_paranoid
|
||||
|
||||
|
||||
has_many :stock_changes
|
||||
|
||||
scope :available, :conditions => "quantity > 0"
|
||||
scope :available, -> { undeleted.where'quantity > 0' }
|
||||
|
||||
before_destroy :check_quantity
|
||||
|
||||
|
|
@ -23,6 +22,11 @@ class StockArticle < Article
|
|||
available.collect { |a| a.quantity * a.gross_price }.sum
|
||||
end
|
||||
|
||||
def mark_as_deleted
|
||||
check_quantity
|
||||
super
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def check_quantity
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue