114 lines
3.9 KiB
Python
114 lines
3.9 KiB
Python
import gc
|
|
|
|
class Accounting():
|
|
all_bills = []
|
|
counter = 0
|
|
def __init__(self, name:str, surname:str, room_num, key_num, period:str, bill_num:str, bill_status:bool):
|
|
print("Wird Ausgeführt")
|
|
self.name = name
|
|
self.surname = surname
|
|
self.room_num = room_num
|
|
self.key_num = key_num
|
|
self.period = period
|
|
self.bill_num = bill_num
|
|
self.bill_status = bill_status
|
|
Accounting.counter += 1
|
|
gc.get_objects()
|
|
gc.get_threshold()
|
|
|
|
def show_bill(self):
|
|
|
|
stay_period = []
|
|
num_string = ""
|
|
for i in self.period:
|
|
if i.isnumeric():
|
|
num_string += i
|
|
if i == ",":
|
|
stay_period.append(num_string)
|
|
num_string = ""
|
|
|
|
stay_period.append(num_string)
|
|
|
|
stay_period = tuple(stay_period)
|
|
# Same month
|
|
|
|
if stay_period[1] == stay_period[3]:
|
|
days = int(stay_period[0]) - int(stay_period[2])
|
|
|
|
# Across months
|
|
if stay_period[1] != stay_period[3]:
|
|
# Stay period more than 1 month
|
|
if int(stay_period[3]) - int(stay_period[1]) > 1:
|
|
days = 28 - int(stay_period[0]) + int(stay_period[2]) + \
|
|
((int(stay_period[3]) - int(stay_period[1])-1) * 28)
|
|
# Stay period
|
|
else:
|
|
days = 28 - int(stay_period[0]) + int(stay_period[2])
|
|
|
|
costs = int(days) * int(self.room_num)
|
|
|
|
"""_______________________________________________________________________"""
|
|
lines = [[] for i in range(13)]
|
|
lines[0].append( '┌─────────────────────────────┐')
|
|
lines[1].append( '│ Rechnung │')
|
|
lines[2].append( '│ │')
|
|
lines[3].append( '│Kunde: {} {} '.format(self.name, self.surname))
|
|
lines[4].append( '│Zimmer: {} '.format(self.room_num))
|
|
lines[5].append( '│Anz. Tage:{} '.format(days))
|
|
lines[6].append( '│pro Nacht:{}€ '.format(self.room_num))
|
|
lines[7].append( '│Kosten: {}€ '.format(costs))
|
|
lines[8].append( '│ ')
|
|
lines[9].append( '│Rech. Nr.:{} '.format(self.bill_num,))
|
|
lines[10].append('│Beglichen:{} '.format(self.bill_status))
|
|
lines[11].append('│ │')
|
|
lines[12].append('└─────────────────────────────┘')
|
|
|
|
for i in lines:
|
|
print(i[0])
|
|
|
|
|
|
def pay_bill(self):
|
|
self.bill_status = True
|
|
print("Rechnung", self.bill_num, "wurde bezahlt.")
|
|
|
|
|
|
def __del__(self):
|
|
print("Rechnung wurde storniert.")
|
|
|
|
|
|
#r43 = Accounting("Karl", "Otto", 16, 21,"2,3,4,5", "", False)
|
|
bill_list = []
|
|
|
|
|
|
def add_bill():
|
|
name = input("Name : ")
|
|
surname = input("Nachname :")
|
|
client_num = input("Kundennummer :")
|
|
room_num = input("Zimmernummer :")
|
|
period = input("Aufenthaltszeitraum :")
|
|
key_num = input("Schlüsselnummer :")
|
|
bill_numb = "r" + str(Accounting.counter)
|
|
|
|
c = bill_numb + " = Accounting(" + '"' + str(name) + '"' + "," + '"' + \
|
|
str(surname) + '"' + "," + '"' + str(room_num) + '"' + "," + '"' + str(key_num) \
|
|
+ '"' + "," + '"' + str(period) + '"' + "," + '"'+ str(bill_numb) + '"' + ", False)"
|
|
bill_list.append(bill_numb)
|
|
return c
|
|
|
|
def show_single_bill():
|
|
while True:
|
|
k = input("Rechnungsnummer? ")
|
|
if k in bill_list:
|
|
break
|
|
c = str(k) + ".show_bill()"
|
|
exec(c)
|
|
|
|
def delete_bill():
|
|
input_ = input("Rechnungsnummer: ")
|
|
delete = "del " + input_
|
|
exec(delete)
|
|
|
|
#while True:
|
|
# k = add_bill()
|
|
# exec(k)
|