Avertissement si prolongation de la connexion au dela de l'adhésion
On empêche tout de même de prolonger au dela d'un mois après la fin de l'adhésion.
This commit is contained in:
parent
f90f0e6f4c
commit
364c2f8f83
1 changed files with 19 additions and 7 deletions
|
@ -252,7 +252,7 @@ class Dialog(proprio.Dialog):
|
|||
else:
|
||||
facture = self.conn.newFacture(adherent.dn, {})
|
||||
to_create = True
|
||||
with facture:
|
||||
with facture as facture:
|
||||
facture['modePaiement'] = unicode(tag_paiement, 'utf-8')
|
||||
facture['info'] = unicode(comment, 'utf-8')
|
||||
facture['article'].append(config.cotisation.dico_adh)
|
||||
|
@ -283,7 +283,7 @@ class Dialog(proprio.Dialog):
|
|||
finadhesion = adherent.fin_adhesion()
|
||||
# Si fin de l'adhésion trop loin dans le futur, rien a faire
|
||||
if finadhesion and finadhesion - config.cotisation.delai_readh > time.time():
|
||||
self.handle_dialog(cont, box_already, finadhesion)
|
||||
self.handle_dialog(cancel_cont if cancel_cont else cont, box_already, finadhesion)
|
||||
raise Continue(cancel_cont if cancel_cont else cont)
|
||||
|
||||
# Sinon, si on accepte l'adhésion
|
||||
|
@ -352,13 +352,23 @@ class Dialog(proprio.Dialog):
|
|||
choices=[(k, menu[k]['text']) for k in menu_order])
|
||||
|
||||
# Génération et crédit de la facture
|
||||
def todo(adherent, mois, finconnexion, cancel_cont, cont, facture=None, tag_paiment=None, comment=None):
|
||||
def todo(adherent, mois, finadhesion, finconnexion, cancel_cont, cont, facture=None, tag_paiment=None, comment=None):
|
||||
now = time.time()
|
||||
new_finconnexion = datetime.datetime.fromtimestamp(max(finconnexion, now))
|
||||
# On ajoute 3600 secondes sur suggestion de Raphaël Bonaque (<bonaque@crans.org>), pour tenir compte des malheureux qui
|
||||
# pourraient subir le changement d'heure.
|
||||
new_finconnexion = time.mktime((new_finconnexion + dateutil.relativedelta.relativedelta(months=mois)).timetuple()) + 3600
|
||||
new_debutconnexion = max(now, finconnexion)
|
||||
|
||||
if new_finconnexion > finadhesion:
|
||||
t_end_adh = time.strftime('%d/%m/%Y %H:%M:%S', time.localtime(finadhesion))
|
||||
t_end_conn = time.strftime('%d/%m/%Y %H:%M:%S', time.localtime(new_finconnexion))
|
||||
if new_finconnexion - finadhesion > 30 * 3600 * 24:
|
||||
raise ValueError("Impossible de prolonger la connexion jusqu'au %s plus d'un mois après la fin de l'adhésion au %s" % (t_end_conn, t_end_adh))
|
||||
else:
|
||||
if not self.confirm("La fin de la connexion de l'adhérent (%s) tombera après la fin de son adhésion (%s).\n" \
|
||||
"S'il veut en profiter, il lui faudra éventuellement réadhérer. Continuer ?" % (t_end_conn, t_end_adh), title="Prolongement de connexon"):
|
||||
raise Continue(cancel_cont)
|
||||
# On édite une facture existante
|
||||
if facture:
|
||||
with self.conn.search(dn=facture.dn, scope=0, mode='rw')[0] as facture:
|
||||
|
@ -420,14 +430,16 @@ class Dialog(proprio.Dialog):
|
|||
finconnexion = adherent.fin_connexion()
|
||||
|
||||
# Si l'adhésion fini avant la connexion
|
||||
if finadhesion <= time.time() or finadhesion < finconnexion:
|
||||
if finadhesion <= time.time() or finadhesion <= finconnexion:
|
||||
if finadhesion:
|
||||
t_end_adh = time.strftime('%d/%m/%Y %H:%M:%S', time.localtime(finadhesion))
|
||||
# Si l'adhésion est déjà fini
|
||||
if finadhesion <= time.time():
|
||||
self.dialog.msgbox(text=u"L'adhésion a expiré, il va falloir réadhérer d'abord", title="Réadhésion nécessaire", width=0, height=0, timeout=self.timeout)
|
||||
self.dialog.msgbox(text=u"L'adhésion a expiré le %s, il va falloir réadhérer d'abord" % t_end_adh, title="Réadhésion nécessaire", width=0, height=0, timeout=self.timeout)
|
||||
# Sinon si elle fini avant la fin de la connexion courante
|
||||
elif finadhesion < finconnexion:
|
||||
self.dialog.msgbox(text=u"L'adhésion de termine avant la fin de la connexion, il va falloir réadhérer d'abord", title="Réadhésion nécessaire", width=0, height=0, timeout=self.timeout)
|
||||
t_end_conn = time.strftime('%d/%m/%Y %H:%M:%S', time.localtime(finconnexion))
|
||||
self.dialog.msgbox(text=u"L'adhésion de termine le %s, avant la fin de la connexion le %s, il va falloir réadhérer d'abord" % (t_end_adh, t_end_conn), title="Réadhésion nécessaire", width=0, height=0, timeout=self.timeout)
|
||||
# Échouera si on essaie de prolonger la connexion au dela de l'adhésion et que l'adhésion est encore valable plus de quinze jours
|
||||
return self.adherent_adhesion(cont=self_cont, cancel_cont=cont, adherent=adherent, crediter=False)
|
||||
|
||||
|
@ -458,7 +470,7 @@ class Dialog(proprio.Dialog):
|
|||
output=[],
|
||||
cancel_cont=lcont,
|
||||
error_cont=lcont,
|
||||
codes_todo=[([self.dialog.DIALOG_OK], todo, [adherent, mois, finconnexion, lcont, cont, facture, tag_paiment, comment_paiement])]
|
||||
codes_todo=[([self.dialog.DIALOG_OK], todo, [adherent, mois, finadhesion, finconnexion, lcont, cont, facture, tag_paiment, comment_paiement])]
|
||||
)
|
||||
# Sinon, il faut choisir une méthode de paiement
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue