Added bank fee
This commit is contained in:
pare
b9819edd5e
commit
de08291d20
S'han modificat 1 arxius amb 29 adicions i 16 eliminacions
43
budget.py
43
budget.py
|
@ -61,6 +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:
|
||||||
|
|
||||||
|
@ -82,7 +83,7 @@ class Bill:
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
|
|
||||||
sql = "INSERT INTO bills(datetime, domain, server, backup, fileserver, setup) VALUES(%s,%s,%s,%s,%s,%s)"
|
sql = "INSERT INTO bills(datetime, domain, server, backup, fileserver, setup, bank_fee) VALUES(%s,%s,%s,%s,%s,%s,%s)"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
|
@ -90,7 +91,7 @@ class Bill:
|
||||||
|
|
||||||
cur = conn.cursor()
|
cur = conn.cursor()
|
||||||
|
|
||||||
cur.execute(sql, (self.date, self.domain, self.server, self.backup, self.fileserver, self.setup))
|
cur.execute(sql, (self.date, self.domain, self.server, self.backup, self.fileserver, self.setup, self.bank_fee))
|
||||||
|
|
||||||
print("\nUpdating bills...")
|
print("\nUpdating bills...")
|
||||||
|
|
||||||
|
@ -224,17 +225,19 @@ 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 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, bank_fee 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 from bills where date_part('year', datetime) = (%s) order by 1 asc"
|
sql = "select datetime, domain, server, backup, fileserver, setup, bank_fee 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 from bills order by 1 asc"
|
sql = "select datetime, domain, server, backup, fileserver, setup, bank_fee from bills order by 1 asc"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
|
@ -266,6 +269,14 @@ class BillShow:
|
||||||
|
|
||||||
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()
|
||||||
|
|
||||||
except (Exception, psycopg2.DatabaseError) as error:
|
except (Exception, psycopg2.DatabaseError) as error:
|
||||||
|
@ -278,7 +289,7 @@ class BillShow:
|
||||||
|
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
return (month_date, month_domain, month_server, month_backup, month_fileserver, month_setup)
|
return (month_date, month_domain, month_server, month_backup, month_fileserver, month_setup, month_bank_fee)
|
||||||
|
|
||||||
class DonationShow:
|
class DonationShow:
|
||||||
|
|
||||||
|
@ -438,19 +449,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)) 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) + coalesce(bank_fee,0)) 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)) from bills 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)"
|
||||||
|
|
||||||
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)) from bills"
|
bills_sql = "select sum(coalesce(domain) + coalesce(server) + coalesce(backup) + coalesce(fileserver) + coalesce(setup) + coalesce(bank_fee,0)) from bills"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
|
@ -560,7 +571,7 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
bill = Bill()
|
bill = Bill()
|
||||||
|
|
||||||
if bill.domain == bill.server == bill.backup == bill.fileserver == bill.setup == 0.0:
|
if bill.domain == bill.server == bill.backup == bill.fileserver == bill.setup == bill.bank_fee == 0.0:
|
||||||
|
|
||||||
print('\nAny bill added')
|
print('\nAny bill added')
|
||||||
|
|
||||||
|
@ -574,13 +585,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 = bill.show(bill.criteria)
|
month_date, month_domain, month_server, month_backup, month_fileserver, month_setup, month_bank_fee = 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']
|
print_table.field_names = ['Date', 'Domain', 'Server', 'Backup', 'File server', 'Setup', 'Bank fee']
|
||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
|
|
||||||
|
@ -600,13 +611,15 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
b_setup = float(month_setup[i])
|
b_setup = float(month_setup[i])
|
||||||
|
|
||||||
total_amount = total_amount + b_domain + b_server + b_backup + b_fileserver + b_setup
|
b_bank_fee = float(month_bank_fee[i])
|
||||||
|
|
||||||
print_table.add_row([b_date, 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, 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