lib/polish_invoicer/validator.rb in polish_invoicer-0.0.24 vs lib/polish_invoicer/validator.rb in polish_invoicer-0.0.25
- old
+ new
@@ -82,10 +82,12 @@
@errors[:price] = 'Cena musi być liczbą'
end
end
def check_price_paid
+ return if @invoice.price_paid.nil?
return if @invoice.price.nil?
+
if @invoice.price_paid.is_a?(Numeric)
@errors[:price_paid] = 'Kwota zapłacona musi być liczbą dodatnią' unless @invoice.price_paid >= 0
@errors[:price_paid] = 'Kwota zapłacona musi być mniejsza lub równa cenie' unless @invoice.price_paid <= @invoice.price
else
@errors[:price_paid] = 'Kwota zapłacona musi być liczbą'