organize transaction split processing a bit
This commit is contained in:
parent
350c2cb30c
commit
0f8b579a34
@ -14,16 +14,18 @@ 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
|
||||||
|
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,
|
account_id: account_id,
|
||||||
value: value_parts.first.to_i,
|
value: value,
|
||||||
}
|
}
|
||||||
end
|
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
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user