Class: ThePlaidApi::CashflowReportMonthlySummary

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/the_plaid_api/models/cashflow_report_monthly_summary.rb

Overview

Monthly summary statistics derived from transaction-level data.

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(start_date:, end_date:, starting_balance:, ending_balance:, average_daily_ending_balance:, average_daily_inflow_amount:, average_daily_outflow_amount:, average_daily_net_cashflow_amount:, average_daily_inflow_transaction_count:, average_daily_outflow_transaction_count:, total_revenue:, total_loan_payment:, total_variable_expense:, total_payroll:, nsf_transaction_count:, overdraft_transaction_count:, negative_ending_balance_day_count:, additional_properties: nil) ⇒ CashflowReportMonthlySummary

Returns a new instance of CashflowReportMonthlySummary.



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
# File 'lib/the_plaid_api/models/cashflow_report_monthly_summary.rb', line 141

def initialize(start_date:, end_date:, starting_balance:, ending_balance:,
               average_daily_ending_balance:, average_daily_inflow_amount:,
               average_daily_outflow_amount:,
               average_daily_net_cashflow_amount:,
               average_daily_inflow_transaction_count:,
               average_daily_outflow_transaction_count:, total_revenue:,
               total_loan_payment:, total_variable_expense:, total_payroll:,
               nsf_transaction_count:, overdraft_transaction_count:,
               negative_ending_balance_day_count:,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @start_date = start_date
  @end_date = end_date
  @starting_balance = starting_balance
  @ending_balance = ending_balance
  @average_daily_ending_balance = average_daily_ending_balance
  @average_daily_inflow_amount = average_daily_inflow_amount
  @average_daily_outflow_amount = average_daily_outflow_amount
  @average_daily_net_cashflow_amount = average_daily_net_cashflow_amount
  @average_daily_inflow_transaction_count = average_daily_inflow_transaction_count
  @average_daily_outflow_transaction_count = average_daily_outflow_transaction_count
  @total_revenue = total_revenue
  @total_loan_payment = total_loan_payment
  @total_variable_expense = total_variable_expense
  @total_payroll = total_payroll
  @nsf_transaction_count = nsf_transaction_count
  @overdraft_transaction_count = overdraft_transaction_count
  @negative_ending_balance_day_count = negative_ending_balance_day_count
  @additional_properties = additional_properties
end

Instance Attribute Details

#average_daily_ending_balanceCashflowReportMonthlySummaryAverageDailyEndingBalance

Calendar-day average of the ending balance.



44
45
46
# File 'lib/the_plaid_api/models/cashflow_report_monthly_summary.rb', line 44

def average_daily_ending_balance
  @average_daily_ending_balance
end

#average_daily_inflow_amountCashflowReportMonthlySummaryAverageDailyInflowAmount

The average daily sum of inflow transactions, calculated over the month. Always represented as a positive monetary amount.



49
50
51
# File 'lib/the_plaid_api/models/cashflow_report_monthly_summary.rb', line 49

def average_daily_inflow_amount
  @average_daily_inflow_amount
end

#average_daily_inflow_transaction_countFloat

The average count of the number of daily inflow transactions. Rounded to 2 decimal places.

Returns:

  • (Float)


64
65
66
# File 'lib/the_plaid_api/models/cashflow_report_monthly_summary.rb', line 64

def average_daily_inflow_transaction_count
  @average_daily_inflow_transaction_count
end

#average_daily_net_cashflow_amountCashflowReportMonthlySummaryAverageDailyNetCashflowAmount

The average daily net cash flow amount, calculated as total daily inflows less total daily outflows.



59
60
61
# File 'lib/the_plaid_api/models/cashflow_report_monthly_summary.rb', line 59

def average_daily_net_cashflow_amount
  @average_daily_net_cashflow_amount
end

#average_daily_outflow_amountCashflowReportMonthlySummaryAverageDailyOutflowAmount

The average daily sum of outflow transactions, calculated over the month. Always represented as a positive monetary amount.



54
55
56
# File 'lib/the_plaid_api/models/cashflow_report_monthly_summary.rb', line 54

def average_daily_outflow_amount
  @average_daily_outflow_amount
end

#average_daily_outflow_transaction_countFloat

The average count of the number of daily outflow transactions. Rounded to 2 decimal places.

Returns:

  • (Float)


69
70
71
# File 'lib/the_plaid_api/models/cashflow_report_monthly_summary.rb', line 69

def average_daily_outflow_transaction_count
  @average_daily_outflow_transaction_count
end

#end_dateDate

The end date of the period included in this monthly summary. This date will be the last day of the month, unless the month being covered is a partial month because it is the last month included in the summary and the date range being requested does not end with the last day of the month. The date will be returned in an ISO 8601 format (YYYY-MM-DD).

Returns:

  • (Date)


28
29
30
# File 'lib/the_plaid_api/models/cashflow_report_monthly_summary.rb', line 28

def end_date
  @end_date
end

#ending_balanceCashflowReportMonthlySummaryEndingBalance

The ending balance of the month. This will be the same as the starting balance of the next month. This field will not be available for the last monthly summary.



40
41
42
# File 'lib/the_plaid_api/models/cashflow_report_monthly_summary.rb', line 40

def ending_balance
  @ending_balance
end

#negative_ending_balance_day_countInteger

The number of days with a negative daily average ending balance. The daily average is calculated across all valid accounts. Values will be in the range [0, 31].

Returns:

  • (Integer)


99
100
101
# File 'lib/the_plaid_api/models/cashflow_report_monthly_summary.rb', line 99

def negative_ending_balance_day_count
  @negative_ending_balance_day_count
end

#nsf_transaction_countInteger

The total number of all NSF transactions during this month.

Returns:

  • (Integer)


89
90
91
# File 'lib/the_plaid_api/models/cashflow_report_monthly_summary.rb', line 89

def nsf_transaction_count
  @nsf_transaction_count
end

#overdraft_transaction_countInteger

The total number of all overdraft transactions during this month.

Returns:

  • (Integer)


93
94
95
# File 'lib/the_plaid_api/models/cashflow_report_monthly_summary.rb', line 93

def overdraft_transaction_count
  @overdraft_transaction_count
end

#start_dateDate

The start date of the period covered in this monthly summary. This date will be the first day of the month, unless the month being covered is a partial month because it is the first month included in the summary and the date range being requested does not begin with the first day of the month. The date will be returned in an ISO 8601 format (YYYY-MM-DD).

Returns:

  • (Date)


19
20
21
# File 'lib/the_plaid_api/models/cashflow_report_monthly_summary.rb', line 19

def start_date
  @start_date
end

#starting_balanceCashflowReportMonthlySummaryStartingBalance

The starting balance of the month. This will be the same as the ending balance of the previous month. This field will not be available for the first monthly summary.



34
35
36
# File 'lib/the_plaid_api/models/cashflow_report_monthly_summary.rb', line 34

def starting_balance
  @starting_balance
end

#total_loan_paymentCashflowReportMonthlySummaryTotalLoanPayment

The total amount of all loan payment transactions during this month.



77
78
79
# File 'lib/the_plaid_api/models/cashflow_report_monthly_summary.rb', line 77

def total_loan_payment
  @total_loan_payment
end

#total_payrollCashflowReportMonthlySummaryTotalPayroll

The total amount of all payroll transactions during this month.



85
86
87
# File 'lib/the_plaid_api/models/cashflow_report_monthly_summary.rb', line 85

def total_payroll
  @total_payroll
end

#total_revenueCashflowReportMonthlySummaryTotalRevenue

The total amount of all revenue transactions during this month.



73
74
75
# File 'lib/the_plaid_api/models/cashflow_report_monthly_summary.rb', line 73

def total_revenue
  @total_revenue
end

#total_variable_expenseCashflowReportMonthlySummaryTotalVariableExpense

The total amount of all variable expense transactions during this month.



81
82
83
# File 'lib/the_plaid_api/models/cashflow_report_monthly_summary.rb', line 81

def total_variable_expense
  @total_variable_expense
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/the_plaid_api/models/cashflow_report_monthly_summary.rb', line 175

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  start_date = hash.key?('start_date') ? hash['start_date'] : nil
  end_date = hash.key?('end_date') ? hash['end_date'] : nil
  if hash['starting_balance']
    starting_balance = CashflowReportMonthlySummaryStartingBalance.from_hash(hash['starting_balance'])
  end
  if hash['ending_balance']
    ending_balance = CashflowReportMonthlySummaryEndingBalance.from_hash(hash['ending_balance'])
  end
  if hash['average_daily_ending_balance']
    average_daily_ending_balance = CashflowReportMonthlySummaryAverageDailyEndingBalance.from_hash(hash['average_daily_ending_balance'])
  end
  if hash['average_daily_inflow_amount']
    average_daily_inflow_amount = CashflowReportMonthlySummaryAverageDailyInflowAmount.from_hash(hash['average_daily_inflow_amount'])
  end
  if hash['average_daily_outflow_amount']
    average_daily_outflow_amount = CashflowReportMonthlySummaryAverageDailyOutflowAmount.from_hash(hash['average_daily_outflow_amount'])
  end
  if hash['average_daily_net_cashflow_amount']
    average_daily_net_cashflow_amount = CashflowReportMonthlySummaryAverageDailyNetCashflowAmount.from_hash(hash['average_daily_net_cashflow_amount'])
  end
  average_daily_inflow_transaction_count =
    hash.key?('average_daily_inflow_transaction_count') ? hash['average_daily_inflow_transaction_count'] : nil
  average_daily_outflow_transaction_count =
    hash.key?('average_daily_outflow_transaction_count') ? hash['average_daily_outflow_transaction_count'] : nil
  total_revenue = CashflowReportMonthlySummaryTotalRevenue.from_hash(hash['total_revenue']) if
    hash['total_revenue']
  if hash['total_loan_payment']
    total_loan_payment = CashflowReportMonthlySummaryTotalLoanPayment.from_hash(hash['total_loan_payment'])
  end
  if hash['total_variable_expense']
    total_variable_expense = CashflowReportMonthlySummaryTotalVariableExpense.from_hash(hash['total_variable_expense'])
  end
  total_payroll = CashflowReportMonthlySummaryTotalPayroll.from_hash(hash['total_payroll']) if
    hash['total_payroll']
  nsf_transaction_count =
    hash.key?('nsf_transaction_count') ? hash['nsf_transaction_count'] : nil
  overdraft_transaction_count =
    hash.key?('overdraft_transaction_count') ? hash['overdraft_transaction_count'] : nil
  negative_ending_balance_day_count =
    hash.key?('negative_ending_balance_day_count') ? hash['negative_ending_balance_day_count'] : nil

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  CashflowReportMonthlySummary.new(start_date: start_date,
                                   end_date: end_date,
                                   starting_balance: starting_balance,
                                   ending_balance: ending_balance,
                                   average_daily_ending_balance: average_daily_ending_balance,
                                   average_daily_inflow_amount: average_daily_inflow_amount,
                                   average_daily_outflow_amount: average_daily_outflow_amount,
                                   average_daily_net_cashflow_amount: average_daily_net_cashflow_amount,
                                   average_daily_inflow_transaction_count: average_daily_inflow_transaction_count,
                                   average_daily_outflow_transaction_count: average_daily_outflow_transaction_count,
                                   total_revenue: total_revenue,
                                   total_loan_payment: total_loan_payment,
                                   total_variable_expense: total_variable_expense,
                                   total_payroll: total_payroll,
                                   nsf_transaction_count: nsf_transaction_count,
                                   overdraft_transaction_count: overdraft_transaction_count,
                                   negative_ending_balance_day_count: negative_ending_balance_day_count,
                                   additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/the_plaid_api/models/cashflow_report_monthly_summary.rb', line 102

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['start_date'] = 'start_date'
  @_hash['end_date'] = 'end_date'
  @_hash['starting_balance'] = 'starting_balance'
  @_hash['ending_balance'] = 'ending_balance'
  @_hash['average_daily_ending_balance'] = 'average_daily_ending_balance'
  @_hash['average_daily_inflow_amount'] = 'average_daily_inflow_amount'
  @_hash['average_daily_outflow_amount'] = 'average_daily_outflow_amount'
  @_hash['average_daily_net_cashflow_amount'] =
    'average_daily_net_cashflow_amount'
  @_hash['average_daily_inflow_transaction_count'] =
    'average_daily_inflow_transaction_count'
  @_hash['average_daily_outflow_transaction_count'] =
    'average_daily_outflow_transaction_count'
  @_hash['total_revenue'] = 'total_revenue'
  @_hash['total_loan_payment'] = 'total_loan_payment'
  @_hash['total_variable_expense'] = 'total_variable_expense'
  @_hash['total_payroll'] = 'total_payroll'
  @_hash['nsf_transaction_count'] = 'nsf_transaction_count'
  @_hash['overdraft_transaction_count'] = 'overdraft_transaction_count'
  @_hash['negative_ending_balance_day_count'] =
    'negative_ending_balance_day_count'
  @_hash
end

.nullablesObject

An array for nullable fields



134
135
136
137
138
139
# File 'lib/the_plaid_api/models/cashflow_report_monthly_summary.rb', line 134

def self.nullables
  %w[
    starting_balance
    ending_balance
  ]
end

.optionalsObject

An array for optional fields



129
130
131
# File 'lib/the_plaid_api/models/cashflow_report_monthly_summary.rb', line 129

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
# File 'lib/the_plaid_api/models/cashflow_report_monthly_summary.rb', line 267

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} start_date: #{@start_date.inspect}, end_date: #{@end_date.inspect},"\
  " starting_balance: #{@starting_balance.inspect}, ending_balance:"\
  " #{@ending_balance.inspect}, average_daily_ending_balance:"\
  " #{@average_daily_ending_balance.inspect}, average_daily_inflow_amount:"\
  " #{@average_daily_inflow_amount.inspect}, average_daily_outflow_amount:"\
  " #{@average_daily_outflow_amount.inspect}, average_daily_net_cashflow_amount:"\
  " #{@average_daily_net_cashflow_amount.inspect}, average_daily_inflow_transaction_count:"\
  " #{@average_daily_inflow_transaction_count.inspect},"\
  ' average_daily_outflow_transaction_count:'\
  " #{@average_daily_outflow_transaction_count.inspect}, total_revenue:"\
  " #{@total_revenue.inspect}, total_loan_payment: #{@total_loan_payment.inspect},"\
  " total_variable_expense: #{@total_variable_expense.inspect}, total_payroll:"\
  " #{@total_payroll.inspect}, nsf_transaction_count: #{@nsf_transaction_count.inspect},"\
  " overdraft_transaction_count: #{@overdraft_transaction_count.inspect},"\
  " negative_ending_balance_day_count: #{@negative_ending_balance_day_count.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
# File 'lib/the_plaid_api/models/cashflow_report_monthly_summary.rb', line 249

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} start_date: #{@start_date}, end_date: #{@end_date}, starting_balance:"\
  " #{@starting_balance}, ending_balance: #{@ending_balance}, average_daily_ending_balance:"\
  " #{@average_daily_ending_balance}, average_daily_inflow_amount:"\
  " #{@average_daily_inflow_amount}, average_daily_outflow_amount:"\
  " #{@average_daily_outflow_amount}, average_daily_net_cashflow_amount:"\
  " #{@average_daily_net_cashflow_amount}, average_daily_inflow_transaction_count:"\
  " #{@average_daily_inflow_transaction_count}, average_daily_outflow_transaction_count:"\
  " #{@average_daily_outflow_transaction_count}, total_revenue: #{@total_revenue},"\
  " total_loan_payment: #{@total_loan_payment}, total_variable_expense:"\
  " #{@total_variable_expense}, total_payroll: #{@total_payroll}, nsf_transaction_count:"\
  " #{@nsf_transaction_count}, overdraft_transaction_count: #{@overdraft_transaction_count},"\
  " negative_ending_balance_day_count: #{@negative_ending_balance_day_count},"\
  " additional_properties: #{@additional_properties}>"
end