コード例 #1
0
    def OnBoutonApercu(self, event):
        """ Aperçu PDF des lettres de rappel """
        # Validation des données saisies
        tracks = self.CTRL_Liste_rappels.GetTracksCoches()
        if len(tracks) == 0:
            dlg = wx.MessageDialog(
                self,
                _(u"Vous n'avez sélectionné aucune lettre de rappel à imprimer !"
                  ), _(u"Erreur"), wx.OK | wx.ICON_EXCLAMATION)
            dlg.ShowModal()
            dlg.Destroy()
            return

        listeIDrappel = []
        for track in tracks:
            listeIDrappel.append(track.IDrappel)

        # Récupération des options
        dictOptions = self.ctrl_options.GetOptions()
        if dictOptions == False:
            return False

        # Impression des factures sélectionnées
        facturation = UTILS_Rappels.Facturation()
        facturation.Impression(listeRappels=listeIDrappel,
                               afficherDoc=True,
                               dictOptions=dictOptions,
                               repertoire=dictOptions["repertoire"])
コード例 #2
0
    def Remplissage(self):
        dlgAttente = wx.BusyInfo(_(u"Recherche des impayés en cours..."),
                                 None)
        wx.Yield()

        try:
            facturation = UTILS_Rappels.Facturation()
            self.dictComptes = facturation.GetDonnees(
                liste_activites=self.dictParametres["listeActivites"],
                listeExceptionsComptes=self.
                dictParametres["listeExceptionsComptes"],
                date_reference=self.dictParametres["date_reference"],
                date_edition=self.dictParametres["date_edition"],
                prestations=self.dictParametres["prestations"],
            )
            del dlgAttente
        except Exception, err:
            del dlgAttente
            traceback.print_exc(file=sys.stdout)
            dlg = wx.MessageDialog(
                self,
                _(u"Désolé, le problème suivant a été rencontré dans la recherche des rappels : \n\n%s"
                  ) % err, _(u"Erreur"), wx.OK | wx.ICON_ERROR)
            dlg.ShowModal()
            dlg.Destroy()
            return False
コード例 #3
0
    def Remplissage(self):
        dlgAttente = PBI.PyBusyInfo(
            _(u"Recherche des impayés en cours..."),
            parent=None,
            title=_(u"Veuillez patienter..."),
            icon=wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Logo.png"),
                           wx.BITMAP_TYPE_ANY))
        wx.Yield()

        try:
            facturation = UTILS_Rappels.Facturation()
            self.dictComptes = facturation.GetDonnees(
                liste_activites=self.dictParametres["listeActivites"],
                listeExceptionsComptes=self.
                dictParametres["listeExceptionsComptes"],
                date_reference=self.dictParametres["date_reference"],
                date_edition=self.dictParametres["date_edition"],
                prestations=self.dictParametres["prestations"],
            )
            del dlgAttente
        except Exception, err:
            del dlgAttente
            traceback.print_exc(file=sys.stdout)
            dlg = wx.MessageDialog(
                self,
                _(u"Désolé, le problème suivant a été rencontré dans la recherche des rappels : \n\n%s"
                  ) % err, _(u"Erreur"), wx.OK | wx.ICON_ERROR)
            dlg.ShowModal()
            dlg.Destroy()
            return False
コード例 #4
0
    def AfficherApercu(self, event=None):
        item = self.GetSelection()
        dictItem = self.GetMainWindow().GetItemPyData(item)
        if dictItem == None :
            dlg = wx.MessageDialog(self, _(u"Vous n'avez sélectionné aucune lettre dans la liste !"), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION)
            dlg.ShowModal()
            dlg.Destroy()
            return
        type = dictItem["type"]
        if type != "compte" : 
            dlg = wx.MessageDialog(self, _(u"Vous n'avez sélectionné aucune lettre dans la liste !"), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION)
            dlg.ShowModal()
            dlg.Destroy()
            return
        IDfamille = dictItem["IDfamille"]
        IDcompte_payeur = dictItem["IDfamille"]
        dictDocument = dictItem["ctrl_document"].GetDictDocument()
        
        # Vérifie qu'un texte a été attribué
        if dictDocument["IDtexte"] == 0 :
            dlg = wx.MessageDialog(self, _(u"Vous devez obligatoirement attribuer un texte à cette lettre !"), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION)
            dlg.ShowModal()
            dlg.Destroy()
            return
        
        # Récupération des données
        dictCompte = self.dictComptes[IDcompte_payeur]
        
        dictCompte["titre"] = dictDocument["titre"] 
        dictCompte["IDtexte"] = dictDocument["IDtexte"] 
        
        # Fusion des mots-clés
        facturation = UTILS_Rappels.Facturation()
        dictCompte["texte"] = facturation.Fusion(dictDocument["IDtexte"] , dictCompte)

        # Récupération des paramètres d'affichage
        dlg = DLG_Apercu_rappel.Dialog(self, provisoire=True)
        if dlg.ShowModal() == wx.ID_OK:
            dictOptions = dlg.GetParametres()
            dlg.Destroy()
        else :
            dlg.Destroy()
            return False
                   
        # Fabrication du PDF
        dlgAttente = wx.BusyInfo(_(u"Création de l'aperçu au format PDF..."), None)
        if 'phoenix' not in wx.PlatformInfo:
            wx.Yield()
        try :
            UTILS_Impression_rappel.Impression({IDcompte_payeur : dictCompte}, dictOptions, IDmodele=dictOptions["IDmodele"])
            del dlgAttente
        except Exception as err:
            del dlgAttente
            traceback.print_exc(file=sys.stdout)
            dlg = wx.MessageDialog(self, _(u"Désolé, le problème suivant a été rencontré dans la création de l'aperçu de la lettre de rappel : \n\n%s") % err, _(u"Erreur"), wx.OK | wx.ICON_ERROR)
            dlg.ShowModal()
            dlg.Destroy()
            return False
コード例 #5
0
 def CreationPDF(self, nomDoc="", afficherDoc=True):
     """ Création du PDF pour Email """
     IDrappel = self.Selection()[0].IDrappel
     from Utils import UTILS_Rappels
     facturation = UTILS_Rappels.Facturation()
     resultat = facturation.Impression(listeRappels=[
         IDrappel,
     ],
                                       nomDoc=nomDoc,
                                       afficherDoc=False)
     if resultat == False:
         return False
     dictChampsFusion, dictPieces = resultat
     return dictChampsFusion[IDrappel]
コード例 #6
0
 def Reedition(self, event):
     if len(self.Selection()) == 0:
         dlg = wx.MessageDialog(
             self,
             _(u"Vous n'avez sélectionné aucune lettre à imprimer !"),
             _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION)
         dlg.ShowModal()
         dlg.Destroy()
         return
     IDrappel = self.Selection()[0].IDrappel
     from Utils import UTILS_Rappels
     facturation = UTILS_Rappels.Facturation()
     facturation.Impression(listeRappels=[
         IDrappel,
     ])
コード例 #7
0
    def SauvegardeRappels(self):
        """ Sauvegarde des rappels """
        dlgAttente = PBI.PyBusyInfo(
            _(u"Génération des rappels en cours..."),
            parent=None,
            title=_(u"Veuillez patienter..."),
            icon=wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Logo.png"),
                           wx.BITMAP_TYPE_ANY))
        wx.Yield()

        # Recherche numéro de facture suivant
        DB = GestionDB.DB()
        req = """SELECT MAX(numero) FROM rappels;"""
        DB.ExecuterReq(req)
        listeDonnees = DB.ResultatReq()
        DB.Close()
        if listeDonnees[0][0] == None:
            numero = 1
        else:
            numero = listeDonnees[0][0] + 1

        # Récupère Utilisateur en cours
        IDutilisateur = UTILS_Identification.GetIDutilisateur()

        # Génération des rappels
        listeRappelsGenerees = []

        # Fusion des mots-clés
        facturation = UTILS_Rappels.Facturation()

        # Tri par ordre alphabétique de la liste
        listeComptes = []
        listeAnomalies = []
        dictCoches = self.ctrl_rappels.GetCoches()
        for IDcompte_payeur, dictCompte in self.ctrl_rappels.dictComptes.iteritems(
        ):
            if dictCompte["select"] == True and dictCoches.has_key(
                    IDcompte_payeur):
                # Insertion du document dans le dictCompte
                dictDocument = self.ctrl_rappels.GetDictDocument(
                    IDcompte_payeur)
                if dictDocument["IDtexte"] == 0:
                    listeAnomalies.append(IDcompte_payeur)
                else:
                    dictCompte["IDtexte"] = dictDocument["IDtexte"]
                    dictCompte["titre"] = dictDocument["titre"]
                    dictCompte["texte"] = facturation.Fusion(
                        dictCompte["IDtexte"], dictCompte)
                listeComptes.append((dictCompte["nomSansCivilite"],
                                     IDcompte_payeur, dictCompte))
        listeComptes.sort()

        # Il reste des textes non attribués :
        if len(listeAnomalies) > 0:
            del dlgAttente
            dlg = wx.MessageDialog(
                self,
                _(u"Il reste %d lettre(s) pour lesquelles vous n'avez pas attribué de texte !"
                  ) % len(listeAnomalies), _(u"Erreur de saisie"),
                wx.OK | wx.ICON_EXCLAMATION)
            dlg.ShowModal()
            dlg.Destroy()
            return False

        # Sauvegarde
        DB = GestionDB.DB()
        try:

            index = 0
            for nomTitulaires, IDcompte_payeur, dictCompte in listeComptes:

                self.EcritStatusbar(
                    _(u"Génération de la lettre de rappel %d sur %d...") %
                    (index + 1, len(listeComptes)))

                # Liste des activités
                texteActivites = ""
                for IDactivite in self.parent.dictParametres["listeActivites"]:
                    texteActivites += "%d;" % IDactivite
                if len(texteActivites) > 0:
                    texteActivites = texteActivites[:-1]

                # Sauvegarde de la facture
                listeDonnees = [
                    ("numero", numero),
                    ("IDcompte_payeur", IDcompte_payeur),
                    ("date_edition", str(datetime.date.today())),
                    ("date_reference",
                     self.parent.dictParametres["date_reference"]),
                    ("IDtexte", dictCompte["IDtexte"]),
                    ("activites", texteActivites),
                    ("date_min", str(dictCompte["date_min"])),
                    ("date_max", str(dictCompte["date_max"])),
                    ("solde", float(dictCompte["solde_num"])),
                    ("IDlot", self.parent.dictParametres["IDlot"]),
                    ("prestations",
                     ";".join(self.parent.dictParametres["prestations"])),
                ]
                IDrappel = DB.ReqInsert("rappels", listeDonnees)

                listeRappelsGenerees.append(IDrappel)
                numero += 1
                index += 1

            DB.Close()
            self.EcritStatusbar(u"")
            del dlgAttente

        except Exception, err:
            DB.Close()
            del dlgAttente
            traceback.print_exc(file=sys.stdout)
            dlg = wx.MessageDialog(
                self,
                _(u"Désolé, le problème suivant a été rencontré : \n\n%s"
                  ) % err, _(u"Erreur"), wx.OK | wx.ICON_ERROR)
            dlg.ShowModal()
            dlg.Destroy()
            self.EcritStatusbar(u"")
            return False
コード例 #8
0
    def OnBoutonOk(self, event): 
        """ Aperçu PDF des rappels """
        # Validation des données saisies
        tracks = self.ctrl_liste_rappels.GetTracksCoches() 
        if len(tracks) == 0 : 
            dlg = wx.MessageDialog(self, _(u"Vous n'avez sélectionné aucune lettre de rappel à envoyer par Email !"), _(u"Erreur"), wx.OK | wx.ICON_EXCLAMATION)
            dlg.ShowModal()
            dlg.Destroy()
            return

        # Création des rappels sélectionnées
        listeIDrappel = []
        for track in tracks :
            listeIDrappel.append(track.IDrappel) 
        facturation = UTILS_Rappels.Facturation()
        dictOptions = self.ctrl_options.GetOptions()
        if dictOptions == False :
            return

        resultat = facturation.Impression(listeRappels=listeIDrappel, nomDoc=None, afficherDoc=False, dictOptions=dictOptions, repertoire=dictOptions["repertoire"], repertoireTemp=True)
        if resultat == False : 
            return
        dictChampsFusion, dictPieces = resultat

        def SupprimerFichiersTemp():
            for IDrappel, fichier in dictPieces.iteritems() :
                os.remove(fichier)  

        # Récupération de toutes les adresses Emails
        DB = GestionDB.DB()
        req = """SELECT IDindividu, mail, travail_mail
        FROM individus;"""
        DB.ExecuterReq(req)
        listeAdressesIndividus = DB.ResultatReq()
        DB.Close() 
        dictAdressesIndividus = {}
        for IDindividu, mail, travail_mail in listeAdressesIndividus :
            dictAdressesIndividus[IDindividu] = {"perso" : mail, "travail" : travail_mail}
                
        # Récupération des données adresse + champs + pièces
        listeDonnees = []
        listeAnomalies = []
        listeEnvoiNonDemande = []
        for track in tracks :
            adresse = None
            
            # Si Famille inscrite à l'envoi par Email :
            if track.email == True : 
                IDindividu, categorie, adresse = track.email_factures.split(";")
                if IDindividu != "" :
                    if dictAdressesIndividus.has_key(int(IDindividu)) :
                        adresse = dictAdressesIndividus[int(IDindividu)][categorie]
            
            # Si famille non inscrite à l'envoi par Email
            else :
                adresse = UTILS_Envoi_email.GetAdresseFamille(track.IDfamille, choixMultiple=False, muet=True, nomTitulaires=track.nomsTitulaires)
            
            # Mémorisation des données
            if adresse not in (None, "", []) : 
                fichier = dictPieces[track.IDrappel]
                champs = dictChampsFusion[track.IDrappel]
                listeDonnees.append({"adresse" : adresse, "pieces" : [fichier,], "champs" : champs})
                if track.email == False :
                    listeEnvoiNonDemande.append(track.nomsTitulaires) 
            else :
                listeAnomalies.append(track.nomsTitulaires)

        
        # Annonce les anomalies trouvées
        if len(listeAnomalies) > 0 :
            texte = _(u"%d des familles sélectionnées n'ont pas d'adresse Email :\n\n") % len(listeAnomalies)
            texte += _(u"Souhaitez-vous quand même continuer avec les %d autres familles ?") % len(listeDonnees)
            dlg = wx.MessageDialog(self, texte, _(u"Avertissement"), wx.YES_NO|wx.NO_DEFAULT|wx.CANCEL|wx.ICON_EXCLAMATION)
            reponse = dlg.ShowModal() 
            dlg.Destroy()
            if reponse != wx.ID_YES :
                SupprimerFichiersTemp()
                return        

        # Annonce les envois non demandés
        if len(listeEnvoiNonDemande) > 0 :
            texte = _(u"%d des familles sélectionnées n'ont pas demandé d'envoi par Email de leur facture :\n\n") % len(listeEnvoiNonDemande)
            texte += _(u"Souhaitez-vous quand même leur envoyer une lettre de rappel ?")
            dlg = wx.MessageDialog(self, texte, _(u"Avertissement"), wx.YES_NO|wx.NO_DEFAULT|wx.CANCEL|wx.ICON_EXCLAMATION)
            reponse = dlg.ShowModal() 
            dlg.Destroy()
            if reponse != wx.ID_YES :
                SupprimerFichiersTemp()
                return        
        
        # Dernière vérification avant transfert
        if len(listeDonnees) == 0 : 
            dlg = wx.MessageDialog(self, _(u"Il ne reste finalement aucune lettre de rappel à envoyer par Email !"), _(u"Erreur"), wx.OK | wx.ICON_EXCLAMATION)
            dlg.ShowModal()
            dlg.Destroy()
            SupprimerFichiersTemp()
            return

        # Transfert des données vers DLG Mailer
        import DLG_Mailer
        dlg = DLG_Mailer.Dialog(self, categorie="rappel")
        dlg.SetDonnees(listeDonnees, modificationAutorisee=False)
        dlg.ChargerModeleDefaut()
        dlg.ShowModal() 
        dlg.Destroy()

        # Suppression des PDF temporaires
        SupprimerFichiersTemp()
コード例 #9
0
    def Remplissage(self):
        dlgAttente = wx.BusyInfo(_(u"Recherche des impayés en cours..."), None)
        if 'phoenix' not in wx.PlatformInfo:
            wx.Yield()
        
        try :
            facturation = UTILS_Rappels.Facturation()
            self.dictComptes = facturation.GetDonnees(     liste_activites=self.dictParametres["listeActivites"],
                                                                                listeExceptionsComptes = self.dictParametres["listeExceptionsComptes"],
                                                                                date_reference=self.dictParametres["date_reference"], 
                                                                                date_edition=self.dictParametres["date_edition"],
                                                                                prestations=self.dictParametres["prestations"],
                                                                                )            
            del dlgAttente
        except Exception as err:
            del dlgAttente
            traceback.print_exc(file=sys.stdout)
            dlg = wx.MessageDialog(self, _(u"Désolé, le problème suivant a été rencontré dans la recherche des rappels : \n\n%s") % err, _(u"Erreur"), wx.OK | wx.ICON_ERROR)
            dlg.ShowModal()
            dlg.Destroy()
            return False

        # Condition famille unique
        if self.dictParametres["IDcompte_payeur"] != None :
            IDcompte_payeur = self.dictParametres["IDcompte_payeur"]
            if IDcompte_payeur in self.dictComptes :
                self.dictComptes = { IDcompte_payeur : self.dictComptes[IDcompte_payeur],}
            else :
                self.dictComptes = {}
        
        # Branches COMPTE
        listeNomsSansCivilite = []
        self.dictControles = {}
        for IDcompte_payeur, dictCompte in self.dictComptes.items() :
            listeNomsSansCivilite.append((dictCompte["nomSansCivilite"], IDcompte_payeur))
        listeNomsSansCivilite.sort() 
        
        index = 0
        for nomSansCivilite, IDcompte_payeur in listeNomsSansCivilite :
            dictCompte = self.dictComptes[IDcompte_payeur]
            IDfamille = dictCompte["IDfamille"]
            solde = dictCompte["solde"]
            date_debut = dictCompte["date_min"]
            date_fin = dictCompte["date_max"]
            nbreJoursRetard = (datetime.date.today() - date_fin).days
            
            # Texte du retard
            if nbreJoursRetard < 31 :
                texteRetard = _(u"%d jours") % nbreJoursRetard
            else :
                nbreMois = nbreJoursRetard // 30
                nbreJours = nbreJoursRetard - (nbreMois*30)
                texteRetard = _(u"%d jours") % nbreJoursRetard
                
            niveauCompte = self.AppendItem(self.root, nomSansCivilite, ct_type=1)
                        
            self.SetItemText(niveauCompte, UTILS_Dates.DateEngFr(str(date_debut)), 1)
            self.SetItemText(niveauCompte, UTILS_Dates.DateEngFr(str(date_fin)), 2)
            self.SetItemText(niveauCompte, texteRetard, 3)
            self.SetItemText(niveauCompte, solde, 4)
            
            ctrl_document = CTRL_document(self.GetMainWindow(), -1, branche=niveauCompte, IDcompte_payeur=IDcompte_payeur, nbreJoursRetard=nbreJoursRetard, infobulle=_(u"Sélectionnez un document"))
            self.SetItemWindow(niveauCompte, ctrl_document, 5)
            self.dictControles[IDcompte_payeur] = ctrl_document

            self.SetPyData(niveauCompte, {"type" : "compte", "valeur" : IDcompte_payeur, "IDcompte_payeur" : IDcompte_payeur, "IDfamille" : IDfamille, "nom" : nomSansCivilite, "ctrl_document" : ctrl_document})

            index += 1