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
|
||||
|
||||
validates_presence_of :price, :tax, :deposit, :unit_quantity
|
||||
validates_numericality_of :price, :unit_quantity, :greater_than => 0
|
||||
validates_numericality_of :deposit, :tax
|
||||
|
||||
# Custom attribute setter that accepts decimal numbers using localized decimal separator.
|
||||
def price=(price)
|
||||
self[:price] = String.delocalized_decimal(price)
|
||||
end
|
||||
|
||||
# Custom attribute setter that accepts decimal numbers using localized decimal separator.
|
||||
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
|
||||
localize_input_of :price, :tax, :deposit
|
||||
|
||||
# The financial gross, net plus tax and deposit.
|
||||
def gross_price
|
||||
|
|
Loading…
Reference in a new issue