foodsoft/app/models/stock_change.rb
Philipp Rothmann fb2b4d8a8a chore: rubocop
chore: fix api test conventions

chore: rubocop -A spec/

chore: more rubocop -A

fix failing test

rubocop fixes

removes helper methods that are in my opinion dead code

more rubocop fixes

rubocop -a --auto-gen-config
2023-06-09 17:35:05 +02:00

18 lines
515 B
Ruby

class StockChange < ApplicationRecord
belongs_to :delivery, optional: true, foreign_key: 'stock_event_id'
belongs_to :order, optional: true
belongs_to :stock_taking, optional: true, foreign_key: 'stock_event_id'
belongs_to :stock_article
validates :stock_article_id, :quantity, presence: true
validates :quantity, numericality: true
after_destroy :update_article_quantity
after_save :update_article_quantity
protected
def update_article_quantity
stock_article.update_quantity!
end
end