Skip to content

Commit

Permalink
display and history better - history calculates. yoseph
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyHubert committed Aug 9, 2024
1 parent 4ac87fa commit b9a673d
Showing 1 changed file with 64 additions and 38 deletions.
102 changes: 64 additions & 38 deletions yoseph/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,84 +25,89 @@ document.querySelector(`#savings-expense-enter`).addEventListener(`click`, () =>
})
*/

let Savings = 0
let Stupid = 0
let Tithes = 0
let SavingsNotes
let StupidNotes
let SavingsSubtract
let StupidSubtract
let PayAmount
let History = []

document.querySelector(`#stupid-total`).innerHTML = 0
document.querySelector(`#tithe-total`).innerHTML = 0
document.querySelector(`#savings-total`).innerHTML = 0
const calculations = () => {
let Savings = 0
let Stupid = 0
let Tithes = 0
History.forEach(historyItem => {
if(historyItem.account === "payday") {
let PayAmount = historyItem.amount
let PayAmount1 = PayAmount / 4
let PayAmount2 = PayAmount / 10
let PayAmount3 = PayAmount / 100
PayAmount3 = PayAmount3 * 65
Savings = Savings + PayAmount3
Stupid = Stupid + PayAmount1
Tithes = Tithes + PayAmount2
} else if(historyItem.account === `savings`) {
let SavingsSubtract = historyItem.amount*-1
Savings = Savings - SavingsSubtract
} else if(historyItem.account === `stupid`) {
let StupidSubtract = historyItem.amount*-1
Stupid = Stupid - StupidSubtract
} else if(historyItem.account === `tithes`) {
let tithesAmount = document.querySelector(`#tithe-total`).innerHTML
Tithes = Tithes - tithesAmount
}
})
document.querySelector(`#stupid-total`).innerHTML = Stupid
document.querySelector(`#tithe-total`).innerHTML = Tithes
document.querySelector(`#savings-total`).innerHTML = Savings
console.log('stupid', Stupid, 'savings', Savings, 'tithes', Tithes)
}
calculations()

document.querySelector(`#savings-expense-enter`).addEventListener(`click`, () => {
SavingsSubtract = document.querySelector(`#savings-expense-amount`).value
Savings = Savings - SavingsSubtract
document.querySelector(`#savings-total`).innerHTML = Savings
document.querySelector(`#savings-expense-amount`).value = ''
const savingsHistoryItem = {
description: document.querySelector(`#savings-expense-description`).value,
amount: SavingsSubtract*-1,
amount: document.querySelector(`#savings-expense-amount`).value*-1,
date: Date.now(),
account: "savings"
}
History.push(savingsHistoryItem)
document.querySelector(`#savings-expense-description`).value = ''
document.querySelector(`#savings-expense-amount`).value = ''
calculations()
})

document.querySelector(`#pay-enter`).addEventListener(`click`, () => {
PayAmount = document.querySelector(`#pay-amount`).value
PayAmount = Number(PayAmount)
let PayAmount1 = PayAmount / 4
let PayAmount2 = PayAmount / 10
let PayAmount3 = PayAmount / 100
PayAmount3 = PayAmount3 * 65
Savings = Savings + PayAmount3
Stupid = Stupid + PayAmount1
Tithes = Tithes + PayAmount2
document.querySelector(`#stupid-total`).innerHTML = Stupid
document.querySelector(`#tithe-total`).innerHTML = Tithes
document.querySelector(`#savings-total`).innerHTML = Savings
document.querySelector(`#pay-amount`).value = ''
const paydayHistoryItem = {
description: 'payday',
amount: PayAmount,
amount: document.querySelector(`#pay-amount`).value,
date: Date.now(),
account: "payday"
}
History.push(paydayHistoryItem)
document.querySelector(`#pay-amount`).value = ''
calculations()
})

document.querySelector(`#stupid-expense-enter`).addEventListener(`click`, () => {
StupidSubtract = document.querySelector(`#stupid-expense-amount`).value
Stupid = Stupid - StupidSubtract
document.querySelector(`#stupid-total`).innerHTML = Stupid
document.querySelector(`#stupid-expense-amount`).value = ''
const stupidHistoryItem = {
description: document.querySelector(`#stupid-expense-description`).value,
amount: StupidSubtract*-1,
amount: document.querySelector(`#stupid-expense-amount`).value*-1,
date: Date.now(),
account: "stupid"
}
History.push(stupidHistoryItem)
document.querySelector(`#stupid-expense-description`).value = ''
document.querySelector(`#stupid-expense-amount`).value = ''
calculations()
})

document.querySelector(`#tithe-clear`).addEventListener(`click`, () => {
const tithesHistoryItem = {
description: document.querySelector(`#stupid-expense-description`).value,
amount: Tithes*-1,
amount: document.querySelector(`#tithe-total`).innerHTML*-1,
date: Date.now(),
account: "tithes",
description: "tithed"
}
History.push(tithesHistoryItem)
Tithes = 0
document.querySelector(`#tithe-total`).innerHTML = Tithes
calculations()
})

document.querySelector(`#view-history`).addEventListener(`click`, () => {
Expand Down Expand Up @@ -135,4 +140,25 @@ document.querySelector(`#view-history`).addEventListener(`click`, () => {
document.querySelector(`#back`).addEventListener(`click`, () => {
document.querySelector(`#screen-main`).classList.remove(`hide`)
document.querySelector(`#screen-history`).classList.add(`hide`)
})
calculations()
})

/*
const calculations = () => {
let Savings = 0
let Stupid = 0
let Tithes = 0
History.forEach(historyItem => {
if(historyItem.account === `payday`) {
console.log(`payday`, historyItem.amount)
} else if(historyItem.account === `savings`) {
console.log(`savings`, historyItem.amount)
} else if(historyItem.account === `stupid`) {
console.log(`stupid`, historyItem.amount)
} else if(historyItem.account === `tithes`) {
console.log(`tithes`, historyItem.amount)
}
})
console.log('Savings', Savings)
}
*/

0 comments on commit b9a673d

Please sign in to comment.