def GetDonneesImpression(self, listeRappels=[]): """ Impression des factures """ dlgAttente = PBI.PyBusyInfo(_(u"Recherche des données de facturation..."), parent=None, title=_(u"Veuillez patienter..."), icon=wx.Bitmap("Images/16x16/Logo.png", wx.BITMAP_TYPE_ANY)) wx.Yield() # 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 __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 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 GetDonnees(self, listeRappels=[], liste_activites=[], listeExceptionsComptes=[], date_reference=None, date_edition=None, prestations=["consommation", "cotisation", "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 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 __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) ) ) if DICT_VALEURS["date_differe"] not in ("", None): dataTableau.append((_(u"Encaissement différé :"), Paragraph(_(u"A partir du %s") % DICT_VALEURS["{DATE_DIFFERE}"], 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 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, 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, listeFactures=[], dictOptions=None): """ Impression des factures """ dlgAttente = PBI.PyBusyInfo(_(u"Recherche des données de facturation..."), parent=None, title=_(u"Veuillez patienter..."), icon=wx.Bitmap("Images/16x16/Logo.png", wx.BITMAP_TYPE_ANY)) try : wx.Yield() except : pass # Récupère les données de la facture if len(listeFactures) == 0 : conditions = "()" elif len(listeFactures) == 1 : conditions = "(%d)" % listeFactures[0] else : conditions = str(tuple(listeFactures)) DB = GestionDB.DB() req = """ SELECT factures.IDfacture, factures.numero, factures.IDcompte_payeur, factures.activites, factures.individus, factures.date_edition, factures.date_echeance, factures.IDutilisateur, factures.date_debut, factures.date_fin, factures.total, factures.regle, factures.solde, factures.prestations, lots_factures.nom FROM factures LEFT JOIN lots_factures ON lots_factures.IDlot = factures.IDlot WHERE factures.IDfacture IN %s GROUP BY factures.IDfacture ORDER BY factures.date_edition ;""" % conditions DB.ExecuterReq(req) listeDonnees = DB.ResultatReq() # Récupération des prélèvements req = """SELECT prelevements.IDprelevement, prelevements.prelevement_numero, prelevements.prelevement_iban, prelevements.IDfacture, prelevements.montant, prelevements.statut, comptes_payeurs.IDcompte_payeur, lots_prelevements.date, prelevement_reference_mandat, comptes_bancaires.code_ics FROM prelevements LEFT JOIN lots_prelevements ON lots_prelevements.IDlot = prelevements.IDlot LEFT JOIN comptes_payeurs ON comptes_payeurs.IDfamille = prelevements.IDfamille LEFT JOIN comptes_bancaires ON comptes_bancaires.IDcompte = lots_prelevements.IDcompte WHERE prelevements.IDfacture IN %s ;""" % conditions DB.ExecuterReq(req) listePrelevements = DB.ResultatReq() dictPrelevements = {} for IDprelevement, numero_compte, iban, IDfacture, montant, statut, IDcompte_payeur, datePrelevement, rum, code_ics in listePrelevements : datePrelevement = UTILS_Dates.DateEngEnDateDD(datePrelevement) dictPrelevements[IDfacture] = { "IDprelevement" : IDprelevement, "numero_compte" : numero_compte, "montant" : montant, "statut" : statut, "IDcompte_payeur" : IDcompte_payeur, "datePrelevement" : datePrelevement, "iban" : iban, "rum" : rum, "code_ics" : code_ics, } DB.Close() if len(listeDonnees) == 0 : del dlgAttente return False listeFactures = [] index = 0 for IDfacture, numero, IDcompte_payeur, activites, individus, date_edition, date_echeance, IDutilisateur, date_debut, date_fin, total, regle, solde, typesPrestations, nomLot in listeDonnees : self.EcritStatusbar(_(u"Recherche de la facture %d sur %d") % (index+1, len(listeDonnees))) if numero == None : numero = 0 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) if typesPrestations != None : prestations = typesPrestations.split(";") else : prestations = ["consommation", "cotisation", "autre"] liste_activites = [] for IDactivite in activites.split(";") : liste_activites.append(int(IDactivite)) liste_individus = [] for IDindividu in individus.split(";") : liste_individus.append(int(IDindividu)) dictFacture = { "IDfacture" : IDfacture, "numero" : numero, "IDcompte_payeur" : IDcompte_payeur, "date_edition" : date_edition, "date_echeance" : date_echeance, "IDutilisateur" : IDutilisateur, "date_debut" : date_debut, "date_fin" : date_fin, "total" : total, "regle" : regle, "solde" : solde, "activites" : liste_activites, "individus" : liste_individus, "prestations" : prestations, } listeFactures.append(dictFacture) index +=1 # Récupération des données de facturation typeLabel = 0 if dictOptions != None and dictOptions.has_key("intitules") : typeLabel = dictOptions["intitules"] dictComptes = self.GetDonnees(listeFactures=listeFactures, typeLabel=typeLabel) dictFactures = {} dictChampsFusion = {} for IDfacture, numero, IDcompte_payeur, activites, individus, date_edition, date_echeance, IDutilisateur, date_debut, date_fin, total, regle, solde, typesPrestations, nomLot in listeDonnees : total = FloatToDecimal(total) regle = FloatToDecimal(regle) solde = FloatToDecimal(solde) if dictComptes.has_key(IDfacture) : dictCompte = dictComptes[IDfacture] dictCompte["select"] = True # Affichage du solde initial if dictOptions != None and dictOptions["affichage_solde"] == 1: dictCompte["ventilation"] = regle dictCompte["solde"] = solde # Attribue un numéro de facture dictCompte["num_facture"] = numero dictCompte["num_codeBarre"] = "%07d" % numero dictCompte["numero"] = _(u"Facture n°%07d") % numero dictCompte["{NUM_FACTURE}"] = u"%06d" % numero dictCompte["{CODEBARRES_NUM_FACTURE}"] = "F%06d" % numero dictCompte["{NUMERO_FACTURE}"] = dictCompte["{NUM_FACTURE}"] dictCompte["{DATE_DEBUT}"] = UTILS_Dates.DateEngFr(str(date_debut)) dictCompte["{DATE_FIN}"] = UTILS_Dates.DateEngFr(str(date_fin)) dictCompte["{DATE_EDITION_FACTURE}"] = UTILS_Dates.DateEngFr(str(date_edition)) dictCompte["{DATE_ECHEANCE}"] = UTILS_Dates.DateEngFr(str(date_echeance)) dictCompte["{SOLDE}"] = u"%.2f %s" % (dictCompte["solde"], SYMBOLE) dictCompte["{SOLDE_LETTRES}"] = UTILS_Conversion.trad(solde, MONNAIE_SINGULIER, MONNAIE_DIVISION).strip().capitalize() if nomLot == None : nomLot = "" dictCompte["{NOM_LOT}"] = nomLot for IDindividu, dictIndividu in dictCompte["individus"].iteritems() : dictIndividu["select"] = True # Recherche de prélèvements if dictPrelevements.has_key(IDfacture) : if datePrelevement < dictCompte["date_edition"] : verbe = _(u"a été") else : verbe = _(u"sera") montant = dictPrelevements[IDfacture]["montant"] datePrelevement = dictPrelevements[IDfacture]["datePrelevement"] iban = dictPrelevements[IDfacture]["iban"] rum = dictPrelevements[IDfacture]["rum"] code_ics = dictPrelevements[IDfacture]["code_ics"] if iban != None : dictCompte["prelevement"] = _(u"La somme de %.2f %s %s prélevée le %s sur le compte ***%s") % (montant, SYMBOLE, verbe, UTILS_Dates.DateEngFr(str(datePrelevement)), iban[-7:]) else : dictCompte["prelevement"] = _(u"La somme de %.2f %s %s prélevée le %s") % (montant, SYMBOLE, verbe, UTILS_Dates.DateEngFr(str(datePrelevement))) if rum != None : dictCompte["prelevement"] += _(u"<br/>Réf. mandat unique : %s / Code ICS : %s") % (rum, code_ics) else : dictCompte["prelevement"] = None # Champs de fusion pour Email dictChampsFusion[IDfacture] = {} dictChampsFusion[IDfacture]["{NUMERO_FACTURE}"] = dictCompte["{NUM_FACTURE}"] dictChampsFusion[IDfacture]["{DATE_DEBUT}"] = UTILS_Dates.DateEngFr(str(date_debut)) dictChampsFusion[IDfacture]["{DATE_FIN}"] = UTILS_Dates.DateEngFr(str(date_fin)) dictChampsFusion[IDfacture]["{DATE_EDITION_FACTURE}"] = UTILS_Dates.DateEngFr(str(date_edition)) dictChampsFusion[IDfacture]["{DATE_ECHEANCE}"] = UTILS_Dates.DateEngFr(str(date_echeance)) dictChampsFusion[IDfacture]["{SOLDE}"] = u"%.2f %s" % (dictCompte["solde"], SYMBOLE) # Fusion pour textes personnalisés dictCompte["texte_titre"] = self.RemplaceMotsCles(dictOptions["texte_titre"], dictCompte) dictCompte["texte_introduction"] = self.RemplaceMotsCles(dictOptions["texte_introduction"], dictCompte) dictCompte["texte_conclusion"] = self.RemplaceMotsCles(dictOptions["texte_conclusion"], dictCompte) # Mémorisation de la facture dictFactures[IDfacture] = dictCompte index += 1 del dlgAttente self.EcritStatusbar("") if len(dictFactures) == 0 : return False return dictFactures, 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 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 CreationPDF(self, nomDoc="Temp/Recu_don_oeuvres.pdf", afficherDoc=True): dictChampsFusion = {} # Vérifie que la cotisation a été payée if self.totalVentilation < self.montant : dlg = wx.MessageDialog(self, _(u"Cette cotisation n'a pas été réglée en intégralité.\n\nSouhaitez-vous quand même l'éditer ?"), _(u"Confirmation"), wx.YES_NO|wx.NO_DEFAULT|wx.CANCEL|wx.ICON_EXCLAMATION) reponse = dlg.ShowModal() dlg.Destroy() if reponse != wx.ID_YES : return False # Récupération des données sur l'organisme nom_organisme = self.ctrl_nom_beneficiaire.GetValue() adresse_organisme = self.ctrl_adresse_beneficiaire.GetValue() objet_organisme = self.ctrl_objet.GetValue() type_organisme = self.ctrl_type.GetValue() # Mémorisation des données ORGANISME if self.ctrl_memoriser_organisme.GetValue() == True : UTILS_Parametres.Parametres(mode="set", categorie="don_oeuvres", nom="nom_organisme", valeur=nom_organisme) UTILS_Parametres.Parametres(mode="set", categorie="don_oeuvres", nom="adresse_organisme", valeur=adresse_organisme) UTILS_Parametres.Parametres(mode="set", categorie="don_oeuvres", nom="objet_organisme", valeur=objet_organisme) UTILS_Parametres.Parametres(mode="set", categorie="don_oeuvres", nom="type_organisme", valeur=type_organisme) # Donateur if self.radio_nom_auto.GetValue() == True : nom_donateur = self.ctrl_nom_auto.GetNom() else: nom_donateur = self.ctrl_nom_autre.GetValue() adresse_donateur = self.ctr_adresse_donateur.GetValue() # Versement date_versement = self.ctrl_date_versement.GetDate(FR=True) if date_versement == u" / / " or date_versement == None : date_versement = u"" if self.radio_mode_auto.GetValue() == True : mode = self.ctrl_mode_auto.GetNomMode() else: mode = self.ctrl_mode_autre.GetValue() # Date édition date_edition = self.ctrl_date_edition.GetDate(FR=True) if date_edition == u" / / " or date_edition == None : date_edition = u"" # Montant montant_chiffres = u"%.2f ¤" % self.montant montant_lettres = UTILS_Conversion.trad(self.montant) dictDonnees = { "numero" : self.numero, "nom_organisme" : nom_organisme, "adresse_organisme" : adresse_organisme, "objet_organisme" : objet_organisme, "type_organisme" : type_organisme, "nom_donateur" : nom_donateur, "adresse_donateur" : adresse_donateur, "date_versement" : date_versement, "montant_chiffres" : montant_chiffres, "montant_lettres" : montant_lettres, "mode" : mode, "date_edition" : date_edition, } dictChampsFusion["{DATE_EDITION}"] = date_edition dictChampsFusion["{NUMERO_RECU}"] = self.numero dictChampsFusion["{NOM_DONATEUR}"] = nom_donateur dictChampsFusion["{ADRESSE_DONATEUR}"] = adresse_donateur dictChampsFusion["{DATE_REGLEMENT}"] = date_versement dictChampsFusion["{MODE_REGLEMENT}"] = mode dictChampsFusion["{MONTANT_CHIFFRES}"] = montant_chiffres dictChampsFusion["{MONTANT_LETTRES}"] = montant_lettres # Lancement de l'édition du PDF Impression(dictDonnees, nomDoc=nomDoc, afficherDoc=afficherDoc) return dictChampsFusion