Skip to content

Commit

Permalink
show outstanding balance on licence
Browse files Browse the repository at this point in the history
  • Loading branch information
dangowans committed May 19, 2022
1 parent 23d5a0d commit b1e1e84
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 8 deletions.
18 changes: 15 additions & 3 deletions public-typescript/licence-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
let licenceTransactions;
const getOutstandingBalance = () => {
const licenceFeeString = document.querySelector("#licenceEdit--licenceFee").value;
const transactionAmountTotalString = licenceTransactionsTableElement.querySelectorAll("tfoot th")[1].textContent.slice(1);
const transactionAmountTotalString = licenceTransactionsTableElement.querySelector("#transactions--total").textContent.slice(1);
const outstandingBalance = Math.max(Number.parseFloat(licenceFeeString) - Number.parseFloat(transactionAmountTotalString), 0);
return outstandingBalance;
};
Expand Down Expand Up @@ -532,8 +532,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
tbodyElement.append(trElement);
transactionTotal += licenceTransaction.transactionAmount;
}
licenceTransactionsTableElement.querySelectorAll("tfoot th")[1].textContent =
"$" + transactionTotal.toFixed(2);
const tfootElement = licenceTransactionsTableElement.querySelector("tfoot");
tfootElement.innerHTML = "<tr>" +
"<th>Total</th>" +
"<th id=\"transactions--total\" class=\"has-text-right\">$" + transactionTotal.toFixed(2) + "</th>" +
"<th></th>" +
"</tr>";
const outstandingBalance = getOutstandingBalance();
if (outstandingBalance > 0) {
tfootElement.insertAdjacentHTML("beforeend", "<tr class=\"has-background-danger-light\">" +
"<th>Outstanding Balance</th>" +
"<th class=\"has-text-right\">$" + outstandingBalance.toFixed(2) + "</th>" +
"<th></th>" +
"</tr>");
}
};
const addTransaction_getBankNameFunction = (changeEvent) => {
changeEvent.preventDefault();
Expand Down
21 changes: 18 additions & 3 deletions public-typescript/licence-edit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ declare const bulmaJS: BulmaJS;

const licenceFeeString = (document.querySelector("#licenceEdit--licenceFee") as HTMLInputElement).value;

const transactionAmountTotalString = licenceTransactionsTableElement.querySelectorAll("tfoot th")[1].textContent.slice(1);
const transactionAmountTotalString = licenceTransactionsTableElement.querySelector("#transactions--total").textContent.slice(1);

const outstandingBalance = Math.max(Number.parseFloat(licenceFeeString) - Number.parseFloat(transactionAmountTotalString), 0);

Expand Down Expand Up @@ -775,8 +775,23 @@ declare const bulmaJS: BulmaJS;
transactionTotal += licenceTransaction.transactionAmount;
}

licenceTransactionsTableElement.querySelectorAll("tfoot th")[1].textContent =
"$" + transactionTotal.toFixed(2);
const tfootElement = licenceTransactionsTableElement.querySelector("tfoot");

tfootElement.innerHTML = "<tr>" +
"<th>Total</th>" +
"<th id=\"transactions--total\" class=\"has-text-right\">$" + transactionTotal.toFixed(2) + "</th>" +
"<th></th>" +
"</tr>";

const outstandingBalance = getOutstandingBalance();

if (outstandingBalance > 0) {
tfootElement.insertAdjacentHTML("beforeend", "<tr class=\"has-background-danger-light\">" +
"<th>Outstanding Balance</th>"+
"<th class=\"has-text-right\">$" + outstandingBalance.toFixed(2) + "</th>" +
"<th></th>" +
"</tr>");
}
};


Expand Down
Loading

0 comments on commit b1e1e84

Please sign in to comment.