-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDev Bank.py
2257 lines (2168 loc) · 124 KB
/
Dev Bank.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python
# coding: utf-8
# In[3]:
def design(stop,design):
r=''
if design == 2:
hyphen='_'
else:
hyphen='*'
for a in range(0,stop):
r+=hyphen
print(r)
def colour(textual_data,color):
a="\033[3{};1m ".format(str(color)) #31:Red,32:Green,33:Yellow,34:Blue,35:Purple,36:Cyan,37:White
return (a+str(textual_data))
def datarep(left_side_data,right_side_data):
print("\n{0:>00}{1:>25}{2:>28}{3:>15}\n".format((colour('|',2)),(colour(left_side_data,4)),(colour(right_side_data,1)),(colour('|',2))),end='')
def center(textual_data):
print("\n{0:<15}".format(''),end='')
print("{0:>22}".format(textual_data))
def message(textual_data,time_interface):
for char in textual_data:
print(char,end='')
time.sleep(time_interface)
try:
import sys
import time
import numpy as np
import pandas as pd
from datetime import datetime,date
import math, random
import os
from getpass import getpass
import mysql.connector as sqltor
get_ipython().run_line_magic('matplotlib', 'inline')
import matplotlib.pyplot as plt
import pyautogui as pyg
from cryptography.fernet import Fernet as fr
import webbrowser
start1=True
except ImportError as err:
design(60,2)
design(60,2)
center(colour('Error Occurs while Importing Libraries\n Error: {}'.format(err),1))
design(60,2)
center(colour('Check All Libraries Presence',4))
design(60,2)
sys.exit()
start1=False
if start1 :
if os.path.exists('Boot_Memory.csv'):
pyg.alert("Boot_Memory.csv at local Path - Found \n All Opeartions Established Successfully !!\n\nNote :\n\t❖ Deletion of this file results Boot-Recovery \n\ti.e. Fresh Start by Rebuilding New Database (clearing all previous data). \n\t❖ Its path should be local with respect to Dev Bank.ipynb\n\t❖ Don't make any Changes in this file. ",'Dev Bank CRM')
start2=True ## Showing Avail. of prior created Boot_Memory.csv
else:
a=['Version','MySQL Password','Database Name','Path','Secret_Key','*CAUTION : CHANGES RESULTS ERRORs & Deletion (whole file) results Mester Reset*']
df=pd.DataFrame(a,columns=['DevBank'])
df.to_csv('Boot_Memory.csv')
pyg.alert('As Boot_Memory.csv absent\nNew Boot_Memory Established Successfully !!\n\n The System will have Master Restart/Start !!\n\nNote :\n\t❖ Deletion of this file results Boot-Recovery \n\ti.e. Fresh Start by Rebuilding New Database (clearing all previous data). \n\t❖ Its path should be local with respect to Dev Bank.ipynb\n\t❖ Don-t make any Changes in this file. ' ,'Dev Bank CRM')
start2=False
## Showing the Availab. of Database but not of Boot_Memory.csv
auth=''
acnum=''
def boot_data(index_value):
df=pd.read_csv('Boot_Memory.csv')
a=df.at[index_value,'DevBank']
return a
if start1 :
df=pd.read_csv('Boot_Memory.csv')
if df.at[0,'DevBank'] == 'Version':
df.at[0,'DevBank']= '4.1.3'
df.to_csv('Boot_Memory.csv')
design(60,2)
center(colour('Boot_Memory Found @local_path',2))
design(60,2)
time.sleep(0.2)
design(60,2)
m=getpass('♕ Provide MySQL DBMS Password│ ')
t=input('♕ Provide Any Existing Database Name│ ')
df.at[1,'DevBank']= m
df.at[2,'DevBank']= t
df.to_csv('Boot_Memory.csv')
design(60,2)
center(colour('❖ Important Points ❖',1))
design(60,2)
datarep('Types of A/C','Saving & Current')
center(colour('For Saving',4))
datarep('Min. Bal','2000')
datarep('Service Chg.','0.5%')
datarep('Min. Bal. Def. Chg.','5%')
datarep('A/C will Suspended','Bal<100')
design(60,2)
time.sleep(0.1)
center(colour('For Current',4))
datarep('Min. Bal','10000')
datarep('Service Chg.','0%')
datarep('Min. Bal. Def. Chg.','5%')
datarep('A/C will Suspended','Bal<100')
design(60,2)
time.sleep(0.1)
design(60,2)
datarep('Version',df.at[0,'DevBank'])
center(colour('Made under Supervision of',2))
center(colour('MR. Shah & Company',2))
center(colour('Mansion3058 ',4))
design(60,2)
center(colour('★ The Above Message only Shows Once ★',1))
design(60,2)
time.sleep(0.3)
#Creating a Directory for Dev BanK Files
design(60,2)
center(colour('Select Drive for Storage',4))
datarep(' Press 1 ➤','D Drive')
datarep(' Press 2 ➤','E Drive')
datarep('Any Key ➤','C Drive')
design(60,2)
c=input('● Condition Chosen │ ')
if c =='1':
p="D:/"
elif c=='2':
p="E:/"
else:
p="C:/"
d="Dev Bank"
df.at[3,'DevBank']= p
df.at[4,'Secret_Key']= fr.generate_key().decode()
df.to_csv('Boot_Memory.csv')
webbrowser.open('file:///'+p)
design(60,2)
center(colour('❖ Repositories Created Sucsfly ❖',2))
design(60,2)
time.sleep(0.2)
## Checking the Availabilities of the Directories
d="Dev Bank"
p=df.at[3,'DevBank']
path=os.path.join(p,d)
if os.path.exists(path) is False:
os.mkdir(path)
d="Report Graphs"
p_dir=p+"Dev Bank/"
path=os.path.join(p_dir,d)
if os.path.exists(path) is False:
os.mkdir(path)
d="ACC Statement"
path=os.path.join(p_dir,d)
if os.path.exists(path) is False:
os.mkdir(path)
d="Others"
path=os.path.join(p_dir,d)
if os.path.exists(path) is False:
os.mkdir(path)
## Checking the Availabilities of the Directories
##PRIVACY OCCURS HERE
fernet=fr(df.at[4,'Secret_Key']) #Creating object
def encrypt(data):
x=fernet.encrypt(data.encode())
return x.decode()
def decrypt(data):
x=fernet.decrypt(data).decode()
return x
##PRIVACY OCCURS HERE
if start1 :
try:
mycon=sqltor.connect(host="localhost",user="root",passwd=boot_data(1),database=boot_data(2))
files=mycon.cursor(buffered=True)
if start2 is False:
try:
files.execute('use devbank')
files.execute('drop database devbank;')
files.execute('create database if not exists devbank')
except sqltor.Error:
files.execute('create database if not exists devbank')
else:
files.execute('create database if not exists devbank')
files.execute('use devbank')
start3=True
except sqltor.Error as err:
start3=False
a='⚠-❌ Something went Wrong ❌-⚠ \n Database Refuse to Connect\n\n Error : {}'.format(err)
pyg.alert(a,'Dev Bank CRM')
design(60,2)
center(colour(a,1))
design(60,2)
sys.exit()
if start1 and start3 :
try:
files.execute('Select * from devcus;')
except sqltor.Error:
sql='''create table if not exists devcus(
cusid char(12) primary key,
acnum integer,
ac_type char(10),
name char(20),
passw blob,
dob date,
age int(3),
uaid bigint(20),
gender char(1),
phone bigint(20),
crdate date,
crtime time,
active tinyint(1) default 0,
balance integer
)'''
files.execute(sql)
try:
files.execute('Select * from staff;')
except sqltor.Error:
sql='''create table if not exists staff(
id char(12) primary key,
name char(20) not null ,
pasw blob,
post char(20) not null
)'''
files.execute(sql)
#Inserting Default Values into Staff Tables
files.execute("insert into staff values('arman@dev','Arman Singh','{}','manager')".format(encrypt('arman123')))
mycon.commit()
files.execute("insert into staff values('aman@dev','Aman Kaur','{}','teller')".format(encrypt('aman123')))
mycon.commit()
files.execute("insert into staff values('rahul@dev','Rahul Kumar','{}','cashier')".format(encrypt('rahul123')))
mycon.commit()
try:
files.execute('Select * from acstatement;')
except sqltor.Error:
sql='''create table if not exists acstatement(
cusid char(12),
description varchar(50),
chqnum varchar(20) default '0',
Withdrawn varchar(20) default '----',
Deposit varchar(20) default '----',
trandate date,
trantime time,
operation char(10),
balance varchar(20)
)'''
files.execute(sql)
try:
files.execute('Select * from atm;')
except sqltor.Error:
sql='''create table if not exists atm(
cusid char(12),
atmnumber varchar(20),
date timestamp default current_timestamp,
pin blob,
status char(12) default 'Active'
)'''
files.execute(sql)
try:
files.execute('Select * from application;')
except sqltor.Error:
sql='''create table if not exists application(
cusid char(12),
application varchar(20),
date timestamp default current_timestamp,
status char(12) default 'Unaccepted'
)'''
files.execute(sql)
try:
files.execute('Select * from blocktrans;')
start3=True
except sqltor.Error:
sql='''create table if not exists blocktrans(
cusid char(12),
cheqnum char(12),
date timestamp default current_timestamp
)'''
files.execute(sql)
message('Welcome to Dev Bank CRM (Customer Relation Management) System',0.2)
print()
while True:
def vals(data):
if data !='' and data!=' ':
if data.isalpha():
return True
else:
design(50,1)
center(colour("❌ Enter Data is Not valid ❌\n",1))
design(50,1)
else:
design(50,1)
center(colour("❌ Null Value unacceptable ❌\n",1))
design(50,1)
def valn(data):
if data.isdigit() :
return True
else:
design(60,2)
center(colour('❌ Given Number is not valid ❌',1))
design(60,2)
def nonzero(numeric_data_in_string_form):
if numeric_data_in_string_form[0] != '0':
return True
else:
design(60,2)
center(colour('❌ Zero at First place Unacceptable ❌',1))
design(60,2)
def valcon(data,length_condition):
if len(data) == length_condition:
return True
else:
design(60,2)
center(colour('❌ Given Argument Unacceptable ❌',1))
design(60,2)
def alpha(numeric_data):
num=["","One","Two","Three","Four","Five","Six","Seven","Eight","Nine"]
tens=["Ten","Eleven","Tweleve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"]
nty=["","","Twenty","Thirty","Fourty","Fifty","Sixty","Seventy","Eighty","Ninety"]
wrd=""
r=1
numeric_data=str(numeric_data)
if numeric_data[0]!="0":
if len(numeric_data)==7:
if numeric_data[0]=="1":
wrd+=tens[int(numeric_data[1])]+ " Lakhs "
numeric_data=numeric_data[2::]
while int(numeric_data[0])==0 and r<5:
numeric_data=numeric_data[1::]
r=r+1
else:
wrd+=nty[int(numeric_data[0])]+ " "+num[int(numeric_data[1])] + " Lakhs "
numeric_data=numeric_data[2::]
while int(numeric_data[0])==0 and r<5:
numeric_data=numeric_data[1::]
r=r+1
if len(numeric_data)==6:
wrd+=num[int(numeric_data[0])]+ " Lakhs "
numeric_data=numeric_data[1::]
while int(numeric_data[0])==0 and r<5:
numeric_data=numeric_data[1::]
r=r+1
if len(numeric_data)==5:
if numeric_data[0]=="1":
wrd+=tens[int(numeric_data[1])]+ " Thousand "
numeric_data=numeric_data[2::]
else:
wrd+=nty[int(numeric_data[0])]+ " "+num[int(numeric_data[1])] + " Thousand "
numeric_data=numeric_data[2::]
if len(numeric_data)==4:
wrd+=num[int(numeric_data[0])]+" Thousand "
numeric_data=numeric_data[1::]
if len(numeric_data)==3:
if numeric_data[0]!="0":
wrd+=num[int(numeric_data[0])]+" Hundred "
numeric_data=numeric_data[1::]
else:
numeric_data=numeric_data[1::]
if len(numeric_data)<=2:
if len(numeric_data)==1:
wrd+=num[int(numeric_data)]
elif int(numeric_data)<20:
if numeric_data[0]=="0":
wrd+=num[int(numeric_data[1])]
else:
wrd+=tens[int(numeric_data[1])]
else:
wrd+=str(nty[int(numeric_data[0])])+" "+str(num[int(numeric_data[1])])
else:
design(60,2)
center(colour("Out of Range 9999999",1))
design(60,2)
return wrd
def unique(column,data):
df=usdetails('staff','a')
if df.empty is False:
for a in df[column]:
if a==data:
break
return False
else:
return True
else:
return True
def usdetails(author,cusid):
if author=='staff':
if cusid!='a':
files.execute("select cusid,acnum,ac_type,name,dob,uaid,age,phone,active,balance from devcus where cusid = '{}' ".format(cusid))
dt=files.fetchall()
df=pd.DataFrame(dt,columns=["Cust ID","A/C_Num","A/C Type","Name","DOB","UAID (Aadhar No.)","Age","Phone","Status","Balance"])
df.set_index('Cust ID',inplace=True)
return df
elif cusid=='a':
files.execute("select cusid,acnum,ac_type,name,dob,uaid,age,phone,active,balance from devcus")
dt=files.fetchall()
df=pd.DataFrame(dt,columns=["Cust ID","A/C_Num","A/C Type","Name","DOB","UAID (Aadhar No.)","Age","Phone","Status","Balance"])
df.set_index('Cust ID',inplace=True)
return df
elif author=='cus':
files.execute("select cusid,acnum,ac_type,name,dob,uaid,age,gender,phone,crdate,crtime,balance from devcus where cusid = '{}' ".format(cusid))
dt=files.fetchall()
df=pd.DataFrame(dt,columns=["Cust ID","A/C_Num","A/C Type","Name","DOB","UAID (Aadhar No.)","Age","M/F","Phone", "Admisn.Date","Admisn.Time","Balance"])
df.set_index('Cust ID',inplace=True)
return df
else:
files.execute("select * from devcus where cusid = '{}' ".format(cusid))
dt=files.fetchall()
df=pd.DataFrame(dt,columns=["Cust ID","A/C_Num","A/C Type","Name","key","DOB","Age","UAID (Aadhar No.)","M/F","Phone","Admisn.Date","Admisn.Time","Status","Balance"])
df.set_index('Cust ID',inplace=True)
return df
def hasatm():
files.execute("select cusid,atmnumber,date,status from atm ")
dt=files.fetchall()
df=pd.DataFrame(dt,columns=["Cust ID","ATM Card No.","Applied Date","Status"])
df.set_index('Cust ID',inplace=True)
return df
def applatm(cusid):
df=hasatm()
if cusid in df.index:
design(60,2)
center(colour('❖ You already have ATM Card ❖',4))
design(60,2)
else:
design(60,2)
center(colour('★ Pin should be = 4 digit ★',1))
cn=getpass('➤ Enter Pin for Your ATM Card │ ')
if valn(cn) and valcon(cn,4):
design(60,2)
acnum=''
digits = "989006500058525800"
for i in range(10):
acnum+=digits[math.floor(random.random() * 10)]
acnum='3058'+acnum
files.execute("insert into atm(cusid,atmnumber,pin,status) values(%s,%s,%s,%s)" ,(cusid,acnum,encrypt(cn),'Unactive'))
mycon.commit()
files.execute("insert into application(cusid,application) values(%s,%s)" ,(cusid,'ATM '+acnum))
mycon.commit()
design(60,2)
pyg.alert('Application Submitted Successfully','Dev CRM -'+str(cusid))
center(colour('❖ Application Submitted Successfully ❖',2))
datarep('ATM No.',acnum)
center(colour('For ATM Card visit Bank',2))
design(60,2)
def atmdetails():
files.execute("select * from atm")
dt=files.fetchall()
df=pd.DataFrame(dt,columns=["Cust ID","ATM Number","Date","Pin","Status"])
df.set_index('Cust ID',inplace=True)
return df
def leave(cusid):
design(60,2)
center(colour('✌ Thanks for Visit ✌ ',2))
datarep('User Id ➤',cusid)
t=datetime.now()
datarep('Leave at ➤',t.strftime("%H:%M:%S"))
center(colour(d.strftime("%A, %B %d"),4))
center(colour('★ Have a Good Day ★',2))
design(60,2)
time.sleep(0.2)
def status(cusid,category):
if category=='Account':
df=usdetails('staff',cusid)
if df.at[cusid,'Status'] == 1:
return True
else:
return False
elif category=='ATM':
df=hasatm()
if df.at[cusid,'Status'] == 'Unactive':
return False
else:
return True
else:
df=appldetails()
if df.at[cusid,'Status'] == 'Unaccepted':
return False
else:
return True
def appldetails():
files.execute("select * from application")
dt=files.fetchall()
df=pd.DataFrame(dt,columns=["Cust ID","Application","Date","Status"])
df.set_index('Cust ID',inplace=True)
return df
def updstatus(cusid,category,active_or_not):
if category=='Account':
files.execute("update devcus set active='{}' where cusid='{}'".format(active_or_not,cusid))
mycon.commit()
design(60,2)
center(colour("❖ Changes made Successfully ❖",2))
design(60,2)
design(60,2)
datarep('Current Status ➤',active_or_not)
design(60,2)
elif category=='ATM':
files.execute("update atm set status='{}' where cusid='{}'".format(active_or_not,cusid))
mycon.commit()
design(60,2)
center(colour("❖ Changes made Successfully ❖",2))
design(60,2)
design(60,2)
datarep('Current Status ➤',active_or_not)
design(60,2)
else:
if status(cusid,'Appl') is False:
files.execute("update application set status='{}' where cusid='{}'".format(active_or_not,cusid))
mycon.commit()
design(60,2)
center(colour("❖ Apllication Accepted Successfully ❖",2))
design(60,2)
else:
design(60,2)
center(colour("❖ Apllication Already Accepted ❖",1))
center(colour(" ✌ No Changes Detected ✌ ",2))
design(60,2)
def is_date(date_in_string_format):
format = "%Y-%m-%d"
try:
datetime.strptime(date_in_string_format, format)
return True
except ValueError:
return False
def acstatement(x,p):
design(60,2)
cn=input('(OPTIONAL) Statement From the Date(format : YYYY-MM-DD) of│ ')
if is_date(cn) == False:
files.execute("select description,chqnum,Withdrawn,Deposit,trandate,trantime,balance from acstatement where cusid = '{}' ".format(x))
else:
files.execute("select description,chqnum,Withdrawn,Deposit,trandate,trantime,balance from acstatement where cusid = '{}' and trandate >= '{}' ".format(x,cn))
dt=files.fetchall()
df=pd.DataFrame(dt,columns=["Description","ChqNum.","Dr.Amt","Cr.Amt","Transaction Date","Transaction Time","Balance"])
df.set_index('Transaction Date',inplace=True)
if df.empty is not True:
design(60,2)
t='Cusid : '+x
center(colour(t+'A/C Statement ',5))
d=datetime.now()
if is_date(cn) :
datarep('From ',cn)
datarep('To ',str(d)[:19:])
else:
datarep('As on ',str(d))
design(60,2)
print(df)
design(60,2)
time.sleep(0.2)
if p!='s':
graph(df,cn)
design(60,2)
cn=input('\n➤ Want to Save this Data 【y/n】 │ ')
if cn == 'Y' or cn=='y':
if p!='s':
design(60,2)
datarep('Press 1 ➤','Statement')
datarep('Press 2 ➤','Graph')
datarep('Press 3 ➤','Both')
datarep('Any Key ➤',' Back')
design(60,2)
c=input('\n● Condition Chosen │ ')
if c == '1':
save(df,'ac')
design(60,2)
elif c == '2':
graph(df,'y')
design(60,2)
elif c == '3':
design(60,2)
center(colour('❖ For Statement ❖',5))
save(df,'ac')
design(60,2)
center(colour('❖ For Graphical Data ❖',5))
design(60,2)
graph(df,'y')
design(60,2)
else:
design(60,2)
center(colour('✤ Back to Menu ✤',4))
design(60,2)
else:
(df,'other')
else:
design(60,2)
center(colour('✤ Proposal Rejected ✤',6))
design(60,2)
else:
design(60,2)
center(colour('✤ No Record Found ✤',4))
design(60,2)
return df
def graph(df,f):
l1=[]
l2=[]
clr=[]
xa=df.index
xa=xa.values
y=df['Balance']
y=y.values
for a in range(len(xa)):
l1.append(a+1)
l2.append(float(y[a]))
if acty(x,0) == 'saving':
if l2[a] < 2000 :
clr.append('r')
elif l2[a] == 2000 or l2[a] < 4000:
clr.append('b')
else:
clr.append('g')
else:
if l2[a] < 10000 :
clr.append('r')
elif l2[a] == 10000 or l2[a] < 20000:
clr.append('b')
else:
clr.append('g')
plt.figure(figsize=(10,5))
plt.grid(True)
d=datetime.now()
if is_date(f) :
cn=f+' to '+ str(d)
plt.title('Change in Balance from '+cn)
plt.xlabel(cn)
else:
plt.title('Change in Balance as on'+str(d)[:19:])
plt.xlabel('Interval of Time')
plt.ylabel('Balance in Rupees')
plt.bar(l1,l2,color=clr)
if f == 'y':
design(60,2)
b=input('\n➤ Enter the Name for Document │ \t ')
design(60,2)
d=boot_data(3)+'Dev Bank\Report Graphs'
p=os.path.join(d,b+'.pdf')
if os.path.exists(p):
design(60,2)
center(colour('【 File Name Already Exists 】',1))
design(60,2)
design(60,2)
a=input('\n➤ Want to Replace or Overwrite ? 【y/n】 │ ')
design(60,2)
if vals(a) :
if a=='y' or a=='Y':
d=date.today()
t=datetime.now()
n='Balances Report till ' + t.strftime("%H:%M:%S")+ ' ' + str(d) + ' Dev Bank ID :- ' + x
plt.title(n)
plt.savefig(p)
center(colour('❖ Graph Save Successfully ❖',2))
datarep('Document Name ➤',b+'.pdf')
datarep('Path ➤ ',p)
p=os.path.join(boot_data(3)+'Dev%20Bank/Report%20Graphs/',b+'.pdf')
webbrowser.open('file:///'+p)
design(60,2)
else:
design(60,2)
center(colour('❖ Try Again with Different Name ❖',4))
design(60,2)
else:
plt.savefig(p)
center(colour('❖ Graph Save Successfully ❖',2))
datarep('Document Name ➤ ',b+'.pdf')
datarep('Path ➤ ',p)
p=os.path.join(boot_data(3)+'Dev%20Bank/Report%20Graphs/',b+'.pdf')
webbrowser.open('file:///'+p)
design(60,2)
else:
plt.show()
def amountstatus(x,a,c,b):
while True:
if c == 'aa' or c=='ac':
if c =='aa':
files.execute("select description,chqnum,Deposit,trandate,trantime from acstatement where deposit={} and cusid = '{}' and operation = 'Add' ".format(a,x))
dt=files.fetchall()
break
else:
files.execute("select description,chqnum,Deposit,trandate,trantime from acstatement where chqnum={} and cusid = '{}' and operation = 'Add'".format(a,x))
dt=files.fetchall()
break
else:
if c == 'wa':
files.execute("select description,chqnum,Withdrawn,trandate,trantime from acstatement where withdrawn={} and cusid = '{}' and operation = 'Less' ".format(a,x))
dt=files.fetchall()
break
else:
files.execute("select description,chqnum,Withdrawn,trandate,trantime from acstatement where chqnum={} and cusid = '{}' and operation = 'Less' ".format(a,x))
dt=files.fetchall()
break
if dt == []:
design(60,2)
center(colour('❖ No Such Transaction Found ❖',1))
design(60,2)
else:
df=pd.DataFrame(dt,columns=["Reference description","Cheq No.","Amount","Transaction Date","Transaction Time"])
df.set_index('Reference description',inplace=True)
return print(df)
def cheqnum(x,c):
files.execute("select chqnum,description from acstatement where cusid = '{}' and operation ='Less';".format(x))
dt=files.fetchall()
df=pd.DataFrame(dt,columns=["Cheq No.","description"])
df.set_index('Cheq No.',inplace=True)
if c in df.index :
design(60,2)
center(colour('☛ Cheque already in System',1))
center(colour('❖ Changes unmade Yet ❖',4))
design(60,2)
else:
return True
def blcdup(x,c):
files.execute("select cheqnum,date from blocktrans where cusid = '{}'".format(x))
dt=files.fetchall()
df=pd.DataFrame(dt,columns=["Cheq No.","Date"])
df.set_index('Cheq No.',inplace=True)
if c in df.index :
design(60,2)
center(colour('☛ Cheque already Blocked',1))
center(colour('❖ Changes unmade Yet ❖',4))
design(60,2)
else:
return True
def chcid(x):
if x!='' and x!=' ':
op=x[::-1]
p=1
if op[0]=='v':
df1=staffdetails()
if x in df1.index:
return True,'staff'
else:
design(60,1)
center(colour('✋【Unauthenticated】 Id has given ✋\n',1))
design(60,1)
return False,'staff'
elif x[0]=='d':
df1=usdetails('staff','a')
if x in df1.index:
return True,'cus'
else:
design(60,1)
center(colour('✋【Unauthenticated】 Id has given ✋\n',1))
design(60,1)
return False,'cus'
else:
design(60,1)
center(colour('✋【Unauthenticated】 Id has given ✋\n',1))
design(60,1)
return False,'cus'
else:
design(60,1)
center(colour('✋【Unauthenticated】 Id has given ✋\n',1))
design(60,1)
return False,'staff'
def staffdetails():
files.execute('select * from staff')
d=files.fetchall()
df1=pd.DataFrame(d,columns=['id','name','key','post'])
df1.set_index('id',inplace=True)
return df1
def login(x,y,z):
if y == 'staff':
df=staffdetails()
if decrypt(df.at[x,'key']) == z:
return True
else:
design(60,2)
datarep('Paswrd is【Wrong】as ID',x)
design(60,2)
else:
df=usdetails('login',x)
if decrypt(df.at[x,'key']) == z:
return True
else:
design(60,2)
datarep('Paswrd is【Wrong】as ID',x)
design(60,2)
def chcauth(x,y):
df1=staffdetails()
if y=='addcus' or y=='updcus':
if df1.at[x,'post'] == 'manager' or df1.at[x,'post'] == 'teller':
return True
else:
pyg.alert('☛ Authorisation Error\n● You Are not Authorised for this Task','Dev CRM - '+str(x))
print('Your are NOT AUTHORISED for this fuction.')
elif y=='updcash':
if df1.at[x,'post'] == 'manager' or df1.at[x,'post'] == 'cashier':
return True
else:
pyg.alert('☛ Authorisation Error\n● You Are not Authorised for Updating Balances of Customers.','Dev CRM - '+str(x))
print('☛ Your are NOT AUTHORISED for updating Cash Balances.')
def acty(x,y):
if y == 0:
df=usdetails('staff',x)
return df.at[x,'A/C Type']
else:
df=usdetails('staff',x)
ty=df.at[x,'A/C Type']
if ty=='saving':
files.execute("update devcus set ac_type='{}' where cusid='{}'".format('current',x))
mycon.commit()
else:
files.execute("update devcus set ac_type='{}' where cusid='{}'".format('saving',x))
mycon.commit()
def phnchg(x):
df=usdetails('staff',x)
p=df.at[c,'Phone']
design(60,2)
datarep('At Present',p)
design(60,2)
d=input('➤ Want to Change Number of Customer 【y/n】 │ ')
if d=='y' or d=='Y':
phn=input('☛ New Phone Number \t │')
if valn(phn) and valcon(phn,10) and nonzero(phn) :
phn=int(phn)
files.execute("update devcus set phone='{}' where cusid='{}'".format(phn,x))
mycon.commit()
return True
else:
design(60,2)
center(colour('❖ Changes unmade Yet ❖',4))
design(60,2)
def cusbal(x):
df=usdetails('staff',x)
return df.at[x,'Balance']
def blchq(x,c):
if c == 'b':
d=input('➤ Want to Block Any Transaction Continue 【y/n】 │ ')
if d == 'y' or d=='Y':
design(60,2)
d=input('\n➤ Enter Cheque Number │ ')
if valn(d) and nonzero(d) :
if cheqnum(x,d) :
if blcdup(x,d) :
files.execute("insert into blocktrans(cusid,cheqnum) values(%s,%s)",(x,d))
mycon.commit()
design(60,2)
t='Blocking Successfully for \n' + 'Cheque No. '+str(d)
pyg.alert(t,'Dev CRM - '+str(x))
center(colour('Changes made Successfully',2))
design(60,2)
else:
design(60,2)
center(colour('❖ Changes unmade Yet ❖',4))
design(60,2)
else:
if c=='h':
files.execute("select * from blocktrans where cusid='{}'".format(x))
else:
files.execute("select * from blocktrans where cusid = '{}' and cheqnum = '{}'".format(x,c))
d=files.fetchall()
df1=pd.DataFrame(d,columns=['ID','Cheq No.','Entered Date'])
df1.set_index('Cheq No.',inplace=True)
return df1
def pswpwr(x):
if len(x)>=6:
if x.isalpha():
design(60,2)
center(colour("✤ Password Status : 【Too Weak】✤",1))
design(60,2)
elif x=="" or x==" ":
design(60,2)
center(colour("✤ Password Status : 【Null】 ✤",1))
design(60,2)
else:
return True
else:
design(60,2)
center(colour("✤ Password must >= 6 digit ✤ ",1))
design(60,2)
def pswmatch(x,y):
if x==y:
return True
else:
design(60,2)
center(colour('✤ Password Not Match ✤',1))
design(60,2)
def changepsw(x,y,z,forget):
design(60,2)
ph=''
x=decrypt(x)
if forget==False:
ph=getpass('\n➤ Current Password/PIN │ \t ')
design(60,2)
if ph == x:
if z==1 or z==0:
design(60,2)
print('Password must have 6 digits including at least ')
datarep('1','Number')
datarep('1','capital char')
design(60,2)
design(60,2)
ph=getpass('\n➤ New Password │ \t ')
if pswpwr(ph) :
ph2=getpass('➤ Confirm Password │ \t ')
design(60,2)
if pswmatch(ph,ph2) :
if z == 1: #if Z==1 it means Staff Password Conversion else of Customer
files.execute("update staff set pasw ='{}' where id='{}'".format(encrypt(ph),y))
mycon.commit()
pyg.alert('❖ Password Sets Successfully ❖','Dev Staff - '+str(y))
design(60,2)
center(colour('❖ Password Sets Successfully ❖',2))
design(60,2)
elif z == 0:
files.execute("update devcus set passw ='{}' where cusid='{}'".format(encrypt(ph),y))
mycon.commit()
pyg.alert('❖ Password Sets Successfully ❖','Dev CRM - '+str(y))
design(60,2)
center(colour('❖ Password Sets Successfully ❖',2))
design(60,2)
else:
design(60,2)
center(colour('★ PIN must have 4 digits ★',1))
design(60,2)
ph=getpass('\n➤ New PIN │ \t ')
if valn(ph) :
if valcon(ph,4) :
ph2=getpass('➤ Confirm PIN │ \t ')
design(60,2)
if pswmatch(ph,ph2) :
files.execute("update atm set pin ='{}' where cusid='{}'".format(encrypt(ph),y))
mycon.commit()
pyg.alert('❖ Pin Change Successfully ❖','Dev CRM - '+str(y))
design(60,2)
center(colour('❖ Pin Change Successfully ❖',2))
design(60,2)
else:
design(60,2)
center(colour('❖ Pssword/PIN is unmatched ❖ ',1))
design(60,2)
def chcbal(x,y):
if y == 'saving':
if x >= 2000 and x < 1000000:
return True
else:
center(colour('Saving A/C Initial Bal.',4))
datarep('★ I.Bal >= 2000 ','I.Bal < 10 Lakh ★')
elif y =='current':
if x >= 10000 and x < 10000000:
return True
else:
center(colour('Current A/C Initial Bal.',4))
datarep('★ I.Bal >= 10000 ','I.Bal < 1 Crore ★')
def amtmang(i,b,v,a,p,c):
files.execute("update devcus set balance ='{}' where cusid='{}'".format(b,i))
mycon.commit()
if p=='Add':
files.execute("insert into acstatement(cusid,description,chqnum,Deposit,operation,trandate,trantime,balance) values(%s,%s,%s,%s,%s,%s,%s,%s)" ,(i,v,c,a,p,dt()[0],dt()[1],str(b)))
else:
files.execute("insert into acstatement(cusid,description,chqnum,Withdrawn,operation,trandate,trantime,balance) values(%s,%s,%s,%s,%s,%s,%s,%s)" ,(i,v,c,a,p,dt()[0],dt()[1],str(b)))
mycon.commit()
if v != 'Def.Chg. 5%' and v!='Service Chg. 0.5%':
if '+Trf By' not in v :
chcdef(i,b,a)