update prices fails if list price is smaller than input price
This commit is contained in:
@@ -15,6 +15,7 @@ class Item < ActiveRecord::Base
|
||||
|
||||
|
||||
validates_presence_of :name, :description, :list_price, :current_input_price, :tags, :unit_id, :code, :sub_category_id, :weight, :supplier_id
|
||||
validate :we_must_earn_money
|
||||
|
||||
def self.items_to_order
|
||||
items_raw = Item.find_by_sql(%Q{
|
||||
@@ -124,5 +125,11 @@ class Item < ActiveRecord::Base
|
||||
puts nonexistent_codes.join("\n")
|
||||
end
|
||||
|
||||
def we_must_earn_money
|
||||
if list_price.to_f <= current_input_price.to_f
|
||||
errors[:list_price] << "#{code} Ulazna cijena veca od izlazne"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user