diff --git a/lib/xero-ruby/models/accounting/contact.rb b/lib/xero-ruby/models/accounting/contact.rb index 9544b2d30..f0acbc4fa 100644 --- a/lib/xero-ruby/models/accounting/contact.rb +++ b/lib/xero-ruby/models/accounting/contact.rb @@ -64,6 +64,12 @@ class Contact EIN ||= "EIN".freeze ITIN ||= "ITIN".freeze ATIN ||= "ATIN".freeze + NONE ||= "NONE".freeze + TAXNUMBERTYPE_SSN ||= "TAXNUMBERTYPE/SSN".freeze + TAXNUMBERTYPE_EIN ||= "TAXNUMBERTYPE/EIN".freeze + TAXNUMBERTYPE_ITIN ||= "TAXNUMBERTYPE/ITIN".freeze + TAXNUMBERTYPE_ATIN ||= "TAXNUMBERTYPE/ATIN".freeze + TAXNUMBERTYPE_NONE ||= "TAXNUMBERTYPE/NONE".freeze # The tax type from TaxRates attr_accessor :accounts_receivable_tax_type @@ -538,7 +544,10 @@ def valid? return false if !@company_number.nil? && @company_number.to_s.length > 50 return false if !@email_address.nil? && @email_address.to_s.length > 255 return false if !@tax_number.nil? && @tax_number.to_s.length > 50 - tax_number_type_validator = EnumAttributeValidator.new('String', ["SSN", "EIN", "ITIN", "ATIN"]) + tax_number_type_validator = EnumAttributeValidator.new( + 'String', + ["SSN", "EIN", "ITIN", "ATIN", "NONE", "TAXNUMBERTYPE/SSN", "TAXNUMBERTYPE/EIN", "TAXNUMBERTYPE/ITIN", "TAXNUMBERTYPE/ATIN", "TAXNUMBERTYPE/NONE"] + ) return false unless tax_number_type_validator.valid?(@tax_number_type) sales_default_line_amount_type_validator = EnumAttributeValidator.new('String', ["INCLUSIVE", "EXCLUSIVE", "NONE"]) return false unless sales_default_line_amount_type_validator.valid?(@sales_default_line_amount_type) @@ -640,7 +649,10 @@ def tax_number=(tax_number) # Custom attribute writer method checking allowed values (enum). # @param [Object] tax_number_type Object to be assigned def tax_number_type=(tax_number_type) - validator = EnumAttributeValidator.new('String', ["SSN", "EIN", "ITIN", "ATIN"]) + validator = EnumAttributeValidator.new( + 'String', + ["SSN", "EIN", "ITIN", "ATIN", "NONE", "TAXNUMBERTYPE/SSN", "TAXNUMBERTYPE/EIN", "TAXNUMBERTYPE/ITIN", "TAXNUMBERTYPE/ATIN", "TAXNUMBERTYPE/NONE"] + ) unless validator.valid?(tax_number_type) fail ArgumentError, "invalid value for \"tax_number_type\", must be one of #{validator.allowable_values}." end diff --git a/spec/accounting/models/contact_spec.rb b/spec/accounting/models/contact_spec.rb index 8c81d2e42..a1275e3df 100644 --- a/spec/accounting/models/contact_spec.rb +++ b/spec/accounting/models/contact_spec.rb @@ -108,6 +108,24 @@ end end + describe 'test attribute "tax_number_type"' do + it 'accepts unprefixed tax number types' do + ["SSN", "EIN", "ITIN", "ATIN", "NONE"].each do |value| + expect { @instance.tax_number_type = value }.not_to raise_error + end + end + + it 'accepts tax number types returned by the API' do + ["TAXNUMBERTYPE/SSN", "TAXNUMBERTYPE/EIN", "TAXNUMBERTYPE/ITIN", "TAXNUMBERTYPE/ATIN", "TAXNUMBERTYPE/NONE"].each do |value| + expect { @instance.tax_number_type = value }.not_to raise_error + end + end + + it 'rejects unsupported tax number types' do + expect { @instance.tax_number_type = "INVALID" }.to raise_error(ArgumentError) + end + end + describe 'test attribute "accounts_receivable_tax_type"' do it 'should work' do # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers