def Supprimer(self, event): if len(self.Selection()) == 0: dlg = wx.MessageDialog( self, _(u"Vous n'avez sélectionné aucune prestation à supprimer dans la liste !" ), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() return track_prestation = self.Selection()[0] if track_prestation.IDfacture != None: dlg = wx.MessageDialog( self, _(u"Vous ne pouvez pas supprimer cette prestation car elle apparaît déjà sur une facture !" ), _(u"Erreur"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() return gestion = UTILS_Gestion.Gestion(None) if gestion.Verification("prestations", track_prestation.date) == False: return False dlg = wx.MessageDialog( self, _(u"Souhaitez-vous vraiment supprimer cette prestation ?"), _(u"Suppression"), wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL | wx.ICON_INFORMATION) if dlg.ShowModal() == wx.ID_YES: self.donnees.remove(track_prestation) self.MAJ() dlg.Destroy()
def Modifier(self, event): if len(self.Selection()) == 0: dlg = wx.MessageDialog( self, _(u"Vous n'avez sélectionné aucune prestation à modifier dans la liste !" ), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() return track_prestation = self.Selection()[0] if track_prestation.IDfacture != None: dlg = wx.MessageDialog( self, _(u"Vous ne pouvez pas modifier cette prestation car elle apparaît déjà sur une facture !" ), _(u"Erreur"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() return gestion = UTILS_Gestion.Gestion(None) if gestion.Verification("prestations", track_prestation.date) == False: return False from Dlg import DLG_Saisie_location_prestation dlg = DLG_Saisie_location_prestation.Dialog( self, track=track_prestation, dictInfosLocation=self.GetDictInfosLocation()) if dlg.ShowModal() == wx.ID_OK: track_prestation = dlg.GetTrack() track_prestation.dirty = True self.MAJ(track_prestation) dlg.Destroy()
def Supprimer(self, event): if UTILS_Utilisateurs.VerificationDroitsUtilisateurActuel("reglements_depots", "supprimer") == False : return if len(self.Selection()) == 0 : dlg = wx.MessageDialog(self, _(u"Vous n'avez sélectionné aucun dépôt à supprimer dans la liste"), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() return track = self.Selection()[0] IDdepot = self.Selection()[0].IDdepot nbre_reglements = self.Selection()[0].nbre if nbre_reglements > 0 : dlg = wx.MessageDialog(self, _(u"Des règlements sont déjà associés à ce dépôt. Vous ne pouvez donc pas le supprimer !"), _(u"Suppression impossible"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() return # Périodes de gestion gestion = UTILS_Gestion.Gestion(None) if gestion.Verification("depots", track.date) == False: return False # Confirmation dlg = wx.MessageDialog(self, _(u"Souhaitez-vous vraiment supprimer ce dépôt ?"), _(u"Suppression"), wx.YES_NO|wx.NO_DEFAULT|wx.CANCEL|wx.ICON_INFORMATION) if dlg.ShowModal() == wx.ID_YES : DB = GestionDB.DB() DB.ReqDEL("depots", "IDdepot", IDdepot) DB.Close() self.MAJ() self.GetGrandParent().MAJreglements() dlg.Destroy()
def OnBoutonOk(self, event): try: TraitmentEnCours = self.traitement.isAlive() except AttributeError: TraitmentEnCours = False if TraitmentEnCours: # Stopper traitement self.Arreter() else: # Récupération des paramètres de sélection IDactivite = self.ctrl_activite.GetID() dictTarif = self.ctrl_forfait.GetDictTarif() date_debut = self.ctrl_date_debut.GetDate() date_fin = self.ctrl_date_fin.GetDate() tracks = self.ctrl_individus.GetTracksCoches() # Périodes de gestion gestion = UTILS_Gestion.Gestion(None) if gestion.IsPeriodeinPeriodes("prestations", date_debut, date_fin) == False: return False if len(tracks) == 0: dlg = wx.MessageDialog( self, _(u"Vous devez cocher au moins un individu dans la liste !" ), _(u"Erreur"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() return False # Demande confirmation de lancement dlgConfirm = wx.MessageDialog( self, _(u"Souhaitez-vous saisir le forfait pour les %d individus cochés ?\n\nLe traitement peut prendre quelques minutes..." ) % len(tracks), _(u"Confirmation"), wx.YES_NO | wx.CANCEL | wx.YES_DEFAULT | wx.ICON_QUESTION) reponse = dlgConfirm.ShowModal() dlgConfirm.Destroy() if reponse != wx.ID_YES: return False # Lancer traitement self.EcritLog(_(u"Lancement du traitement")) self.bouton_ok.SetImageEtTexte( cheminImage="Images/32x32/Arreter.png", texte=u"Arrêter") self.bouton_fermer.Enable(False) self.Layout() # Traitement self.traitement = Traitement(self, IDactivite=IDactivite, dictTarif=dictTarif, date_debut=date_debut, date_fin=date_fin, tracks=tracks) self.traitement.start()
def __init__(self, parent): wx.Dialog.__init__(self, parent, -1, style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.MAXIMIZE_BOX|wx.MINIMIZE_BOX) self.parent = parent # Bandeau titre = _(u"Recalculer les prestations") intro = _(u"Vous pouvez ici recalculer le montant des prestations déduits des consommations pour un ensemble d'individus. Sélectionnez l'activité et la période à recalculer, cochez les individus souhaités puis cliquez sur le bouton Commencer pour lancer le traitement.") self.SetTitle(titre) self.ctrl_bandeau = CTRL_Bandeau.Bandeau(self, titre=titre, texte=intro, hauteurHtml=30, nomImage="Images/32x32/Euro.png") # Individus self.box_prestations_staticbox = wx.StaticBox(self, -1, _(u"Sélection des individus")) self.label_periode = wx.StaticText(self, -1, u"Période :") self.ctrl_date_debut = CTRL_Saisie_date.Date2(self) self.label_date_fin = wx.StaticText(self, -1, "au") self.ctrl_date_fin = CTRL_Saisie_date.Date2(self) self.label_activite = wx.StaticText(self, -1, u"Activité :") self.ctrl_activite = CTRL_Activite(self) self.bouton_actualiser = wx.Button(self, -1, _(u"Actualiser la liste")) self.listviewAvecFooter = OL_Recalculer_prestations.ListviewAvecFooter(self, kwargs={}) self.ctrl_individus = self.listviewAvecFooter.GetListview() self.ctrl_recherche = OL_Recalculer_prestations.CTRL_Outils(self, listview=self.ctrl_individus, afficherCocher=True) # Grille des conso self.box_grille_staticbox = wx.StaticBox(self, -1, _(u"Journal")) self.ctrl_log = wx.TextCtrl(self, -1, style=wx.TE_MULTILINE|wx.TE_READONLY) self.ctrl_log.SetMinSize((-1, 80)) self.ctrl_gauge = wx.Gauge(self, -1, style=wx.GA_SMOOTH) self.ctrl_grille = DLG_Badgeage_grille.CTRL(self) self.ctrl_grille.Show(False) # Boutons self.bouton_aide = CTRL_Bouton_image.CTRL(self, texte=_(u"Aide"), cheminImage="Images/32x32/Aide.png") self.bouton_ok = CTRL_Bouton_image.CTRL(self, texte=_(u"Commencer"), cheminImage="Images/32x32/Valider.png") self.bouton_fermer = CTRL_Bouton_image.CTRL(self, texte=_(u"Fermer"), cheminImage="Images/32x32/Annuler.png") self.__set_properties() self.__do_layout() self.Bind(wx.EVT_CHOICE, self.OnChoixActivite, self.ctrl_activite) self.Bind(wx.EVT_BUTTON, self.OnBoutonActualiser, self.bouton_actualiser) self.Bind(wx.EVT_BUTTON, self.OnBoutonAide, self.bouton_aide) self.Bind(wx.EVT_BUTTON, self.OnBoutonOk, self.bouton_ok) self.Bind(wx.EVT_BUTTON, self.OnBoutonAnnuler, self.bouton_fermer) self.Bind(wx.EVT_CLOSE, self.OnBoutonAnnuler) self.ctrl_individus.MAJ() wx.CallLater(0, self.Layout) # Périodes de gestion self.gestion = UTILS_Gestion.Gestion(None)
def __init__(self, *args, **kwds): # Initialisation du listCtrl self.IDcompte_payeur = kwds.pop("IDcompte_payeur", None) self.codesColonnes = kwds.pop("codesColonnes", []) self.checkColonne = kwds.pop("checkColonne", False) self.triColonne = kwds.pop("triColonne", "IDfacture") self.afficherAnnulations = kwds.pop("afficherAnnulations", False) self.filtres = None self.selectionID = None self.selectionTrack = None self.nom_fichier_liste = __file__ FastObjectListView.__init__(self, *args, **kwds) # Binds perso self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnActivated) self.Bind(wx.EVT_CONTEXT_MENU, self.OnContextMenu) # Périodes de gestion self.gestion = UTILS_Gestion.Gestion(None)
def Supprimer(self, event): if len(self.Selection()) == 0 : dlg = wx.MessageDialog(self, _(u"Vous n'avez sélectionné aucune consommation à supprimer dans la liste !"), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() return track = self.Selection()[0] # Vérifie l'état if track.etat in ("present", "absenti", "absentj"): dlg = wx.MessageDialog(self, _(u"Cette consommation ne peut pas être supprimée car elle a déjà été pointée !"), _(u"Suppression impossible"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() return # Vérifie que le règlement n'est pas dans une période de gestion gestion = UTILS_Gestion.Gestion(None) if gestion.Verification("consommations", track.date) == False: return False # Demande confirmation si prestation associée if track.IDprestation: dlg = wx.MessageDialog(self, _(u"Attention, cette consommation est associée à la prestation ID%d %s. Cette prestation ne sera pas supprimée automatiquement. Souhaitez-vous tout de même continuer ?") % (track.IDprestation, track.label_prestation), _(u"Avertissement"), wx.YES_NO|wx.NO_DEFAULT|wx.CANCEL|wx.ICON_EXCLAMATION) if dlg.ShowModal() != wx.ID_YES: return False # Demande de confirmation de suppression dlg = wx.MessageDialog(self, _(u"Confirmez-vous la suppression de cette consommation ?"), _(u"Suppression"), wx.YES_NO|wx.NO_DEFAULT|wx.CANCEL|wx.ICON_INFORMATION) if dlg.ShowModal() == wx.ID_YES : DB = GestionDB.DB() DB.ReqDEL("consommations", "IDconso", track.IDconso) DB.Close() # Mémorise l'action dans l'historique UTILS_Historique.InsertActions([{ "IDfamille": track.IDfamille, "IDcategorie": 10, "action": _(u"Suppression de la consommation ID%d : %s le %s pour %s %s") % (track.IDconso, track.nom_unite, track.date, track.nom, track.prenom), },]) # MAJ de l'affichage self.MAJ() dlg.Destroy()
def __init__(self, parent, grille=None, listePrestations=[]): HTL.HyperTreeList.__init__(self, parent, -1) self.SetAGWWindowStyleFlag(HTL.TR_NO_HEADER | wx.TR_HIDE_ROOT | wx.TR_FULL_ROW_HIGHLIGHT ) self.parent = parent self.grille = grille self.dictForfaits = {} self.listeSelectionIndividus = [] self.dictActivites = {} self.SetBackgroundColour(wx.WHITE) # Adapte taille Police pour Linux from Utils import UTILS_Linux UTILS_Linux.AdaptePolice(self) # Périodes de gestion self.gestion = UTILS_Gestion.Gestion(self) # Binds self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.Modifier) self.GetMainWindow().Bind(wx.EVT_RIGHT_UP, self.OnContextMenu)
def __init__(self, *args, **kwds): # Récupération des paramètres perso self.IDindividu = kwds.pop("IDindividu", None) self.IDfamille = kwds.pop("IDfamille", None) self.dictFamillesRattachees = kwds.pop("dictFamillesRattachees", None) self.mode = kwds.pop("mode", "liste") self.codesColonnes = kwds.pop("codesColonnes", []) self.checkColonne = kwds.pop("checkColonne", False) self.triColonne = kwds.pop("triColonne", "numero") self.filtres = None self.selectionID = None self.selectionTrack = None self.criteres = "" self.itemSelected = False self.popupIndex = -1 self.labelParametres = "" self.titre = _(u"Liste des cotisations") # Périodes de gestion self.gestion = UTILS_Gestion.Gestion(None) # Importation des activités DB = GestionDB.DB() req = """SELECT IDactivite, nom, abrege FROM activites ORDER BY date_fin DESC;""" DB.ExecuterReq(req) listeTemp = DB.ResultatReq() DB.Close() self.dictActivites = {} for IDactivite, nom, abrege in listeTemp : dictTemp = {"IDactivite":IDactivite, "nom":nom, "abrege":abrege} self.dictActivites[IDactivite] = dictTemp # Initialisation du listCtrl self.nom_fichier_liste = __file__ FastObjectListView.__init__(self, *args, **kwds) # Binds perso self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated) self.Bind(wx.EVT_CONTEXT_MENU, self.OnContextMenu)
def __init__(self, *args, **kwds): # Initialisation du listCtrl self.IDfamille = kwds.pop("IDfamille", None) self.selectionID = None self.selectionTrack = None ## locale.setlocale(locale.LC_ALL, 'FR') GroupListView.__init__(self, *args, **kwds) self.listePeriodes = [] self.listeIndividus = [] self.listeActivites = [] self.listeFactures = [] self.titre = _(u"Liste des prestations") self.total = 0.0 self.dictFiltres = {} ## self.InitModel() ## self.InitObjectListView() # Binds perso self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnActivated) self.Bind(wx.EVT_CONTEXT_MENU, self.OnContextMenu) self.SetShowGroups(False) # Périodes de gestion self.gestion = UTILS_Gestion.Gestion(None)
def Supprimer_location(parent, IDlocation=None): gestion = UTILS_Gestion.Gestion(None) def GetLocations(condition=""): DB = GestionDB.DB() # Récupère les infos sur cette location req = """SELECT IDlocation, IDfamille, date_debut, date_fin, serie, produits.nom, produits_categories.nom FROM locations LEFT JOIN produits ON produits.IDproduit = locations.IDproduit LEFT JOIN produits_categories ON produits_categories.IDcategorie = produits.IDcategorie WHERE %s;""" % condition DB.ExecuterReq(req) listeDonnees = DB.ResultatReq() DB.Close() liste_resultats = [] for IDlocation, IDfamille, date_debut, date_fin, serie, nom_produit, nom_categorie in listeDonnees: if isinstance(date_debut, str) or isinstance(date_debut, six.text_type): date_debut = datetime.datetime.strptime(date_debut, "%Y-%m-%d %H:%M:%S") if date_fin == None: date_fin = datetime.datetime(2999, 1, 1) if isinstance(date_fin, str) or isinstance(date_fin, six.text_type): date_fin = datetime.datetime.strptime(date_fin, "%Y-%m-%d %H:%M:%S") periode = _(u"%s - %s") % (date_debut.strftime("%d/%m/%Y %H:%M:%S"), date_fin.strftime("%d/%m/%Y %H:%M:%S") if (date_fin and date_fin.year != 2999) else _(u"Illimitée")) label_produit = u"%s (%s)" % (nom_produit, nom_categorie) liste_resultats.append({"IDlocation": IDlocation, "IDfamille": IDfamille, "date_debut": date_debut, "date_fin": date_fin, "periode": periode, "label_produit": label_produit, "serie": serie, "prestations": []}) return liste_resultats # Importe de la location cliquée liste_locations = GetLocations(condition="IDlocation=%d" % IDlocation) # Vérifie si la location est dans une série if liste_locations[0]["serie"]: num_serie = liste_locations[0]["serie"] liste_locations_serie = GetLocations(condition="serie='%s'" % num_serie) dlg = DLG_Supprimer_occurences(None, nbre_occurences=len(liste_locations_serie)) if dlg.ShowModal() == wx.ID_OK: dict_donnees = dlg.GetDonnees() dlg.Destroy() else: dlg.Destroy() return if dict_donnees["mode"] == "toutes": liste_locations = liste_locations_serie if dict_donnees["mode"] == "periode": liste_locations = [] for dict_location in liste_locations_serie: if dict_location["date_debut"] <= dict_donnees["date_fin"] and dict_location["date_fin"] >= dict_donnees["date_debut"]: liste_locations.append(dict_location) # Vérifie si les prestations de cette location sont déjà facturées liste_anomalies = [] liste_valides = [] DB = GestionDB.DB() index = 0 for dict_location in liste_locations: valide = True req = """SELECT IDprestation, date, IDfacture FROM prestations WHERE categorie="location" and IDdonnee=%d;""" % dict_location["IDlocation"] DB.ExecuterReq(req) listeDonnees = DB.ResultatReq() listeIDprestations = [] listePrestations = [] nbrePrestationsFacturees = 0 for IDprestation, date, IDfacture in listeDonnees: date = UTILS_Dates.DateEngEnDateDD(date) listePrestations.append({"IDprestation" : IDprestation, "date" : date, "IDfacture" : IDfacture}) listeIDprestations.append(IDprestation) # Vérifie la période de gestion if gestion.Verification("prestations", date) == False: liste_anomalies.append(u"Location du %s : Impossible à supprimer car une prestation associée est comprise dans une période de gestion verrouillée") valide = False if IDfacture != None : nbrePrestationsFacturees += 1 liste_locations[index]["prestations"] = listeIDprestations if nbrePrestationsFacturees > 0: liste_anomalies.append(u"Location du %s : Impossible à supprimer car %d prestations y sont déjà associées" % (dict_location["periode"], nbrePrestationsFacturees)) valide = False if valide: liste_valides.append(dict_location) index += 1 DB.Close() # Annonce les anomalies trouvées if len(liste_anomalies) > 0: introduction = _(u"%d anomalies ont été détectées :") % len(liste_anomalies) if len(liste_valides) > 0: conclusion = _(u"Souhaitez-vous continuer avec les %d autres locations ?") % len(liste_valides) dlg = DLG_Messagebox.Dialog(None, titre=_(u"Anomalies"), introduction=introduction, detail=u"\n".join(liste_anomalies), conclusion=conclusion, icone=wx.ICON_EXCLAMATION, boutons=[_(u"Oui"), _(u"Non"), _(u"Annuler")]) reponse = dlg.ShowModal() dlg.Destroy() if reponse in (1, 2): return False else: dlg = DLG_Messagebox.Dialog(None, titre=_(u"Anomalies"), introduction=introduction, detail=u"\n".join(liste_anomalies), icone=wx.ICON_EXCLAMATION, boutons=[_(u"Fermer")]) reponse = dlg.ShowModal() dlg.Destroy() return False # Suppression if len(liste_valides) == 1: dlg = wx.MessageDialog(parent, _(u"Souhaitez-vous vraiment supprimer la location ?"), _(u"Confirmation de suppression"), wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL | wx.ICON_INFORMATION) reponse = dlg.ShowModal() dlg.Destroy() else: introduction = _(u"Confirmez-vous la suppression des %d locations suivantes :") % len(liste_valides) liste_locations_temp = [dict_location["periode"] for dict_location in liste_valides] dlg = DLG_Messagebox.Dialog(None, titre=_(u"Confirmation de suppression"), introduction=introduction, detail=u"\n".join(liste_locations_temp), icone=wx.ICON_EXCLAMATION, boutons=[_(u"Oui"), _(u"Non"), _(u"Annuler")]) reponse = dlg.ShowModal() dlg.Destroy() if reponse not in (0, wx.ID_YES): return False DB = GestionDB.DB() for dict_location in liste_valides: # Suppression DB.ReqDEL("locations", "IDlocation", dict_location["IDlocation"]) DB.ExecuterReq("DELETE FROM questionnaire_reponses WHERE type='location' AND IDdonnee=%d;" % dict_location["IDlocation"]) DB.ReqMAJ("locations_demandes", [("statut", "attente"), ], "IDlocation", dict_location["IDlocation"]) DB.ReqMAJ("locations_demandes", [("IDlocation", None), ], "IDlocation", dict_location["IDlocation"]) DB.ExecuterReq("DELETE FROM prestations WHERE categorie='location' AND IDdonnee=%d;" % dict_location["IDlocation"]) for IDprestation in dict_location["prestations"]: DB.ReqDEL("ventilation", "IDprestation", IDprestation) # Historique texte_historique = _(u"Suppression de la location ID%d : %s %s") % (dict_location["IDlocation"], dict_location["label_produit"], dict_location["periode"]) UTILS_Historique.InsertActions([{"IDfamille": dict_location["IDfamille"], "IDcategorie": 39, "action": texte_historique, "IDdonnee": dict_location["IDlocation"]}], DB=DB) DB.Close() return True
def Supprimer(self, event): if self.IDcompte_payeur != None and UTILS_Utilisateurs.VerificationDroitsUtilisateurActuel( "familles_reglements", "supprimer") == False: return if len(self.Selection()) == 0: dlg = wx.MessageDialog( self, _(u"Vous n'avez sélectionné aucun règlement à supprimer dans la liste" ), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() return track = self.Selection()[0] IDreglement = self.Selection()[0].IDreglement IDdepot = self.Selection()[0].IDdepot # Si appartient à un dépot : annulation if IDdepot != None: dlg = wx.MessageDialog( self, _(u"Ce règlement est déjà attribué à un dépôt. Vous ne pouvez donc pas le supprimer !" ), _(u"Règlement déposé"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() return # Avertissement si appartient à un prélèvement if self.Selection()[0].IDprelevement != None: dlg = wx.MessageDialog( self, _(u"Ce règlement est rattaché à un prélèvement automatique.\n\nSouhaitez-vous vraiment le supprimer ?" ), _(u"Avertissement"), wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL | wx.ICON_EXCLAMATION) reponse = dlg.ShowModal() dlg.Destroy() if reponse != wx.ID_YES: return # Vérifie que le règlement n'est pas dans une période de gestion gestion = UTILS_Gestion.Gestion(None) if gestion.Verification("reglements", track.date) == False: return False # Recherche si frais de gestion existant pour ce règlement DB = GestionDB.DB() req = """SELECT IDprestation, montant_initial, label FROM prestations WHERE reglement_frais=%d; """ % IDreglement DB.ExecuterReq(req) listeFrais = DB.ResultatReq() DB.Close() if len(listeFrais) > 0: IDprestationFrais, montantFrais, labelFrais = listeFrais[0] dlg = wx.MessageDialog( self, _(u"Une prestation d'un montant de %.2f %s pour frais de gestion est associée à ce règlement. Cette prestation sera automatiquement supprimée en même temps que le règlement.\n\nConfirmez-vous tout de même la suppression de ce règlement ?" ) % (montantFrais, SYMBOLE), _(u"Avertissement"), wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL | wx.ICON_EXCLAMATION) if dlg.ShowModal() != wx.ID_YES: return else: IDprestationFrais = None # Demande de confirmation de suppression dlg = wx.MessageDialog( self, _(u"Confirmez-vous la suppression de ce règlement ?"), _(u"Suppression"), wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL | wx.ICON_INFORMATION) if dlg.ShowModal() == wx.ID_YES: DB = GestionDB.DB() DB.ReqDEL("reglements", "IDreglement", IDreglement) DB.ReqDEL("ventilation", "IDreglement", IDreglement) # Mémorise l'action dans l'historique req = """SELECT IDfamille FROM comptes_payeurs WHERE IDcompte_payeur=%d """ % self.Selection()[0].compte_payeur DB.ExecuterReq(req) IDfamille = DB.ResultatReq()[0][0] montant = u"%.2f ¤" % self.Selection()[0].montant texteMode = self.Selection()[0].nom_mode textePayeur = self.Selection()[0].nom_payeur UTILS_Historique.InsertActions([ { "IDfamille": IDfamille, "IDcategorie": 8, "action": _(u"Suppression du règlement ID%d : %s en %s payé par %s" ) % (IDreglement, montant, texteMode, textePayeur), }, ]) # Suppression des frais de gestion if IDprestationFrais != None: DB.ReqDEL("prestations", "IDprestation", IDprestationFrais) DB.ReqDEL("ventilation", "IDprestation", IDprestationFrais) DB.Close() # MAJ de l'affichage self.MAJ() dlg.Destroy()
def __init__(self, parent, IDdepot=None): wx.Dialog.__init__(self, parent, -1, name="DLG_Saisie_depot", style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER | wx.MAXIMIZE_BOX | wx.MINIMIZE_BOX) self.parent = parent self.IDdepot = IDdepot # Reglements self.staticbox_parametres_staticbox = wx.StaticBox( self, -1, _(u"Paramètres")) self.label_nom = wx.StaticText(self, -1, _(u"Nom du dépôt :")) self.ctrl_nom = wx.TextCtrl(self, -1, u"", size=(300, -1)) self.label_date = wx.StaticText(self, -1, _(u"Date du dépôt :")) self.ctrl_date = CTRL_Saisie_date.Date2(self) self.label_verrouillage = wx.StaticText(self, -1, _(u"Verrouillage :")) self.ctrl_verrouillage = wx.CheckBox(self, -1, u"") self.label_code_compta = wx.StaticText(self, -1, _(u"Code compta :")) self.ctrl_code_compta = wx.TextCtrl(self, -1, u"") self.label_compte = wx.StaticText(self, -1, _(u"Compte bancaire :")) self.ctrl_compte = Choix_compte(self) self.label_observations = wx.StaticText(self, -1, _(u"Observations :")) self.ctrl_observations = wx.TextCtrl(self, -1, u"", style=wx.TE_MULTILINE) # Reglements self.staticbox_reglements_staticbox = wx.StaticBox( self, -1, _(u"Règlements")) self.listviewAvecFooter = OL_Reglements_depots.ListviewAvecFooter( self, kwargs={ "inclus": True, "selectionPossible": False }) self.ctrl_reglements = self.listviewAvecFooter.GetListview() self.ctrl_infos = CTRL_Infos(self, hauteur=32, couleurFond="#F0FBED", style=wx.html.HW_NO_SELECTION | wx.html.HW_SCROLLBAR_NEVER | wx.SUNKEN_BORDER) self.bouton_ajouter = CTRL_Bouton_image.CTRL( self, texte=_(u"Ajouter ou retirer des règlements"), cheminImage="Images/32x32/Reglement_ajouter.png") # Boutons self.bouton_aide = CTRL_Bouton_image.CTRL( self, texte=_(u"Aide"), cheminImage="Images/32x32/Aide.png") self.bouton_imprimer = CTRL_Bouton_image.CTRL( self, texte=_(u"Outils"), cheminImage="Images/32x32/Configuration.png") self.bouton_avis_depots = CTRL_Bouton_image.CTRL( self, texte=_(u"Envoyer les avis de dépôt"), cheminImage="Images/32x32/Emails_exp.png") self.bouton_ok = CTRL_Bouton_image.CTRL( self, texte=_(u"Ok"), cheminImage="Images/32x32/Valider.png") self.bouton_annuler = CTRL_Bouton_image.CTRL( self, texte=_(u"Annuler"), cheminImage="Images/32x32/Annuler.png") self.__set_properties() self.__do_layout() self.Bind(wx.EVT_BUTTON, self.OnBoutonAjouter, self.bouton_ajouter) self.Bind(wx.EVT_BUTTON, self.OnBoutonAide, self.bouton_aide) self.Bind(wx.EVT_BUTTON, self.OnBoutonImprimer, self.bouton_imprimer) self.Bind(wx.EVT_BUTTON, self.OnBoutonAvisDepots, self.bouton_avis_depots) self.Bind(wx.EVT_BUTTON, self.OnBoutonOk, self.bouton_ok) self.Bind(wx.EVT_BUTTON, self.OnBoutonAnnuler, self.bouton_annuler) self.Bind(wx.EVT_CHECKBOX, self.OnCheckVerrouillage, self.ctrl_verrouillage) # Périodes de gestion self.gestion = UTILS_Gestion.Gestion(None) # Importation lors d'une modification if self.IDdepot != None: self.SetTitle(_(u"Modification d'un dépôt")) self.Importation() self.OnCheckVerrouillage(None) else: self.SetTitle(_(u"Saisie d'un dépôt")) self.ctrl_date.SetDate(datetime.date.today()) # Importation des règlements self.tracks = self.GetTracks() self.ctrl_reglements.MAJ(tracks=self.tracks) self.MAJinfos()
def OnBoutonOk(self, event): # Récupération et vérification des données saisies if self.IDfacture != None: dlg = wx.MessageDialog( self, _(u"Cette prestation apparaît déjà sur une facture. Il est donc impossible de la modifier !\n\nVous devez obligatoirement cliquer sur le bouton ANNULER pour quitter." ), _(u"Validation impossible"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() return date = self.ctrl_date.GetDate() if date == None: dlg = wx.MessageDialog( self, _(u"Vous devez obligatoirement saisir une date !"), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() self.ctrl_date.SetFocus() return categorie = self.ctrl_categorie.GetCategorie() label = self.ctrl_label.GetValue() if label == "": dlg = wx.MessageDialog( self, _(u"Vous devez obligatoirement saisir un intitulé !"), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() self.ctrl_label.SetFocus() return IDactivite = self.ctrl_activite.GetID() IDcategorie_tarif = self.ctrl_categorie_tarif.GetID() IDtarif = self.ctrl_tarif.GetID() montant_initial = self.ctrl_montant_avant_deduc.GetMontant() montant = self.ctrl_montant.GetMontant() if montant == None: dlg = wx.MessageDialog( self, _(u"Le montant que vous avez saisi ne semble pas valide !"), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() self.ctrl_montant.SetFocus() return IDfamille = self.IDfamille if self.radio_type_individuelle.GetValue() == True: IDindividu = self.ctrl_individu.GetID() if IDindividu == None: dlg = wx.MessageDialog( self, _(u"Etant donné que vous avez sélectionné le type 'prestation individuelle', vous devez obligatoirement sélectionner un individu dans la liste !" ), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() self.ctrl_individu.SetFocus() return else: IDindividu = 0 code_comptable = self.ctrl_code_comptable.GetValue() if code_comptable == "": code_comptable = None code_produit_local = self.ctrl_code_produit_local.GetValue() if code_produit_local == "": code_produit_local = None tva = self.ctrl_tva.GetValue() if tva == 0.0: tva = None # Vérifie temps facturé temps_facture = UTILS_Dates.DeltaEnStr(self.ctrl_temps.GetDuree(), separateur=":") if temps_facture != None: if self.ctrl_temps.Validation() == False: dlg = wx.MessageDialog( self, _(u"Le temps facturé que vous avez saisi ne semble pas correct !" ), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() self.ctrl_temps.SetFocus() return # Périodes de gestion gestion = UTILS_Gestion.Gestion(None) if gestion.Verification("prestations", date) == False: return False # Récupération du IDcompte_payeur DB = GestionDB.DB() req = "SELECT IDcompte_payeur FROM familles WHERE IDfamille=%d" % self.IDfamille DB.ExecuterReq(req) listeDonnees = DB.ResultatReq() DB.Close() IDcompte_payeur = listeDonnees[0][0] DB = GestionDB.DB() # Recherche si cette prestation a déjà été ventilée sur un règlement if self.IDprestation != None: req = """SELECT IDventilation, ventilation.montant FROM ventilation LEFT JOIN reglements ON reglements.IDreglement = ventilation.IDreglement WHERE IDprestation=%d ORDER BY reglements.date;""" % self.IDprestation DB.ExecuterReq(req) listeVentilations = DB.ResultatReq() montantVentilation = 0.0 for IDventilation, montantTmp in listeVentilations: montantVentilation += montantTmp if montantVentilation > montant: # Si le montant total ventilé est supérieur au montant de la prestation : montantVentilationTmp = 0.0 for IDventilation, montantTmp in listeVentilations: montantVentilationTmp += montantTmp if montantVentilationTmp > montant: nouveauMontant = montantTmp - (montantVentilationTmp - montant) if nouveauMontant > 0.0: DB.ReqMAJ("ventilation", [ ("montant", nouveauMontant), ], "IDventilation", IDventilation) montantVentilationTmp = ( montantVentilationTmp - montantTmp) + nouveauMontant else: DB.ReqDEL("ventilation", "IDventilation", IDventilation) # Sauvegarde de la prestation listeDonnees = [ ("IDcompte_payeur", IDcompte_payeur), ("date", date), ("categorie", categorie), ("label", label), ("montant_initial", montant_initial), ("montant", montant), ("IDactivite", IDactivite), ("IDtarif", IDtarif), ("IDfamille", IDfamille), ("IDindividu", IDindividu), ("temps_facture", temps_facture), ("IDcategorie_tarif", IDcategorie_tarif), ("code_compta", code_comptable), ("tva", tva), ("code_produit_local", code_produit_local), ] if self.IDprestation == None: listeDonnees.append(("date_valeur", str(datetime.date.today()))) self.IDprestation = DB.ReqInsert("prestations", listeDonnees) else: DB.ReqMAJ("prestations", listeDonnees, "IDprestation", self.IDprestation) DB.Close() # Sauvegarde des déductions self.ctrl_deductions.Sauvegarde(IDprestation=self.IDprestation) # Fermeture de la fenêtre self.EndModal(wx.ID_OK)
def Importation(self): """ Importation des données """ DB = GestionDB.DB() req = """SELECT IDprestation, prestations.IDcompte_payeur, date, categorie, label, montant_initial, montant, prestations.IDactivite, prestations.IDtarif, prestations.IDfacture, IDfamille, IDindividu, temps_facture, categories_tarifs, prestations.IDcategorie_tarif, prestations.code_compta, prestations.code_produit_local, prestations.tva, factures.IDprefixe, factures_prefixes.prefixe, factures.numero FROM prestations LEFT JOIN tarifs ON prestations.IDtarif = tarifs.IDtarif LEFT JOIN noms_tarifs ON tarifs.IDnom_tarif = noms_tarifs.IDnom_tarif LEFT JOIN factures ON factures.IDfacture = prestations.IDfacture LEFT JOIN factures_prefixes ON factures_prefixes.IDprefixe = factures.IDprefixe WHERE IDprestation=%d;""" % self.IDprestation DB.ExecuterReq(req) listeDonnees = DB.ResultatReq() DB.Close() if len(listeDonnees) == 0: return prestation = listeDonnees[0] IDprestation, IDcompte_payeur, date, categorie, label, montant_initial, montant, IDactivite, IDtarif, IDfacture, IDfamille, IDindividu, temps_facture, categories_tarifs, IDcategorie_tarif, code_compta, code_produit_local, tva, IDprefixe, prefixe, numFacture = prestation date = UTILS_Dates.DateEngEnDateDD(date) # Date self.ctrl_date.SetDate(date) # Label self.ctrl_label.SetValue(label) # Catégorie self.ctrl_categorie.SetCategorie(categorie) # Individu if IDindividu != None and IDindividu != 0: self.radio_type_individuelle.SetValue(True) self.ctrl_individu.SetID(IDindividu) # Activité if IDactivite != None: self.ctrl_activite.SetID(IDactivite) if categorie == "cotisation": self.ctrl_activite.Enable(False) # Catégorie de tarif self.OnChoixActivite(None) self.ctrl_categorie_tarif.SetID(IDcategorie_tarif) # Tarif self.OnChoixCategorieTarif(None) self.ctrl_tarif.SetID(IDtarif) # Comptabilité if code_compta != None: self.ctrl_code_comptable.SetValue(code_compta) if code_produit_local != None: self.ctrl_code_produit_local.SetValue(code_produit_local) # TVA if tva != None: self.ctrl_tva.SetValue(tva) # Montant initial self.ctrl_montant_avant_deduc.SetMontant(montant_initial) # Montant final self.ctrl_montant.SetMontant(montant) self.ancienMontant = montant # Facture self.IDfacture = IDfacture verrouillage = False if numFacture != None: if IDprefixe != None: numFacture = u"%s-%06d" % (prefixe, numFacture) else: numFacture = u"%06d" % numFacture self.ctrl_facture.SetLabel(_(u"Facture n°%s") % numFacture) verrouillage = True # Périodes de gestion self.gestion = UTILS_Gestion.Gestion(None) if self.gestion.Verification("prestations", date, silencieux=True) == False: verrouillage = True if verrouillage == True: self.ctrl_deductions.Enable(False) self.bouton_ajouter.Enable(False) self.bouton_modifier.Enable(False) self.bouton_supprimer.Enable(False) # Liste des consommations self.ctrl_consommations.SetIDprestation(IDprestation) # Temps facturé if temps_facture != None: self.ctrl_temps.SetDuree(temps_facture)
def Supprimer_location(parent, IDlocation=None): gestion = UTILS_Gestion.Gestion(None) # Vérifie si les prestations de cette location sont déjà facturées DB = GestionDB.DB() req = """SELECT IDprestation, date, IDfacture FROM prestations WHERE categorie="location" and IDdonnee=%d;""" % IDlocation DB.ExecuterReq(req) listeDonnees = DB.ResultatReq() DB.Close() listeIDprestations = [] listePrestations = [] nbrePrestationsFacturees = 0 for IDprestation, date, IDfacture in listeDonnees: date = UTILS_Dates.DateEngEnDateDD(date) listePrestations.append({ "IDprestation": IDprestation, "date": date, "IDfacture": IDfacture }) listeIDprestations.append(IDprestation) # Vérifie la période de gestion if gestion.Verification("prestations", date) == False: return False if IDfacture != None: nbrePrestationsFacturees += 1 if nbrePrestationsFacturees > 0: dlg = wx.MessageDialog( parent, _(u"Vous ne pouvez pas supprimer cette location car elle est déjà associée à %d prestations facturées !" ) % nbrePrestationsFacturees, _(u"Erreur"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() return False # Suppression dlg = wx.MessageDialog( parent, _(u"Souhaitez-vous vraiment supprimer cette location ?"), _(u"Suppression"), wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL | wx.ICON_INFORMATION) if dlg.ShowModal() == wx.ID_YES: DB = GestionDB.DB() DB.ReqDEL("locations", "IDlocation", IDlocation) DB.ExecuterReq( "DELETE FROM questionnaire_reponses WHERE type='location' AND IDdonnee=%d;" % IDlocation) DB.ReqMAJ("locations_demandes", [ ("statut", "attente"), ], "IDlocation", IDlocation) DB.ReqMAJ("locations_demandes", [ ("IDlocation", None), ], "IDlocation", IDlocation) DB.ExecuterReq( "DELETE FROM prestations WHERE categorie='location' AND IDdonnee=%d;" % IDlocation) for IDprestation in listeIDprestations: DB.ReqDEL("ventilation", "IDprestation", IDprestation) DB.Close() dlg.Destroy() return True
def OnBoutonOk(self, event): try: TraitmentEnCours = self.traitement.isAlive() except AttributeError: TraitmentEnCours = False if TraitmentEnCours: # Stopper traitement self.Arreter() else: # Récupération des paramètres de sélection IDactivite = self.ctrl_activite.GetID() tracks = self.ctrl_individus.GetTracksCoches() if IDactivite == None: dlg = wx.MessageDialog( self, _(u"Vous devez sélectionner une activité dans la liste !" ), _(u"Erreur"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() return False if self.dictAction == None: dlg = wx.MessageDialog( self, _(u"Vous devez sélectionner une action en cliquant sur le bouton 'Sélectionner une action' !" ), _(u"Erreur"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() return False if len(tracks) == 0: dlg = wx.MessageDialog( self, _(u"Vous devez cocher au moins un individu dans la liste !" ), _(u"Erreur"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() return False # Périodes de gestion gestion = UTILS_Gestion.Gestion(self) if gestion.IsPeriodeinPeriodes( "consommations", self.dictAction["date_debut"], self.dictAction["date_fin"]) == False: return False # Demande confirmation de lancement dlgConfirm = wx.MessageDialog( self, _(u"Souhaitez-vous appliquer le traitement par lot pour les %d individus cochés ?\n\nLe processus peut prendre quelques minutes..." ) % len(tracks), _(u"Confirmation"), wx.YES_NO | wx.CANCEL | wx.YES_DEFAULT | wx.ICON_QUESTION) reponse = dlgConfirm.ShowModal() dlgConfirm.Destroy() if reponse != wx.ID_YES: return False # Lancer traitement self.EcritLog(_(u"Lancement du traitement")) self.bouton_ok.SetImageEtTexte( cheminImage="Images/32x32/Arreter.png", texte=u"Arrêter") self.bouton_fermer.Enable(False) self.Layout() # Traitement # Ajout de la liste des individus dans l'action sinon problème dans CTRL_Grille.TraitementLot_processus for track in tracks: self.dictAction["individus"].append( dict((key, value) for key, value in track.__dict__.iteritems() if not callable(value) and not key.startswith('__'))) self.traitement = Traitement(self, IDactivite=IDactivite, dictAction=self.dictAction, tracks=tracks) self.traitement.start()
def Supprimer(self, event): if len(self.Selection()) == 0 : dlg = wx.MessageDialog(self, _(u"Vous n'avez sélectionné aucune inscription à supprimer dans la liste"), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() return IDinscription = self.Selection()[0].IDinscription IDfamille = self.Selection()[0].IDfamille IDindividu = self.Selection()[0].IDindividu nomActivite = self.Selection()[0].nom_activite IDactivite = self.Selection()[0].IDactivite # Verrouillage utilisateurs if UTILS_Utilisateurs.VerificationDroitsUtilisateurActuel("individus_inscriptions", "supprimer", IDactivite=IDactivite) == False : return DB = GestionDB.DB() # Recherche si des consommations existent req = """SELECT IDconso, date, forfait FROM consommations WHERE IDinscription=%d AND (forfait IS NULL OR forfait=1);""" % IDinscription DB.ExecuterReq(req) listeDonnees = DB.ResultatReq() listeConso = [] for IDconso, date, forfait in listeDonnees : date = UTILS_Dates.DateEngEnDateDD(date) listeConso.append({"IDconso" : IDconso, "date" : date, "forfait" : forfait}) if len(listeConso) > 0 : dlg = wx.MessageDialog(self, _(u"Il existe déjà %d consommations enregistrées sur cette inscription. \n\nIl est donc impossible de la supprimer !") % len(listeConso), _(u"Annulation impossible"), wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() DB.Close() return # Recherche si des prestations existent req = """SELECT IDprestation, prestations.date, prestations.forfait FROM prestations WHERE IDactivite=%d AND IDindividu=%d ;""" % (IDactivite, IDindividu) DB.ExecuterReq(req) listePrestations = DB.ResultatReq() listePrestationsForfait = [] listePrestationsNormales = [] listeDatesPrestations = [] for IDprestation, date, forfait in listePrestations : listeDatesPrestations.append(UTILS_Dates.DateEngEnDateDD(date)) if forfait == 2 : if IDprestation not in listePrestationsForfait : listePrestationsForfait.append(IDprestation) else: if IDprestation not in listePrestationsNormales : listePrestationsNormales.append(IDprestation) if len(listePrestations) - len(listePrestationsForfait) > 0 : dlg = wx.MessageDialog(self, _(u"Il existe déjà %d prestations enregistrées sur cette inscription. \n\nIl est donc impossible de la supprimer !") % len(listePrestations), _(u"Annulation impossible"), wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() DB.Close() return DB.Close() # Périodes de gestion self.gestion = UTILS_Gestion.Gestion(self) if self.gestion.Verification("consommations", listeConso) == False: return False if self.gestion.Verification("prestations", listeDatesPrestations) == False: return False # Demande de confirmation if len(listePrestationsForfait) == 0 : texteForfait = u"" elif len(listePrestationsForfait) == 1 : texteForfait = _(u"\n\n(La prestation associée sera également supprimée)") else : texteForfait = _(u"\n\n(Les %d prestations associées seront également supprimées)") % len(listePrestationsForfait) dlg = wx.MessageDialog(self, _(u"Souhaitez-vous vraiment supprimer cette inscription ?%s") % texteForfait, _(u"Suppression"), wx.YES_NO|wx.NO_DEFAULT|wx.CANCEL|wx.ICON_INFORMATION) if dlg.ShowModal() == wx.ID_YES : IDinscription = self.Selection()[0].IDinscription DB = GestionDB.DB() DB.ReqDEL("inscriptions", "IDinscription", IDinscription) # Suppression des forfaits associés déjà saisis for IDprestation in listePrestationsForfait : DB.ReqDEL("prestations", "IDprestation", IDprestation) DB.ReqDEL("consommations", "IDprestation", IDprestation) DB.ReqDEL("deductions", "IDprestation", IDprestation) DB.ReqDEL("ventilation", "IDprestation", IDprestation) DB.Close() # Mémorise l'action dans l'historique UTILS_Historique.InsertActions([{ "IDindividu" : self.IDindividu, "IDfamille" : IDfamille, "IDcategorie" : 19, "action" : _(u"Suppression de l'inscription à l'activité '%s'") % nomActivite },]) # Actualise l'affichage self.MAJ() dlg.Destroy()
def OnBoutonOk(self, event): # Loueur IDfamille = self.ctrl_loueur.GetIDfamille() if IDfamille == None: dlg = wx.MessageDialog( self, _(u"Vous devez obligatoirement sélectionner un loueur pour ce produit !" ), _(u"Erreur"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() return # Produit IDproduit = self.ctrl_produit.GetIDproduit() if IDproduit == None: dlg = wx.MessageDialog( self, _(u"Vous devez obligatoirement sélectionner un produit !"), _(u"Erreur"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() return # Observations observations = self.ctrl_observations.GetValue() # Date de début date_debut = self.ctrl_date_debut.GetDate() if date_debut == None: dlg = wx.MessageDialog( self, _(u"Vous devez obligatoirement saisir une date de début de location !" ), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() self.ctrl_date_debut.SetFocus() return heure_debut = self.ctrl_heure_debut.GetHeure() if heure_debut == None or self.ctrl_heure_debut.Validation() == False: dlg = wx.MessageDialog( self, _(u"Vous devez obligatoirement saisir une heure de début valide !" ), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() self.ctrl_heure_debut.SetFocus() return date_debut = datetime.datetime(year=date_debut.year, month=date_debut.month, day=date_debut.day, hour=int(heure_debut[:2]), minute=int(heure_debut[3:])) # Date de fin if self.check_date_fin.GetValue() == True: date_fin = self.ctrl_date_fin.GetDate() if date_fin == None: dlg = wx.MessageDialog( self, _(u"Vous devez obligatoirement saisir une date de fin de location !" ), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() self.ctrl_date_fin.SetFocus() return heure_fin = self.ctrl_heure_fin.GetHeure() if heure_fin == None or self.ctrl_heure_fin.Validation() == False: dlg = wx.MessageDialog( self, _(u"Vous devez obligatoirement saisir une heure de fin valide !" ), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() self.ctrl_heure_fin.SetFocus() return date_fin = datetime.datetime(year=date_fin.year, month=date_fin.month, day=date_fin.day, hour=int(heure_fin[:2]), minute=int(heure_fin[3:])) else: date_fin = None if date_fin != None and date_debut > date_fin: dlg = wx.MessageDialog( self, _(u"Vous devez obligatoirement saisir une date de fin supérieure à la date de début !" ), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() self.ctrl_date_fin.SetFocus() return # Quantité quantite = int(self.ctrl_quantite.GetValue()) # Vérifie que la quantité demandée est disponible dictPeriodes = UTILS_Locations.GetStockDisponible( IDproduit=IDproduit, date_debut=date_debut, date_fin=date_fin, IDlocation_exception=self.IDlocation) liste_periode_non_dispo = [] for periode, valeurs in dictPeriodes.iteritems(): if valeurs["disponible"] < quantite: debut = datetime.datetime.strftime(periode[0], "%d/%m/%Y-%Hh%M") if periode[1].year == 2999: fin = _(u"Illimité") else: fin = datetime.datetime.strftime(periode[1], "%d/%m/%Y-%Hh%M") liste_periode_non_dispo.append( _(u"Stock disponible du %s au %s : %d produits") % (debut, fin, valeurs["disponible"])) if len(liste_periode_non_dispo) > 0: introduction = _( u"La quantité souhaitée n'est pas disponible sur les périodes suivantes :" ) conclusion = _(u"Vous ne pouvez pas valider la location.") dlg = DLG_Messagebox.Dialog( None, titre=_(u"Information"), introduction=introduction, detail=u"\n".join(liste_periode_non_dispo), conclusion=conclusion, icone=wx.ICON_EXCLAMATION, boutons=[ _(u"Ok"), ]) dlg.ShowModal() dlg.Destroy() return # Périodes de gestion liste_prestations = self.ctrl_parametres.GetPageAvecCode( "facturation").GetDonnees()["prestations"] gestion = UTILS_Gestion.Gestion(None) for track_prestation in liste_prestations: if gestion.Verification("prestations", track_prestation.date) == False: return False # Sauvegarde DB = GestionDB.DB() # Sauvegarde de la location listeDonnees = [ ("IDfamille", IDfamille), ("IDproduit", IDproduit), ("observations", observations), ("date_debut", date_debut), ("date_fin", date_fin), ("quantite", quantite), ] if self.IDlocation == None: listeDonnees.append(("date_saisie", datetime.date.today())) self.IDlocation = DB.ReqInsert("locations", listeDonnees) else: DB.ReqMAJ("locations", listeDonnees, "IDlocation", self.IDlocation) # Sauvegarde des prestations listeID = [] for track_prestation in liste_prestations: IDprestation = track_prestation.IDprestation listeDonnees = [ ("IDcompte_payeur", self.ctrl_loueur.GetIDcomptePayeur()), ("date", track_prestation.date), ("categorie", "location"), ("label", track_prestation.label), ("montant_initial", track_prestation.montant), ("montant", track_prestation.montant), ("IDfamille", self.ctrl_loueur.GetIDfamille()), ("IDindividu", None), ("code_compta", None), ("tva", None), ("IDdonnee", self.IDlocation), ] if IDprestation == None: listeDonnees.append( ("date_valeur", str(datetime.date.today()))) IDprestation = DB.ReqInsert("prestations", listeDonnees) else: if track_prestation.dirty == True: DB.ReqMAJ("prestations", listeDonnees, "IDprestation", IDprestation) listeID.append(IDprestation) # Suppression des prestations obsolètes for IDprestation in self.liste_initiale_IDprestation: if IDprestation not in listeID: DB.ReqDEL("prestations", "IDprestation", IDprestation) DB.ReqDEL("ventilation", "IDprestation", IDprestation) # Sauvegarde du questionnaire self.ctrl_parametres.GetPageAvecCode( "questionnaire").ctrl_questionnaire.Sauvegarde( DB=DB, IDdonnee=self.IDlocation) DB.Close() # Fermeture de la fenêtre self.EndModal(wx.ID_OK)
def OnBoutonOk(self, event=None): # validation : Famille if self.ctrl_famille.GetIDfamille() == None: dlg = wx.MessageDialog( self, _(u"Vous devez obligatoirement sélectionner une famille !"), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() self.ctrl_famille.SetFocus() return False # validation des dates if self.ctrl_date_debut.Validation( ) == False or self.ctrl_date_debut.GetDate() == None: dlg = wx.MessageDialog( self, _(u"Vous devez saisir une date de début valide !"), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() self.ctrl_date_debut.SetFocus() return False if self.ctrl_date_fin.Validation( ) == False or self.ctrl_date_fin.GetDate() == None: dlg = wx.MessageDialog( self, _(u"Vous devez saisir une date de fin valide !"), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() self.ctrl_date_fin.SetFocus() return False if self.ctrl_date_debut.GetDate() > self.ctrl_date_fin.GetDate(): dlg = wx.MessageDialog( self, _(u"Vous ne pouvez pas saisir une date de début supérieure à la date de fin !" ), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() self.ctrl_date_debut.SetFocus() return False # Validation Forfait dictTarif = self.ctrl_forfaits.GetForfait() if dictTarif == None: dlg = wx.MessageDialog( self, _(u"Vous devez sélectionner un tarif dans la liste proposée !" ), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() self.ctrl_forfaits.SetFocus() return False # Validation Prestation if len(self.ctrl_label.GetValue()) == 0: dlg = wx.MessageDialog( self, _(u"Vous devez saisir un label pour cette prestation !"), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() self.ctrl_label.SetFocus() return False if self.ctrl_date_prestation.GetDate() == None: dlg = wx.MessageDialog( self, _(u"Vous devez saisir une date pour cette prestation !"), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() self.ctrl_date_prestation.SetFocus() return False if self.ctrl_montant.GetMontant() == None: dlg = wx.MessageDialog( self, _(u"Vous devez saisir un montant pour cette prestation !"), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() self.ctrl_montant.SetFocus() return False # Périodes de gestion self.gestion = UTILS_Gestion.Gestion(self) date_debut = self.ctrl_date_debut.GetDate() date_fin = self.ctrl_date_fin.GetDate() if self.gestion.IsPeriodeinPeriodes("consommations", date_debut, date_fin) == False: return False date_prestation = self.ctrl_date_prestation.GetDate() if self.gestion.Verification("prestations", date_prestation) == False: return False # Ferme la fenêtre self.EndModal(wx.ID_OK)
def Validation(self): """ Validation des données saisies """ # Vérifie date début date_debut = self.ctrl_date_debut.GetDate() if self.ctrl_date_debut.FonctionValiderDate() == False or date_debut == None : dlg = wx.MessageDialog(self, _(u"La date de début de période ne semble pas valide !"), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() self.ctrl_date_debut.SetFocus() return False # Vérifie date fin date_fin = self.ctrl_date_fin.GetDate() if self.ctrl_date_fin.FonctionValiderDate() == False or date_fin == None : dlg = wx.MessageDialog(self, _(u"La date de fin de période ne semble pas valide !"), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() self.ctrl_date_fin.SetFocus() return False # Vérifie les deux dates if date_debut > date_fin : dlg = wx.MessageDialog(self, _(u"La date de début de période est supérieure à la date de fin !"), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() self.ctrl_date_fin.SetFocus() return False # Vérifie que la période sélectionnée n'est pas dans une période de gestion gestion = UTILS_Gestion.Gestion(None) if gestion.IsPeriodeinPeriodes("factures", date_debut, date_fin) == False: return False # Vérifier si lot de factures IDlot = self.ctrl_lot.GetID() nomLot = self.ctrl_lot.GetNom() if IDlot == None : dlg = wx.MessageDialog(self, _(u"Vous n'avez pas sélectionné de lot de factures à associer.\n\nSouhaitez-vous quand même continuer ?"), _(u"Confirmation"), wx.YES_NO|wx.NO_DEFAULT|wx.CANCEL|wx.ICON_EXCLAMATION) resultat = dlg.ShowModal() dlg.Destroy() if resultat != wx.ID_YES : return False # Préfixe de facture IDprefixe = self.ctrl_prefixe.GetID() prefixe = self.ctrl_prefixe.GetPrefixe() # Prochain numéro de facture if self.check_numero_auto.GetValue() == True : # Numéro auto prochain_numero = None else : # Numéro perso try : prochain_numero = int(self.ctrl_prochain_numero.GetValue()) except : prochain_numero = None if prochain_numero in (None, "") : dlg = wx.MessageDialog(self, _(u"Le prochain numéro de facture ne semble pas valide !"), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() self.ctrl_prochain_numero.SetFocus() return False if prochain_numero < self.prochain_numero_defaut : dlg = wx.MessageDialog(self, _(u"Le prochain numéro de facture n'est pas valide : une facture générée porte déjà un numéro égal ou supérieur !"), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() self.ctrl_prochain_numero.SetFocus() return False # Date d'émission date_emission = self.ctrl_date_emission.GetDate() if self.ctrl_date_emission.FonctionValiderDate() == False or date_emission == None : dlg = wx.MessageDialog(self, _(u"La date d'émission ne semble pas valide !"), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() self.ctrl_date_emission.SetFocus() return False # Date d'échéance date_echeance = self.ctrl_date_echeance.GetDate() if date_echeance == None : dlg = wx.MessageDialog(self, _(u"Vous n'avez pas saisi de date d'échéance. \n\nSouhaitez-vous quand même continuer ?"), _(u"Confirmation"), wx.YES_NO|wx.NO_DEFAULT|wx.CANCEL|wx.ICON_EXCLAMATION) resultat = dlg.ShowModal() dlg.Destroy() if resultat != wx.ID_YES : return False # Vérifier si lot de factures prestations = [] if self.check_consommations.GetValue() == True : prestations.append("consommation") if self.check_cotisations.GetValue() == True : prestations.append("cotisation") if self.check_locations.GetValue() == True: prestations.append("location") if self.check_autres.GetValue() == True : prestations.append("autre") if len(prestations) == 0 : dlg = wx.MessageDialog(self, _(u"Vous devez obligatoirement cocher au moins un type de prestation à facturer !"), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() return False # Familles if self.radio_familles_toutes.GetValue() == True : IDcompte_payeur_unique = None else : IDcompte_payeur_unique = self.ctrl_famille.GetIDcompte_payeur() if IDcompte_payeur_unique == None : dlg = wx.MessageDialog(self, _(u"Vous avez sélectionné l'option 'famille unique' mais sans sélectionner de famille dans la liste proposée !"), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() return False # Vérifie les activités sélectionnées listeActivites = self.ctrl_activites.GetActivites() if len(listeActivites) == 0 : dlg = wx.MessageDialog(self, _(u"Vous n'avez sélectionné aucune activité !"), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() return False # Date antérieure date_anterieure = None if self.check_prestations_anterieures.GetValue() == True : date_anterieure = self.ctrl_date_anterieures.GetDate() if self.ctrl_date_anterieures.FonctionValiderDate() == False or date_anterieure == None: dlg = wx.MessageDialog(self, _(u"La date antérieure ne semble pas valide !"), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() self.ctrl_date_anterieures.SetFocus() return False # Vérification droits utilisateurs for IDactivite in listeActivites : if UTILS_Utilisateurs.VerificationDroitsUtilisateurActuel("facturation_factures", "creer", IDactivite=IDactivite, afficheMessage=False) == False : dlg = wx.MessageDialog(self, _(u"Vous n'avez pas l'autorisation de générer des factures pour l'ensemble des activités sélectionnées !"), _(u"Action non autorisée"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() return False # Vérifie la compatibilité des régies des activités sélectionnées if len(listeActivites) >= 1 : listeAllRegies = [] for IDactivite in listeActivites : DB=GestionDB.DB() req = """SELECT regie FROM activites WHERE IDactivite = %d""" % IDactivite DB.ExecuterReq(req) listeresult = DB.ResultatReq() result = listeresult[0] listeAllRegies.append(result[0]) DB.Close() listeRegies = list(set(listeAllRegies)) if len(listeRegies) > 1 : dlg = wx.MessageDialog(self, _(u"Vous ne pouvez pas générer des factures pour l'ensemble des activités sélectionnées !\n Certaines activités sont liées à des régies différentes"), _(u"Régies différentes"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() return False else : IDregie = listeRegies[0] # Envoi des données à DLG_Factures_generation self.parent.dictParametres = { "date_debut" : date_debut, "date_fin" : date_fin, "IDlot" : IDlot, "nomLot" : nomLot, "date_emission" : date_emission, "date_echeance" : date_echeance, "prochain_numero" : prochain_numero, "prestations" : prestations, "IDcompte_payeur" : IDcompte_payeur_unique, "listeActivites" : listeActivites, "IDprefixe" : IDprefixe, "prefixe" : prefixe, "date_anterieure" : date_anterieure, "IDregie" : IDregie, } return True
def OnBoutonOk(self, event): # Déduction label = self.ctrl_label.GetValue() if len(label) == 0: dlg = wx.MessageDialog( self, _(u"Vous devez obligatoirement saisir un label pour la déduction !" ), _(u"Erreur"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() self.ctrl_label.SetFocus() return False if self.radio_montant_fixe.GetValue() == True: montant = self.ctrl_montant_fixe.GetMontant() typeValeur = "montant" if montant == 0.0: dlg = wx.MessageDialog( self, _(u"Vous devez obligatoirement saisir un montant !"), _(u"Erreur"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() self.ctrl_montant_fixe.SetFocus() return False else: pourcent = self.ctrl_montant_pourcent.GetValue() typeValeur = "pourcent" if pourcent == 0.0: dlg = wx.MessageDialog( self, _(u"Vous devez obligatoirement saisir un pourcentage !"), _(u"Erreur"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() self.ctrl_montant_pourcent.SetFocus() return False # Tracks tracks = self.ctrl_prestations.GetTracksCoches() if len(tracks) == 0: dlg = wx.MessageDialog( self, _(u"Vous devez cocher au moins une ligne dans la liste !"), _(u"Erreur"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() return False # Périodes de gestion gestion = UTILS_Gestion.Gestion(None) date_debut = self.ctrl_date_debut.GetDate() date_fin = self.ctrl_date_fin.GetDate() if gestion.IsPeriodeinPeriodes("prestations", date_debut, date_fin) == False: return False listePrestations = self.ctrl_prestations.GetListePrestations() # Demande les prestations concernées listeLabelsPrestations = [] for dictPrestation in listePrestations: if dictPrestation["label"] not in listeLabelsPrestations: listeLabelsPrestations.append(dictPrestation["label"]) listeLabelsPrestations.sort() dlg = wx.MultiChoiceDialog( self, _(u"Cochez les prestations auxquelles vous souhaitez appliquer les déductions :" ), _(u"Sélection des prestations"), listeLabelsPrestations) dlg.SetSelections(range(0, len(listeLabelsPrestations))) reponse = dlg.ShowModal() selections = dlg.GetSelections() listeSelectionPrestations = [ listeLabelsPrestations[x] for x in selections ] dlg.Destroy() if reponse != wx.ID_OK: return False # Confirmation nbrePrestations = 0 for dictPrestation in listePrestations: if dictPrestation["label"] in listeSelectionPrestations: nbrePrestations += 1 dlg = wx.MessageDialog( self, _(u"Confirmez-vous la création automatique de %d déductions ?") % nbrePrestations, _(u"Demande de confirmation"), wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL | wx.ICON_QUESTION) reponse = dlg.ShowModal() dlg.Destroy() if reponse != wx.ID_YES: return False # ----------------------------- Création des déductions ----------------------------------------------------------- DB = GestionDB.DB() listeAjouts = [] listeModifications = [] listeSupprVentilations = [] listeAnomalies = [] for dictPrestation in listePrestations: # Vérifie si label sélectionné : if dictPrestation["label"] in listeSelectionPrestations: # Calcul du montant de la déduction montantPrestation = float(dictPrestation["montant"]) montantVentilation = float(dictPrestation["paye"]) if typeValeur == "montant": montantDeduction = montant if typeValeur == "pourcent": montantDeduction = float( decimal.Decimal(montantPrestation * pourcent / 100.0)) nouveauMontantPrestation = montantPrestation - montantDeduction # Détection anomalie valide = True labelPrestation = _(u"Famille ID%d - Prestation ID%d '%s' : " ) % (dictPrestation["IDfamille"], dictPrestation["IDprestation"], dictPrestation["label"]) if nouveauMontantPrestation < 0.0: listeAnomalies.append(labelPrestation + _( u"La déduction est plus élevée que le montant de la prestation !" )) valide = False if nouveauMontantPrestation < montantVentilation: listeAnomalies.append(labelPrestation + _( u"La ventilation est plus élevée que le nouveau montant de la prestation !" )) valide = False if dictPrestation["IDfacture"] != None: listeAnomalies.append(labelPrestation + _( u"La prestation ne peut être modifiée car elle apparaît sur une facture !" )) valide = False # Mémorisation if valide == True: listeAjouts.append( (dictPrestation["IDprestation"], dictPrestation["IDcompte_payeur"], str(datetime.date.today()), montantDeduction, label)) listeModifications.append((nouveauMontantPrestation, dictPrestation["IDprestation"])) listeSupprVentilations.append( dictPrestation["IDprestation"]) # Affichages anomalies if len(listeAnomalies) > 0: dlg = DLG_Messagebox.Dialog( self, titre=_(u"Anomalies"), introduction=_( u"Les %d anomalies suivantes ont été détectées :") % len(listeAnomalies), detail=u"\n".join(listeAnomalies), conclusion= _(u"Souhaitez-vous continuer pour les %d déductions valides ?" ) % len(listeAjouts), icone=wx.ICON_EXCLAMATION, boutons=[_(u"Oui"), _(u"Non"), _(u"Annuler")]) reponse = dlg.ShowModal() dlg.Destroy() if reponse in (1, 2): return False # Sauvegarde DB = GestionDB.DB() if len(listeAjouts) > 0: DB.Executermany( u"INSERT INTO deductions (IDprestation, IDcompte_payeur, date, montant, label) VALUES (?, ?, ?, ?, ?)", listeAjouts, commit=False) if len(listeModifications) > 0: DB.Executermany( _(u"UPDATE prestations SET montant=? WHERE IDprestation=?"), listeModifications, commit=False) if len(listeSupprVentilations) > 0: if len(listeSupprVentilations) == 1: conditionSuppressions = "(%d)" % listeSupprVentilations[0] else: conditionSuppressions = str(tuple(listeSupprVentilations)) DB.ExecuterReq("DELETE FROM ventilation WHERE IDprestation IN %s" % conditionSuppressions) DB.Commit() DB.Close() # Confirmation dlg = wx.MessageDialog( self, _(u"%d déductions ont été créées avec succès.") % len(listeAjouts), _(u"Confirmation"), wx.OK | wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy() if len(listeAjouts) == 0: return False # Fermeture self.EndModal(wx.ID_OK)