Added validation for article_price. Avoid unit_quantity of 0.
This commit is contained in:
parent
bae09624b7
commit
d9681eaf30
1 changed files with 3 additions and 14 deletions
|
@ -4,21 +4,10 @@ class ArticlePrice < ActiveRecord::Base
|
||||||
has_many :order_articles
|
has_many :order_articles
|
||||||
|
|
||||||
validates_presence_of :price, :tax, :deposit, :unit_quantity
|
validates_presence_of :price, :tax, :deposit, :unit_quantity
|
||||||
|
validates_numericality_of :price, :unit_quantity, :greater_than => 0
|
||||||
# Custom attribute setter that accepts decimal numbers using localized decimal separator.
|
validates_numericality_of :deposit, :tax
|
||||||
def price=(price)
|
|
||||||
self[:price] = String.delocalized_decimal(price)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Custom attribute setter that accepts decimal numbers using localized decimal separator.
|
localize_input_of :price, :tax, :deposit
|
||||||
def tax=(tax)
|
|
||||||
self[:tax] = String.delocalized_decimal(tax)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Custom attribute setter that accepts decimal numbers using localized decimal separator.
|
|
||||||
def deposit=(deposit)
|
|
||||||
self[:deposit] = String.delocalized_decimal(deposit)
|
|
||||||
end
|
|
||||||
|
|
||||||
# The financial gross, net plus tax and deposit.
|
# The financial gross, net plus tax and deposit.
|
||||||
def gross_price
|
def gross_price
|
||||||
|
|
Loading…
Reference in a new issue