Skip to content

Commit

Permalink
updated to support credit
Browse files Browse the repository at this point in the history
credit previously displayed as -- now displays plain number
  • Loading branch information
Matee001 authored Nov 8, 2024
1 parent 6388180 commit 0b8ff14
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ <h2>Login</h2>
apiKey: "AIzaSyDl6hnUPdneEuC9emWbELvYoplR8vWhEsA",
authDomain: "debts-92f72.firebaseapp.com",
projectId: "debts-92f72",
storageBucket: "debts-92f72.firebaseapp.com",
storageBucket: "debts-92f72.appspot.com",
messagingSenderId: "904817355212",
appId: "1:904817355212:web:fd6837ba25f57d0ec6d569"
};
Expand Down Expand Up @@ -188,22 +188,26 @@ <h2>Login</h2>

transactionList.push({ ...data, type, date });

// Update total debt based on transaction type
if (type === "debt") {
totalDebt += amount;
totalDebt -= amount; // Subtract debt
} else if (type === "payment") {
totalDebt -= amount;
totalDebt += amount; // Add payment
}
});

document.getElementById("total-debt").innerText = `-${totalDebt} Ft`;
// Display the total debt as negative for debt, positive for payments
document.getElementById("total-debt").innerText = `${totalDebt} Ft`;

// Display each transaction with correct signs
const transactionContainer = document.getElementById("transaction-list");
transactionContainer.innerHTML = "";
transactionList.forEach((transaction) => {
const transactionElement = document.createElement("div");
transactionElement.className = `transaction ${transaction.type}`;
const sign = transaction.type === "debt" ? "-" : "+";
transactionElement.innerHTML = `
<div>${transaction.type === "debt" ? "-" : "+"}${transaction.amount} Ft</div>
<div>${sign}${transaction.amount} Ft</div>
<div>${transaction.date}</div>
`;
transactionContainer.appendChild(transactionElement);
Expand Down

0 comments on commit 0b8ff14

Please sign in to comment.