organize transaction split processing a bit
This commit is contained in:
1 parent
350c2cb30c
commit
0f8b579a34
1 file changed
+9
-7
@@ -14,16 +14,18 @@ module Gnucash
|
||||
unless value_parts.size == 2 and value_parts[1] == '100'
|
||||
raise "Unexpected value format: #{value_str.inspect}"
|
||||
end
|
||||
account_id = split_node.xpath('split:account').text
|
||||
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
|
||||
account.add_transaction(self, value)
|
||||
{
|
||||
account_id: split_node.xpath('split:account').text,
|
||||
value: value_parts.first.to_i,
|
||||
account_id: account_id,
|
||||
value: value,
|
||||
}
|
||||
end
|
||||
@splits.each do |split|
|
||||
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.add_transaction(self, split[:value])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user