Class: Quickbooks::Model::Account

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/quickbooks/model/account.rb

Constant Summary collapse

XML_COLLECTION_NODE =
"Account"
XML_NODE =
"Account"
REST_RESOURCE =
'account'
ASSET =
'Asset'
EQUITY =
'Equity'
EXPENSE =
'Expense'
LIABILITY =
'Liability'
REVENUE =
'Revenue'
ACCOUNT_CLASSIFICATION =
[ASSET, EQUITY, EXPENSE, LIABILITY, REVENUE]

Instance Method Summary collapse

Methods inherited from BaseModel

reference_setters, resource_for_collection, resource_for_singular, #to_xml_inject_ns, #to_xml_ns

Instance Method Details

#active? ⇒ Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/quickbooks/model/account.rb', line 82

def active?
  active.to_s == 'true'
end

#has_attachment? ⇒ Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/quickbooks/model/account.rb', line 74

def has_attachment?
  has_attachment.to_s == 'true'
end

#name_cannot_contain_invalid_characters ⇒ Object



51
52
53
54
55
# File 'lib/quickbooks/model/account.rb', line 51

def name_cannot_contain_invalid_characters
  if name && (name.index(':') || name.index('"'))
    errors.add('name', ":#{name} cannot contain a colon (:) or double quotes (\").")
  end
end

#sub_account? ⇒ Boolean

Returns:

  • (Boolean)


78
79
80
# File 'lib/quickbooks/model/account.rb', line 78

def sub_account?
  .to_s == 'true'
end

#tax_account? ⇒ Boolean

Returns:

  • (Boolean)


86
87
88
# File 'lib/quickbooks/model/account.rb', line 86

def tax_account?
  .to_s == 'true'
end

#valid_for_create? ⇒ Boolean

Returns:

  • (Boolean)


64
65
66
67
# File 'lib/quickbooks/model/account.rb', line 64

def valid_for_create?
  valid?
  errors.empty?
end

#valid_for_deletion? ⇒ Boolean

Returns:

  • (Boolean)


69
70
71
72
# File 'lib/quickbooks/model/account.rb', line 69

def valid_for_deletion?
  return false if(id.nil? || sync_token.nil?)
  id.to_i > 0 && !sync_token.to_s.empty? && sync_token.to_i >= 0
end

#valid_for_update? ⇒ Boolean

Returns:

  • (Boolean)


57
58
59
60
61
62
# File 'lib/quickbooks/model/account.rb', line 57

def valid_for_update?
  if sync_token.nil?
    errors.add(:sync_token, "Missing required attribute SyncToken for update")
  end
  errors.empty?
end