def automaticInsert(xrisi_id,period_id,db): from utils import variusSQL xrisi = dbutils.getDbSingleVal("SELECT xrisi FROM m12_xrisi WHERE id='%s'" % xrisi_id, db) period = dbutils.getDbSingleVal("SELECT period FROM m12_period WHERE id='%s'" % period_id, db) print xrisi_id, period_id par = dbutils.getDbOneRow(isValSQL %(xrisi,period), db) if par: print u'Έχουν γίνει εγγραφές για την περίοδο %s %s' % (xrisi,period) return False arr = dbutils.getDbRows(variusSQL.InsertParousiesSQL % (xrisi,period,xrisi,period), db) if not arr: print u'Δεν υπάρχουν εργαζόμενοι στην περίοδο %s %s' % (xrisi,period) return False for el in arr: for c in el: print c, print '' par_id = dbutils.commitToDb(insParSQL % (xrisi_id, period_id), db) insArr = [] for el in arr: insArr.append(dbutils.commitToDb(insPardSQL % (par_id,el[0],1,0),db)) print insArr
def setValue(self,idVal): if idVal is None: self.idValue = None return idName = self.sql.split()[1][:-1] if self.sql1: sql = self.sql1 % idVal # Μάλλον ακυρώνεται ... else: if 'WHERE' in self.sql: sqlWhere = " AND %s=%s" % (idName,idVal) else: sqlWhere = " WHERE %s=%s" % (idName,idVal) sql = self.sql + sqlWhere v = dbutils.getDbOneRow(sql, self.db) if v: self.setText(v[1]) self.idValue = idVal else: self.setText('') self.idValue = None
def makeApd(xrisi,trimino,db): ''' 1. Συγκέντρωση στοιχείων εταιρείας 2. Συγκέντρωση στοιχείων εργαζομένων 3. Συγκέντρωση στοιχείων μισθοδοσιών ''' xrid = adb.getDbSingleVal("SELECT id FROM m12_xrisi WHERE xrisi='%s'" % xrisi, db) h = adb.getDbOneRow(sql0 % (xrid,trimino), db) arr = adb.getDbRows(sql1 % (xrid,trimino), db) if not h: return 'Error' if not arr: return 'Error' l0, l1, l2, l3 = lApd() doc = td.egrDoc([l0, l1,l2,l3]) doc.addLine(0, [u'',u'',u'',u'',u'',u'',h[0],tu.caps(h[1]),tu.caps(h[2]),tu.caps(h[3]),tu.caps(h[4]),h[5],h[6],tu.caps(h[7]),tu.caps(h[8]),h[9],tu.caps(h[10]),h[11],h[12],h[13],h[12],u'',u'',u'',tu.nowToStr(),u'',u'']) ergno=0 for lin in arr: if ergno == int(lin[2]): pass else: ergno = int(lin[2]) doc.addLine(1, [u'',lin[3],lin[4],tu.caps(lin[5]),tu.caps(lin[6]),tu.caps(lin[7]),tu.caps(lin[8]),tu.dateTostr(lin[9]),lin[10]]) doc.addLine(2,[u'',u'',lin[11],u'',u'',u'',lin[12],u'',lin[20],lin[21],lin[22],u'',u'',lin[19],lin[13],lin[14],lin[15],lin[16],lin[17],lin[18],u'',u'',u'',lin[18]]) doc.addLine(3,[u'',]) return doc.__str__()
def __init__(self,misNo,pdfName,db): QtGui.QDialog.__init__(self) self.setAttribute(Qt.Qt.WA_DeleteOnClose) head = adb.getDbOneRow(sqlHeader % misNo, db) footd = adb.getDbOneRow(sqlFooter,db) if int(head[4]) == 1: h1 = head[2] else: h1 = head[3] title = u'Μισθοδοσία για την περίοδο : %s %s' % (h1,head[1]) title2 = u'Τύπος : %s' % head[3] foot = u'%s ΑΦΜ: %s ΔΟΥ: %s' % (footd[1],footd[6],footd[7]) hlabels = [u'Ονοματεπώνυμο',u'Ειδικότητα',u'Ημ/σθιο',u'Μέρες',u'Αποδοχές', u'ΙΚΑ Εργ/νου',u'ΙΚΑ Εργοδότη',u'ΙΚΑ',u'ΦΜΥ',u'Eιδ.Επ. Αληλεγγ.',u'Kρατήσεις Eργ/νου',u'Πληρωτέο'] data = adb.getDbRows(sql1 % misNo,db) colSizes=[20,14,7,7,8,8,8,8,7,7,7,8] colTypes=[ 0,0,2,1,2,2,2,2,2,2,2,2] colAlign=[ 0,0,1,1,2,2,2,2,2,2,2,2] colSum =[ 0,0,0,1,1,1,1,1,1,1,1,1] f ={'orientation' :1, 'pdfName' :pdfName, 'fontFamily' :'Helvetica', 'ReportHeader1':title, 'ReportHeader2':title2, 'ReportHeader3':u'', 'headerLabels':hlabels, 'columnSizes' :colSizes, 'columnToSum' :colSum, 'columnTypes' :colTypes, 'columnAlign' :colAlign, 'footerLine' :False, 'footerText' :foot, 'footerPageNumberText':u'Σελίδα', 'data' :data } self.rep = qttr.qtTableReport(f) tstButton = QtGui.QPushButton('test') tstButton.clicked.connect(self.onClick) layout = QtGui.QHBoxLayout() layout.addWidget(tstButton) self.setLayout(layout)
def __populate(self): if not self.id: # Εάν δεν έχει τιμή το id επιστρέφουμε ... return None #Πρώτα απ'όλα βρίσκουμε την εγγραφή rowVal = dbutils.getDbOneRow(self.selectSQL(), self.db) i=0 if rowVal: for key in self.od: self.od[key].setValue(rowVal[i]) i += 1
def populateFormFields(self): rowVal = dbutils.getDbOneRow(self.tablePars.sqlSelect % self.id, self.db) if rowVal: for i in range(self.tablePars.numberOfFields): if self.tablePars._fieldNames[i][2] == "date": yr, mn, dt = rowVal[i].split("-") qd = QtCore.QDate() qd.setDate(int(yr), int(mn), int(dt)) self.masterFields[i].setDate(qd) elif self.tablePars._fieldNames[i][2] == "dec": self.masterFields[i].setValue(rowVal[i]) elif self.tablePars._fieldNames[i][2] == "fkey": self.masterFields[i].idValue = str(rowVal[i]) if self.tablePars._fieldNames[i][6]: sqlForField = self.tablePars._fieldNames[i][6] % rowVal[i] sqlWhere = "" else: sqlForField = self.tablePars._fieldNames[i][4] if "WHERE" in sqlForField: sqlWhere = " AND id=%s" % rowVal[i] else: sqlWhere = " WHERE id=%s" % rowVal[i] fkSql = sqlForField + sqlWhere print "Line 252 : fksql = %s" % fkSql v = dbutils.getDbOneRow(fkSql, self.db) self.masterFields[i].setText(v[1]) elif self.tablePars._fieldNames[i][2] == "int": self.masterFields[i].setValue(rowVal[i]) else: self.masterFields[i].setText("%s" % rowVal[i])
def makeRpt(misNo,pdfName,db): head = adb.getDbOneRow(sqlHeader % misNo, db) footd = adb.getDbOneRow(sqlFooter,db) if int(head[4]) == 1: h1 = head[2] else: h1 = head[3] title = u'Μισθοδοσία για την περίοδο : %s %s' % (h1,head[1]) title2 = u'Τύπος : %s' % head[3] foot = u'%s ΑΦΜ: %s ΔΟΥ: %s' % (footd[1],footd[6],footd[7]) titles = [u'AA',u'Ονοματεπώνυμο',u'Ειδικότητα',u'Ημ/σθιο',u'Μέρες',u'Αποδοχές', u'ΙΚΑ Εργ/νου',u'ΙΚΑ Εργοδότη',u'ΙΚΑ',u'ΦΜΥ',u'Eιδ.Επ. Αληλεγγ.',u'Kρατήσεις Eργ/νου',u'Πληρωτέο'] typeArr = ['t','tc','n','i','n','n','n','n','n','n','n','n'] sumArr = [ 0 , 0 , 0 , 0 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ] sizeArr = [20 ,150 ,80 ,50 ,40 ,50 ,50 ,50 ,50 ,50 ,50 ,50 ,50 ] v = cr.makePrintTable(adb.getDbRows(sql1 % misNo,db),typeArr,sumArr,True) rep = cr.pdfReport(portrait=False) rep.makepdf(title,titles,v,sizeArr,pdfName,title2,foot) return True
def makeMisData(self,misNo,pdfName): head = adb.getDbOneRow(sqlHeader % misNo, self.db) footd = adb.getDbOneRow(sqlFooter,self.db) if int(head[4]) == 1: h1 = head[2] else: h1 = head[3] title = u'Μισθοδοσία για την περίοδο : %s %s' % (h1,head[1]) title2 = u'Τύπος : %s' % head[3] foot = u'%s ΑΦΜ : %s ΔΟΥ : %s' % (footd[1],footd[6],footd[7]) hlabels = [u'AA',u'Ονοματεπώνυμο',u'Ειδικότητα',u'Μισθός Ημ/σθιο',u'Μέρες',u'Αποδοχές', u'ΙΚΑ Εργ/νου',u'ΙΚΑ Εργοδότη',u'ΙΚΑ',u'ΦΜΥ',u'Eιδ.Επ. Αληλεγγ.',u'Kρατήσεις Eργ/νου',u'Πληρωτέο'] data = adb.getDbRowsCounted(sql1 % misNo,self.db) colSizes=[3,15,10,7,5,8,7,7,8,7,7,8,7] colTypes=[1,0,0,2,1,2,2,2,2,2,2,2,2] colAlign=[1,0,0,1,1,2,2,2,2,2,2,2,2] colSum =[0,0,0,0,1,1,1,1,1,1,1,1,1] f ={'orientation' :1, 'pdfName' :pdfName, 'fontFamily' :'Tahoma', 'ReportHeader1':title, 'ReportHeader2':title2, 'ReportHeader3':u'', 'headerLabels':hlabels, 'columnSizes' :colSizes, 'columnToSum' :colSum, 'columnTypes' :colTypes, 'columnAlign' :colAlign, 'footerLine' :True, 'footerText' :foot, 'footerPageNumberText':u'Σελίδα', 'data' :data } self.rep = qttr.qtTableReport(f)
def __init__(self, tableName, db, parameterdb): self.db = db self._sqlTable = "SELECT id, tname, tper FROM tbl WHERE tname='%s'" % tableName self._tname = dbutils.getDbOneRow(self._sqlTable, parameterdb) self._sqlFields = ( "SELECT fname, fper, ftyp, frequired, fsql, ftitles, sqlUpdate FROM tbl_d WHERE tbl_id='%s'" % self._tname[0] ) self._fieldNames = dbutils.getDbRows(self._sqlFields, parameterdb) self.numberOfFields = len(self._fieldNames) self.tableLabel = self._tname[2] self.tableName = self._tname[1] self.sqlCreate()
def fmyEtoys(etos,rundate,db): from utils import dbutils as dbu from utils.tedutils import dec as d xrisiId = dbu.getDbSingleVal("SELECT id from m12_xrisi WHERE xrisi='%s'" % etos, db) cd = dbu.getDbOneRow("SELECT cop,ono,pat,cotyp,afm,dra,pol,odo,num,tk FROM m12_co INNER JOIN m12_cotyp ON m12_cotyp.id=m12_co.cotyp_id",db) #Company Data co = { 'eponymia':u'%s %s' % (cd[0],cd[1]), 'AFM':u'%s' % cd[4], 'Antikeimeno':u'%s' % cd[5], 'Adress':u'%s %s %s %s' % (cd[6],cd[7],cd[8],cd[9]), 'Tel':u'' } ed = dbu.getDbRows(sqlergData1 % xrisiId, db) # Ergazomenoi Data l0, l1, l2 , l3 = lfmy() doc = td.egrDoc([l0,l1,l2,l3]) doc.addLine(0, ['','',etos+'1231',etos,'']) doc.addLine(1, ['',etos,cd[0],cd[1],cd[2],cd[3],cd[4],cd[5],cd[6],cd[7],cd[8],cd[9],'']) doc.addLine(2,[u'',u'',u'',u'',u'',u'',u'',u'']) vls = [] for l in ed: fpa = d(l[11]/0.985) doc.addLine(3,['',l[1],'',l[2],l[3],l[4],l[5],l[6],l[7],l[8],l[9],l[10],fpa,l[11],l[13],'']) vl = { 'Apo':u'1/1/%s' % etos, 'Eos':u'31/12/%s' % etos, 'Onomatep':u'%s %s' % (l[3],l[2]), 'Patronymo':u'%s' % l[4], 'AdrErg':u'%s, %s %s, %s' % (l[5],l[6],l[7],l[8]), 'TelErg':u'', 'Eid':u'%s'% l[14], 'AFMErg':u'%s' % l[1], 'Doy':u'', 'At':u'', 'ApodType':u'Μισθοί', 'AkApod':u'%s'% gr0(l[8]), 'Kratiseis':u'%s'% gr0(l[9]), 'SynoloKrat':u'%s'% gr0(l[9]), 'Katharo':u'%s' % gr0(l[10]), 'Analogei':u'%s' % gr0(fpa), 'Parakrat':u'%s' % gr0(l[11]), 'Hmnia':u'%s' % rundate, 'eea' :u'%s' % gr0(l[13]) } vls.append(vl) return doc.__str__(),co,vls
def __init__(self,tableName,parameterDb): self._sqlTable = "SELECT id, tname, tper FROM tbl WHERE tname='%s'" % tableName self._tname = dbutils.getDbOneRow(self._sqlTable,parameterDb) self._sqlFields = "SELECT fname, fper, ftyp, frequired, fsql, ftitles, sqlUpdate FROM tbl_d WHERE tbl_id='%s'" % self._tname[0] self._fields=['id',] self._headers=['id',] self._colTypes=['text',] self._isRequired=[0,] self._fkeySql=['',] self._fkeyTitles=['',] self._fsqlUpdate=['',] for row in dbutils.getDbRows(self._sqlFields, parameterDb): self._fields.append(row[0]) self._headers.append(row[1]) self._colTypes.append(row[2]) self._isRequired.append(row[3]) self._fkeySql.append(row[4]) self._fkeyTitles.append(row[5]) self._fsqlUpdate.append(row[6])
def populateFormFields(self): rowVals = dbutils.getDbRows('SELECT * FROM m12_pard WHERE m12_pard.par_id=3', 'c:/ted/mis.sql3') if rowVals: for rowVal in rowVals: self.addNewLine() for i in range(self.columnCount()): if self.dataProvider._colTypes[i] == 'date': yr,mn,dt = rowVal[i].split('-') qd = QtCore.QDate() qd.setDate(int(yr),int(mn),int(dt)) #self.masterFields[i].setDate(qd) self.cellWidget(self.rowCount()-1,i).setDate(qd) elif self.dataProvider._colTypes[i] == 'dec': self.cellWidget(self.rowCount()-1,i).setValue(rowVal[i]) elif self.dataProvider._colTypes[i] == 'fkey': self.cellWidget(self.rowCount()-1,i).idValue = str(rowVal[i]) if self.dataProvider._fsqlUpdate[i]: sqlForField = self.dataProvider._fsqlUpdate[i] % rowVal[i] sqlWhere = '' else: sqlForField = self.dataProvider._fkeySql[i] if 'WHERE' in sqlForField: sqlWhere = " AND id=%s" % rowVal[i] else: sqlWhere = " WHERE id=%s" % rowVal[i] fkSql = sqlForField + sqlWhere print 'Line 176 : fksql = %s' % fkSql v = dbutils.getDbOneRow(fkSql, 'c:/ted/mis.sql3') self.cellWidget(self.rowCount()-1,i).setText(v[1]) elif self.dataProvider._colTypes[i] == 'int': self.cellWidget(self.rowCount()-1,i).setValue(rowVal[i]) else: self.setItem(self.rowCount()-1,i,QtGui.QTableWidgetItem('%s' % rowVal[i]))
def getFields(tableName,db): sql1 = "SELECT id, tname, tper FROM tbl WHERE tname='%s'" % tableName tname = dbutils.getDbOneRow(sql1,db) sql2 = "SELECT fname, fper, ftyp, frequired, fsql, ftitles FROM tbl_d WHERE tbl_id='%s'" % tname[0] ar = dbutils.getDbRows(sql2, db) return tname, ar
def isMisDB(db): # check if db is payroll db try: print dbutils.getDbOneRow('SELECT * FROM m12_co',db) return True except: return False