organize transaction split processing a bit

This commit is contained in:
Josh Holtrop 2013-08-04 17:20:39 -04:00
parent 350c2cb30c
commit 0f8b579a34

View File

@ -14,15 +14,17 @@ module Gnucash
unless value_parts.size == 2 and value_parts[1] == '100' unless value_parts.size == 2 and value_parts[1] == '100'
raise "Unexpected value format: #{value_str.inspect}" raise "Unexpected value format: #{value_str.inspect}"
end end
{ account_id = split_node.xpath('split:account').text
account_id: split_node.xpath('split:account').text, value = value_parts.first.to_i
value: value_parts.first.to_i, account = @book.find_account_by_id(account_id)
} unless account
raise "Could not find account with ID #{account_id} for transaction #{@id}"
end end
@splits.each do |split| account.add_transaction(self, value)
account = @book.find_account_by_id(split[:account_id]) {
raise "Could not find account with ID #{split[:account_id]} for transaction #{@id}" unless account account_id: account_id,
account.add_transaction(self, split[:value]) value: value,
}
end end
end end
end end