Added sorting of accounts based on alloc priority

master
William Lewis 11 months ago
parent 47076b0833
commit 609962f37a

@ -76,6 +76,8 @@
document.getElementById("budget-table").innerHTML = header;
jsonData.body.sort(allocSort);
for (const item of jsonData.body) {
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) {
let header = "<tr>"
+ "<th>ID</th>"

Loading…
Cancel
Save