Commit 921c982e authored by Leo Peron's avatar Leo Peron
Browse files

Updating files

parent 38fbc0f4
......@@ -52,24 +52,49 @@ def userInterface(raw: List[str]):
print("5. Modifier votre profil")
print("6. Supprimer votre profil")
pass
def accountsInterface():
print('Compte Courants:')
print('Compte Epargne:')
print('Compte Revolving:')
def displayAccount(num: int, type: str):
raws = []
if type == 'courant':
raws = req.getUserCourantAccounts(num)
for raw in raws:
print(f"ID: {raw[0]}, Solde: {raw[0]}")
elif type == 'epargne':
raws = req.getUserEpargneAccounts(num)
for raw in raws:
print(f"ID: {raw[0]}, Solde: {raw[0]}")
elif type == 'revolving':
raws = req.getUserRevolvingAccounts(num)
for raw in raws:
print(f"ID: {raw[0]}, Solde: {raw[0]}")
if not raws:
return print(f'Auncun compte {type} trouvé')
pass
def makeOperation(num: int):
pass
def addAccount(num: int):
pass
def addAccount(num: int, id: int):
result = req.addUserToAccount(num, id, 'courant')
if result:
return print("Vous avez bien été ajouté à ce compte")
else:
return print("Ce compte n'existe pas ou il vous appartient déjà")
def removeAccount(num: int):
pass
result = req.removeUserFromAccount(num, id, 'courant')
if result:
return print("Vous avez bien été retiré de ce compte")
else:
return print("Ce compte n'existe pas ou il ne vous appartient pas")
def modifyProfile(num: int):
......
......@@ -59,6 +59,7 @@ class Requests:
)
return True
except sql.Error as e:
self.utils.writeLogs(e)
return False
def modifyUser(self, num: int, prenom: str, adresse: str) -> bool:
......@@ -69,6 +70,7 @@ class Requests:
)
return True
except sql.Error as e:
self.utils.writeLogs(e)
return False
def deleteUser(self, num: int) -> bool:
......@@ -76,6 +78,7 @@ class Requests:
self.cur.execute("DELETE FROM clients WHERE telephone=%s", (num,))
return True
except sql.Error as e:
self.utils.writeLogs(e)
return False
def getUserCourantAccounts(self, num: int):
......@@ -84,15 +87,32 @@ class Requests:
"SELECT * FROM appartenance WHERE client=%s INNER JOIN comptescourant ON appartenance.courant = comptescourant.id",
(num,),
)
return True
return self.cur.fetchall()
except sql.Error as e:
return False
self.utils.writeLogs(e)
return None
def getUserEpargneAccounts(self, num: int):
pass
try:
self.cur.execute(
"SELECT * FROM appartenance WHERE client=%s INNER JOIN comptesepargne ON appartenance.epargne = comptescourant.epargne",
(num,),
)
return self.cur.fetchall()
except sql.Error as e:
self.utils.writeLogs(e)
return None
def getUserRevolvingAccounts(self, num: int):
pass
try:
self.cur.execute(
"SELECT * FROM appartenance WHERE client=%s INNER JOIN comptescrevolving ON appartenance.revolving = comptesrevolving.id",
(num,),
)
return self.cur.fetchall()
except sql.Error as e:
self.utils.writeLogs(e)
return None
# CREATION DES COMPTES BANCAIRES
......@@ -106,6 +126,7 @@ class Requests:
self.addUserToAccount(num, id, "courant")
return True
except sql.Error as e:
self.utils.writeLogs(e)
return False
def createRevolvingAccount(
......@@ -120,7 +141,7 @@ class Requests:
self.addUserToAccount(num, id, "revolving")
return True
except sql.Error as e:
print(e)
self.utils.writeLogs(e)
return False
def createEpargneAccount(
......@@ -135,7 +156,7 @@ class Requests:
self.addUserToAccount(num, id, "epargne")
return True
except sql.Error as e:
print(e)
self.utils.writeLogs(e)
return False
# MODIFICATION DES COMPTES BANCAIRES
......@@ -147,6 +168,7 @@ class Requests:
)
return True
except sql.Error as e:
self.utils.writeLogs(e)
return False
def modifyRevolvingAccount(self, id: int, taux: int) -> bool:
......@@ -156,6 +178,7 @@ class Requests:
)
return True
except sql.Error as e:
self.utils.writeLogs(e)
return False
def modifyEpargneAccount(self, num: int, interet: int) -> bool:
......@@ -165,8 +188,37 @@ class Requests:
)
return True
except sql.Error as e:
self.utils.writeLogs(e)
return False
# RECUPERATION DES COMPTES BANCAIRES
def getCourantAccounts(self):
try:
self.cur.execute("SELECT * FROM comptescourant")
return self.cur.fetchall()
except sql.Error as e:
self.utils.writeLogs(e)
return False
def getEpargneAccounts(self):
try:
self.cur.execute("SELECT * FROM comptesepargne")
return self.cur.fetchall()
except sql.Error as e:
self.utils.writeLogs(e)
return False
def getRevolvingAccounts(self):
try:
self.cur.execute("SELECT * FROM comptesrevolving")
return self.cur.fetchall()
except sql.Error as e:
self.utils.writeLogs(e)
return False
# SUPPRESION D'UN COMPTE
def deleteAccount(self, id: int):
......@@ -191,7 +243,7 @@ class Requests:
self.__updateSoldById(compte, type, montant)
return True
except sql.Error as e:
print(e)
self.utils.writeLogs(e)
return False
pass
......
......@@ -4,14 +4,12 @@ from datetime import datetime as dt
class Utils:
def __init__(self):
self.logs = open('logs.txt', 'w')
pass
def loadDatas(self) -> Dict[str, str]:
with open("db_config.json", "r") as json_file:
return json.loads(json_file.read())
def hasAccount(self, id, datas):
for raw in datas:
if id in raw:
return True
return False
def writeLogs(self, message: str):
self.logs.write(f"[{dt.now()}] {str} \n")
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment