lib/reckon/app.rb in reckon-0.5.0 vs lib/reckon/app.rb in reckon-0.5.1
- old
+ new
@@ -154,19 +154,21 @@
end
def each_row_backwards
rows = []
(0...@csv_parser.columns.first.length).to_a.each do |index|
+ if @csv_parser.date_for(index).nil?
+ LOGGER.warn("Skipping row: '#{@csv_parser.row(index)}' that doesn't have a valid date")
+ next
+ end
rows << { :date => @csv_parser.date_for(index),
:pretty_date => @csv_parser.pretty_date_for(index),
:pretty_money => @csv_parser.pretty_money_for(index),
:pretty_money_negated => @csv_parser.pretty_money_for(index, :negate),
:money => @csv_parser.money_for(index),
:description => @csv_parser.description_for(index) }
end
- rows.sort { |a, b| a[:date] <=> b[:date] }.each do |row|
- yield row
- end
+ rows.sort_by { |n| n[:date] }.each {|row| yield row }
end
def most_specific_regexp_match( row )
matches = regexps.map { |regexp, account|
if match = regexp.match(row[:description])