def IsValidDates(self): out = True cn = lambda name: self.FindWindowByName(name) datlas = cn('lastliq_data').GetValue() datmin, datmax = [cn(name).GetValue() for name in ('datmin', 'datmax')] if datmin is None or datmax is None or datmax < datmin: out = False if cn('tipoliq').GetValue() == "D": if out and datlas is not None: if datmin < datlas: awu.MsgDialog( self, "La data di partenza è inferiore all'ultima liquidazione", style=wx.ICON_ERROR) return False elif datmin != (datlas + 1): if awu.MsgDialog( self, "La data di partenza non è consequenziale\nall'ultima liquidazione. Confermi l'esattezza?", style=wx.ICON_QUESTION | wx.YES_NO | wx.NO_DEFAULT) != wx.ID_YES: return False if out: for ri in self.dbstatus: if ri.rieponly != 1 and (ri.lastprtdat is None or ri.lastprtdat < datmin): awu.MsgDialog( self, "Alcuni registri non sono allineati alla data di stampa.", style=wx.ICON_ERROR) return False if not out: awu.MsgDialog(self, "Date errate", style=wx.ICON_ERROR) return out
def UpdateGridReg(self, msg=True): cn = lambda x: self.FindWindowById(x) cv = lambda x: cn(x).GetValue() reg = self.dbreg reg.SetTipoStampa(self.tiposta) reg.SetLimits(cv(wdr.ID_DATMIN), cv(wdr.ID_DATMAX),\ protini=cv(wdr.ID_NUMMIN),\ radate= cv(wdr.ID_RADATE),\ raprot= cv(wdr.ID_RAPROT)) if reg.Retrieve(): self.gridreg.ResetView() self.CreateGridTotAliq() if reg.RowsCount() == 0 and msg: awu.MsgDialog(self, "Nessuna registrazione trovata") else: cn(wdr.ID_GRIDZONE).SetSelection(1) smsg, snum, sdat = reg.CtrSeq() if smsg: awu.MsgDialog(self, message=\ """Attenzione!\n\n""" """Problema sul protocollo n.%d: %s"""\ % (snum, smsg), style=wx.ICON_WARNING) else: awu.MsgDialog(self, repr(reg.GetError()))
def OnConfirm(self, event ): cn = lambda x: self.FindWindowById(x) psw1 = cn(wdr.ID_PSW1).GetValue() psw2 = cn(wdr.ID_PSW2).GetValue() if psw1==psw2==self.oldpsw: util.MsgDialog(self, "La nuova password non puo' essere uguale alla vecchia password") elif len(psw1)<PSWD_MIN and psw1==psw2: util.MsgDialog(self, "La password deve avere un lunghezza minima di %d caratteri" % PSWD_MIN) else: self.x4cursor.execute("select old_password('%s');" % psw1) e_psw=self.x4cursor.fetchone()[0] sql="UPDATE utenti SET psw='%s' WHERE descriz='%s';" % (e_psw, self.username ) self.x4cursor.execute(sql) self.OnAbort(event) event.Skip()
def Stampa(self): reg = self.dbreg r = reg._riepaliq #per compatilibità alias tabelle con riep.iva fatto x lista mov. r.reg.regiva = r.reg.rei r.aliqiva = r.iva if self.FindWindowById(wdr.ID_GRIDZONE).GetSelection() == 2: name = 'Riepilogo IVA' db = r else: name = 'Registro IVA' db = reg def cn(x): return self.FindWindowByName(x) for c in 'tiposta intatt intdes intanno intpag'.split(): for o in (reg, r): setattr(o._info, c, cn(c).GetValue()) r._info.noperiodo = True #evita di stampare il periodo su riep. iva s = rpt.Report(self, db, name) if reg._tipostampa == "D": q = awu.MsgDialog(self, message=\ "Confermi l'aggiornamento del database con le "\ "informazioni stampate?", style=wx.YES_NO|wx.YES_DEFAULT|wx.ICON_QUESTION) if q == wx.ID_YES: wait = awu.WaitDialog(self, message=\ "Aggiornamento dati in corso", maximum=reg.RowsCount()) try: e = self.dbreg.ElaboraDefin( lambda n, reg: wait.SetValue(n)) ri = adb.DbTable(bt.TABNAME_REGIVA, 'rei') if ri.Get(reg._rivid): p = s.usedReport.oCanvas.userVariableList['intpag'] ri.intanno = cn('intanno').GetValue() ri.intpag = p.valore reg.MoveLast() ri.lastprtnum = reg.numiva ri.lastprtdat = reg._datmax ri.Save() finally: wait.Destroy() if e: awu.MsgDialog(self, "Aggiornamento correttamente effettuato") self.GetParent().Close()
def OnContabilizza(self, event): nsel = self.dbeff.GetCountOf(lambda rse: rse[selcol] or False) if nsel > 0: self.Contabilizza() else: awu.MsgDialog(self, "Nessun effetto selezionato") event.Skip()
def OnAccorpaWrite(self, event): if awu.MsgDialog(self, message="Confermi gli accorpamenti effettuati?", style=wx.ICON_QUESTION | wx.YES_NO | wx.NO_DEFAULT) == wx.ID_YES: self.AccorpaWrite() event.Skip()
def ValidateControls(self, controls): """ Esamina la lista dei controlli passati. Per ognuno vailda il metodo Validate(); in caso di esito negativo, setta il colore di sfondo come COLOR_ERROR Ritorna True se tutti i controlli danno esito positivo. """ valid = True for ctr in controls: if isinstance(ctr, wx.Window): v = ctr.Validate() if v: ctr.SetBackgroundColour(wx.NullColour) else: try: ctr.SetBackgroundColour('red') except: pass valid = False if not valid: awu.MsgDialog(self,\ """Sono presenti valori non validi. Correggere le parti evidenziate """\ """per continuare. I dati non sono stati salvati.""" ) return valid
def UpdateEff(self, msg=True): cn = lambda x: self.FindWindowById(x) eff = self.dbeff eff.ClearFilters() te = cn(wdr.ID_TIPEFF).GetValue() if te == 'I': #rid, filtro su tipologia della mod.pag. eff.AddFilter("modpag.tipo='I'") else: #riba, filtro su flag della partita eff.AddFilter("pcf.riba=1") for ctrid, filt in ((wdr.ID_CAUS, r"pcf.id_caus=%s"),\ (wdr.ID_MODPAG, r"pcf.id_modpag=%s"),\ (wdr.ID_PDC, r"pcf.id_pdc=%s"),\ (wdr.ID_DATSCA1, r"pcf.datscad>=%s"),\ (wdr.ID_DATSCA2, r"pcf.datscad<=%s"),\ (wdr.ID_DATDOC1, r"pcf.datdoc>=%s"),\ (wdr.ID_DATDOC2, r"pcf.datdoc<=%s"),\ (wdr.ID_NUMDOC1, r"pcf.numdoc>=%s"),\ (wdr.ID_NUMDOC2, r"pcf.numdoc<=%s")): ctr = cn(ctrid) val = ctr.GetValue() if val: eff.AddFilter(filt, val) if not cn(wdr.ID_INCLEMES).GetValue(): eff.AddFilter("pcf.f_effemes IS NULL OR pcf.f_effemes=0") eff.AddFilter("pcf.imptot<>pcf.imppar") if not cn(wdr.ID_INCLCONT).GetValue(): eff.AddFilter("pcf.f_effcont IS NULL OR pcf.f_effcont=0") if not cn(wdr.ID_INCLINSOL).GetValue(): eff.AddFilter("pcf.insoluto IS NULL OR pcf.insoluto=0") if not cn(wdr.ID_INCLCHIUS).GetValue(): eff.AddFilter("pcf.imptot<>pcf.imppar") if eff.Retrieve(): self.grideff.ResetView() if eff.RowsCount() == 0 and msg: awu.MsgDialog(self, "Nessun effetto trovato") else: awu.MsgDialog(self, repr(eff.GetError())) del self.effsel[:] rse = eff.GetRecordset() self.effsel += [row for row in range(eff.RowsCount())\ if rse[row][selcol]] cn(wdr.ID_NUMEFF).SetValue(eff.RowsCount()) col = eff._GetFieldIndex('impeff', inline=True) cn(wdr.ID_TOTEFF).SetValue(sum([e[col] for e in eff.GetRecordset()])) self.UpdateTot()
def TransferDataFromWindow(self, *args, **kwargs): """ Il metodo si fa carico di memorizzare i dati presentati a video, in particolare per l'utente identificato da self.db_recid e per ogni azienda presente in self.aziende viene memorizzato un record nella tabella x4.diritti che indica se l'utente è abilitato o meno ad operare sull'azienda. Prima di richiamare il metodo padre che provvede alla memorizzazione dei dati nel database il valore crittografato della chiave digitata, viene assegnato al controllo identificato da wx.ID_PSW. """ id = self.FindWindowByName("id") code = self.FindWindowByName("codice") user = self.FindWindowById(wdr.ID_UTENTE) psw = self.FindWindowById(wdr.ID_PSW).GetValue() if self.oldPassword <> psw: self.db_curs.execute("select old_password('%s');" % psw) ecrypt_psw = self.db_curs.fetchone()[0] self.FindWindowById(wdr.ID_PSW).SetValue(ecrypt_psw) out = ga.AnagPanel.TransferDataFromWindow(self, *args, **kwargs) if out: du = self.dbdir l = self.FindWindowById(wdr.ID_AZIENDE) for r, a in enumerate(self.aziende): attivo = False du.ClearFilters() du.AddFilter('diritti.id_utente=%s', self.db_recid) du.AddFilter('diritti.id_azienda=%s', a) if du.IsEmpty(): self.checkDiritti() du.ClearFilters() du.AddFilter('diritti.id_utente=%s', self.db_recid) du.AddFilter('diritti.id_azienda=%s', a) if du.Retrieve() and du.OneRow(): attivo = l.IsChecked(r) du.attivo = int(l.IsChecked(r)) if not du.Save(): util.MsgDialog(self, repr(du.GetError())) else: util.MsgDialog(self, repr(du.GetError())) record = (self.db_recid, a, attivo) pass self.createMySqlUser() return out
def SaveSel(self): """ Salva le selezioni """ out = self.dbeff.Save() if not out: awu.MsgDialog(self, repr(self.dbeff.GetError())) return out
def OnActivate(self, event): if not self.canModify: util.MsgDialog(self, "Impossibile impostare nuova password") cn = lambda x: self.FindWindowById(x) psw1 = cn(wdr.ID_PSW1).Enable(False) psw2 = cn(wdr.ID_PSW2).Enable(False) cn(wdr.ID_CONFIRM).Enable(False) event.Skip()
def SaveEff(self): out = self.dbeff.Save() if not out: awu.MsgDialog(\ self,\ "Problema durante la memorizzazione degli effetti:\n%s"\ % repr(self.dbeff.GetError())) return out
def OnSaveLiq(self, event): liq = self.dbliq if liq.TestValori(): mt = self.dbliq._totali ver, deb, cred = mt['vertra1'], mt['docfin1'], mt['docfin2'] if ver: message =\ """Questa liquidazione porta ad un versamento """\ """di Euro """+Env.StrImp(ver) else: if deb: message =\ """Questa liquidazione porta ad un debito di imposta di Euro %s\n"""\ """da non versare poiché inferiore al limite minimo di versamento\n"""\ """di Euro 25,82.\n"""\ """Il debito di Euro %s verrà riportato nella prossima liquidazione."""\ % (Env.StrImp(deb), Env.StrImp(deb)) elif cred: message =\ """Con questa liquidazione non c'è da versare nulla.\n"""\ """Il credito di Euro %s verrà riportato nella prossima liquidazione."""\ % Env.StrImp(cred) else: message =\ """Questa liquidazione è a zero.""" message += """\n\nConfermi l'operazione?""" r = awu.MsgDialog(self, message, "Conferma liquidazione", style=wx.ICON_QUESTION | wx.YES_NO | wx.NO_DEFAULT) if r == wx.ID_YES: cn = self.FindWindowByName if liq.SaveLiq(self.regivasta, cn('intanno').GetValue(), cn('intpag').GetValue() - 1): awu.MsgDialog(self, """La liquidazione è stata confermata.""") evt = FineLiquidEvent(_evtLIQEND) evt.SetEventObject(self) self.GetEventHandler().AddPendingEvent(evt) else: awu.MsgDialog( self, """Problemi nel salvataggio della """ """liquidazione\n%s""" % repr(liq.GetError())) event.Skip()
def onButtonWEB(event): try: wx.BeginBusyCursor() try: self.ctrpiva.GetPIvaDateOpenWebPage() finally: wx.EndBusyCursor() except Exception, e: awu.MsgDialog(self, repr(e.args))
def Calcola(self): liq = self.dbliq mt = liq._totali for key in self.calcdigit + self.prospdigit: mt[key] = self.FindWindowByName(key).GetValue() try: liq.Calcola() except dbc.ValoriErrati_Exception, e: awu.MsgDialog(self, e.args[0])
def PdfPrint(filename, printer, copies=1, cbex=None, usedde=False, cmdprint=False, pdfcmd=None): out = False pdfcmd = 'lpr' try: subprocess.Popen([pdfcmd, '-P', printer, '-#%d'%copies, filename]) out = True except Exception, e: awu.MsgDialog(None, repr(e.args), style=awu.wx.ICON_ERROR)
def TestEditedValues(self, row, gridcol, col, value): if gridcol == 2: if not (value is None or value in 'DA'): awu.MsgDialog(self, 'Segno contabile errato') return False pcp = self.dbpcp pcp.MoveRow(row) pcp.segno = value self.ResetView() return True
def DeleteMagRegIva(self): out = False rim = self.dbrim if rim.Retrieve('rim.id_magazz=%s', self.db_recid): for r in rim: r.Delete() out = rim.Save() if not out: awu.MsgDialog(self, message=repr(rim.GetError())) return out
def __init__(self, *args, **kwargs): self.values = {} aw.Panel.__init__(self, *args, **kwargs) wdr.ProgrLiqIvaFunc(self) ci = lambda x: self.FindWindowById(x) cn = lambda x: self.FindWindowByName(x) s = adb.DbTable(bt.TABNAME_CFGSETUP, 'setup') s.Retrieve('setup.chiave=%s', 'liqiva_periodic') self.periodic = s.flag curyear = Env.Azienda.Esercizio.dataElab.year self.progr = adb.DbTable(bt.TABNAME_CFGPROGR, "progr", writable=True) p = adb.DbTable(bt.TABNAME_CFGPROGR, "progr") p.Retrieve('progr.codice=%s', "iva_liqreg") cn('intestaz').SetValue(p.progrdesc or '') cn('regiva').SetValue(p.progrimp1) p = adb.DbTable(bt.TABNAME_CFGPROGR, "progr", fields=None) p.AddGroupOn("progr.keydiff") p.AddOrder("progr.keydiff") p.AddFilter("progr.keydiff<%s", curyear) p.AddFilter("progr.codice IN %s" % repr( ('iva_debcred', 'iva_cricomstart', 'iva_cricomdisp'))) p.ClearOrders() p.AddOrder("progr.keydiff", adb.ORDER_DESCENDING) l = ci(wdr.ID_ANNI) l.Append(str(curyear), curyear) if p.Retrieve(): for p in p: l.Append(p.keydiff, int(p.keydiff)) else: awu.MsgDialog(self, "Problema nella lettura dei progressivi\n%s"\ % repr(p.GetError())) cn = self.FindWindowByName for name in 'periodo debcred cricomstart cricomdisp'.split(): self.Bind(wx.EVT_TEXT, self.OnValueChanged, cn(name)) from awc.controls.datectrl import EVT_DATECHANGED self.Bind(EVT_DATECHANGED, self.OnValueChanged, cn('datlast')) self.Bind(wx.EVT_RADIOBOX, self.OnValueChanged, cn('laspom')) self.Bind(wx.EVT_LISTBOX, self.OnYear, ci(wdr.ID_ANNI)) self.Bind(wx.EVT_BUTTON, self.OnSave, ci(wdr.ID_SALVA)) self.Bind(wx.EVT_BUTTON, self.OnLiqEff, ci(wdr.ID_LIQEFF)) self.SetYear(curyear) l.SetSelection(0)
def checkDiritti(self): """ Il metodo provvede ad controllare per ogni utente e per ogni azienda l'esistenza del corrispondente record sulla tabella dei diritti (x4.diritti). Nel caso tale record non fosse presente, viene creato negando il diritto dell'utente ad operare sull'azienda. """ du = self.dbdir for u in self.db_rs: for a in self.aziende: if not self.existDiritti(u[2], a): if not du.New(id_utente=u[2], id_azienda=a, attivo=0): util.MsgDialog(self, repr(du.GetError())) return
def existSupervisor(self, id): lEsito = False db = adb.DB() db._dbCon = self.db_conn db.connected = True ute = adb.DbTable('utenti', db=db, writable=False) if not ute.Retrieve("amministratore='X' and not id=%s" % id): util.MsgDialog(None,\ "Impossibile accedere alla tabella Utenti:\n"\ % repr(ute.GetError())) else: if ute.RowsCount() > 0: lEsito = True return lEsito
def ValidateRsRim(self): err = None diff = False rp = [] for r in self.rsrim: ri = r[MAGREGIVA_REGIVA_ID] if not ri: err = "Ogni magazzino deve avere un corrispondente registro IVA" break elif rp and not ri in rp: diff = True rp.append(ri) if err: awu.MsgDialog(self, message=err, style=wx.ICON_ERROR) out = False else: if diff: awu.MsgDialog(self, message=\ """Non c'è lo stesso registro su tutte le """\ """causali, assicurarsi che sia corretto""", style=wx.ICON_WARNING) out = True return out
def AccorpaWrite(self): accs = [] accmap = {} for wr, wa in self.wrirac.iteritems(): for acc in wa: accmap[acc] = wr accs.append(acc) scad = adb.DbTable(bt.TABNAME_CONTAB_S, 'scad', writable=True) if scad.Retrieve("id_pcf IN (%s)" % ','.join(map(str, accs))): for scad in scad: scad.id_pcf = accmap[scad.id_pcf] if not scad.Save(): awu.MsgDialog(self, message="Problema in aggiornamento riferimenti\n%s" % repr(scad.GetError())) return if not self.dbpcf.Save(): awu.MsgDialog(self, message="Problema in aggiornamento partite\n%s" % repr(scad.GetError())) return awu.MsgDialog(self, message="Scrittura accorpamenti terminata con successo.")
def GetValori(self, *campi): ctrls = {wdr.ID_DATDIST: "Data distinta",\ wdr.ID_BANCA: "Banca emittente",\ wdr.ID_CONTOEFF: "Conto effetti",\ wdr.ID_CAUCONT: "Causale contabile",\ wdr.ID_FILEPATH: "Percorso generazione file"} out = [] cn = lambda x: self.FindWindowById(x) for c in campi: v = cn(c).GetValue() if not v and c in ctrls: awu.MsgDialog(self, "Occorre indicare: %s" % ctrls[c]) out.append(v) return out
def TransferDataFromWindow(self, *args, **kwargs): out = ga.AnagPanel.TransferDataFromWindow(self, *args, **kwargs) if out: ddr = self.dbddr l = self.FindWindowById(wdr.ID_DOCS) for r, d in enumerate(self.docs): ddr.ClearFilters() ddr.AddFilter('ddr.id_ftd=%s', self.db_recid) ddr.AddFilter('ddr.id_docrag=%s', d) if ddr.Retrieve(): if ddr.IsEmpty(): ddr.CreateNewRow() ddr.id_ftd = self.db_recid ddr.id_docrag = d ddr.f_attivo = int(l.IsChecked(r)) if not ddr.Save(): awu.MsgDialog(self, repr(ddr.GetError())) break else: awu.MsgDialog(self, repr(ddr.GetError())) evt = wx.PyCommandEvent(lib._evtCHANGEMENU) wx.GetApp().GetTopWindow().AddPendingEvent(evt) return out
def PhoneTo(self): addr = self.FindWindowById(wdr.ID_ADDRESS).GetValue() if addr and addr[0].isdigit(): newaddr = '' for c in addr: if c.isdigit(): newaddr += c addr = '+39%s' % newaddr else: if ' ' in addr: addr = addr[:addr.index(' ') - 1] if addr: if awu.MsgDialog(self, message="Confermi la chiamata al n.%s?" % addr, style=wx.ICON_QUESTION | wx.YES_NO | wx.YES_DEFAULT) == wx.ID_YES: os.startfile('callto://%s' % addr)
def GetAgEntrPIvaDate(self): c = self.ctrpiva t = self.GetChildren()[0] piva = t.GetValue() c.SetPIva(piva) if c.Analizza() == c.PIVA_OK: if self.askforlink: r = awu.MsgDialog(self,\ """Confermi la connessione al sito dell'""" """Agenzia delle Entrate per verificare le """ """date di inizio e fine attività dell'""" """azienda con questa Partita IVA?""", style=wx.ICON_QUESTION|wx.YES_NO|wx.YES_DEFAULT) if r != wx.ID_YES: return wait = awu.WaitDialog(self, message="Controllo online in corso...") e = 'INDEFINITO' try: e = 'ESISTENTE' wx.BeginBusyCursor() try: try: if not c.CheckVies(): e = 'NON %s' % e err = None except FaultException, e: err = e.fault.args[1] except Exception, e: err = repr(e.args) finally: wx.EndBusyCursor() if err: err = "Problema di accesso al webservice del sistema comunitario VIES:\n%s\n\nE' possibile provare con l'accesso via web." % err awu.MsgDialog(self, err, style=wx.ICON_ERROR) e = "ERRORE" finally:
def TestData(self, parent, dbt, testrec, datareq=False): ok = True if testrec is None: testrec = dbt if testrec is None: ok = not datareq else: if testrec.RowsCount() == 0: msg = "Nessun dato da stampare" if self.messages: awu.MsgDialog(parent, msg) return False else: raise Exception, msg return ok
def WriteMagRegIva(self): rim = self.dbrim rim.Get(-1) for r in self.rsrim: rimid = r[MAGREGIVA_ID] if rimid is None or not rim.Locate(lambda x: x.id == rimid): rim.CreateNewRow() rim.id_magazz = self.db_recid rim.id = rimid rim.id_caus = r[MAGREGIVA_CAUCON_ID] rim.id_regiva = r[MAGREGIVA_REGIVA_ID] out = rim.Save() if not out: awu.MsgDialog(self, message=repr(rim.GetError())) return out
def HelpBuilder_RunEditor(self, obj, edit=False): if not self.HelpBuilder_IsObjectValidName(obj): awu.MsgDialog( self, "Il nome dell'elemento non è valido, in quanto generico (%s)" % obj.GetName()) return self.HelpBuilder_LoadObjectHelp(obj, init=True) filename = self.HelpBuilder_GetFileName(obj) afn = os.path.abspath(filename) if edit: os.spawnl(os.P_NOWAIT, 'C:\\KompoZer 0.7.10\\kompozer.exe', '"%s"' % afn, '"%s"' % afn) else: HelpBuilder_ShowHelp(afn)