Comparar commits
No hay commits en común. 'main' y 'master' tienen historias completamente diferentes.
45
budget.py
45
budget.py
|
@ -61,8 +61,7 @@ class Bill:
|
||||||
self.backup = float(input('Backup Bill: ') or '0.00')
|
self.backup = float(input('Backup Bill: ') or '0.00')
|
||||||
self.fileserver = float(input("File server Bill: ") or '0.00')
|
self.fileserver = float(input("File server Bill: ") or '0.00')
|
||||||
self.setup = float(input(f'Setup Bill: ') or '0.00')
|
self.setup = float(input(f'Setup Bill: ') or '0.00')
|
||||||
self.bank_fee = float(input(f'Bank Maintenance Fee: ') or '0.00')
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -83,7 +82,7 @@ class Bill:
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
|
|
||||||
sql = "INSERT INTO bills(datetime, domain, server, backup, fileserver, setup, bank_fee) VALUES(%s,%s,%s,%s,%s,%s,%s)"
|
sql = "INSERT INTO bills(datetime, domain, server, backup, fileserver, setup) VALUES(%s,%s,%s,%s,%s,%s)"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
|
@ -91,7 +90,7 @@ class Bill:
|
||||||
|
|
||||||
cur = conn.cursor()
|
cur = conn.cursor()
|
||||||
|
|
||||||
cur.execute(sql, (self.date, self.domain, self.server, self.backup, self.fileserver, self.setup, self.bank_fee))
|
cur.execute(sql, (self.date, self.domain, self.server, self.backup, self.fileserver, self.setup))
|
||||||
|
|
||||||
print("\nUpdating bills...")
|
print("\nUpdating bills...")
|
||||||
|
|
||||||
|
@ -225,19 +224,17 @@ class BillShow:
|
||||||
|
|
||||||
month_setup = []
|
month_setup = []
|
||||||
|
|
||||||
month_bank_fee = []
|
|
||||||
|
|
||||||
if self.option == 1:
|
if self.option == 1:
|
||||||
|
|
||||||
sql = "select datetime, domain, server, backup, fileserver, setup, bank_fee from bills where date_part('year', datetime) = date_part('year', CURRENT_DATE) and date_part('month', datetime) = (%s) order by 1 asc"
|
sql = "select datetime, domain, server, backup, fileserver, setup from bills where date_part('year', datetime) = date_part('year', CURRENT_DATE) and date_part('month', datetime) = (%s) order by 1 asc"
|
||||||
|
|
||||||
elif self.option == 2:
|
elif self.option == 2:
|
||||||
|
|
||||||
sql = "select datetime, domain, server, backup, fileserver, setup, bank_fee from bills where date_part('year', datetime) = (%s) order by 1 asc"
|
sql = "select datetime, domain, server, backup, fileserver, setup from bills where date_part('year', datetime) = (%s) order by 1 asc"
|
||||||
|
|
||||||
elif self.option == 3:
|
elif self.option == 3:
|
||||||
|
|
||||||
sql = "select datetime, domain, server, backup, fileserver, setup, bank_fee from bills order by 1 asc"
|
sql = "select datetime, domain, server, backup, fileserver, setup from bills order by 1 asc"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
|
@ -268,14 +265,6 @@ class BillShow:
|
||||||
month_fileserver.append(row[4])
|
month_fileserver.append(row[4])
|
||||||
|
|
||||||
month_setup.append(row[5])
|
month_setup.append(row[5])
|
||||||
|
|
||||||
if row[6] != None:
|
|
||||||
|
|
||||||
month_bank_fee.append(row[6])
|
|
||||||
|
|
||||||
else:
|
|
||||||
|
|
||||||
month_bank_fee.append('0.00')
|
|
||||||
|
|
||||||
cur.close()
|
cur.close()
|
||||||
|
|
||||||
|
@ -289,7 +278,7 @@ class BillShow:
|
||||||
|
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
return (month_date, month_domain, month_server, month_backup, month_fileserver, month_setup, month_bank_fee)
|
return (month_date, month_domain, month_server, month_backup, month_fileserver, month_setup)
|
||||||
|
|
||||||
class DonationShow:
|
class DonationShow:
|
||||||
|
|
||||||
|
@ -449,19 +438,19 @@ class BalanceShow:
|
||||||
|
|
||||||
incomes_sql = "select sum(donations) from incomes where date_part('year', datetime) = date_part('year', CURRENT_DATE) and date_part('month', datetime) = (%s)"
|
incomes_sql = "select sum(donations) from incomes where date_part('year', datetime) = date_part('year', CURRENT_DATE) and date_part('month', datetime) = (%s)"
|
||||||
|
|
||||||
bills_sql = "select sum(coalesce(domain) + coalesce(server) + coalesce(backup) + coalesce(fileserver) + coalesce(setup) + coalesce(bank_fee,0)) from bills where date_part('year', datetime) = date_part('year', CURRENT_DATE) and date_part('month', datetime) = (%s)"
|
bills_sql = "select sum(coalesce(domain) + coalesce(server) + coalesce(backup) + coalesce(fileserver) + coalesce(setup)) from bills where date_part('year', datetime) = date_part('year', CURRENT_DATE) and date_part('month', datetime) = (%s)"
|
||||||
|
|
||||||
elif self.option == 2:
|
elif self.option == 2:
|
||||||
|
|
||||||
incomes_sql = "select sum(donations) from incomes where date_part('year', datetime) = (%s)"
|
incomes_sql = "select sum(donations) from incomes where date_part('year', datetime) = (%s)"
|
||||||
|
|
||||||
bills_sql = "select sum(coalesce(domain) + coalesce(server) + coalesce(backup) + coalesce(fileserver) + coalesce(setup) + coalesce(bank_fee,0)) from bills where date_part('year', datetime) = (%s)"
|
bills_sql = "select sum(coalesce(domain) + coalesce(server) + coalesce(backup) + coalesce(fileserver) + coalesce(setup)) from bills where date_part('year', datetime) = (%s)"
|
||||||
|
|
||||||
elif self.option == 3:
|
elif self.option == 3:
|
||||||
|
|
||||||
incomes_sql = "select sum(donations) from incomes order by 1 asc"
|
incomes_sql = "select sum(donations) from incomes order by 1 asc"
|
||||||
|
|
||||||
bills_sql = "select sum(coalesce(domain) + coalesce(server) + coalesce(backup) + coalesce(fileserver) + coalesce(setup) + coalesce(bank_fee,0)) from bills"
|
bills_sql = "select sum(coalesce(domain) + coalesce(server) + coalesce(backup) + coalesce(fileserver) + coalesce(setup)) from bills"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
|
@ -571,7 +560,7 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
bill = Bill()
|
bill = Bill()
|
||||||
|
|
||||||
if bill.domain == bill.server == bill.backup == bill.fileserver == bill.setup == bill.bank_fee == 0.0:
|
if bill.domain == bill.server == bill.backup == bill.fileserver == bill.setup == 0.0:
|
||||||
|
|
||||||
print('\nAny bill added')
|
print('\nAny bill added')
|
||||||
|
|
||||||
|
@ -585,13 +574,13 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
if bill.option == 1 or bill.option == 2 or bill.option == 3:
|
if bill.option == 1 or bill.option == 2 or bill.option == 3:
|
||||||
|
|
||||||
month_date, month_domain, month_server, month_backup, month_fileserver, month_setup, month_bank_fee = bill.show(bill.criteria)
|
month_date, month_domain, month_server, month_backup, month_fileserver, month_setup = bill.show(bill.criteria)
|
||||||
|
|
||||||
if bill.option != 4:
|
if bill.option != 4:
|
||||||
|
|
||||||
print_table = PrettyTable()
|
print_table = PrettyTable()
|
||||||
|
|
||||||
print_table.field_names = ['Date', 'Domain', 'Server', 'Backup', 'File server', 'Setup', 'Bank fee']
|
print_table.field_names = ['Date', 'Domain', 'Server', 'Backup', 'File server', 'Setup']
|
||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
|
|
||||||
|
@ -611,15 +600,13 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
b_setup = float(month_setup[i])
|
b_setup = float(month_setup[i])
|
||||||
|
|
||||||
b_bank_fee = float(month_bank_fee[i])
|
total_amount = total_amount + b_domain + b_server + b_backup + b_fileserver + b_setup
|
||||||
|
|
||||||
total_amount = total_amount + b_domain + b_server + b_backup + b_fileserver + b_setup + b_bank_fee
|
print_table.add_row([b_date, b_domain, b_server, b_backup, b_fileserver, b_setup])
|
||||||
|
|
||||||
print_table.add_row([b_date, b_domain, b_server, b_backup, b_fileserver, b_setup, b_bank_fee])
|
|
||||||
|
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
print_table.add_row(['', '', '', '', '', 'Total', round(total_amount, 2)])
|
print_table.add_row(['', '', '', '', 'Total', round(total_amount, 2)])
|
||||||
|
|
||||||
print(print_table)
|
print(print_table)
|
||||||
|
|
||||||
|
|
Loading…
Referencia en una nova incidència