update prices fails if list price is smaller than input price

This commit is contained in:
Senad Uka
2015-10-06 12:03:22 +02:00
parent 2c19f97971
commit 205c8352a1

View File

@@ -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