API v1 order_articles endpoints

This commit is contained in:
wvengen 2018-10-13 16:21:37 +02:00 committed by wvengen
parent 127ae83f04
commit ed9192c47f
14 changed files with 323 additions and 4 deletions

View file

@ -9,6 +9,16 @@ class StockArticle < Article
before_destroy :check_quantity
ransack_alias :quantity_available, :quantity # in-line with {StockArticleSerializer}
def self.ransackable_attributes(auth_object = nil)
super(auth_object) - %w(supplier_id) + %w(quantity)
end
def self.ransackable_associations(auth_object = nil)
super(auth_object) - %w(supplier)
end
# Update the quantity of items in stock
def update_quantity!
update_attribute :quantity, stock_changes.collect(&:quantity).sum