# DELETE FROM balance WHERE id = (SELECT id FROM account WHERE name = ${name});
# DELETE FROM transaction WHERE account = (SELECT id FROM account WHERE name = ${name});
# DELETE FROM account WHERE name = ${name};
@ -115,7 +170,7 @@ delete_account() {
}
make_deposit() {
eval "$dbconnect -c \"SELECT * FROM account;\""
eval "$dbconnect -c \"SELECT id,name FROM account WHERE enabled = true;\""
read -p "Enter Account ID: " ID
read -p "Enter amount of gp to deposit: " amount
tstamp=$(date +%Y-%m-%d\ %H:%M:%S)
@ -141,7 +196,7 @@ make_deposit() {
}
make_withdrawal() {
eval "$dbconnect -c \"SELECT * FROM account;\""
eval "$dbconnect -c \"SELECT id,name FROM account WHERE enabled = true;\""
read -p "Enter Account ID: " ID
read -p "Enter amount of gp to withdraw: " amount
tstamp=$(date +%Y-%m-%d\ %H:%M:%S)
@ -167,12 +222,36 @@ make_withdrawal() {
}
bank_transfer() {
printf "\n$(tput bold)$(tput setaf 3)This action is not yet supported!\n\n$(tput sgr0)"
# show balances first
eval "$dbconnect -c \"SELECT account.id,account.name,gold FROM balance INNER JOIN account ON account.id = balance.id WHERE account.enabled = true ORDER BY name;\""
read -p "Enter Account ID to transfer $(tput bold)FROM$(tput sgr0): " FROM
read -p "Enter Account ID to transfer $(tput bold)TO$(tput sgr0): " TO
read -p "Enter amount of gp to transfer: " amount
tstamp=$(date +%Y-%m-%d\ %H:%M:%S)
read -p "Transfer ${amount}gp from account ${FROM} to account ${TO}. Are you sure? (y/N)" -n1 CONFIRM
eval "$dbconnect -c \"SELECT account.id,account.name,gold FROM balance INNER JOIN account ON account.id = balance.id ORDER BY name;\""
eval "$dbconnect -c \"SELECT account.id,account.name,gold FROM balance INNER JOIN account ON account.id = balance.id WHERE account.enabled = true ORDER BY name;\""
hold_menu
}
@ -189,6 +268,11 @@ show_transactions() {
hold_menu
}
show_transfers() {
eval "$dbconnect -c \"SELECT transfer.id,f.name AS from,t.name AS to,gold,timestamp FROM transfer LEFT JOIN account AS f ON f.id = transfer.from_id LEFT JOIN account AS t ON t.id = transfer.to_id;\""