Added sorting of accounts based on alloc priority
This commit is contained in:
parent
47076b0833
commit
609962f37a
20
index.html
20
index.html
@ -76,6 +76,8 @@
|
|||||||
|
|
||||||
document.getElementById("budget-table").innerHTML = header;
|
document.getElementById("budget-table").innerHTML = header;
|
||||||
|
|
||||||
|
jsonData.body.sort(allocSort);
|
||||||
|
|
||||||
for (const item of jsonData.body) {
|
for (const item of jsonData.body) {
|
||||||
summation += Number(item.balance);
|
summation += Number(item.balance);
|
||||||
|
|
||||||
@ -119,6 +121,24 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function allocSort(a, b) {
|
||||||
|
if (a.notes != null && b.notes != null) {
|
||||||
|
let astr = a.notes.split('_')[1];
|
||||||
|
let bstr = b.notes.split('_')[1];
|
||||||
|
|
||||||
|
if (astr == "MAIN") {
|
||||||
|
return -1;
|
||||||
|
} else if (bstr == "MAIN") {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return Number(astr) - Number(bstr);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log("ERROR: alloc object doesn't have notes");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function addToTransactionTable(jsonData) {
|
function addToTransactionTable(jsonData) {
|
||||||
let header = "<tr>"
|
let header = "<tr>"
|
||||||
+ "<th>ID</th>"
|
+ "<th>ID</th>"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user