@@ -2,24 +2,24 @@ module Zuora::Objects
2
2
class Amendment < Base
3
3
belongs_to :subscription
4
4
5
- validates_presence_of :subscription_id , :name
6
- validates_length_of :name , :maximum => 100
7
- validates_inclusion_of :auto_renew , :in => [ true , false ] , :allow_nil => true
8
- validates_length_of :code , :maximum => 50 , :allow_nil => true
9
- validates_date_of :contract_effective_date , :allow_nil => true
10
- validates_date_of :customer_acceptance_date , :allow_nil => true
11
- validates_date_of :effective_date , :allow_nil => true
12
- validates_date_of :service_activation_date , :if => Proc . new { |a | a . status == 'PendingAcceptance' }
13
- validates_length_of :description , :maximum => 500 , :allow_nil => true
5
+ validates_presence_of :subscription_id , :name
6
+ validates_length_of :name , :maximum => 100
7
+ validates_inclusion_of :auto_renew , :in => [ true , false ] , :allow_nil => true
8
+ validates_length_of :code , :maximum => 50 , :allow_nil => true
9
+ validates_datetime_of :contract_effective_date , :allow_nil => true
10
+ validates_datetime_of :customer_acceptance_date , :allow_nil => true
11
+ validates_datetime_of :effective_date , :allow_nil => true
12
+ validates_datetime_of :service_activation_date , :if => Proc . new { |a | a . status == 'PendingAcceptance' }
13
+ validates_length_of :description , :maximum => 500 , :allow_nil => true
14
14
validates_numericality_of :initial_term , :if => Proc . new { |a | a . type == 'TermsAndConditions' }
15
15
validates_numericality_of :renewal_term , :if => Proc . new { |a | a . type == 'TermsAndConditions' }
16
- validates_date_of :term_start_date , :if => Proc . new { |a | a . type == 'TermsAndConditions' }
17
- validates_presence_of :destination_account_id , :if => Proc . new { |a | a . type == 'OwnerTransfer' }
18
- validates_presence_of :destination_invoice_owner_id , :if => Proc . new { |a | a . type == 'OwnerTransfer' }
19
- validates_inclusion_of :status , :in => [ "Completed" , "Cancelled" , "Draft" , "Pending Acceptance" , "Pending Activation" ]
20
- validates_inclusion_of :term_type , :in => [ 'TERMED' , 'EVERGREEN' ] , :allow_nil => true
21
- validates_inclusion_of :type , :in => [ 'Cancellation' , 'NewProduct' , 'OwnerTransfer' , 'RemoveProduct' , 'Renewal' , 'UpdateProduct' , 'TermsAndConditions' ]
22
- validates_presence_of :rate_plan_data , :if => Proc . new { |a | [ 'NewProduct' , 'RemoveProduct' , 'UpdateProduct' ] . include? ( a . type ) } , :only => :apply_percentage_discount
16
+ validates_date_of :term_start_date , :if => Proc . new { |a | a . type == 'TermsAndConditions' }
17
+ validates_presence_of :destination_account_id , :if => Proc . new { |a | a . type == 'OwnerTransfer' }
18
+ validates_presence_of :destination_invoice_owner_id , :if => Proc . new { |a | a . type == 'OwnerTransfer' }
19
+ validates_inclusion_of :status , :in => [ "Completed" , "Cancelled" , "Draft" , "Pending Acceptance" , "Pending Activation" ]
20
+ validates_inclusion_of :term_type , :in => [ 'TERMED' , 'EVERGREEN' ] , :allow_nil => true
21
+ validates_inclusion_of :type , :in => [ 'Cancellation' , 'NewProduct' , 'OwnerTransfer' , 'RemoveProduct' , 'Renewal' , 'UpdateProduct' , 'TermsAndConditions' ]
22
+ validates_presence_of :rate_plan_data , :if => Proc . new { |a | [ 'NewProduct' , 'RemoveProduct' , 'UpdateProduct' ] . include? ( a . type ) } , :only => :apply_percentage_discount
23
23
24
24
attr_accessor :amendment_ids
25
25
attr_accessor :invoice_id
@@ -32,10 +32,12 @@ class Amendment < Base
32
32
33
33
def apply_percentage_discount
34
34
self . status = 'Completed'
35
- result = self . connector . amend
35
+ result = self . connector . amend ( { 'process_payments' => false } )
36
36
apply_percentage_discount_response ( result . to_hash , :amend_response )
37
37
end
38
38
39
+ private
40
+
39
41
def apply_percentage_discount_response ( response_hash , type )
40
42
result = response_hash [ type ] [ :results ]
41
43
if result [ :success ]
@@ -46,8 +48,7 @@ def apply_percentage_discount_response(response_hash, type)
46
48
clear_changes_information
47
49
return true
48
50
else
49
- self . errors . add ( :base , result [ :errors ] [ :message ] )
50
- return false
51
+ raise StandardError . new ( result [ :errors ] [ :message ] )
51
52
end
52
53
end
53
54
end
0 commit comments