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
|
# Return the fully qualified account name
|
||||||
def full_name
|
def full_name
|
||||||
prefix = ""
|
@full_name ||= calculate_full_name
|
||||||
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
|
||||||
|
|
||||||
# Internal method used to associate a transaction with the account
|
# Internal method used to associate a transaction with the account
|
||||||
@ -87,5 +80,18 @@ module Gnucash
|
|||||||
end
|
end
|
||||||
@balances[idx][:value]
|
@balances[idx][:value]
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user