-
Notifications
You must be signed in to change notification settings - Fork 0
/
NWM_AML.py
217 lines (180 loc) · 7.51 KB
/
NWM_AML.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
#!/usr/bin/env python
# coding: utf-8
#import plotly.graph_objects as go
from PyQt5 import QtWidgets, uic
from PyQt5 import QtGui
from PyQt5.QtCore import Qt
import json
from Account import Account
from AML import AML
import datetime
import matplotlib.pyplot as plt
def accountDetails():
outputWindow.show()
account1 = Account(str(checkAccountBox.text()))
opDict=account1.getAccountDetails()
op=open('Account_Details.html').read()
op=op.replace('idVal',opDict['AccountID'])
op=op.replace('typeVal',opDict['Account Type'])
op=op.replace('nameVal',opDict['Customer Name'])
op=op.replace('balanceVal',opDict['Balance'])
outputWindow.setHtml(op)
def validationCheck(paymentDetails):
if(limitCheck.isChecked()):
open('Limit_Check.txt','w').write("Yes")
else:
open('Limit_Check.txt','w').write("No")
if(countryCheck.isChecked()):
open('Country_Check.txt','w').write("Yes")
else:
open('Country_Check.txt','w').write("No")
if(userCheck.isChecked()):
open('User_Check.txt','w').write("Yes")
else:
open('User_Check.txt','w').write("No")
account = Account(paymentDetails['BeneficiaryAcc'])
aml = AML(account.getAccountDetailsAML(paymentDetails['Amount'], paymentDetails['Currency']))
return aml.validateAml();
def transactionDetails():
outputWindow.show()
account1 = Account(str(checkAccountBox.text()))
opList=account1.getTransactions()
noOfTr=len(opList)
#op=open('Table_Header.html','r').read()
#rowHtml=open('Table_Row.html','r').read()
dates=[]
y_vals=[]
for row in range(noOfTr):
dates.append(opList[row]['TransactionDate'])
balVal=(opList[row]['Balance Amount']).split(" ")
y_vals.append(float(balVal[0]))
x_vals = [datetime.datetime.strptime(d,"%d-%m-%Y").date() for d in dates]
#formatter = mdates.DateFormatter("%Y-%m-%d")
#formatter = mdates.DateFormatter("%Y-%m-%d")
#formatter = mdates.DateFormatter("%Y-%m-%d")
#formatter = mdates.DateFormatter("%Y-%m-%d")
#fig = go.Figure(data=go.Scatter(x=x_vals, y=y_vals))
#fig.update_layout(title='Balance Trend for Account No. '+str(checkAccountBox.text()),
# xaxis_title='Dates',
# yaxis_title='Balance (in '+str(balVal[1])+')')
#fig.show()
#fig.write_image("graph.png")
fig=plt.figure()
fig.suptitle('Balance Trend for Account No. '+ str(checkAccountBox.text()))
plt.xlabel('Dates')
plt.ylabel(str(balVal[1]))
plt.xticks(rotation=30)
plt.plot(x_vals, y_vals)
plt.savefig('graph.png')
# op+=rowHtml
# op=op.replace('ITEM1',opList[row]['TransactionId']).replace('ITEM2',opList[row]['Status']).replace('ITEM3',opList[row]['Type']).replace('ITEM4',opList[row]['Transaction Amount']).replace('ITEM5',opList[row]['Balance Amount'])
#op+="</tbody> </table> <p> </p>"
#outputWindow.setHtml(op)
outputWindow.setHtml(open('Graph.html','r').read())
def getBalanceTrend():
op=open('Graph.html','r').read()
outputWindow.show()
outputWindow.setHtml(op)
def transactionDetailss():
outputWindow.show()
#outputTable.setRowCount(5)
#outputTable.setColumnCount(5)
#outputTable.setHorizontalHeaderLabels(['Transaction Id','Status','Type','Transaction Amount','Balance Amount'])
#outputTable.horizontalHeader().setStretchLastSection(True)
#outputTable.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents)
#for i in range(5):
# item1=QtWidgets.QTableWidgetItem("asdf-fdf-37737484883239939-hjsdsfas8338384-3434")
# item1.setTextAlignment(Qt.AlignHCenter)
# item2=QtWidgets.QTableWidgetItem("Booked")
# item2.setTextAlignment(Qt.AlignHCenter)
# item3=QtWidgets.QTableWidgetItem("Credit")
# item3.setTextAlignment(Qt.AlignHCenter)
# item4=QtWidgets.QTableWidgetItem("24 GBP")
# item4.setTextAlignment(Qt.AlignHCenter)
# item5=QtWidgets.QTableWidgetItem("330 GBP")
# item5.setTextAlignment(Qt.AlignHCenter)
# outputTable.setItem(i,0,item1)
# outputTable.setItem(i,1,item2)
# outputTable.setItem(i,2,item3)
# outputTable.setItem(i,3,item4)
# outputTable.setItem(i,4,item5)
def anomalyAccounts():
op=open('Anomaly_Account.html','r').read().replace('DDMMYYYY',datetime.datetime.now().strftime("%d-%m-%Y"))
outputWindow.setHtml(op)
def maheshFunction(inputJson):
outputDataSet={"blocked":True,"reason":"Country is Sanctioned"}
outputJson=json.dumps(outputDataSet)
outputWindow.setPlainText(inputJson+outputJson)
return(outputJson)
def validate():
inputDataSet={"PayeeAccount":str(acc1Box.text()),"BeneficiaryAcc":str(acc2Box.text()),"Currency":currencyBox.currentText(),"Amount":str(amountBox.value())}
#inputJson=json.dumps(inputDataSet)
outputDataSet=validationCheck(inputDataSet)
approvedVal=outputDataSet['approved']
reason=outputDataSet['reason']
reasonList=reason.split(",")
if(approvedVal=="False"):
op=open('Payment_Blocked.html','r').read()
reasonText="<ul>"
for i in reasonList:
reasonText+='<li style="text-align: left;"><em>'+str(i)+'</em></li>'
reasonText+='</ul>'
op=op.replace('REASON',reasonText)
outputWindow.show()
outputWindow.setHtml(op)
else:
op=open('Payment_Approved.html','r').read()
outputWindow.show()
outputWindow.setHtml(op)
def clearAll():
acc1Box.clear()
acc2Box.clear()
currencyBox.setCurrentIndex(0)
amountBox.setValue(100)
outputWindow.clear()
outputWindow.show()
checkAccountBox.clear()
limitCheck.setChecked(False)
userCheck.setChecked(False)
countryCheck.setChecked(False)
#Set Window Label
app = QtWidgets.QApplication([])
#window = uic.loadUi("C:\\Users\\13gur\\Desktop\\Hackathon\\mainwindow.ui")
window = uic.loadUi("mainwindow.ui")
window.setWindowTitle("NWM Anti-Money Laundering")
#Set Window icon
window.setWindowIcon(QtGui.QIcon('icon.png'))
#Add Header Image
headerLabel=window.findChild(QtWidgets.QLabel,'heading')
pixmap=QtGui.QPixmap('nw.png')
headerLabel.setPixmap(pixmap)
#headerLabel.resize(pixmap.width(),pixmap.height())
#Identify Elements
#Left Widgets
acc1Box=window.findChild(QtWidgets.QLineEdit,'account1')
acc2Box=window.findChild(QtWidgets.QLineEdit,'account2')
currencyBox=window.findChild(QtWidgets.QComboBox,'currencyBox')
currencyBox.addItems(["Select Currency...","INR","GBP","USD","EUR"])
amountBox=window.findChild(QtWidgets.QSpinBox,'amountBox')
#Bottom Buttons
validateButton=window.findChild(QtWidgets.QPushButton,'validateButton')
validateButton.clicked.connect(validate)
clearButton=window.findChild(QtWidgets.QPushButton,'clearButton')
clearButton.clicked.connect(clearAll)
limitCheck=window.findChild(QtWidgets.QCheckBox,'limitCheck')
countryCheck=window.findChild(QtWidgets.QCheckBox,'countryCheck')
userCheck=window.findChild(QtWidgets.QCheckBox,'userCheck')
#Output Widgets
outputWindow=window.findChild(QtWidgets.QTextEdit,'outputWindow')
outputWindow.show()
#Right Widgets
checkAccountBox=window.findChild(QtWidgets.QLineEdit,'checkAccount')
accountDetailsBtn=window.findChild(QtWidgets.QPushButton,'accountDetails')
accountDetailsBtn.clicked.connect(accountDetails)
transactionDetailsBtn=window.findChild(QtWidgets.QPushButton,'transactionDetails')
transactionDetailsBtn.clicked.connect(transactionDetails)
anomalyAccountsBtn=window.findChild(QtWidgets.QPushButton,'anomalyAccounts')
anomalyAccountsBtn.clicked.connect(anomalyAccounts)
#Execute
window.show()
app.exec_()