Class: AspireBudget::Worksheets::Transactions

Inherits:
WorksheetBase show all
Defined in:
lib/aspire_budget/worksheets/transactions.rb

Direct Known Subclasses

CategoryTransfers

Constant Summary collapse

WS_TITLE =
'Transactions'

Instance Method Summary collapse

Methods inherited from WorksheetBase

#dirty?, #initialize, instance

Constructor Details

This class inherits a constructor from AspireBudget::Worksheets::WorksheetBase

Instance Method Details

#allArray<AspireBudget::Transaction>

Returns all transactions.

Returns:

  • (Array<AspireBudget::Transaction>)

    all transactions



12
13
14
15
16
# File 'lib/aspire_budget/worksheets/transactions.rb', line 12

def all
  rows.map do |row|
    klass.from_row(header, row)
  end
end

#insert(record, sync: true) ⇒ AspireBudget::Transaction

Inserts a transaction to the spreadsheet. Accepts either a transaction record or a hash (that is passed to the transaction initializer)

Parameters:

  • record (AspireBudget::Transaction, Hash)

Returns:

  • (AspireBudget::Transaction)

    a transaction

See Also:



23
24
25
26
27
28
29
# File 'lib/aspire_budget/worksheets/transactions.rb', line 23

def insert(record, sync: true)
  record = klass.new(**record) if record.is_a?(Hash)
  row = record.to_row(header)
  ws.update_cells(*next_row_col, [row])
  ws.synchronize if sync
  record
end