Skip to content

Commit

Permalink
Merge pull request #159 from AnthonyDeSantiago/users
Browse files Browse the repository at this point in the history
Fixed Account Ledger so only transactions from the selected account a…
  • Loading branch information
AnthonyDeSantiago authored Dec 5, 2023
2 parents ed2e225 + 5522b1d commit 0dac61d
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions public/js/ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,11 @@ const accountBreadCrumb = document.getElementById("accountBreadcrumb-element");
const approvedJournalEntries = await getDocReferencesWithValue('journals', 'approval', 'approved');
const specJs = getJournalsSpecificToCurrentAccount(approvedJournalEntries);
const approvedTransactions = getTransactions(specJs);
console.log("approved transactions:", approvedTransactions);

const transactionsSpecificToCurrentAccount = await getDocReferencesWithValue('transactions', 'account', accountID);
console.log("!!!!!!!!!!!!", transactionsSpecificToCurrentAccount);


console.log("accountNumber:", accountNumber);
console.log("accountName:", accountName);
console.log("account ID:", accountID);
console.log("debit: ", await getDocumentReference('transactions', approvedTransactions[0]).debit);
console.log("transactions length", approvedTransactions.length);
console.log("Normal side", normalSide);


populateLedgerTable(approvedTransactions, 'ledger');
populateLedgerTable(transactionsSpecificToCurrentAccount, 'ledger');
printTotal();
accountBreadCrumb.textContent = accountName;

Expand All @@ -40,8 +32,8 @@ function loadDataTables() {

async function populateLedgerTable(transactions, tableId) {
const tableBody = document.querySelector(`#${tableId} tbody`);
for (let i = 0; i < transactions.length; i++) {
const transaction = await getDocumentReference('transactions', transactions[i]);
for (let i = 0; i < transactions.docs.length; i++) {
const transaction = transactions.docs[i].data();
tableBody.innerHTML += `
<tr>
<td>${transaction.creationDate.toDate()}</td>
Expand Down Expand Up @@ -88,22 +80,18 @@ function getJournalsSpecificToCurrentAccount(journals) {
for (let i = 0; i < journals.docs.length; i++) {
const parentAccounts = journals.docs[i].data().accounts;
for (let j = 0; j < parentAccounts.length; j++) {
console.log("Account ID: " + accountID + " Parent Account: " + parentAccounts[j]);
if (parentAccounts[j] == accountID) {
console.log("They are a match!");
specificJournals.push(journals.docs[i]);
break;
}
}
}
console.log("111111111111111111111111", specificJournals);
return specificJournals;
}


function getTransactions(journalEntries) {
const approvedTransactions = [];
console.log("Testing: ", journalEntries[0].data());
for (let i = 0; i < journalEntries.length; i++) {
const currentJournalTransactions = journalEntries[i].data().transactions;
if (Array.isArray(currentJournalTransactions)) {
Expand Down

0 comments on commit 0dac61d

Please sign in to comment.