From 20e439c2a70565bf1898917871084aae72fe3861 Mon Sep 17 00:00:00 2001 From: Benjamin Meichsner Date: Mon, 8 Apr 2013 14:40:02 +0200 Subject: [PATCH] Allow article price equal to zero. Closes #111 --- app/models/article.rb | 3 ++- app/models/article_price.rb | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/models/article.rb b/app/models/article.rb index 80ef567e..097c6cbb 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -18,7 +18,8 @@ class Article < ActiveRecord::Base validates_presence_of :name, :unit, :price, :tax, :deposit, :unit_quantity, :supplier_id, :article_category validates_length_of :name, :in => 4..60 validates_length_of :unit, :in => 2..15 - validates_numericality_of :price, :unit_quantity, :greater_than => 0 + validates_numericality_of :price, :greater_than_or_equal_to => 0 + validates_numericality_of :unit_quantity, :greater_than => 0 validates_numericality_of :deposit, :tax validates_uniqueness_of :name, :scope => [:supplier_id, :deleted_at, :type] diff --git a/app/models/article_price.rb b/app/models/article_price.rb index e946fc92..29e8d507 100644 --- a/app/models/article_price.rb +++ b/app/models/article_price.rb @@ -4,7 +4,8 @@ class ArticlePrice < ActiveRecord::Base has_many :order_articles validates_presence_of :price, :tax, :deposit, :unit_quantity - validates_numericality_of :price, :unit_quantity, :greater_than => 0 + validates_numericality_of :price, :greater_than_or_equal_to => 0 + validates_numericality_of :unit_quantity, :greater_than => 0 validates_numericality_of :deposit, :tax localize_input_of :price, :tax, :deposit