mirror of
https://github.com/aclindsa/moneygo.git
synced 2025-07-01 03:58:38 -04:00
Reorganization around building JavaScript differently
This commit is contained in:
32
js/utils.js
Normal file
32
js/utils.js
Normal file
@ -0,0 +1,32 @@
|
||||
const recursiveAccountDisplayInfo = function(account, prefix) {
|
||||
var name = prefix + account.Name;
|
||||
var accounts = [{AccountId: account.AccountId, Name: name}];
|
||||
for (var i = 0; i < account.Children.length; i++)
|
||||
accounts = accounts.concat(recursiveAccountDisplayInfo(account.Children[i], name + "/"));
|
||||
return accounts
|
||||
};
|
||||
|
||||
const getAccountDisplayList = function(account_list, includeRoot, rootName) {
|
||||
var accounts = []
|
||||
if (includeRoot)
|
||||
accounts.push({AccountId: -1, Name: rootName});
|
||||
for (var i = 0; i < account_list.length; i++) {
|
||||
if (account_list[i].isRootAccount())
|
||||
accounts = accounts.concat(recursiveAccountDisplayInfo(account_list[i], ""));
|
||||
}
|
||||
return accounts;
|
||||
};
|
||||
|
||||
const getAccountDisplayName = function(account, account_map) {
|
||||
var name = account.Name;
|
||||
while (account.ParentAccountId >= 0) {
|
||||
account = account_map[account.ParentAccountId];
|
||||
name = account.Name + "/" + name;
|
||||
}
|
||||
return name;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
getAccountDisplayList: getAccountDisplayList,
|
||||
getAccountDisplayName: getAccountDisplayName
|
||||
};
|
Reference in New Issue
Block a user