Account: cache full name instead of recalculating it every time
This commit is contained in:
parent
309e8a9c29
commit
c14ac56a32
@ -32,14 +32,7 @@ module Gnucash
|
||||
|
||||
# Return the fully qualified account name
|
||||
def full_name
|
||||
prefix = ""
|
||||
if @parent_id
|
||||
parent = @book.find_account_by_id(@parent_id)
|
||||
if parent and parent.type != 'ROOT'
|
||||
prefix = parent.full_name + "::"
|
||||
end
|
||||
end
|
||||
prefix + name
|
||||
@full_name ||= calculate_full_name
|
||||
end
|
||||
|
||||
# Internal method used to associate a transaction with the account
|
||||
@ -87,5 +80,18 @@ module Gnucash
|
||||
end
|
||||
@balances[idx][:value]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def calculate_full_name
|
||||
prefix = ""
|
||||
if @parent_id
|
||||
parent = @book.find_account_by_id(@parent_id)
|
||||
if parent and parent.type != 'ROOT'
|
||||
prefix = parent.full_name + "::"
|
||||
end
|
||||
end
|
||||
prefix + name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user