def aceptar( self ): fecha = QDate.currentDate() fecha = QDate( fecha.year(), fecha.month(), fecha.daysInMonth() ) if self.dtPicker.date() > fecha: QMessageBox.information( None, "Cuentas Bancarias", "La cuenta seleccionada ya fue conciliada" ) else: return self.accept()
def __init__(self, parent=None): super(NewEntryDialog, self).__init__(parent) loadUi(__file__, self) # General window settings self.monthTab = parent.currentMonthTab() self.setWindowTitle('New Entry for \'%s\'' % self.monthTab.month()) self.setFixedSize(self.size()) # Entry name LineEdit settings strValidator = QRegExpValidator(QRegExp('.+')) self.nameLineEdit.setValidator(strValidator) completer = QCompleter(self.monthTab.entriesStringList()) completer.setCaseSensitivity(Qt.CaseInsensitive) self.nameLineEdit.setCompleter(completer) # DateEdit settings date = QDate(parent.year(), self.monthTab.monthIndex() + 1, 1) self.dateEdit.setDateRange( date, QDate(date.year(), date.month(), date.daysInMonth())) self.dateEdit.setDate(date) self.dateEdit.setCalendarPopup(True) self.dateEdit.calendarWidget().setFirstDayOfWeek(Qt.Monday) # CategoryComboBox settings self.categoryComboBox.setModel(self.monthTab.categoriesModel()) # OK PushButton settings self.okButton = self.buttonBox.button(QDialogButtonBox.Ok) self.okButton.setEnabled(False) # CONNECTIONS self.nameLineEdit.textEdited.connect(self.setOKButton)
def __init__(self, parent): CItemEditorBaseDialog.__init__(self, parent, 'DloDrugFormulary') self.addModels('Items', CItemsModel(self)) self.setupUi(self) self.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.WindowMaximizeButtonHint | QtCore.Qt.WindowCloseButtonHint) self.setWindowTitleEx(u'Лекарственный формуляр ДЛО') self.prepareTable(self.tblItems, self.modelItems) self.cmbType.addItem(u'Справочник лекарственных средств (ДЛО)') tmpDate = QDate().currentDate().addMonths(1) begDate = (QDate(tmpDate.year(), tmpDate.month(), 1)) self.edtBegDate.setDate(begDate) self.edtEndDate.setDate(begDate.addMonths(1).addDays(-1)) self.setupDirtyCather()
def data(self, index, role=None): """return a QVariant saying if exists a payment at index.(row|column)""" if not index.isValid() or role not in (Qt.DisplayRole, Qt.CheckStateRole): return QVariant() #self.update_db_content() # find the month from the row number month_year = QDate().fromString( self.headerData(index.row(), Qt.Vertical, role).toString(), 'MMMM yyyy') month = month_year.month() year = month_year.year() # find the client from the column number header_infos = self.headerData(index.column(), Qt.Horizontal, role).toString().split('\n') client = header_infos[0] machine = header_infos[1] selldate = QDate.fromString(header_infos[2], 'd MMMM yyyy') deltamonth = int(header_infos[3][5:-5]) # [len('Ogni '):-len(' mesi')] anticiped = header_infos[4][10:-6] == 'anti' # 'Pagamento ':-'cipato' query = QSqlQuery( 'SELECT expected_datepayd, effective_datepayd FROM ' 'payments WHERE clients_client = :client AND clients_machine = ' ':machine AND clients_selldate = :selldate AND ' 'expected_datepayd BETWEEN :datebefore AND :dateafter', self._db) query.bindValue(':client', QVariant(client)) query.bindValue(':machine', QVariant(machine)) query.bindValue(':selldate', QVariant(selldate)) # primo giorno del mese d = QDate(year, month, 1) query.bindValue(':datebefore', QVariant(d)) # ultimo giorno del mese query.bindValue(':dateafter', QVariant(d.addMonths(1).addDays(-1))) if not query.exec_(): raise StandardError('SYNTAX ERROR') if not query.first(): return QVariant() expected_datepayd = query.value(0).toDate() payed = not query.isNull(1) effective_datepayd = query.value(1).toDate() if role == Qt.CheckStateRole: return QVariant(Qt.Checked if payed else Qt.Unchecked) else: # DisplayRole date = effective_datepayd if payed else expected_datepayd return QVariant(date.toString('d MMMM yyyy'))
def __init__(self, parent): CItemEditorBaseDialog.__init__(self, parent, 'DrugFormulary') self.addModels('Items', CItemsModel(self)) self.setupUi(self) self.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.WindowMaximizeButtonHint | QtCore.Qt.WindowCloseButtonHint) self.setWindowTitleEx(u'Лекарственный формуляр') self.prepareTable(self.tblItems, self.modelItems) self.cmbType.addItems( [u'Формуляр отделение', u'Наркотики', u'Расходные материалы']) tmpDate = QDate().currentDate().addMonths(1) begDate = (QDate(tmpDate.year(), tmpDate.month(), 1)) self.edtBegDate.setDate(begDate) self.edtEndDate.setDate(begDate.addMonths(1).addDays(-1)) self.chkIsActive.setChecked(True) self.setupDirtyCather()
def details(regdent, trtdent, startdate, enddate, filters=""): ''' returns an html table, for regdent, trtdent,startdate,enddate ''' dent_conditions = "" dents = [] try: if regdent != "*ALL*": dent_conditions = 'dntid=%s and ' dents.append(localsettings.ops_reverse[regdent]) if trtdent != "*ALL*": dent_conditions += 'trtid=%s and ' dents.append(localsettings.ops_reverse[trtdent]) except KeyError: print "Key Error - %s or %s unregconised" % (regdent, trtdent) return '<html><body>%s</body></html>' % _( "Error - unrecognised practioner- sorry") total, nettotal = 0, 0 iterDate = QDate(startdate.year(), startdate.month(), 1) retarg = ''' <html><body><h4>%s %s %s %s %s %s %s %s %s</h4>''' % ( _("Patients of"), regdent, _("treated by"), trtdent, _("between"), localsettings.formatDate(startdate.toPyDate()), _("and"), localsettings.formatDate(enddate.toPyDate()), filters) retarg += '''<table width="100%" border="1"><tr><th>DATE</th> <th>Dents</th><th>Serial Number</th><th>Name</th> <th>Pt Type</th><th>Treatment</th><th></th> <th>Gross Fee</th><th>Net Fee</th>''' db = connect.connect() cursor = db.cursor() query = DETAILS_QUERY.replace("{{DENT CONDITIONS}}", dent_conditions) query = query.replace("{{FILTERS}}", filters) while enddate >= iterDate: monthtotal, monthnettotal = 0, 0 if startdate > iterDate: queryStartDate = startdate else: queryStartDate = iterDate queryEndDate = iterDate.addMonths(1).addDays(-1) if enddate < queryEndDate: queryEndDate = enddate values = tuple( dents + [queryStartDate.toPyDate(), queryEndDate.toPyDate()]) cursor.execute(query, (values)) rows = cursor.fetchall() for i, row in enumerate(rows): retarg += '<tr>' if i % 2 else '<tr bgcolor="#eeeeee">' retarg += "<td>%s</td>" % row[0] try: retarg += '<td> %s / ' % localsettings.ops[row[4]] except KeyError: retarg += "<td>?? / " try: retarg += localsettings.ops[row[5]] except KeyError: retarg += "??" retarg += '</td><td>%s</td><td>%s</td><td>%s</td>' % (row[1:4]) tx = "" for item in (6, 7, 8, 9, 10, 11, 12, 13, 14, 15): if row[item] is not None and row[item] != "": tx += "%s " % row[item] if ALLOW_TX_EDITS: extra_link = ' / <a href="daybook_id_edit?%s">%s</a>' % ( row[19], _("Edit Tx")) else: extra_link = "" retarg += '''<td>%s</td> <td><a href="daybook_id?%sfeesa=%sfeesb=%s">%s</a>%s</td> <td align="right">%s</td> <td align="right">%s</td></tr>''' % (tx.strip("%s " % chr(0)), row[19], row[16], row[17], _("Ests"), extra_link, localsettings.formatMoney( row[16]), localsettings.formatMoney(row[17])) total += int(row[16]) monthtotal += int(row[16]) nettotal += int(row[17]) monthnettotal += int(row[17]) retarg += '''<tr><td colspan="6"></td><td><b>SUBTOTAL - %s %s</b></td> <td align="right"><b>%s</b></td> <td align="right"><b>%s</b></td></tr>''' % ( localsettings.monthName(iterDate.toPyDate()), iterDate.year(), localsettings.formatMoney(monthtotal), localsettings.formatMoney(monthnettotal)) iterDate = iterDate.addMonths(1) cursor.close() # db.close() retarg += '''<tr><td colspan="6"></td><td><b>GRAND TOTAL</b></td> <td align="right"><b>%s</b></td> <td align="right"><b>%s</b></td></tr></table></body></html>''' % ( localsettings.formatMoney(total), localsettings.formatMoney(nettotal)) return retarg