Class: ModernTreasury::LedgerAccountStatement

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/modern_treasury/models/ledger_account_statement.rb

Overview

LedgerAccountStatement Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(id:, object:, live_mode:, created_at:, updated_at:, ledger_id:, description:, ledger_account_id:, ledger_account_lock_version:, ledger_account_normal_balance:, effective_at_lower_bound:, effective_at_upper_bound:, starting_balance:, ending_balance:, metadata:) ⇒ LedgerAccountStatement

Returns a new instance of LedgerAccountStatement.



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/modern_treasury/models/ledger_account_statement.rb', line 116

def initialize(id:, object:, live_mode:, created_at:, updated_at:,
               ledger_id:, description:, ledger_account_id:,
               ledger_account_lock_version:, ledger_account_normal_balance:,
               effective_at_lower_bound:, effective_at_upper_bound:,
               starting_balance:, ending_balance:, metadata:)
  @id = id
  @object = object
  @live_mode = live_mode
  @created_at = created_at
  @updated_at = updated_at
  @ledger_id = ledger_id
  @description = description
  @ledger_account_id = 
  @ledger_account_lock_version = 
  @ledger_account_normal_balance = 
  @effective_at_lower_bound = effective_at_lower_bound
  @effective_at_upper_bound = effective_at_upper_bound
  @starting_balance = starting_balance
  @ending_balance = ending_balance
  @metadata = 
end

Instance Attribute Details

#created_atDateTime

This field will be true if this object exists in the live environment or false if it exists in the test environment.

Returns:

  • (DateTime)


29
30
31
# File 'lib/modern_treasury/models/ledger_account_statement.rb', line 29

def created_at
  @created_at
end

#descriptionString

The description of the ledger account statement.

Returns:

  • (String)


42
43
44
# File 'lib/modern_treasury/models/ledger_account_statement.rb', line 42

def description
  @description
end

#effective_at_lower_boundDateTime

The inclusive lower bound of the effective_at timestamp of the ledger entries to be included in the ledger account statement.

Returns:

  • (DateTime)


60
61
62
# File 'lib/modern_treasury/models/ledger_account_statement.rb', line 60

def effective_at_lower_bound
  @effective_at_lower_bound
end

#effective_at_upper_boundDateTime

The exclusive upper bound of the effective_at timestamp of the ledger entries to be included in the ledger account statement.

Returns:

  • (DateTime)


65
66
67
# File 'lib/modern_treasury/models/ledger_account_statement.rb', line 65

def effective_at_upper_bound
  @effective_at_upper_bound
end

#ending_balanceLedgerBalances

The exclusive upper bound of the effective_at timestamp of the ledger entries to be included in the ledger account statement.

Returns:



75
76
77
# File 'lib/modern_treasury/models/ledger_account_statement.rb', line 75

def ending_balance
  @ending_balance
end

#idUUID | String

TODO: Write general description for this method

Returns:

  • (UUID | String)


15
16
17
# File 'lib/modern_treasury/models/ledger_account_statement.rb', line 15

def id
  @id
end

#ledger_account_idUUID | String

The id of the ledger account whose ledger entries are queried against, and its balances are computed as a result.

Returns:

  • (UUID | String)


47
48
49
# File 'lib/modern_treasury/models/ledger_account_statement.rb', line 47

def 
  @ledger_account_id
end

#ledger_account_lock_versionInteger

Lock version of the ledger account at the time of statement generation.

Returns:

  • (Integer)


51
52
53
# File 'lib/modern_treasury/models/ledger_account_statement.rb', line 51

def 
  @ledger_account_lock_version
end

#ledger_account_normal_balanceLedgerAccountNormalBalance

The normal balance of the ledger account.



55
56
57
# File 'lib/modern_treasury/models/ledger_account_statement.rb', line 55

def 
  @ledger_account_normal_balance
end

#ledger_idUUID | String

The id of the ledger that this ledger account statement belongs to.

Returns:

  • (UUID | String)


38
39
40
# File 'lib/modern_treasury/models/ledger_account_statement.rb', line 38

def ledger_id
  @ledger_id
end

#live_modeTrueClass | FalseClass

This field will be true if this object exists in the live environment or false if it exists in the test environment.

Returns:

  • (TrueClass | FalseClass)


24
25
26
# File 'lib/modern_treasury/models/ledger_account_statement.rb', line 24

def live_mode
  @live_mode
end

#metadataHash[String, String]

Additional data represented as key-value pairs. Both the key and value must be strings.

Returns:

  • (Hash[String, String])


80
81
82
# File 'lib/modern_treasury/models/ledger_account_statement.rb', line 80

def 
  @metadata
end

#objectString

TODO: Write general description for this method

Returns:

  • (String)


19
20
21
# File 'lib/modern_treasury/models/ledger_account_statement.rb', line 19

def object
  @object
end

#starting_balanceLedgerBalances

The exclusive upper bound of the effective_at timestamp of the ledger entries to be included in the ledger account statement.

Returns:



70
71
72
# File 'lib/modern_treasury/models/ledger_account_statement.rb', line 70

def starting_balance
  @starting_balance
end

#updated_atDateTime

This field will be true if this object exists in the live environment or false if it exists in the test environment.

Returns:

  • (DateTime)


34
35
36
# File 'lib/modern_treasury/models/ledger_account_statement.rb', line 34

def updated_at
  @updated_at
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/modern_treasury/models/ledger_account_statement.rb', line 139

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : nil
  object = hash.key?('object') ? hash['object'] : nil
  live_mode = hash.key?('live_mode') ? hash['live_mode'] : nil
  created_at = if hash.key?('created_at')
                 (DateTimeHelper.from_rfc3339(hash['created_at']) if hash['created_at'])
               end
  updated_at = if hash.key?('updated_at')
                 (DateTimeHelper.from_rfc3339(hash['updated_at']) if hash['updated_at'])
               end
  ledger_id = hash.key?('ledger_id') ? hash['ledger_id'] : nil
  description = hash.key?('description') ? hash['description'] : nil
   =
    hash.key?('ledger_account_id') ? hash['ledger_account_id'] : nil
   =
    hash.key?('ledger_account_lock_version') ? hash['ledger_account_lock_version'] : nil
   =
    hash.key?('ledger_account_normal_balance') ? hash['ledger_account_normal_balance'] : nil
  effective_at_lower_bound = if hash.key?('effective_at_lower_bound')
                               (DateTimeHelper.from_rfc3339(hash['effective_at_lower_bound']) if hash['effective_at_lower_bound'])
                             end
  effective_at_upper_bound = if hash.key?('effective_at_upper_bound')
                               (DateTimeHelper.from_rfc3339(hash['effective_at_upper_bound']) if hash['effective_at_upper_bound'])
                             end
  starting_balance = LedgerBalances.from_hash(hash['starting_balance']) if
    hash['starting_balance']
  ending_balance = LedgerBalances.from_hash(hash['ending_balance']) if hash['ending_balance']
   = hash.key?('metadata') ? hash['metadata'] : nil

  # Create object from extracted values.
  LedgerAccountStatement.new(id: id,
                             object: object,
                             live_mode: live_mode,
                             created_at: created_at,
                             updated_at: updated_at,
                             ledger_id: ledger_id,
                             description: description,
                             ledger_account_id: ,
                             ledger_account_lock_version: ,
                             ledger_account_normal_balance: ,
                             effective_at_lower_bound: effective_at_lower_bound,
                             effective_at_upper_bound: effective_at_upper_bound,
                             starting_balance: starting_balance,
                             ending_balance: ending_balance,
                             metadata: )
end

.namesObject

A mapping from model property names to API property names.



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/modern_treasury/models/ledger_account_statement.rb', line 83

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['object'] = 'object'
  @_hash['live_mode'] = 'live_mode'
  @_hash['created_at'] = 'created_at'
  @_hash['updated_at'] = 'updated_at'
  @_hash['ledger_id'] = 'ledger_id'
  @_hash['description'] = 'description'
  @_hash['ledger_account_id'] = 'ledger_account_id'
  @_hash['ledger_account_lock_version'] = 'ledger_account_lock_version'
  @_hash['ledger_account_normal_balance'] =
    'ledger_account_normal_balance'
  @_hash['effective_at_lower_bound'] = 'effective_at_lower_bound'
  @_hash['effective_at_upper_bound'] = 'effective_at_upper_bound'
  @_hash['starting_balance'] = 'starting_balance'
  @_hash['ending_balance'] = 'ending_balance'
  @_hash['metadata'] = 'metadata'
  @_hash
end

.nullablesObject

An array for nullable fields



110
111
112
113
114
# File 'lib/modern_treasury/models/ledger_account_statement.rb', line 110

def self.nullables
  %w[
    description
  ]
end

.optionalsObject

An array for optional fields



105
106
107
# File 'lib/modern_treasury/models/ledger_account_statement.rb', line 105

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



218
219
220
221
222
223
224
225
226
227
228
229
# File 'lib/modern_treasury/models/ledger_account_statement.rb', line 218

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id.inspect}, object: #{@object.inspect}, live_mode:"\
  " #{@live_mode.inspect}, created_at: #{@created_at.inspect}, updated_at:"\
  " #{@updated_at.inspect}, ledger_id: #{@ledger_id.inspect}, description:"\
  " #{@description.inspect}, ledger_account_id: #{@ledger_account_id.inspect},"\
  " ledger_account_lock_version: #{@ledger_account_lock_version.inspect},"\
  " ledger_account_normal_balance: #{@ledger_account_normal_balance.inspect},"\
  " effective_at_lower_bound: #{@effective_at_lower_bound.inspect}, effective_at_upper_bound:"\
  " #{@effective_at_upper_bound.inspect}, starting_balance: #{@starting_balance.inspect},"\
  " ending_balance: #{@ending_balance.inspect}, metadata: #{@metadata.inspect}>"
end

#to_custom_created_atObject



189
190
191
# File 'lib/modern_treasury/models/ledger_account_statement.rb', line 189

def to_custom_created_at
  DateTimeHelper.to_rfc3339(created_at)
end

#to_custom_effective_at_lower_boundObject



197
198
199
# File 'lib/modern_treasury/models/ledger_account_statement.rb', line 197

def to_custom_effective_at_lower_bound
  DateTimeHelper.to_rfc3339(effective_at_lower_bound)
end

#to_custom_effective_at_upper_boundObject



201
202
203
# File 'lib/modern_treasury/models/ledger_account_statement.rb', line 201

def to_custom_effective_at_upper_bound
  DateTimeHelper.to_rfc3339(effective_at_upper_bound)
end

#to_custom_updated_atObject



193
194
195
# File 'lib/modern_treasury/models/ledger_account_statement.rb', line 193

def to_custom_updated_at
  DateTimeHelper.to_rfc3339(updated_at)
end

#to_sObject

Provides a human-readable string representation of the object.



206
207
208
209
210
211
212
213
214
215
# File 'lib/modern_treasury/models/ledger_account_statement.rb', line 206

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id}, object: #{@object}, live_mode: #{@live_mode}, created_at:"\
  " #{@created_at}, updated_at: #{@updated_at}, ledger_id: #{@ledger_id}, description:"\
  " #{@description}, ledger_account_id: #{@ledger_account_id}, ledger_account_lock_version:"\
  " #{@ledger_account_lock_version}, ledger_account_normal_balance:"\
  " #{@ledger_account_normal_balance}, effective_at_lower_bound: #{@effective_at_lower_bound},"\
  " effective_at_upper_bound: #{@effective_at_upper_bound}, starting_balance:"\
  " #{@starting_balance}, ending_balance: #{@ending_balance}, metadata: #{@metadata}>"
end