organize transaction split processing a bit
This commit is contained in:
parent
350c2cb30c
commit
0f8b579a34
@ -14,15 +14,17 @@ 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_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
|
||||
@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])
|
||||
account.add_transaction(self, value)
|
||||
{
|
||||
account_id: account_id,
|
||||
value: value,
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user