From a2595f187013a0ee04b1c73eae044271bd6d078a Mon Sep 17 00:00:00 2001 From: Bartosz Blimke Date: Wed, 18 Jul 2012 22:56:05 +0200 Subject: [PATCH] Validate account attributes only for new record. Existing account requires only id for subscribe call. --- lib/zuora/objects/account.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/zuora/objects/account.rb b/lib/zuora/objects/account.rb index 2f5ff6f..ecd8af8 100644 --- a/lib/zuora/objects/account.rb +++ b/lib/zuora/objects/account.rb @@ -7,13 +7,13 @@ class Account < Base belongs_to :bill_to, :class_name => 'Contact' belongs_to :sold_to, :class_name => 'Contact' - validates_presence_of :account_number, :name, :status, :payment_term, :batch, :currency - validates_length_of :name, :maximum => 50 + validates_presence_of :account_number, :name, :status, :payment_term, :batch, :currency, :if => :new_record? + validates_length_of :name, :maximum => 50, :if => :new_record? validates_length_of :purchase_order_number, :maximum => 100, :allow_nil => true - validates_inclusion_of :payment_term, :in => ['Due Upon Receipt','Net 30','Net 45','Net 90'] - validates_inclusion_of :batch, :in => (1..20).map{|n| "Batch#{n}" } + validates_inclusion_of :payment_term, :in => ['Due Upon Receipt','Net 30','Net 45','Net 90'], :if => :new_record? + validates_inclusion_of :batch, :in => (1..20).map{|n| "Batch#{n}" }, :if => :new_record? validates_inclusion_of :bcd_setting_option, :in => ['AutoSet','ManualSet'], :allow_nil => true - validates_inclusion_of :bill_cycle_day, :in => (0..30).to_a + (0..30).map(&:to_s) + validates_inclusion_of :bill_cycle_day, :in => (0..30).to_a + (0..30).map(&:to_s), :if => :new_record? validates_inclusion_of :status, :in => ['Draft','Active','Canceled'], :allow_nil => true define_attributes do