Class: AspireBudget::Worksheets::Transactions

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

Direct Known Subclasses

CategoryTransfers

Constant Summary collapse

WS_TITLE =
'Transactions'
MARGIN_LEFT =
1

Constants included from Utils

Utils::DATE_FORMAT, Utils::TRANSACTION_STATUS_MAPPING

Instance Method Summary collapse

Methods inherited from WorksheetBase

#dirty?, #initialize, instance, method_missing, respond_to_missing?

Methods included from Utils

parse_currency, parse_date, parse_status, serialize_currency, serialize_date, serialize_status

Constructor Details

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

Instance Method Details

#allObject


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

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

#insert(record, sync: true) ⇒ Object


18
19
20
21
22
23
24
# File 'lib/worksheets/transactions.rb', line 18

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
  klass.from_row(header, sanitize(ws.rows.last))
end