def __init__(self, donnees): self.IDperiode = donnees[0] self.IDactivite = donnees[1] self.nom = donnees[2] # Période self.date_debut = UTILS_Dates.DateEngEnDateDD(donnees[3]) self.date_fin = UTILS_Dates.DateEngEnDateDD(donnees[4]) self.periode = u"%s;%s" % (self.date_fin, self.date_debut) # Affichage self.affichage = bool(donnees[5]) self.affichage_date_debut = donnees[6] self.affichage_date_fin = donnees[7] if self.affichage == True : if self.affichage_date_debut == None : self.affichage_periode = True #_(u"Toujours afficher") self.affichage_actuel = True else : self.affichage_periode = (self.affichage_date_fin, self.affichage_date_debut) if datetime.datetime.strptime(self.affichage_date_debut, "%Y-%m-%d %H:%M:%S") <= datetime.datetime.now() and datetime.datetime.strptime(self.affichage_date_fin, "%Y-%m-%d %H:%M:%S") >= datetime.datetime.now() : self.affichage_actuel = True else : self.affichage_actuel = False else : self.affichage_periode = False #_(u"Ne pas afficher") self.affichage_actuel = False
def GetInfosActivites(DB=None, listeActivites=[]): """ Récupération des infos sur les activités souhaitées """ if len(listeActivites) == 0: conditionActivites = "()" elif len(listeActivites) == 1: conditionActivites = "(%d)" % listeActivites[0] else: conditionActivites = str(tuple(listeActivites)) req = _( u"SELECT IDactivite, nom, abrege, date_debut, date_fin FROM activites WHERE IDactivite IN %s ORDER BY date_debut;" ) % conditionActivites DB.ExecuterReq(req) listeDonnees = DB.ResultatReq() listeInfosActivites = [] for IDactivite, nom, abrege, date_debut, date_fin in listeDonnees: if date_debut != None: date_debut = UTILS_Dates.DateEngEnDateDD(date_debut) if date_fin != None: date_fin = UTILS_Dates.DateEngEnDateDD(date_fin) if date_debut not in (datetime.date( 1977, 1, 1), datetime.date( 2999, 1, 1), None) and date_fin not in (datetime.date( 1977, 1, 1), datetime.date(2999, 1, 1), None): date_milieu = date_debut + ((date_fin - date_debut) / 2) else: date_milieu = None listeInfosActivites.append({ "nom": nom, "abrege": abrege, "date_debut": date_debut, "date_fin": date_fin, "date_milieu": date_milieu }) return listeInfosActivites
def RechercheFormat(valeur): """ Recherche le type de la donnée """ if type(valeur) == decimal.Decimal: valeur = float(valeur) return (valeur, styleEuros) if type(valeur) == float: return (valeur, None) if type(valeur) == int: return (valeur, None) if type(valeur) == datetime.date: valeur = UTILS_Dates.DateDDEnFr(valeur) return (valeur, styleDate) if type(valeur) == datetime.timedelta: return (valeur, styleHeure) try: if len(valeur) > 3: if ":" in valeur: separateur = ":" elif "h" in valeur: separateur = "h" else: separateur = None if separateur != None: donnees = valeur.split(separateur) if len(donnees) == 2: heures, minutes = donnees if len(donnees) == 3: heures, minutes, secondes = donnees valeur = datetime.timedelta(minutes=int(heures) * 60 + int(minutes)) # valeur = datetime.time(hour=int(valeur.split(separateur)[0]), minute=int(valeur.split(separateur)[1])) return (valeur, styleHeure) except: pass if type(valeur) in (str, unicode): if len(valeur) == 10: if valeur[2] == "/" and valeur[5] == "/": return (valeur, styleDate) if valeur[4] == "-" and valeur[7] == "-": return (UTILS_Dates.DateEngFr(valeur), styleDate) return unicode(valeur), None
def ConsommationsErronees(self): labelProbleme = _(u"Consommations erronées") labelCorrection = _(u"Réparer la table des consommations") req = """SELECT IDconso, date, heure_debut, heure_fin, individus.nom, individus.prenom FROM consommations LEFT JOIN individus ON individus.IDindividu = consommations.IDindividu ;""" self.DB.ExecuterReq(req) listeConso = self.DB.ResultatReq() listeTemp = [] def ValidationHeure(heure): if len(heure) < 5 : return False if heure[0] not in ("0", "1", "2") : return False if heure[1] not in ("0", "1", "2", "3", "4", "5", "6", "7", "8", "9") : return False if heure[2] != ":" : return False if heure[3] not in ("0", "1", "2", "3", "4", "5") : return False if heure[4] not in ("0", "1", "2", "3", "4", "5", "6", "7", "8", "9") : return False if int(heure[:2]) > 24 : return False if int(heure[-2:]) > 59 : return False return True for IDconso, date, heure_debut, heure_fin, nomIndividu, prenomIndividu in listeConso : date = UTILS_Dates.DateEngEnDateDD(date) individu = "" if nomIndividu != None : individu += nomIndividu if prenomIndividu != None : individu += " " + prenomIndividu if heure_debut != None : if ValidationHeure(heure_debut) == False : label = _(u"Conso ID%d de %s : Heure de début de consommation erronée ('%s')") % (IDconso, individu, heure_debut) listeTemp.append(CorrigerHeuresConso(label=label, IDconso=IDconso, date=date, individu=individu, heure_debut=heure_debut, heure_fin=None)) if heure_fin != None : if ValidationHeure(heure_fin) == False : label = _(u"Conso ID%d de %s : Heure de fin de consommation erronée ('%s')") % (IDconso, individu, heure_fin) listeTemp.append(CorrigerHeuresConso(label=label, IDconso=IDconso, date=date, individu=individu, heure_debut=None, heure_fin=heure_fin)) self.listeResultats.append((labelProbleme, labelCorrection, listeTemp))
def PrestationsFantomes(self): labelProbleme = _(u"Prestations fantômes") labelCorrection = _(u"Supprimer la prestation fantôme") # Récupération des prestations from dateutil import relativedelta date_limite = datetime.date.today() + relativedelta.relativedelta( months=-2) req = """SELECT IDprestation, label, date, IDfamille, prestations.IDindividu, individus.nom, individus.prenom FROM prestations LEFT JOIN individus ON individus.IDindividu = prestations.IDindividu WHERE categorie='consommation' AND forfait IS NULL AND IDfacture IS NULL AND date>='%s' ORDER BY date, prestations.IDfamille, prestations.IDindividu ;""" % date_limite self.DB.ExecuterReq(req) listePrestations = self.DB.ResultatReq() # Récupération des consommations req = """SELECT IDconso, IDprestation FROM consommations;""" self.DB.ExecuterReq(req) listeConsommations = self.DB.ResultatReq() # Analyse dictPrestations = {} for IDconso, IDprestation in listeConsommations: if dictPrestations.has_key(IDprestation) == False: dictPrestations[IDprestation] = [] dictPrestations[IDprestation].append(IDconso) listeTemp = [] for IDprestation, label, date, IDfamille, IDindividu, nom, prenom in listePrestations: date = UTILS_Dates.DateEngEnDateDD(date) if dictPrestations.has_key(IDprestation) == False: if nom != None and prenom != None: nomIndividu = u"%s %s" % (nom, prenom) else: nomIndividu = u"" label = u"Prestation ID%d du %s pour %s : %s" % ( IDprestation, UTILS_Dates.DateDDEnFr(date), nomIndividu, label) listeTemp.append( PrestationsFantomes(label=label, IDprestation=IDprestation)) self.listeResultats.append((labelProbleme, labelCorrection, listeTemp))
def VerificationConditions(self, dictSauvegarde={}): """ Vérifie si conditions de la procédure sont valides """ jours_scolaires = dictSauvegarde["condition_jours_scolaires"] jours_vacances = dictSauvegarde["condition_jours_vacances"] heures = dictSauvegarde["condition_heure"] poste = dictSauvegarde["condition_poste"] derniere = dictSauvegarde["condition_derniere"] utilisateur = dictSauvegarde["condition_utilisateur"] dateDuJour = datetime.date.today() # Jour if jours_scolaires != None or jours_vacances != None : jours_scolaires = ConvertChaineEnListe(jours_scolaires) jours_vacances = ConvertChaineEnListe(jours_vacances) valide = False if jours_scolaires != None : if self.EstEnVacances(dateDuJour) == False : if dateDuJour.weekday() in jours_scolaires : valide = True if jours_vacances != None : if self.EstEnVacances(dateDuJour) == True : if dateDuJour.weekday() in jours_vacances : valide = True if valide == False : return False # Heure if heures != None : heureActuelle = time.strftime('%H:%M', time.localtime()) heure_min, heure_max = heures.split(";") if heureActuelle < heure_min or heureActuelle > heure_max : return False # Poste if poste != None : listePostes = poste.split(";") if socket.gethostname() not in listePostes : return False # Dernière sauvegarde if derniere != None : date_derniere = dictSauvegarde["date_derniere"] if date_derniere != None : date_derniere = UTILS_Dates.DateEngEnDateDD(date_derniere) nbreJours = (dateDuJour - date_derniere).days if nbreJours < int(derniere) : return False # Utilisateur if utilisateur != None : listeUtilisateurs = ConvertChaineEnListe(utilisateur) IDutilisateur = UTILS_Identification.GetIDutilisateur() if IDutilisateur not in listeUtilisateurs : return False return True
def __init__(self, **kwargs): self.callback = kwargs.pop("callback", None) self.selectionActivite = kwargs.pop("IDactivite", None) super(Popup, self).__init__(**kwargs) self.ctrl_listview.layout_manager.bind( selected_nodes=self.selectionChange) # Importation des activités DB = GestionDB.DB() req = """SELECT IDactivite, nom, date_debut, date_fin FROM activites ORDER BY date_fin DESC;""" DB.ExecuterReq(req) listeTemp = DB.ResultatReq() DB.Close() # Préparation des données self.data = [] self.dictActivites = {} index = 0 selection = None for IDactivite, nom, date_debut, date_fin in listeTemp: date_debut = UTILS_Dates.DateEngFr(date_debut) date_fin = UTILS_Dates.DateEngFr(date_fin) label = nom if IDactivite == self.selectionActivite: selection = index dictActivite = ({ "IDactivite": IDactivite, "nom": nom, "nom": nom, "label": label, "date_debut": date_debut, "date_fin": date_fin }) self.data.append(dictActivite) self.dictActivites[IDactivite] = dictActivite index += 1 self.ctrl_listview.data = self.data if selection != None: self.controller.select_node(selection)
def __init__(self, **kwargs): self.callback = kwargs.pop("callback", None) self.dictConso = kwargs.pop("dictConso", None) self.typeAction = kwargs.pop("typeAction", None) self.grille = kwargs.pop("grille", None) super(Popup, self).__init__(**kwargs) # Importation des données if self.dictConso != None : # Titre nomUnite = self.grille.dictUnites[self.dictConso["IDunite"]]["nom"] dateStr = UTILS_Dates.DateDDEnFr(self.dictConso["date"]) self.title = nomUnite + " du " + dateStr # Etat self.etat = self.dictConso["etat"] # Horaires if self.dictConso["heure_debut"] != None : self.ctrl_heure_debut.text = self.dictConso["heure_debut"] if self.dictConso["heure_fin"] != None : self.ctrl_heure_fin.text = self.dictConso["heure_fin"] if self.grille.dictUnites[self.dictConso["IDunite"]]["heure_debut_fixe"] == 1 : self.ctrl_heure_debut.disabled = True self.bouton_horloge_heure_debut.disabled = True if self.grille.dictUnites[self.dictConso["IDunite"]]["heure_fin_fixe"] == 1 : self.ctrl_heure_fin.disabled = True self.bouton_horloge_heure_fin.disabled = True # Quantité if self.grille.dictUnites[self.dictConso["IDunite"]]["type"] == "Quantite" : if self.dictConso["quantite"] != None : self.ctrl_quantite.text = str(self.dictConso["quantite"]) else : self.ctrl_quantite_moins.disabled = 1 self.ctrl_quantite.disabled = 1 self.ctrl_quantite_plus.disabled = 1 # Remplissage du contrôle Groupe self.liste_groupes = [] nomGroupeSelection = None for IDgroupe, dictGroupe in self.grille.dictGroupes.items() : self.liste_groupes.append((dictGroupe["ordre"], dictGroupe["nom"], IDgroupe)) if IDgroupe == self.dictConso["IDgroupe"] : nomGroupeSelection = dictGroupe["nom"] self.liste_groupes.sort() if nomGroupeSelection != None : self.spinner_groupe.text = nomGroupeSelection
def Fusion(self, IDtexte=None, dictRappel={}): # Fusion du texte avec les champs texte = self.dictTextesRappels[IDtexte]["texte_pdf"] for motCle, code in MOTSCLES: valeur = dictRappel[code] if type(valeur) == int: valeur = str(valeur) if type(valeur) == float: if valeur < 0: valeur = -valeur valeur = str(valeur) if type(valeur) == datetime.date: valeur = UTILS_Dates.DateEngFr(str(valeur)) if valeur == None: valeur = u"" texte = texte.replace(motCle, valeur) return texte
def InscriptionsSansIndividus(self): labelProbleme = _(u"Inscriptions sans individus associés") labelCorrection = _(u"Supprimer l'inscription") req = """SELECT IDinscription, inscriptions.IDactivite, activites.nom, inscriptions.date_inscription, inscriptions.IDindividu FROM inscriptions LEFT JOIN individus ON individus.IDindividu = inscriptions.IDindividu LEFT JOIN activites ON activites.IDactivite = inscriptions.IDactivite WHERE individus.IDindividu IS NULL;""" self.DB.ExecuterReq(req) listePrestations = self.DB.ResultatReq() listeTemp = [] for IDinscription, IDactivite, nomActivite, dateInscription, IDindividu in listePrestations : label = _(u"Individu ID%d inscrit le %s à l'activité %s") % (IDindividu, UTILS_Dates.DateEngFr(dateInscription), nomActivite) listeTemp.append(InscriptionsSansIndividus(label=label, IDinscription=IDinscription, IDindividu=IDindividu)) self.listeResultats.append((labelProbleme, labelCorrection, listeTemp))
def GetMandats(self): """ Récupération des mandats """ DB = GestionDB.DB() req = """SELECT IDmandat, IDfamille, rum, type, date, IDbanque, mandats.IDindividu, individu_nom, iban, bic, sequence, actif, individus.nom, individus.prenom FROM mandats LEFT JOIN individus ON individus.IDindividu = mandats.IDindividu ORDER BY date;""" DB.ExecuterReq(req) listeDonnees = DB.ResultatReq() DB.Close() dictMandats = {} dictMandatsFamilles = {} for IDmandat, IDfamille, rum, type, date, IDbanque, IDindividu, individu_nom, iban, bic, sequence, actif, nomIndividu, prenomIndividu in listeDonnees: date = UTILS_Dates.DateEngEnDateDD(date) if IDindividu == None: if individu_nom == None: individu_nom = u"" titulaire = individu_nom else: if nomIndividu == None: nomIndividu = u"" if prenomIndividu == None: prenomIndividu = u"" titulaire = u"%s %s" % (nomIndividu, prenomIndividu) dictTemp = { "IDmandat": IDmandat, "IDfamille": IDfamille, "rum": rum, "type": type, "date": date, "IDbanque": IDbanque, "IDindividu": IDindividu, "individu_nom": individu_nom, "iban": iban, "bic": bic, "sequence": sequence, "actif": actif, "nomIndividu": nomIndividu, "prenomIndividu": prenomIndividu, "titulaire": titulaire, } dictMandats[IDmandat] = dictTemp if dictMandatsFamilles.has_key(IDfamille) == False: dictMandatsFamilles[IDfamille] = [] dictMandatsFamilles[IDfamille].append(IDmandat) return dictMandats, dictMandatsFamilles
def PrestationsSansFamilles(self): labelProbleme = _(u"Prestations sans familles associées") labelCorrection = _(u"Supprimer la prestation") req = """SELECT IDprestation, date, label, prestations.IDfamille FROM prestations LEFT JOIN familles ON familles.IDfamille = prestations.IDfamille WHERE familles.IDfamille IS NULL;""" self.DB.ExecuterReq(req) listeDonnees = self.DB.ResultatReq() listeTemp = [] for IDprestation, date, label, IDfamille in listeDonnees: label = _(u"Prestation ID%d '%s' saisie le %s pour la famille ID%d" ) % (IDprestation, label, UTILS_Dates.DateEngFr(date), IDfamille) listeTemp.append( PrestationsSansFamilles(label=label, IDprestation=IDprestation, IDfamille=IDfamille)) self.listeResultats.append((labelProbleme, labelCorrection, listeTemp))
def CotisationsSansFamilles(self): labelProbleme = _(u"Cotisations sans familles associées") labelCorrection = _(u"Supprimer la cotisation") req = """SELECT IDcotisation, types_cotisations.nom, unites_cotisations.nom, cotisations.date_saisie, cotisations.IDfamille, cotisations.IDprestation FROM cotisations LEFT JOIN familles ON familles.IDfamille = cotisations.IDfamille LEFT JOIN types_cotisations ON types_cotisations.IDtype_cotisation = cotisations.IDtype_cotisation LEFT JOIN unites_cotisations ON unites_cotisations.IDunite_cotisation = cotisations.IDunite_cotisation WHERE familles.IDfamille IS NULL AND cotisations.IDfamille IS NOT NULL;""" self.DB.ExecuterReq(req) listeDonnees = self.DB.ResultatReq() listeTemp = [] for IDcotisation, nomType, nomUnite, dateSaisie, IDfamille, IDprestation in listeDonnees: label = _( u"Cotisation ID%d de type '%s - %s' saisie le %s pour la famille ID%d" ) % (IDcotisation, nomType, nomUnite, UTILS_Dates.DateEngFr(dateSaisie), IDfamille) listeTemp.append( CotisationsSansFamilles(label=label, IDcotisation=IDcotisation, IDfamille=IDfamille, IDprestation=IDprestation)) self.listeResultats.append((labelProbleme, labelCorrection, listeTemp))
def GetPrelevementsMandats(self): """ Récupère les prélèvements existants pour chaque mandat """ DB = GestionDB.DB() # Prélèvements req = """SELECT IDprelevement, IDfamille, IDmandat, statut, lots_prelevements.date FROM prelevements LEFT JOIN lots_prelevements ON lots_prelevements.IDlot = prelevements.IDlot WHERE IDmandat IS NOT NULL ORDER BY lots_prelevements.date ;""" DB.ExecuterReq(req) listePrelevements = DB.ResultatReq() # Pièces PES ORMC req = """SELECT IDpiece, IDfamille, prelevement_IDmandat, prelevement_statut, pes_lots.date_prelevement FROM pes_pieces LEFT JOIN pes_lots ON pes_lots.IDlot = pes_pieces.IDlot WHERE prelevement_IDmandat IS NOT NULL AND prelevement=1 ORDER BY pes_lots.date_prelevement ;""" DB.ExecuterReq(req) listePieces = DB.ResultatReq() DB.Close() dictPrelevements = {} for listeDonnees in (listePrelevements, listePieces): for IDprelevement, IDfamille, IDmandat, statut, date in listeDonnees: date = UTILS_Dates.DateEngEnDateDD(date) if dictPrelevements.has_key(IDmandat) == False: dictPrelevements[IDmandat] = [] dictPrelevements[IDmandat].append({ "IDprelevement": IDprelevement, "IDfamille": IDfamille, "IDmandat": IDmandat, "statut": statut, "date": date }) return dictPrelevements
def __init__(self, dictValeurs={}, IDmodele=None, nomDoc=FonctionsPerso.GenerationNomDoc( "RECU_REGLEMENT", "pdf"), afficherDoc=True): """ Impression """ global DICT_VALEURS DICT_VALEURS = dictValeurs # Initialisation du document doc = BaseDocTemplate(nomDoc, pagesize=TAILLE_PAGE, showBoundary=False) # Mémorise le ID du modèle modeleDoc = DLG_Noedoc.ModeleDoc(IDmodele=IDmodele) doc.modeleDoc = modeleDoc # Vérifie qu'un cadre principal existe bien dans le document if doc.modeleDoc.FindObjet("cadre_principal") == None: raise Exception( "Votre modele de document doit obligatoirement comporter un cadre principal. Retournez dans l'editeur de document et utilisez pour votre modele la commande 'Inserer un objet special > Inserer le cadre principal'." ) # Mémorise le ID du modèle modeleDoc = DLG_Noedoc.ModeleDoc(IDmodele=IDmodele) doc.modeleDoc = modeleDoc doc.addPageTemplates(MyPageTemplate(pageSize=TAILLE_PAGE, doc=doc)) story = [] styleSheet = getSampleStyleSheet() h3 = styleSheet['Heading3'] styleTexte = styleSheet['BodyText'] styleTexte.fontName = "Helvetica" styleTexte.fontSize = 9 styleTexte.borderPadding = 9 styleTexte.leading = 12 ## # Définit le template des pages suivantes ## story.append(NextPageTemplate("suivante")) # ----------- Insertion du contenu des frames -------------- # ------------------- TITRE ----------------- dataTableau = [] largeursColonnes = [ TAILLE_CADRE_CONTENU[2], ] dataTableau.append((_(u"Reçu de règlement"), )) dataTableau.append((u"", )) style = TableStyle([ ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'), ('FONT', (0, 0), (0, 0), "Helvetica-Bold", 19), ('FONT', (0, 1), (0, 1), "Helvetica", 8), ('LINEBELOW', (0, 0), (0, 0), 0.25, colors.black), ('ALIGN', (0, 0), (-1, -1), 'LEFT'), ]) tableau = Table(dataTableau, largeursColonnes) tableau.setStyle(style) story.append(tableau) story.append(Spacer(0, 10)) # TEXTE D'INTRODUCTION paraStyleIntro = ParagraphStyle( name="intro", fontName="Helvetica", fontSize=11, leading=14, spaceBefore=0, spaceafter=0, leftIndent=0, rightIndent=0, alignment=0, ) if DICT_VALEURS["intro"] != None: texteIntro = DICT_VALEURS["intro"] story.append(Paragraph(u"<i>%s</i>" % texteIntro, paraStyleIntro)) story.append(Spacer(0, 20)) couleurFond = (0.8, 0.8, 1) # ------------------- TABLEAU CONTENU ----------------- dataTableau = [] largeursColonnes = [120, 280] paraStyle = ParagraphStyle( name="detail", fontName="Helvetica-Bold", fontSize=9, ) dataTableau.append((_(u"Caractéristiques du règlement"), "")) montantEnLettres = UTILS_Conversion.trad(DICT_VALEURS["montant"], MONNAIE_SINGULIER, MONNAIE_DIVISION).strip() dataTableau.append((_(u"Montant du règlement :"), Paragraph(montantEnLettres.capitalize(), paraStyle))) dataTableau.append((_(u"Mode de règlement :"), Paragraph(DICT_VALEURS["nomMode"], paraStyle))) dataTableau.append((_(u"Nom du payeur :"), Paragraph(DICT_VALEURS["nomPayeur"], paraStyle))) if DICT_VALEURS["nomEmetteur"] != None: dataTableau.append((_(u"Nom de l'émetteur :"), Paragraph(DICT_VALEURS["nomEmetteur"], paraStyle))) if DICT_VALEURS["numPiece"] not in ("", None): dataTableau.append((_(u"Numéro de pièce :"), Paragraph(DICT_VALEURS["numPiece"], paraStyle))) style = TableStyle([ ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'), ('FONT', (0, 0), (0, -1), "Helvetica", 9), ('FONT', (1, 0), (1, -1), "Helvetica-Bold", 9), ('GRID', (0, 0), (-1, -1), 0.25, colors.black), ('ALIGN', (0, 1), (0, -1), 'RIGHT'), ('ALIGN', (1, 1), (1, -1), 'LEFT'), ('FONT', (0, 0), (0, 0), "Helvetica", 7), ('SPAN', (0, 0), (-1, 0)), ('BACKGROUND', (0, 0), (-1, 0), couleurFond), ]) tableau = Table(dataTableau, largeursColonnes) tableau.setStyle(style) story.append(tableau) # --------------------- LISTE DES PRESTATIONS ---------------- listePrestations = dictValeurs["prestations"] if len(listePrestations) > 0: story.append(Spacer(0, 20)) textePrestations = _(u"En paiement des prestations suivantes :") story.append( Paragraph(u"<i>%s</i>" % textePrestations, paraStyleIntro)) story.append(Spacer(0, 20)) dataTableau = [ (_(u"Date"), _(u"Activité"), _(u"Individu"), _(u"Intitulé"), _(u"Part utilisée")), ] largeursColonnes = [50, 95, 70, 135, 50] paraStyle = ParagraphStyle( name="detail", fontName="Helvetica", fontSize=7, leading=7, spaceBefore=0, spaceAfter=0, ) for dictPrestation in listePrestations: date = UTILS_Dates.DateDDEnFr(dictPrestation["date"]) activite = dictPrestation["nomActivite"] individu = dictPrestation["prenomIndividu"] label = dictPrestation["label"] montant = dictPrestation["montant"] ventilation = dictPrestation["ventilation"] dataTableau.append(( Paragraph(u"<para align='center'>%s</para>" % date, paraStyle), Paragraph(activite, paraStyle), Paragraph(individu, paraStyle), Paragraph(label, paraStyle), Paragraph( u"<para align='right'>%.2f %s</para>" % (ventilation, SYMBOLE), paraStyle), )) style = TableStyle([ ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'), ('GRID', (0, 0), (-1, -1), 0.25, colors.black), ('FONT', (0, 0), (-1, -1), "Helvetica", 7), ('TOPPADDING', (0, 1), (-1, -1), 1), ('BOTTOMPADDING', (0, 1), (-1, -1), 3), # Ligne Entetes ('FONT', (0, 0), (-1, 0), "Helvetica", 7), ('BACKGROUND', (0, 0), (-1, 0), couleurFond), ('ALIGN', (0, 0), (-1, 0), 'CENTER'), ]) tableau = Table(dataTableau, largeursColonnes) tableau.setStyle(style) story.append(tableau) # Enregistrement et ouverture du PDF try: doc.build(story) except Exception, err: print "Erreur dans ouverture PDF :", err if "Permission denied" in err: dlg = wx.MessageDialog( None, _(u"Noethys ne peut pas créer le PDF.\n\nVeuillez vérifier qu'un autre PDF n'est pas déjà ouvert en arrière-plan..." ), _(u"Erreur d'édition"), wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() return
def __init__(self, **kwargs): self.IDactivite = kwargs.pop("IDactivite", None) self.date_debut = kwargs.pop("date_debut", None) self.date_fin = kwargs.pop("date_fin", None) self.callback = kwargs.pop("callback", None) super(Popup, self).__init__(**kwargs) self.ctrl_standards.layout_manager.bind( selected_nodes=self.OnSelectionStandard) self.ctrl_groupes.layout_manager.bind( selected_nodes=self.OnSelectionGroupe) self.ctrl_ecoles.layout_manager.bind( selected_nodes=self.OnSelectionEcole) self.ctrl_classes.layout_manager.bind( selected_nodes=self.OnSelectionClasse) # Filtres standards data = [] data.append({"filtre": "presents", "nom": "Présents"}) data.append({"filtre": "inscrits", "nom": "Inscrits"}) self.ctrl_standards.data = data DB = GestionDB.DB() # Importation des groupes if self.IDactivite == None: self.IDactivite = 0 req = """SELECT IDgroupe, nom FROM groupes WHERE IDactivite=%d ORDER BY nom;""" % self.IDactivite DB.ExecuterReq(req) liste_groupes = DB.ResultatReq() data = [] for IDgroupe, nom in liste_groupes: dictGroupe = {"idgroupe": IDgroupe, "nom": nom} data.append(dictGroupe) self.ctrl_groupes.data = data # Importation des classes req = """SELECT IDecole, nom FROM ecoles ORDER BY nom;""" DB.ExecuterReq(req) liste_ecoles = DB.ResultatReq() data = [] for IDecole, nom in liste_ecoles: dictEcole = {"idecole": IDecole, "nom": nom} data.append(dictEcole) self.ctrl_ecoles.data = data req = """SELECT IDniveau, nom, ordre FROM niveaux_scolaires ORDER BY ordre;""" DB.ExecuterReq(req) liste_niveaux = DB.ResultatReq() dict_niveaux = {} for IDniveau, nom, ordre in liste_niveaux: dict_niveaux[IDniveau] = {"nom": nom, "ordre": ordre} req = """SELECT IDclasse, classes.nom, date_debut, date_fin, niveaux, classes.IDecole, ecoles.nom FROM classes LEFT JOIN ecoles ON ecoles.IDecole = classes.IDecole WHERE date_debut<='%s' AND date_fin>='%s' ORDER BY ecoles.nom, date_debut;""" % (self.date_fin, self.date_debut) DB.ExecuterReq(req) liste_classes = DB.ResultatReq() DB.Close() # Préparation des données self.dictClasses = {} dictTemp = {} index = 0 for IDclasse, nom, date_debut, date_fin, niveaux, IDecole, nom_ecole in liste_classes: niveaux = UTILS_Divers.ConvertStrToListe(niveaux) ordres = [] for IDniveau in niveaux: ordres.append(dict_niveaux[IDniveau]["ordre"]) ordres.sort() dictClasse = { "idclasse": IDclasse, "nom": nom, "nom_ecole": nom_ecole, "niveaux": niveaux, "label": nom, "date_debut": UTILS_Dates.DateEngFr(date_debut), "date_fin": UTILS_Dates.DateEngFr(date_fin), "IDecole": IDecole, } self.dictClasses[IDclasse] = dictClasse key_tri = (IDecole, date_debut, tuple(ordres), IDclasse) dictTemp[key_tri] = dictClasse index += 1 keys = list(dictTemp) keys.sort() self.ctrl_classes.data = [dictTemp[key] for key in keys]
def GetDonnees( self, listeRappels=[], liste_activites=[], listeExceptionsComptes=[], date_reference=None, date_edition=None, prestations=["consommation", "cotisation", "location", "autre"]): """ Recherche des rappels à créer """ # Création des conditions SQL if len(liste_activites) == 0: conditionActivites = "()" elif len(liste_activites) == 1: conditionActivites = "(%d)" % liste_activites[0] else: conditionActivites = str(tuple(liste_activites)) if len(listeExceptionsComptes) == 0: conditionComptes = "()" elif len(listeExceptionsComptes) == 1: conditionComptes = "(%d)" % listeExceptionsComptes[0] else: conditionComptes = str(tuple(listeExceptionsComptes)) if len(prestations) == 1: conditionPrestations = " prestations.categorie='%s'" % prestations[ 0] else: conditionPrestations = " prestations.categorie IN %s" % str( tuple(prestations)).replace("u'", "'") DB = GestionDB.DB() # Recherche des prestations de la période req = """SELECT prestations.IDcompte_payeur, prestations.IDfamille, MIN(prestations.date), MAX(prestations.date), SUM(prestations.montant) FROM prestations WHERE (prestations.IDactivite IN %s OR prestations.IDactivite IS NULL) AND prestations.date <= '%s' AND prestations.IDcompte_payeur NOT IN %s AND %s GROUP BY prestations.IDcompte_payeur ;""" % (conditionActivites, str(date_reference), conditionComptes, conditionPrestations) DB.ExecuterReq(req) listePrestations = DB.ResultatReq() # Récupération de la ventilation req = """SELECT prestations.IDcompte_payeur, SUM(ventilation.montant) FROM ventilation LEFT JOIN prestations ON prestations.IDprestation = ventilation.IDprestation WHERE (prestations.IDactivite IN %s OR prestations.IDactivite IS NULL) AND prestations.date <= '%s' AND prestations.IDcompte_payeur NOT IN %s GROUP BY prestations.IDcompte_payeur ;""" % (conditionActivites, str(date_reference), conditionComptes) DB.ExecuterReq(req) listeVentilation = DB.ResultatReq() dictVentilation = {} for IDcompte_payeur, totalVentilation in listeVentilation: dictVentilation[IDcompte_payeur] = totalVentilation DB.Close() # Analyse et regroupement des données dictComptes = {} for IDcompte_payeur, IDfamille, date_min, date_max, montant in listePrestations: if dictVentilation.has_key(IDcompte_payeur): montant_ventilation = dictVentilation[IDcompte_payeur] else: montant_ventilation = 0.0 # Regroupement par compte payeur if montant_ventilation == None: montant_ventilation = 0.0 # conversion en decimal if montant == None: montant = 0.0 montant = decimal.Decimal(str(montant)) montant_ventilation = decimal.Decimal(str(montant_ventilation)) numero = 0 solde = montant_ventilation - montant if solde < decimal.Decimal("0.0"): dictComptes[IDcompte_payeur] = { "{FAMILLE_NOM}": self.dictTitulaires[IDfamille]["titulairesAvecCivilite"], "nomSansCivilite": self.dictTitulaires[IDfamille]["titulairesSansCivilite"], "IDfamille": IDfamille, "{IDFAMILLE}": IDfamille, "{FAMILLE_RUE}": self.dictTitulaires[IDfamille]["adresse"]["rue"], "{FAMILLE_CP}": self.dictTitulaires[IDfamille]["adresse"]["cp"], "{FAMILLE_VILLE}": self.dictTitulaires[IDfamille]["adresse"]["ville"], "num_rappel": numero, "{NUM_RAPPEL}": u"%06d" % numero, "{NOM_LOT}": "", "solde_num": -solde, "solde": u"%.02f %s" % (-solde, SYMBOLE), "{SOLDE}": u"%.02f %s" % (-solde, SYMBOLE), "solde_lettres": UTILS_Conversion.trad(-solde, MONNAIE_SINGULIER, MONNAIE_DIVISION), "{SOLDE_LETTRES}": UTILS_Conversion.trad(-solde, MONNAIE_SINGULIER, MONNAIE_DIVISION), "select": True, "num_codeBarre": "%07d" % numero, "numero": _(u"Rappel n°%07d") % numero, "{CODEBARRES_NUM_RAPPEL}": "F%06d" % numero, "date_min": UTILS_Dates.DateEngEnDateDD(date_min), "date_max": UTILS_Dates.DateEngEnDateDD(date_max), "{DATE_MIN}": UTILS_Dates.DateEngEnDateDD(date_min), "{DATE_MAX}": UTILS_Dates.DateEngEnDateDD(date_max), "{DATE_EDITION_LONG}": UTILS_Dates.DateComplete(date_edition), "{DATE_EDITION_COURT}": UTILS_Dates.DateEngFr(str(date_edition)), "{ORGANISATEUR_NOM}": self.dictOrganisme["nom"], "{ORGANISATEUR_RUE}": self.dictOrganisme["rue"], "{ORGANISATEUR_CP}": self.dictOrganisme["cp"], "{ORGANISATEUR_VILLE}": self.dictOrganisme["ville"], "{ORGANISATEUR_TEL}": self.dictOrganisme["tel"], "{ORGANISATEUR_FAX}": self.dictOrganisme["fax"], "{ORGANISATEUR_MAIL}": self.dictOrganisme["mail"], "{ORGANISATEUR_SITE}": self.dictOrganisme["site"], "{ORGANISATEUR_AGREMENT}": self.dictOrganisme["num_agrement"], "{ORGANISATEUR_SIRET}": self.dictOrganisme["num_siret"], "{ORGANISATEUR_APE}": self.dictOrganisme["code_ape"], } # Ajout les données de base familles dictComptes[IDcompte_payeur].update( self.infosIndividus.GetDictValeurs(mode="famille", ID=IDfamille, formatChamp=True)) # Ajoute les réponses des questionnaires for dictReponse in self.Questionnaires.GetDonnees(IDfamille): dictComptes[IDcompte_payeur][ dictReponse["champ"]] = dictReponse["reponse"] if dictReponse["controle"] == "codebarres": dictComptes[IDcompte_payeur][ "{CODEBARRES_QUESTION_%d}" % dictReponse["IDquestion"]] = dictReponse["reponse"] return dictComptes
def A8956(): """ Réparation des factures : Rapprochement des factures et des prestations détachées """ from UTILS_Decimal import FloatToDecimal import UTILS_Dates import copy DB = GestionDB.DB() # Lecture des prestations req = """SELECT IDprestation, IDcompte_payeur, date, montant, IDfacture FROM prestations ;""" DB.ExecuterReq(req) listeDonnees = DB.ResultatReq() dictPrestations = {} dictPrestationsFactures = {} for IDprestation, IDcompte_payeur, date, montant, IDfacture in listeDonnees : montant = FloatToDecimal(montant) date = UTILS_Dates.DateEngEnDateDD(date) dictTemp = {"IDprestation":IDprestation, "IDcompte_payeur":IDcompte_payeur, "date":date, "montant":montant, "IDfacture":IDfacture} if dictPrestations.has_key(IDcompte_payeur) == False : dictPrestations[IDcompte_payeur] = [] dictPrestations[IDcompte_payeur].append(dictTemp) if dictPrestationsFactures.has_key(IDfacture) == False : dictPrestationsFactures[IDfacture] = {"total" : FloatToDecimal(0.0), "prestations" : []} dictPrestationsFactures[IDfacture]["prestations"].append(dictTemp) dictPrestationsFactures[IDfacture]["total"] += montant # Lecture des factures req = """SELECT IDfacture, IDcompte_payeur, date_debut, date_fin, total FROM factures ;""" DB.ExecuterReq(req) listeDonnees = DB.ResultatReq() listePrestationsReparees = [] listeFacturesReparees = [] for IDfacture, IDcompte_payeur, date_debut, date_fin, total_facture in listeDonnees : date_debut = UTILS_Dates.DateEngEnDateDD(date_debut) date_fin = UTILS_Dates.DateEngEnDateDD(date_fin) total_facture = FloatToDecimal(total_facture) # Vérifie si le total des prestations correspond bien au total de la facture if dictPrestationsFactures.has_key(IDfacture): total_prestations = dictPrestationsFactures[IDfacture]["total"] else : total_prestations = FloatToDecimal(0.0) if total_prestations < total_facture : #print "PROBLEME : ", IDcompte_payeur, IDfacture, total_prestations, total_facture # Recherche les possibles prestations à rattacher listePrestationsTrouvees = [] totalPrestationsTrouvees = copy.copy(total_prestations) if dictPrestations.has_key(IDcompte_payeur) : for dictPrestation in dictPrestations[IDcompte_payeur] : if dictPrestation["IDfacture"] == None and dictPrestation["date"] >= date_debut and dictPrestation["date"] <= date_fin : listePrestationsTrouvees.append(dictPrestation) totalPrestationsTrouvees += dictPrestation["montant"] # Si la liste des prestations correspond bien aux prestations manquantes de la facture, on les associe if total_facture == totalPrestationsTrouvees : for dictPrestation in listePrestationsTrouvees : DB.ReqMAJ("prestations", [("IDfacture", IDfacture),], "IDprestation", dictPrestation["IDprestation"]) listePrestationsReparees.append(dictPrestation) if IDfacture not in listeFacturesReparees : listeFacturesReparees.append(IDfacture) DB.Close() # Message de fin dlg = wx.MessageDialog(None, _(u"Résultats :\n\nNombre de factures réparées = %d\nNombre de prestations réparées = %d" % (len(listeFacturesReparees), len(listePrestationsReparees))), _(u"Fin de la procédure"), wx.OK | wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy()
def A5500(): """ Réparation des liens prestations/factures """ import UTILS_Dates import time from Dlg import DLG_Selection_dates dlg = DLG_Selection_dates.Dialog(None) if dlg.ShowModal() == wx.ID_OK: periode_date_debut = dlg.GetDateDebut() periode_date_fin = dlg.GetDateFin() dlg.Destroy() else : dlg.Destroy() return DB = GestionDB.DB() # Lecture des factures req = """SELECT IDfacture, IDcompte_payeur, date_debut, date_fin FROM factures;""" DB.ExecuterReq(req) listeFactures = DB.ResultatReq() dictFactures = {} for IDfacture, IDcompte_payeur, date_debut, date_fin in listeFactures : if dictFactures.has_key(IDcompte_payeur) == False : dictFactures[IDcompte_payeur] = [] dictFactures[IDcompte_payeur].append({"IDfacture":IDfacture, "date_debut":UTILS_Dates.DateEngEnDateDD(date_debut), "date_fin":UTILS_Dates.DateEngEnDateDD(date_fin)}) # Lecture des prestations req = """SELECT IDprestation, IDcompte_payeur, date, IDfacture FROM prestations WHERE IDfacture IS NULL AND date>='%s' AND date<='%s';""" % (periode_date_debut, periode_date_fin) DB.ExecuterReq(req) listePrestations = DB.ResultatReq() nbrePrestations = len(listePrestations) # Demande de confirmation dlg = wx.MessageDialog(None, _(u"Souhaitez-vous vraiment lancer cette procédure pour %d prestations ?\n\n(Vous pourrez suivre la progression dans la barre d'état)") % nbrePrestations, _(u"Confirmation"), wx.YES_NO|wx.NO_DEFAULT|wx.CANCEL|wx.ICON_QUESTION) if dlg.ShowModal() != wx.ID_YES : dlg.Destroy() return dlg.Destroy() # Traitement index = 0 nbreSucces = 0 for IDprestation, IDcompte_payeur, date, IDfacture in listePrestations : date = UTILS_Dates.DateEngEnDateDD(date) # Recherche la facture probable if dictFactures.has_key(IDcompte_payeur) : for dictFacture in dictFactures[IDcompte_payeur] : if date >= dictFacture["date_debut"] and date <= dictFacture["date_fin"] : IDfacture = dictFacture["IDfacture"] DB.ReqMAJ("prestations", [("IDfacture", IDfacture),], "IDprestation", IDprestation) ## print "Traitement en cours... %d/%d .... Prestation ID%d -> Facture ID%d" % (index, nbrePrestations, IDprestation, IDfacture) EcritStatusbar(_(u"Traitement en cours... %d/%d .... Prestation ID%d -> Facture ID%d") % (index, nbrePrestations, IDprestation, IDfacture)) nbreSucces += 1 time.sleep(0.05) index += 1 DB.Close() # Fin du traitement dlg = wx.MessageDialog(None, _(u"Procédure terminée !\n\n%d prestations sur %s ont été rattachées avec succès !") % (nbreSucces, nbrePrestations), _(u"Fin"), wx.OK | wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy()
;""" DB.ExecuterReq(req) listeVentilation = DB.ResultatReq() dictVentilation = {} for IDfacture, montantVentilation in listeVentilation: if IDfacture != None: dictVentilation[IDfacture] = montantVentilation for IDfacture, IDprefixe, prefixe, numero, IDcompte_payeur, date_edition, date_echeance, IDutilisateur, date_debut, date_fin, total, regle, solde, IDfamille, etat in listeFactures: if numero == None: numero = 0 if IDprefixe != None: numero = u"%s-%06d" % (prefixe, numero) else: numero = u"%06d" % numero date_edition = UTILS_Dates.DateEngEnDateDD(date_edition) date_debut = UTILS_Dates.DateEngEnDateDD(date_debut) date_fin = UTILS_Dates.DateEngEnDateDD(date_fin) date_echeance = UTILS_Dates.DateEngEnDateDD(date_echeance) total = FloatToDecimal(total) if dictVentilation.has_key(IDfacture): totalVentilation = FloatToDecimal(dictVentilation[IDfacture]) else: totalVentilation = FloatToDecimal(0.0) if dictPrestations.has_key(IDfacture): totalPrestations = FloatToDecimal(dictPrestations[IDfacture]) else: totalPrestations = FloatToDecimal(0.0) solde_actuel = totalPrestations - totalVentilation m = models.Facture(IDfacture=IDfacture, IDfamille=IDfamille, numero=numero, date_edition=date_edition, date_debut=date_debut,\
def GetDonneesImpression(self, tracks=[], dictOptions={}): """ Impression des factures """ dlgAttente = PBI.PyBusyInfo(_(u"Recherche des données..."), parent=None, title=_(u"Veuillez patienter..."), icon=wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Logo.png"), wx.BITMAP_TYPE_ANY)) wx.Yield() dictDonnees = {} dictChampsFusion = {} for track in tracks : IDfamille = track.IDfamille IDcompte_payeur = track.IDcompte_payeur # Regroupement des enfants dictEnfants = {} for prestation in track.listePrestations : IDindividu = prestation["IDindividu"] if dictEnfants.has_key(IDindividu) == False : if prestation["prenom"] == None : prenom = "" else : prenom = prestation["prenom"] if prestation["date_naiss"] == None : date_naiss = "" else : date_naiss = UTILS_Dates.DateEngFr(prestation["date_naiss"]) genre = "" if prestation["IDcivilite"] != None : sexe = DICT_CIVILITES[prestation["IDcivilite"]]["sexe"] if sexe == "F" : genre = "e" nomComplet = u"%s %s" % (prestation["nom"], prenom) dictEnfants[IDindividu] = {"nomComplet" : nomComplet, "nom" : prestation["nom"], "prenom" : prenom, "date_naiss" : date_naiss, "genre" : genre, "regle" : FloatToDecimal(0.0)} dictEnfants[IDindividu]["regle"] += prestation["regle"] listeIndividus = [] for IDindividu, dictTemp in dictEnfants.iteritems() : listeIndividus.append((dictTemp["nomComplet"], dictTemp)) listeIndividus.sort() # Formatage du texte d'intro textIntro = "" if dictOptions["intro"] != None : textIntro = dictOptions["intro"] textIntro = textIntro.replace("{GENRE}", dictOptions["signataire"]["genre"]) textIntro = textIntro.replace("{NOM}", dictOptions["signataire"]["nom"]) textIntro = textIntro.replace("{FONCTION}", dictOptions["signataire"]["fonction"]) textIntro = textIntro.replace("{DATE_DEBUT}", UTILS_Dates.DateEngFr(str(dictOptions["date_debut"]))) textIntro = textIntro.replace("{DATE_FIN}", UTILS_Dates.DateEngFr(str(dictOptions["date_fin"]))) # Mémorisation des données dictDonnee = { "{ORGANISATEUR_NOM}" : self.dictOrganisme["nom"], "{ORGANISATEUR_RUE}" : self.dictOrganisme["rue"], "{ORGANISATEUR_CP}" : self.dictOrganisme["cp"], "{ORGANISATEUR_VILLE}" : self.dictOrganisme["ville"], "{ORGANISATEUR_TEL}" : self.dictOrganisme["tel"], "{ORGANISATEUR_FAX}" : self.dictOrganisme["fax"], "{ORGANISATEUR_MAIL}" : self.dictOrganisme["mail"], "{ORGANISATEUR_SITE}" : self.dictOrganisme["site"], "{ORGANISATEUR_AGREMENT}" : self.dictOrganisme["num_agrement"], "{ORGANISATEUR_SIRET}" : self.dictOrganisme["num_siret"], "{ORGANISATEUR_APE}" : self.dictOrganisme["code_ape"], "{IDFAMILLE}" : str(track.IDfamille), "{IDCOMPTE_PAYEUR}" : str(track.IDcompte_payeur), "{FAMILLE_NOM}" : track.nomsTitulairesSansCivilite, "{FAMILLE_RUE}" : track.rue_resid, "{FAMILLE_CP}" : track.cp_resid, "{FAMILLE_VILLE}" : track.ville_resid, "{DATE_EDITION_COURT}" : UTILS_Dates.DateDDEnFr(datetime.date.today()), "{DATE_EDITION_LONG}" : UTILS_Dates.DateComplete(datetime.date.today()), "{DATE_DEBUT}" : UTILS_Dates.DateDDEnFr(dictOptions["date_debut"]), "{DATE_FIN}" : UTILS_Dates.DateDDEnFr(dictOptions["date_fin"]), "{MONTANT_FACTURE}" : u"%.2f %s" % (track.montant_total, SYMBOLE), "{MONTANT_REGLE}" : u"%.2f %s" % (track.montant_regle, SYMBOLE), "{MONTANT_IMPAYE}" : u"%.2f %s" % (track.montant_impaye, SYMBOLE), "{MONTANT_FACTURE_LETTRES}" : UTILS_Conversion.trad(track.montant_total, MONNAIE_SINGULIER, MONNAIE_DIVISION), "{MONTANT_REGLE_LETTRES}" : UTILS_Conversion.trad(track.montant_regle, MONNAIE_SINGULIER, MONNAIE_DIVISION), "{MONTANT_IMPAYE_LETTRES}" : UTILS_Conversion.trad(track.montant_impaye, MONNAIE_SINGULIER, MONNAIE_DIVISION), "{INTRO}" : textIntro, "TXT_ENFANT_1" : "", "TXT_ENFANT_2" : "", "TXT_ENFANT_3" : "", "TXT_ENFANT_4" : "", "TXT_ENFANT_5" : "", "TXT_ENFANT_6" : "", "individus" : listeIndividus, } # Ajoute les infos de base familles dictDonnee.update(self.infosIndividus.GetDictValeurs(mode="famille", ID=IDfamille, formatChamp=True)) # Insertion des enfants index = 1 for nomCompletIndividu, dictIndividu in listeIndividus : dictDonnee["TXT_ENFANT_%d" % index] = _(u"%.2f %s pour %s né%s le %s") % (dictIndividu["regle"], SYMBOLE, nomCompletIndividu, dictIndividu["genre"], dictIndividu["date_naiss"]) index += 1 # Ajoute les réponses des questionnaires for dictReponse in self.Questionnaires.GetDonnees(IDfamille) : dictDonnee[dictReponse["champ"]] = dictReponse["reponse"] if dictReponse["controle"] == "codebarres" : dictDonnee["{CODEBARRES_QUESTION_%d}" % dictReponse["IDquestion"]] = dictReponse["reponse"] dictDonnees[IDcompte_payeur] = dictDonnee # Champs de fusion pour Email dictChampsFusion[IDcompte_payeur] = {} for key, valeur in dictDonnee.iteritems() : if key[0] == "{" : dictChampsFusion[IDcompte_payeur][key] = valeur del dlgAttente return dictDonnees, dictChampsFusion
def GetDonneesImpression(self, listeCotisations=[]): """ Impression des factures """ dlgAttente = PBI.PyBusyInfo( _(u"Recherche des données..."), parent=None, title=_(u"Veuillez patienter..."), icon=wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Logo.png"), wx.BITMAP_TYPE_ANY)) wx.Yield() # Récupère les données de la facture if len(listeCotisations) == 0: conditions = "()" elif len(listeCotisations) == 1: conditions = "(%d)" % listeCotisations[0] else: conditions = str(tuple(listeCotisations)) DB = GestionDB.DB() # Récupération des activités req = """SELECT IDactivite, nom, abrege FROM activites ORDER BY date_fin DESC;""" DB.ExecuterReq(req) listeTemp = DB.ResultatReq() dictActivites = {} for IDactivite, nom, abrege in listeTemp: dictTemp = {"IDactivite": IDactivite, "nom": nom, "abrege": abrege} dictActivites[IDactivite] = dictTemp # Récupère les prestations dictFacturation = {} req = """SELECT IDcotisation, SUM(montant) FROM prestations LEFT JOIN cotisations ON cotisations.IDprestation = prestations.IDprestation WHERE cotisations.IDcotisation IN %s GROUP BY cotisations.IDcotisation;""" % conditions DB.ExecuterReq(req) listePrestations = DB.ResultatReq() for IDcotisation, montant in listePrestations: dictFacturation[IDcotisation] = { "montant": montant, "ventilation": 0.0, "dateReglement": None, "modeReglement": None } # Récupère la ventilation req = """SELECT IDcotisation, SUM(ventilation.montant), MIN(reglements.date), MIN(modes_reglements.label) FROM ventilation LEFT JOIN prestations ON prestations.IDprestation = ventilation.IDprestation LEFT JOIN cotisations ON cotisations.IDprestation = ventilation.IDprestation LEFT JOIN reglements ON reglements.IDreglement = ventilation.IDreglement LEFT JOIN modes_reglements ON modes_reglements.IDmode = reglements.IDmode WHERE cotisations.IDcotisation IN %s GROUP BY cotisations.IDcotisation;""" % conditions DB.ExecuterReq(req) listeVentilations = DB.ResultatReq() for IDcotisation, ventilation, dateReglement, modeReglement in listeVentilations: if dictFacturation.has_key(IDcotisation): dictFacturation[IDcotisation]["ventilation"] = ventilation dictFacturation[IDcotisation]["dateReglement"] = dateReglement dictFacturation[IDcotisation]["modeReglement"] = modeReglement # Recherche les cotisations req = """ SELECT cotisations.IDcotisation, cotisations.IDfamille, cotisations.IDindividu, cotisations.IDtype_cotisation, cotisations.IDunite_cotisation, cotisations.date_saisie, cotisations.IDutilisateur, cotisations.date_creation_carte, cotisations.numero, cotisations.IDdepot_cotisation, cotisations.date_debut, cotisations.date_fin, cotisations.IDprestation, types_cotisations.nom, types_cotisations.type, types_cotisations.carte, unites_cotisations.nom, comptes_payeurs.IDcompte_payeur, cotisations.observations, cotisations.activites FROM cotisations LEFT JOIN types_cotisations ON types_cotisations.IDtype_cotisation = cotisations.IDtype_cotisation LEFT JOIN unites_cotisations ON unites_cotisations.IDunite_cotisation = cotisations.IDunite_cotisation LEFT JOIN comptes_payeurs ON comptes_payeurs.IDfamille = cotisations.IDfamille WHERE cotisations.IDcotisation IN %s ORDER BY cotisations.date_saisie ;""" % conditions DB.ExecuterReq(req) listeDonnees = DB.ResultatReq() DB.Close() if len(listeDonnees) == 0: del dlgAttente return False # Création des dictRappels dictDonnees = {} dictChampsFusion = {} for item in listeDonnees: IDcotisation = item[0] IDfamille = item[1] IDindividu = item[2] IDtype_cotisation = item[3] IDunite_cotisation = item[4] date_saisie = UTILS_Dates.DateEngEnDateDD(item[5]) IDutilisateur = item[6] date_creation_carte = item[7] numero = item[8] IDdepot_cotisation = item[9] date_debut = UTILS_Dates.DateEngEnDateDD(item[10]) date_fin = UTILS_Dates.DateEngEnDateDD(item[11]) IDprestation = item[12] nomTypeCotisation = item[13] typeTypeCotisation = item[14] typeHasCarte = item[15] nomUniteCotisation = item[16] IDcompte_payeur = item[17] observations = item[18] activites = item[19] if activites == None: activites = "" # Activités texte = "" if len(activites) > 0: listeTemp = [] listeIDactivites = UTILS_Divers.ConvertChaineEnListe(activites) for IDactivite in listeIDactivites: if dictActivites.has_key(IDactivite): nomActivite = dictActivites[IDactivite]["nom"] listeTemp.append(nomActivite) if len(listeTemp) > 0: texte = ", ".join(listeTemp) activites = texte nomCotisation = u"%s - %s" % (nomTypeCotisation, nomUniteCotisation) # Type if typeTypeCotisation == "famille": typeStr = _(u"Cotisation familiale") else: typeStr = _(u"Cotisation individuelle") # Dépôt if IDdepot_cotisation == None: depotStr = _(u"Non déposée") else: depotStr = _(u"Dépôt n°%d") % IDdepot_cotisation # Nom des titulaires de famille beneficiaires = "" rue = "" cp = "" ville = "" if IDfamille != None: beneficiaires = self.dictTitulaires[IDfamille][ "titulairesAvecCivilite"] rue = self.dictTitulaires[IDfamille]["adresse"]["rue"] cp = self.dictTitulaires[IDfamille]["adresse"]["cp"] ville = self.dictTitulaires[IDfamille]["adresse"]["ville"] if IDindividu != None and self.dictIndividus.has_key(IDindividu): beneficiaires = self.dictIndividus[IDindividu]["nom_complet"] rue = self.dictIndividus[IDindividu]["rue"] cp = self.dictIndividus[IDindividu]["cp"] ville = self.dictIndividus[IDindividu]["ville"] # Famille if IDfamille != None: nomTitulaires = self.dictTitulaires[IDfamille][ "titulairesAvecCivilite"] famille_rue = self.dictTitulaires[IDfamille]["adresse"]["rue"] famille_cp = self.dictTitulaires[IDfamille]["adresse"]["cp"] famille_ville = self.dictTitulaires[IDfamille]["adresse"][ "ville"] else: nomTitulaires = "Famille inconnue" famille_rue = "" famille_cp = "" famille_ville = "" # Facturation montant = 0.0 ventilation = 0.0 dateReglement = None modeReglement = None if dictFacturation.has_key(IDcotisation): montant = dictFacturation[IDcotisation]["montant"] ventilation = dictFacturation[IDcotisation]["ventilation"] dateReglement = dictFacturation[IDcotisation]["dateReglement"] modeReglement = dictFacturation[IDcotisation]["modeReglement"] solde = float( FloatToDecimal(montant) - FloatToDecimal(ventilation)) montantStr = u"%.02f %s" % (montant, SYMBOLE) regleStr = u"%.02f %s" % (ventilation, SYMBOLE) soldeStr = u"%.02f %s" % (solde, SYMBOLE) montantStrLettres = UTILS_Conversion.trad(montant, MONNAIE_SINGULIER, MONNAIE_DIVISION) regleStrLettres = UTILS_Conversion.trad(ventilation, MONNAIE_SINGULIER, MONNAIE_DIVISION) soldeStrLettres = UTILS_Conversion.trad(solde, MONNAIE_SINGULIER, MONNAIE_DIVISION) # Mémorisation des données dictDonnee = { "select": True, "{IDCOTISATION}": str(IDcotisation), "{IDTYPE_COTISATION}": str(IDtype_cotisation), "{IDUNITE_COTISATION}": str(IDunite_cotisation), "{DATE_SAISIE}": UTILS_Dates.DateDDEnFr(date_saisie), "{IDUTILISATEUR}": str(IDutilisateur), "{DATE_CREATION_CARTE}": UTILS_Dates.DateDDEnFr(date_creation_carte), "{NUMERO_CARTE}": numero, "{IDDEPOT_COTISATION}": str(IDdepot_cotisation), "{DATE_DEBUT}": UTILS_Dates.DateDDEnFr(date_debut), "{DATE_FIN}": UTILS_Dates.DateDDEnFr(date_fin), "{IDPRESTATION}": str(IDprestation), "{NOM_TYPE_COTISATION}": nomTypeCotisation, "{NOM_UNITE_COTISATION}": nomUniteCotisation, "{COTISATION_FAM_IND}": typeStr, "{IDCOMPTE_PAYEUR}": str(IDcompte_payeur), "{NOM_COTISATION}": nomCotisation, "{NOM_DEPOT}": depotStr, "{MONTANT_FACTURE}": montantStr, "{MONTANT_REGLE}": regleStr, "{SOLDE_ACTUEL}": soldeStr, "{MONTANT_FACTURE_LETTRES}": montantStrLettres.capitalize(), "{MONTANT_REGLE_LETTRES}": regleStrLettres.capitalize(), "{SOLDE_ACTUEL_LETTRES}": soldeStrLettres.capitalize(), "{DATE_REGLEMENT}": UTILS_Dates.DateDDEnFr(dateReglement), "{MODE_REGLEMENT}": modeReglement, "{ACTIVITES}": activites, "{NOTES}": observations, "{IDINDIVIDU}": IDindividu, "{BENEFICIAIRE_NOM}": beneficiaires, "{BENEFICIAIRE_RUE}": rue, "{BENEFICIAIRE_CP}": cp, "{BENEFICIAIRE_VILLE}": ville, "{IDFAMILLE}": str(IDfamille), "{FAMILLE_NOM}": nomTitulaires, "{FAMILLE_RUE}": famille_rue, "{FAMILLE_CP}": famille_cp, "{FAMILLE_VILLE}": famille_ville, "{ORGANISATEUR_NOM}": self.dictOrganisme["nom"], "{ORGANISATEUR_RUE}": self.dictOrganisme["rue"], "{ORGANISATEUR_CP}": self.dictOrganisme["cp"], "{ORGANISATEUR_VILLE}": self.dictOrganisme["ville"], "{ORGANISATEUR_TEL}": self.dictOrganisme["tel"], "{ORGANISATEUR_FAX}": self.dictOrganisme["fax"], "{ORGANISATEUR_MAIL}": self.dictOrganisme["mail"], "{ORGANISATEUR_SITE}": self.dictOrganisme["site"], "{ORGANISATEUR_AGREMENT}": self.dictOrganisme["num_agrement"], "{ORGANISATEUR_SIRET}": self.dictOrganisme["num_siret"], "{ORGANISATEUR_APE}": self.dictOrganisme["code_ape"], "{DATE_EDITION_COURT}": UTILS_Dates.DateDDEnFr(datetime.date.today()), "{DATE_EDITION_LONG}": UTILS_Dates.DateComplete(datetime.date.today()), } # Ajoute les informations de base individus et familles if IDindividu != None: dictDonnee.update( self.infosIndividus.GetDictValeurs(mode="individu", ID=IDindividu, formatChamp=True)) if IDfamille != None: dictDonnee.update( self.infosIndividus.GetDictValeurs(mode="famille", ID=IDfamille, formatChamp=True)) # Ajoute les réponses des questionnaires for dictReponse in self.Questionnaires.GetDonnees(IDfamille): dictDonnee[dictReponse["champ"]] = dictReponse["reponse"] if dictReponse["controle"] == "codebarres": dictDonnee[ "{CODEBARRES_QUESTION_%d}" % dictReponse["IDquestion"]] = dictReponse["reponse"] dictDonnees[IDcotisation] = dictDonnee # Champs de fusion pour Email dictChampsFusion[IDcotisation] = {} for key, valeur in dictDonnee.iteritems(): if key[0] == "{": dictChampsFusion[IDcotisation][key] = valeur del dlgAttente return dictDonnees, dictChampsFusion
def GetDonneesImpression(self, listeRappels=[]): """ Impression des factures """ dlgAttente = wx.BusyInfo( _(u"Recherche des données de facturation..."), None) try: wx.Yield() except: pass # Récupère les données de la facture if len(listeRappels) == 0: conditions = "()" elif len(listeRappels) == 1: conditions = "(%d)" % listeRappels[0] else: conditions = str(tuple(listeRappels)) DB = GestionDB.DB() req = """ SELECT rappels.IDrappel, rappels.numero, rappels.IDcompte_payeur, rappels.date_edition, rappels.activites, rappels.IDutilisateur, rappels.IDtexte, rappels.date_reference, rappels.solde, rappels.date_min, rappels.date_max, rappels.prestations, comptes_payeurs.IDfamille, lots_rappels.nom FROM rappels LEFT JOIN comptes_payeurs ON comptes_payeurs.IDcompte_payeur = rappels.IDcompte_payeur LEFT JOIN lots_rappels ON lots_rappels.IDlot = rappels.IDlot WHERE rappels.IDrappel IN %s GROUP BY rappels.IDrappel ORDER BY rappels.date_edition ;""" % conditions DB.ExecuterReq(req) listeDonnees = DB.ResultatReq() DB.Close() if len(listeDonnees) == 0: del dlgAttente return False # Création des dictRappels dictRappels = {} dictChampsFusion = {} for IDrappel, numero, IDcompte_payeur, date_edition, activites, IDutilisateur, IDtexte, date_reference, solde, date_min, date_max, prestations, IDfamille, nomLot in listeDonnees: if numero == None: numero = 0 date_edition = UTILS_Dates.DateEngEnDateDD(date_edition) date_reference = UTILS_Dates.DateEngEnDateDD(date_reference) if nomLot == None: nomLot = "" dictRappel = { "{FAMILLE_NOM}": self.dictTitulaires[IDfamille]["titulairesAvecCivilite"], "nomSansCivilite": self.dictTitulaires[IDfamille]["titulairesSansCivilite"], "IDfamille": IDfamille, "{IDFAMILLE}": IDfamille, "{FAMILLE_RUE}": self.dictTitulaires[IDfamille]["adresse"]["rue"], "{FAMILLE_CP}": self.dictTitulaires[IDfamille]["adresse"]["cp"], "{FAMILLE_VILLE}": self.dictTitulaires[IDfamille]["adresse"]["ville"], "num_rappel": numero, "{NUM_RAPPEL}": u"%06d" % numero, "{NOM_LOT}": nomLot, "solde_num": -solde, "solde": u"%.02f %s" % (solde, SYMBOLE), "{SOLDE}": u"%.02f %s" % (-solde, SYMBOLE), "solde_lettres": UTILS_Conversion.trad(solde, MONNAIE_SINGULIER, MONNAIE_DIVISION), "{SOLDE_LETTRES}": UTILS_Conversion.trad(-solde, MONNAIE_SINGULIER, MONNAIE_DIVISION), "select": True, "num_codeBarre": "%07d" % numero, "numero": _(u"Rappel n°%07d") % numero, "{CODEBARRES_NUM_RAPPEL}": "F%06d" % numero, "date_min": date_min, "date_max": date_max, "{DATE_MIN}": date_min, "{DATE_MAX}": date_max, "{DATE_EDITION_LONG}": UTILS_Dates.DateComplete(date_edition), "{DATE_EDITION_COURT}": UTILS_Dates.DateEngFr(str(date_edition)), "{ORGANISATEUR_NOM}": self.dictOrganisme["nom"], "{ORGANISATEUR_RUE}": self.dictOrganisme["rue"], "{ORGANISATEUR_CP}": self.dictOrganisme["cp"], "{ORGANISATEUR_VILLE}": self.dictOrganisme["ville"], "{ORGANISATEUR_TEL}": self.dictOrganisme["tel"], "{ORGANISATEUR_FAX}": self.dictOrganisme["fax"], "{ORGANISATEUR_MAIL}": self.dictOrganisme["mail"], "{ORGANISATEUR_SITE}": self.dictOrganisme["site"], "{ORGANISATEUR_AGREMENT}": self.dictOrganisme["num_agrement"], "{ORGANISATEUR_SIRET}": self.dictOrganisme["num_siret"], "{ORGANISATEUR_APE}": self.dictOrganisme["code_ape"], "titre": self.dictTextesRappels[IDtexte]["titre"], "IDtexte": IDtexte, } dictRappel["texte"] = self.Fusion(IDtexte, dictRappel) # Ajout les données de base familles dictRappel.update( self.infosIndividus.GetDictValeurs(mode="famille", ID=IDfamille, formatChamp=True)) # Ajoute les réponses des questionnaires for dictReponse in self.Questionnaires.GetDonnees(IDfamille): dictRappel[dictReponse["champ"]] = dictReponse["reponse"] if dictReponse["controle"] == "codebarres": dictRappel[ "{CODEBARRES_QUESTION_%d}" % dictReponse["IDquestion"]] = dictReponse["reponse"] dictRappels[IDrappel] = dictRappel # Champs de fusion pour Email dictChampsFusion[IDrappel] = {} dictChampsFusion[IDrappel]["{NUMERO_RAPPEL}"] = dictRappel[ "{NUM_RAPPEL}"] dictChampsFusion[IDrappel]["{DATE_MIN}"] = UTILS_Dates.DateEngFr( str(date_min)) dictChampsFusion[IDrappel]["{DATE_MAX}"] = UTILS_Dates.DateEngFr( str(date_max)) dictChampsFusion[IDrappel][ "{DATE_EDITION_RAPPEL}"] = UTILS_Dates.DateEngFr( str(date_edition)) dictChampsFusion[ IDrappel]["{DATE_REFERENCE}"] = UTILS_Dates.DateEngFr( str(date_reference)) dictChampsFusion[IDrappel]["{SOLDE_CHIFFRES}"] = dictRappel[ "solde"] dictChampsFusion[IDrappel]["{SOLDE_LETTRES}"] = dictRappel[ "{SOLDE_LETTRES}"] del dlgAttente return dictRappels, dictChampsFusion
def FormateDate(dateDD): return UTILS_Dates.DateComplete(dateDD)
def ReceptionFichier(self, nomFichier): """ Analyse du fichier recu """ config = UTILS_Config.Config() cryptage_mdp = config.Lire(section="synchronisation", option="cryptage_mdp", defaut="") IDfichier = config.Lire(section="fichier", option="ID", defaut="") ID_appareil = config.Lire(section="general", option="ID_appareil", defaut="") config.Close() # Décryptage du fichier if nomFichier.endswith(EXTENSION_CRYPTE): fichierCrypte = True self.EcritLog(u"Décryptage du fichier") if cryptage_mdp == "": self.EcritLog( u"Erreur : Décryptage impossible. Vous devez saisir le mot de passe dans les paramètres." ) os.remove(nomFichier) return if UTILS_Cryptage_fichier.IMPORT_AES == False: self.EcritLog( u"Erreur : Décryptage impossible. Le module de décryptage n'est pas disponible." ) os.remove(nomFichier) return nouveauCheminFichier = nomFichier.replace(EXTENSION_CRYPTE, EXTENSION_DECRYPTE) resultat = UTILS_Cryptage_fichier.DecrypterFichier( nomFichier, nouveauCheminFichier, cryptage_mdp) os.remove(nomFichier) else: fichierCrypte = False nouveauCheminFichier = nomFichier # Décompression du fichier if zipfile.is_zipfile(nouveauCheminFichier) == False: self.EcritLog( u"Erreur : Le fichier '%s' n'est pas une archive valide" % nouveauCheminFichier) if fichierCrypte == True: self.EcritLog( u"Vérifiez que le mot de passe de cryptage est exact dans les paramètres de synchronisation" ) return False fichierZip = zipfile.ZipFile(nouveauCheminFichier, "r") buffer = fichierZip.read("database.dat") nomFichierFinal = nouveauCheminFichier.replace(EXTENSION_DECRYPTE, ".dat") f = open(nomFichierFinal, "wb") f.write(buffer) f.close() fichierZip.close() os.remove(nouveauCheminFichier) self.EcritLog(u"Fichier installé avec succès") # Suppression des fichiers d'actions obsolètes DB = GestionDB.DB() req = """SELECT IDarchive, nom_fichier, ID_appareil, date FROM nomade_archivage;""" DB.ExecuterReq(req) listeArchives = DB.ResultatReq() DB.Close() DB = GestionDB.DB(typeFichier="actions") for IDarchive, nom_fichier_archive, ID_appareil_archive, date in listeArchives: # Recherche si c'est bien un fichier de sync genere par cet appareil et pour le fichier actuel if nom_fichier_archive.startswith( "actions_%s" % IDfichier) and ID_appareil_archive == ID_appareil: horodatage = nom_fichier_archive.split("_")[2] horodatage = UTILS_Dates.HorodatageEnDatetime(horodatage) horodatage_str = horodatage.strftime('%Y-%m-%d-%H-%M-%S') # Suppression de toutes les actions antérieures à l'horodatage """ for nom_table in ("consommations", "memo_journee"): req = """DELETE FROM %s WHERE horodatage<'%s';""" % ( nom_table, horodatage_str) DB.ExecuterReq(req) DB.Commit() DB.Close()
def InitParametres(self): """ Récupération des paramètres d'impression """ # DLG des paramètres d'impression dictOptions = { "titre": self.titre, "introduction": self.intro, "conclusion": self.total, "orientation": self.orientation, } dlg = DLG_Options_impression_listes.Dialog(None, dictOptions=dictOptions) if dlg.ShowModal() == wx.ID_OK: dictOptions = dlg.GetOptions() dlg.Destroy() else: dlg.Destroy() return False # Remplacement des mots-clés listeChamps = [ "pied_page_texte_gauche", "pied_page_texte_milieu", "pied_page_texte_droite" ] nomOrganisateur = self.GetNomOrganisateur() for key, valeur in dictOptions.iteritems(): if key in listeChamps: valeur = valeur.replace( "{DATE_JOUR}", UTILS_Dates.DateDDEnFr(datetime.date.today())) valeur = valeur.replace("{TITRE_DOCUMENT}", self.titre) valeur = valeur.replace("{NOM_ORGANISATEUR}", nomOrganisateur) valeur = valeur.replace("{NUM_PAGE}", "%(currentPage)d") valeur = valeur.replace("{NBRE_PAGES}", "%(totalPages)d") dictOptions[key] = valeur # Préparation du printout self.printer = ListCtrlPrinter.ListCtrlPrinter(self.listview, dictOptions["titre"]) self.printer.printout.margins = (wx.Point( int(dictOptions["marge_gauche"]), int(dictOptions["marge_haut"])), wx.Point( int(dictOptions["marge_droite"]), int(dictOptions["marge_bas"]))) self.printer.printout.printData.SetOrientation( dictOptions["orientation"]) self.printer.printout.printData.SetQuality( int(dictOptions["qualite_impression"])) self.printer.PageFooter = (dictOptions["pied_page_texte_gauche"], dictOptions["pied_page_texte_milieu"], dictOptions["pied_page_texte_droite"]) ListCtrlPrinter.LISTINTRO = dictOptions["introduction"] ListCtrlPrinter.LISTFOOTER = dictOptions["conclusion"] # Préparation du format fmt = ReportFormat() # Entête de page ## fmt.PageHeader.Font = wx.FFont(10, wx.FONTFAMILY_DECORATIVE, wx.FONTFLAG_BOLD, face=headerFontName) ## fmt.PageHeader.TextColor = wx.WHITE ## fmt.PageHeader.Background(wx.GREEN, wx.RED, space=(16, 4, 0, 4)) ## fmt.PageHeader.Padding = (0, 0, 0, 12) # Titre de liste fmt.ListHeader.Font = wx.Font(int(dictOptions["titre_taille_texte"]), wx.SWISS, wx.NORMAL, int(dictOptions["titre_style"]), faceName="Arial") fmt.ListHeader.TextColor = dictOptions["titre_couleur"] fmt.ListHeader.Padding = (0, 12, 0, 10) fmt.ListHeader.TextAlignment = dictOptions["titre_alignement"] fmt.ListHeader.Frame(wx.Pen(wx.BLACK, 0.25, wx.SOLID), space=10) # Intro fmt.ListIntro.Font = wx.Font(int(dictOptions["intro_taille_texte"]), wx.SWISS, wx.NORMAL, int(dictOptions["intro_style"]), faceName="Arial") fmt.ListIntro.TextColor = dictOptions["intro_couleur"] fmt.ListIntro.Padding = (12, 2, 12, 2) fmt.ListIntro.TextAlignment = dictOptions["intro_alignement"] fmt.ListIntro.CanWrap = True # Titre de colonne fmt.ColumnHeader.Font = wx.Font( int(dictOptions["titre_colonne_taille_texte"]), wx.SWISS, wx.NORMAL, int(dictOptions["titre_colonne_style"]), faceName="Arial") fmt.ColumnHeader.TextColor = dictOptions["titre_colonne_couleur"] fmt.ColumnHeader.Padding = (0, 15, 0, 0) fmt.ColumnHeader.Background(dictOptions["titre_colonne_couleur_fond"]) fmt.ColumnHeader.CellPadding = 5 fmt.ColumnHeader.TextAlignment = dictOptions[ "titre_colonne_alignement"] fmt.ColumnHeader.GridPen = wx.Pen( dictOptions["grille_trait_couleur"], dictOptions["grille_trait_epaisseur"], wx.SOLID) fmt.ColumnHeader.SetAlwaysCenter(True) # Titre d'un groupe fmt.GroupTitle.Font = wx.FFont(10, wx.FONTFAMILY_SWISS, wx.FONTFLAG_BOLD, faceName="Arial") fmt.GroupTitle.Padding = (2, 10, 2, 2) fmt.GroupTitle.CellPadding = 12 fmt.GroupTitle.GridPen = wx.Pen(dictOptions["grille_trait_couleur"], dictOptions["grille_trait_epaisseur"], wx.SOLID) ## fmt.GroupTitle.TextColor = wx.BLUE ## fmt.GroupTitle.Padding = (0, 12, 0, 12) ## fmt.GroupTitle.Line(wx.BOTTOM, wx.GREEN, 4, toColor=wx.WHITE, space=0) # Ligne fmt.Row.Font = wx.Font(int(dictOptions["ligne_taille_texte"]), wx.SWISS, wx.NORMAL, int(dictOptions["ligne_style"]), faceName="Arial") fmt.Row.TextColor = dictOptions["ligne_couleur"] fmt.Row.CellPadding = 5 fmt.Row.GridPen = wx.Pen(dictOptions["grille_trait_couleur"], dictOptions["grille_trait_epaisseur"], wx.SOLID) fmt.Row.CanWrap = dictOptions["ligne_multilignes"] # Pied de page fmt.PageFooter.Font = wx.Font(int( dictOptions["pied_page_taille_texte"]), wx.SWISS, wx.NORMAL, int(dictOptions["pied_page_style"]), faceName="Arial") fmt.PageFooter.TextColor = dictOptions["pied_page_couleur"] fmt.PageFooter.Line(wx.TOP, wx.BLACK, 1, space=3) fmt.PageFooter.Padding = (0, 16, 0, 0) # Pied de colonne fmt.ColumnFooter.Font = wx.Font(int( dictOptions["pied_colonne_taille_texte"]), wx.SWISS, wx.NORMAL, int(dictOptions["pied_colonne_style"]), faceName="Arial") fmt.ColumnFooter.TextColor = dictOptions["pied_colonne_couleur"] fmt.ColumnFooter.Padding = (0, 0, 0, 0) fmt.ColumnFooter.Background(dictOptions["pied_colonne_couleur_fond"]) fmt.ColumnFooter.CellPadding = 5 fmt.ColumnFooter.TextAlignment = dictOptions["pied_colonne_alignement"] fmt.ColumnFooter.GridPen = wx.Pen( dictOptions["grille_trait_couleur"], dictOptions["grille_trait_epaisseur"], wx.SOLID) ## fmt.ColumnFooter.SetAlwaysCenter(True) # Conclusion fmt.ListFooter.Font = wx.Font(int( dictOptions["conclusion_taille_texte"]), wx.SWISS, wx.NORMAL, int(dictOptions["conclusion_style"]), faceName="Arial") fmt.ListFooter.TextColor = dictOptions["conclusion_couleur"] fmt.ListFooter.Padding = (12, 12, 0, 0) fmt.ListFooter.CellPadding = 5 ## fmt.ListFooter.Line(wx.TOP, wx.BLACK, 1, space=3) fmt.ListFooter.TextAlignment = dictOptions["conclusion_alignement"] fmt.ListFooter.CanWrap = True # Divers paramètres fmt.IsShrinkToFit = True fmt.IncludeImages = dictOptions["inclure_images"] fmt.IsColumnHeadingsOnEachPage = dictOptions["entetes_toutes_pages"] fmt.UseListCtrlTextFormat = True self.printer.ReportFormat = fmt return True
def FormatePeriode(periode): if periode != None and ";" in periode : date_fin, date_debut = periode.split(";") return _(u"Du %s au %s") % (UTILS_Dates.DateDDEnFr(date_debut), UTILS_Dates.DateDDEnFr(date_fin)) else : return periode