Make StockEvent a base class for Delivery and StockTaking
This helps to share code between the two entities and allows easier extensions in the future.
This commit is contained in:
parent
a5582e9542
commit
785313ac23
9 changed files with 69 additions and 33 deletions
|
|
@ -1,12 +1,11 @@
|
|||
class Delivery < ApplicationRecord
|
||||
class Delivery < StockEvent
|
||||
|
||||
belongs_to :supplier
|
||||
belongs_to :invoice
|
||||
has_many :stock_changes, -> { includes(:stock_article).order('articles.name ASC') }, :dependent => :destroy
|
||||
|
||||
scope :recent, -> { order('created_at DESC').limit(10) }
|
||||
|
||||
validates_presence_of :supplier_id, :date
|
||||
validates_presence_of :supplier_id
|
||||
validate :stock_articles_must_be_unique
|
||||
|
||||
accepts_nested_attributes_for :stock_changes, :allow_destroy => :true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue