Improve delivery workflow; introduce sortable tables; use js.erb for deliveries
This commit is contained in:
parent
49cfa9aded
commit
65f61e09d5
18 changed files with 357 additions and 105 deletions
|
|
@ -2,7 +2,10 @@ class Delivery < ActiveRecord::Base
|
|||
|
||||
belongs_to :supplier
|
||||
has_one :invoice
|
||||
has_many :stock_changes, :dependent => :destroy
|
||||
has_many :stock_changes,
|
||||
:dependent => :destroy,
|
||||
:include => 'stock_article',
|
||||
:order => 'articles.name COLLATE NOCASE ASC'
|
||||
|
||||
scope :recent, :order => 'created_at DESC', :limit => 10
|
||||
|
||||
|
|
@ -15,6 +18,10 @@ class Delivery < ActiveRecord::Base
|
|||
stock_changes.build(attributes) unless attributes[:quantity].to_i == 0
|
||||
end
|
||||
end
|
||||
|
||||
def includes_article?(article)
|
||||
self.stock_changes.map{|stock_change| stock_change.stock_article.id}.include? article.id
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue