-
Notifications
You must be signed in to change notification settings - Fork 28
/
opvrDienstenmutaties.py
283 lines (251 loc) · 12.6 KB
/
opvrDienstenmutaties.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
from login import hoofdMenu
from PyQt5.QtCore import Qt, QAbstractTableModel
from PyQt5.QtGui import QFont, QPixmap, QIcon
from PyQt5.QtWidgets import QLabel, QPushButton, QWidget, QGridLayout, QVBoxLayout,\
QComboBox, QDialog, QLineEdit, QMessageBox, QTableView
from sqlalchemy import (Table, Column, Integer, Float, String, MetaData, ForeignKey,\
create_engine)
from sqlalchemy.sql import select, and_
def windowSluit(self, m_email):
self.close()
hoofdMenu(m_email)
def geenRecord():
msg = QMessageBox()
msg.setStyleSheet("color: black; background-color: gainsboro")
msg.setWindowIcon(QIcon('./images/logos/logo.jpg'))
msg.setIcon(QMessageBox.Warning)
msg.setText('No record found\ncreate another selection please!')
msg.setWindowTitle('Request services / Equipment')
msg.exec_()
def ongInvoer():
msg = QMessageBox()
msg.setStyleSheet("color: black; background-color: gainsboro")
msg.setWindowIcon(QIcon('./images/logos/logo.jpg'))
msg.setIcon(QMessageBox.Warning)
msg.setText('Please re-enter incorrect input\nsearch term!')
msg.setWindowTitle('Request services / Equipment')
msg.exec_()
def mutatieKeuze(m_email):
class Widget(QDialog):
def __init__(self, parent=None):
super(Widget, self).__init__(parent)
self.setWindowTitle("Request changes services-portal accounting")
self.setWindowIcon(QIcon('./images/logos/logo.jpg'))
self.setFont(QFont('Arial', 10))
self.Keuze = QLabel()
k0Edit = QComboBox()
k0Edit.setFixedWidth(230)
k0Edit.setFont(QFont("Arial",10))
k0Edit.setStyleSheet("color: black; background-color: #F8F7EE")
k0Edit.addItem(' Search sort key')
k0Edit.addItem('1. All mutations')
k0Edit.addItem('2. Work number')
k0Edit.addItem('3. Work description')
k0Edit.addItem('4. Supplier number')
k0Edit.addItem('5. Company name')
k0Edit.addItem('6. By sales order')
k0Edit.addItem('7. Cost type (1-8)')
k0Edit.addItem('8. Booking date yyyy(-mm(-dd))')
k0Edit.activated[str].connect(self.k0Changed)
self.Zoekterm = QLabel()
zktermEdit = QLineEdit()
zktermEdit.setFixedWidth(230)
zktermEdit.setFont(QFont("Arial",10))
zktermEdit.textChanged.connect(self.zktermChanged)
grid = QGridLayout()
grid.setSpacing(20)
lbl = QLabel()
pixmap = QPixmap('./images/logos/verbinding.jpg')
lbl.setPixmap(pixmap)
grid.addWidget(lbl , 0, 0, 1, 2)
logo = QLabel()
pixmap = QPixmap('./images/logos/logo.jpg')
logo.setPixmap(pixmap)
grid.addWidget(logo , 0, 1, 1, 1, Qt.AlignRight)
grid.addWidget(k0Edit, 1, 1)
lbl1 = QLabel('Search term')
lbl1.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
grid.addWidget(lbl1, 2, 0)
grid.addWidget(zktermEdit, 2, 1)
self.setLayout(grid)
self.setGeometry(500, 300, 150, 150)
grid.addWidget(QLabel('\u00A9 2017 all rights reserved [email protected]'), 4, 0, 1, 3 , Qt.AlignCenter)
applyBtn = QPushButton('Search')
applyBtn.clicked.connect(self.accept)
grid.addWidget(applyBtn, 3, 1, 1, 1, Qt.AlignRight)
applyBtn.setFont(QFont("Arial",10))
applyBtn.setFixedWidth(100)
applyBtn.setStyleSheet("color: black; background-color: gainsboro")
cancelBtn = QPushButton('Close')
cancelBtn.clicked.connect(lambda: windowSluit(self, m_email))
grid.addWidget(cancelBtn, 3, 1)
cancelBtn.setFont(QFont("Arial",10))
cancelBtn.setFixedWidth(100)
cancelBtn.setStyleSheet("color: black; background-color: gainsboro")
def k0Changed(self, text):
self.Keuze.setText(text)
def zktermChanged(self, text):
self.Zoekterm.setText(text)
def returnk0(self):
return self.Keuze.text()
def returnzkterm(self):
return self.Zoekterm.text()
@staticmethod
def getData(parent=None):
dialog = Widget(parent)
dialog.exec_()
return [dialog.returnk0(), dialog.returnzkterm()]
window = Widget()
data = window.getData()
if data[0]:
keuze = int(data[0][0])
else:
ongInvoer()
mutatieKeuze(m_email)
if data[1]:
zoekterm = data[1]
else:
zoekterm = ''
toonMutaties(keuze, zoekterm, m_email)
def toonMutaties(keuze,zoekterm, m_email):
import validZt
metadata = MetaData()
dienstenmutaties = Table('dienstenmutaties', metadata,
Column('mutatieID', Integer, primary_key=True),
Column('werknummerID', None, ForeignKey('werken.werknummerID')),
Column('orderinkoopID', None, ForeignKey('orders_inkoop.orderinkoopID')),
Column('boekbedrag', Float),
Column('boekdatum', String),
Column('leverancierID', None, ForeignKey('leveranciers.leverancierID')),
Column('werkomschr', String),
Column('btw_hoog', Float),
Column('omschrijving', String),
Column('regel', Integer))
werken = Table('werken', metadata,
Column('werknummerID', Integer(), primary_key=True),
Column('werkomschrijving', String(50)))
orders_inkoop = Table('orders_inkoop', metadata,
Column('orderinkoopID', Integer, primary_key=True),
Column('leverancierID', None, ForeignKey('leveranciers.leverancierID')))
leveranciers = Table('leveranciers', metadata,
Column('leverancierID', Integer, primary_key=True),
Column('bedrijfsnaam', String),
Column('rechtsvorm', String))
engine = create_engine('postgresql://postgres@localhost/bisystem')
conn = engine.connect()
if keuze == 1:
sel = select([dienstenmutaties, werken, orders_inkoop, leveranciers])\
.where(and_(werken.c.werknummerID==dienstenmutaties.c.werknummerID,\
leveranciers.c.leverancierID == dienstenmutaties.c.leverancierID,\
orders_inkoop.c.orderinkoopID==dienstenmutaties.c.orderinkoopID))\
.order_by(werken.c.werknummerID)
elif keuze == 2 and validZt.zt(zoekterm, 8):
sel = select([dienstenmutaties, werken, orders_inkoop, leveranciers])\
.where(and_(werken.c.werknummerID==dienstenmutaties.c.werknummerID,\
leveranciers.c.leverancierID == dienstenmutaties.c.leverancierID,\
orders_inkoop.c.orderinkoopID==dienstenmutaties.c.orderinkoopID,\
werken.c.werknummerID== int(zoekterm)))
elif keuze == 3:
sel = select([dienstenmutaties, werken, orders_inkoop, leveranciers])\
.where(and_(werken.c.werknummerID==dienstenmutaties.c.werknummerID,\
leveranciers.c.leverancierID == dienstenmutaties.c.leverancierID,\
orders_inkoop.c.orderinkoopID==dienstenmutaties.c.orderinkoopID,\
werken.c.werkomschrijving.ilike('%'+zoekterm+'%')))\
.order_by(werken.c.werknummerID)
elif keuze == 4 and validZt.zt(zoekterm, 3):
sel = select([dienstenmutaties, werken, orders_inkoop, leveranciers])\
.where(and_(werken.c.werknummerID==dienstenmutaties.c.werknummerID,\
leveranciers.c.leverancierID == dienstenmutaties.c.leverancierID,\
orders_inkoop.c.orderinkoopID==dienstenmutaties.c.orderinkoopID,\
leveranciers.c.leverancierID == int(zoekterm)))
elif keuze == 5:
sel = select([dienstenmutaties, werken, orders_inkoop, leveranciers])\
.where(and_(werken.c.werknummerID==dienstenmutaties.c.werknummerID,\
leveranciers.c.leverancierID == dienstenmutaties.c.leverancierID,\
orders_inkoop.c.orderinkoopID==dienstenmutaties.c.orderinkoopID,\
leveranciers.c.bedrijfsnaam.ilike('%'+zoekterm+'%')))
elif keuze == 6 and validZt.zt(zoekterm, 5):
sel = select([dienstenmutaties, werken, orders_inkoop, leveranciers])\
.where(and_(werken.c.werknummerID==dienstenmutaties.c.werknummerID,\
leveranciers.c.leverancierID == dienstenmutaties.c.leverancierID,\
orders_inkoop.c.orderinkoopID==dienstenmutaties.c.orderinkoopID,\
orders_inkoop.c.orderinkoopID== int(zoekterm)))
elif keuze == 7 and validZt.zt(zoekterm, 16):
sel = select([dienstenmutaties, werken, orders_inkoop, leveranciers])\
.where(and_(werken.c.werknummerID==dienstenmutaties.c.werknummerID,\
leveranciers.c.leverancierID == dienstenmutaties.c.leverancierID,\
orders_inkoop.c.orderinkoopID==dienstenmutaties.c.orderinkoopID,\
dienstenmutaties.c.werkomschr.like(zoekterm+'%')))\
.order_by(dienstenmutaties.c.werkomschr)
elif keuze == 8 and validZt.zt(zoekterm, 10):
sel = select([dienstenmutaties, werken, orders_inkoop, leveranciers])\
.where(and_(werken.c.werknummerID==dienstenmutaties.c.werknummerID,\
leveranciers.c.leverancierID == dienstenmutaties.c.leverancierID,\
orders_inkoop.c.orderinkoopID==dienstenmutaties.c.orderinkoopID,\
dienstenmutaties.c.boekdatum.ilike(zoekterm+'%')))\
.order_by(dienstenmutaties.c.boekdatum)
else:
ongInvoer()
mutatieKeuze(m_email)
if conn.execute(sel).fetchone():
rp = conn.execute(sel)
else:
geenRecord()
mutatieKeuze(m_email)
class MyWindow(QDialog):
def __init__(self, data_list, header, *args):
QWidget.__init__(self, *args,)
self.setGeometry(50, 50, 1800, 900)
self.setWindowTitle('Request services mutations')
self.setWindowIcon(QIcon('./images/logos/logo.jpg'))
self.setWindowFlags(self.windowFlags()| Qt.WindowSystemMenuHint |
Qt.WindowMinMaxButtonsHint)
table_model = MyTableModel(self, data_list, header)
table_view = QTableView()
table_view.setModel(table_model)
font = QFont("Arial", 10)
table_view.setFont(font)
table_view.resizeColumnsToContents()
table_view.setSelectionBehavior(QTableView.SelectRows)
table_view.setColumnHidden(1, True)
table_view.setColumnHidden(2, True)
table_view.setColumnHidden(5, True)
table_view.setColumnHidden(12, True)
#table_view.clicked.connect(showAccount)
layout = QVBoxLayout(self)
layout.addWidget(table_view)
self.setLayout(layout)
class MyTableModel(QAbstractTableModel):
def __init__(self, parent, mylist, header, *args):
QAbstractTableModel.__init__(self, parent, *args)
self.mylist = mylist
self.header = header
def rowCount(self, parent):
return len(self.mylist)
def columnCount(self, parent):
return len(self.mylist[0])
def data(self, index, role):
veld = self.mylist[index.row()][index.column()]
if not index.isValid():
return None
elif role == Qt.TextAlignmentRole and (type(veld) == float or type(veld) == int):
return Qt.AlignRight | Qt.AlignVCenter
elif role != Qt.DisplayRole:
return None
if type(veld) == float:
return '{:12.2f}'.format(veld)
else:
return veld
def headerData(self, col, orientation, role):
if orientation == Qt.Horizontal and role == Qt.DisplayRole:
return self.header[col]
return None
header = ['Mutation number','Work number', 'Supplier orderID','Amount booking', 'Booking date', 'SupplierID',\
'Category work','VAT high', 'Description', 'Line number', 'Work number', 'Description',\
'Supplier orderID', 'SupplierID', 'SupplierID','Company name', 'Legal status']
data_list=[]
for row in rp:
data_list += [(row)]
win = MyWindow(data_list, header)
win.exec_()
mutatieKeuze(m_email)