Skip to content

Merge shorten-the-code to main #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Jan 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
2 methods added for clients
  • Loading branch information
OJASisLive committed Dec 30, 2022
commit a8240058caa4674e65eed74dcf8172d60ce49c9e
Binary file added photos/cash_in_hand.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions src/main/OmJShah/client/depositmoney.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from tools import dataentering
def cp2(conn,cur,acc_type,acc_no):
cur.execute("select cash_in_hand from cash_in_hand where acc_no={}".format(acc_no))
cash_in_hand=cur.fetchall()
if cash_in_hand==[]:
query="insert into cash_in_hand values(%s,0)"
data=(acc_no,)
done=dataentering.tableupdate(conn,cur,query,data)
if done:
cash_in_hand=0
else:
print("Unable to figure out your cash in hand values.")
else:
cash_in_hand=cash_in_hand[0][0]

deposit_amt=dataentering.amounts("deposit",cash_in_hand,acc_type)
if deposit_amt:
query2="update {} set balance = balance+{} where acc_no = %s".format(acc_type,deposit_amt)
data2=(acc_no,)
done2=dataentering.tableupdate(conn,cur,query2,data2)
if done2:
query3="update cash_in_hand set cash_in_hand = cash_in_hand-%s where acc_no = %s"
data3=(cash_in_hand,acc_no)
done3=dataentering.tableupdate(conn,cur,query3,data3)
if done3:
print("Deposit of {} currency successful".format(deposit_amt))
print()
else:
query2="update {} set balance = balance-{} where acc_no = %s".format(acc_type,deposit_amt)
data2=(acc_no,)
done2=dataentering.tableupdate(conn,cur,query2,data2)
if done2:
print("Unable to subtract amount from cash_in_hand\n")
else:
print("Error while trying to add amount to balance.\n")
else:
pass
13 changes: 13 additions & 0 deletions src/main/OmJShah/client/redeemcode.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from tools import dataentering
def cp4(conn,cur,acc_type,acc_no):
rc=input("Enter redeem code: ")
if rc=="TESTREDEEMCODE":
query="update {} set balance = balance+%s where acc_no = %s".format(acc_type)
data=(5000,acc_no)
done = dataentering.tableupdate(conn,cur,query,data)
if done:
print("Added 5000 currency to your account!!")
else:
print("There was a problem while processing the request")
else:
print("Sorry! This redeem code doesn't work")
10 changes: 9 additions & 1 deletion src/main/OmJShah/initialization/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@
") "
)

TABLES['cash_in_hand']=(
"CREATE TABLE `cash_in_hand` ("
" `acc_no` int(5) NOT NULL,"
" `cash_in_hand` int NOT NULL,"
" PRIMARY KEY (`acc_no`)"
") "
)


############################################################################################
query=""
Expand Down Expand Up @@ -143,7 +151,7 @@ def querycheck():
print(err.msg)
else:
print("OK")
if existing==7:
if existing==8:
with open("firsttime.txt","w") as f:
f.write("False")
ans=True
Expand Down
13 changes: 8 additions & 5 deletions src/main/OmJShah/panels/clientpanel.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from tools import dataentering
from client import redeemcode
from client import depositmoney
def cp(conn,cur):
print("\n------------------Client Panel------------------")
print("Welcome client!!")
Expand Down Expand Up @@ -26,11 +28,12 @@ def cmenu(conn,cur,acc_no,acc_type):
print("1.Show Balance")
print("2.Deposit money")
print("3.Withdraw money")
print("4.Redeem Code")
if acc_type=='savings':
print("4.Ask for loan")
print("5.Check loan status")
print("5.Ask for loan")
print("6.Check loan status")
else:
print("4.Check overdraft status")
print("5.Check overdraft status")
print("~ to quit")
choice=input("Enter your choice: ")
if choice=="~": pass
Expand All @@ -40,11 +43,11 @@ def cmenu(conn,cur,acc_no,acc_type):
print("Your balance is: ",balance[0][0])
print()
elif choice=="2":
pass
depositmoney.cp2(conn,cur,acc_type,acc_no)
elif choice=="3":
pass
elif choice=="4":
pass
redeemcode.cp4(conn,cur,acc_type,acc_no)
elif choice=="5":
pass
else:
Expand Down
30 changes: 29 additions & 1 deletion src/main/OmJShah/tools/dataentering.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,32 @@ def balance():
if bank_balance>=1000:
return bank_balance
else:
print("Minimum balance is 1000 currency")
print("Minimum balance is 1000 currency")

#Withdraw amount and Deposit amount
def amounts(deposit_or_withdraw,cash_in_hand,acc_type):
while True:
print()
print("--------------------{} screen-------------------")
amt=input("Enter amount to {}: ".format(deposit_or_withdraw))
try:
amt=int(amt)
print("Done OK")
except ValueError:
print("{} amount should be an integer!!".format(deposit_or_withdraw))
else:
if amt<cash_in_hand:
return amt
else:
if deposit_or_withdraw=="withdraw":
if acc_type=="current":
overdraft=amt-cash_in_hand
if (overdraft) <= 50000:
return amt,overdraft,bool(True)
else:
return bool(False)
else:
print("You do not have enough balance\n")
else:
print("You do not have sufficient cash_in_hand\n")
return bool(False)