[dialog/adherent] Possibilité de facturer des adhésions
This commit is contained in:
parent
af3806d9a3
commit
fb3086c434
1 changed files with 81 additions and 3 deletions
|
@ -8,9 +8,12 @@ Licence : GPLv3
|
||||||
"""
|
"""
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
import datetime
|
||||||
if '/usr/scripts' not in sys.path:
|
if '/usr/scripts' not in sys.path:
|
||||||
sys.path.append('/usr/scripts')
|
sys.path.append('/usr/scripts')
|
||||||
|
|
||||||
|
import config.cotisation
|
||||||
|
|
||||||
import lc_ldap.objets as objets
|
import lc_ldap.objets as objets
|
||||||
import lc_ldap.attributs as attributs
|
import lc_ldap.attributs as attributs
|
||||||
from lc_ldap.attributs import UniquenessError
|
from lc_ldap.attributs import UniquenessError
|
||||||
|
@ -156,9 +159,84 @@ class Dialog(proprio.Dialog):
|
||||||
codes_todo=[([self.dialog.DIALOG_OK], todo, [tag, menu, adherent, self_cont])]
|
codes_todo=[([self.dialog.DIALOG_OK], todo, [tag, menu, adherent, self_cont])]
|
||||||
)
|
)
|
||||||
|
|
||||||
def adherent_adhesion(self, cont, adherent):
|
def adherent_adhesion(self, cont, adherent, tag_paiment=None, comment_paiement=None):
|
||||||
self.dialog.msgbox("todo", width=0, height=0)
|
|
||||||
return cont
|
# Boite si on ne peux pas réahdérer
|
||||||
|
def box_already(end):
|
||||||
|
t_end = time.strftime('%d/%m/%Y %H:%M:%S', time.localtime(end))
|
||||||
|
self.dialog.msgbox("Actuellement adhérent jusqu'au %s.\nMerci de revenir lorsqu'il restera moins de %s jours avant la fin." % (t_end, config.cotisation.delai_readh_jour),
|
||||||
|
width=0,
|
||||||
|
height=0,
|
||||||
|
timeout=self.timeout,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Boite de confirmation à l'ahésion
|
||||||
|
def box_adherer(end=None):
|
||||||
|
if end:
|
||||||
|
t_end = time.strftime('%d/%m/%Y %H:%M:%S', time.localtime(end))
|
||||||
|
adherer=self.confirm(text="Adhésion jusqu'au %s. Réadhérer ?" % t_end, title="Adhésion de %s %s" % (adherent.get("prenom", [''])[0], adherent["nom"][0]))
|
||||||
|
else:
|
||||||
|
adherer=self.confirm(text="Adhésion pour un an, continuer ?", title="Adhésion de %s %s" % (adherent.get("prenom", [''])[0], adherent["nom"][0]))
|
||||||
|
return adherer
|
||||||
|
|
||||||
|
# Génération de la facture pour adhésion
|
||||||
|
def paiement(tag_paiement, adherent, finadhesion, comment, cancel_cont, cont):
|
||||||
|
now = time.time()
|
||||||
|
new_finadhesion = datetime.datetime.fromtimestamp(max(finadhesion, now))
|
||||||
|
new_finadhesion = time.mktime(new_finadhesion.replace(year=new_finadhesion.year + config.cotisation.duree_adh_an).timetuple()) + 86400
|
||||||
|
new_debutadhesion = now
|
||||||
|
with self.conn.newFacture(adherent.dn, {}) as facture:
|
||||||
|
facture['modePaiement']=unicode(tag_paiement, 'utf-8')
|
||||||
|
facture['article'].append(config.cotisation.dico_adh)
|
||||||
|
facture['info']=unicode(comment, 'utf-8')
|
||||||
|
facture["finAdhesion"]=unicode(new_finadhesion)
|
||||||
|
facture["debutAdhesion"]=unicode(new_debutadhesion)
|
||||||
|
if self.confirm_item(item=facture,
|
||||||
|
text=u"Le paiement de %sEUR a-t-il bien été reçu (mode : %s) ?\n" % (facture.total(), tag_paiement),
|
||||||
|
title=u"Validation du paiement",
|
||||||
|
timeout=self.timeout):
|
||||||
|
# Appeler créditer va créditer ou débiter le solde, sauver le proprio et créer la facture
|
||||||
|
facture.crediter()
|
||||||
|
with self.conn.search(dn=adherent.dn, scope=0, mode='rw')[0] as adherent:
|
||||||
|
adherent["finAdhesion"].append(unicode(new_finadhesion))
|
||||||
|
adherent["debutAdhesion"].append(unicode(new_debutadhesion))
|
||||||
|
adherent.validate_changes()
|
||||||
|
adherent.history_gen()
|
||||||
|
adherent.save()
|
||||||
|
self.dialog.msgbox(
|
||||||
|
text=u"Adhésion effectué avec success",
|
||||||
|
title=u"Adhésion terminé",
|
||||||
|
width=0, height=0, timeout=self.timeout)
|
||||||
|
if tag_paiement == "solde":
|
||||||
|
self.dialog.msgbox(text=u"Le solde de l'adhérent à bien été débité", title="Solde débité", width=0, height=0, timeout=self.timeout)
|
||||||
|
else:
|
||||||
|
if not self.confirm(text=u"Le paiement n'a pas été reçue.\n Annuler ?", title="Annulation de l'adhésion", defaultno=True):
|
||||||
|
raise Continue(cancel_cont)
|
||||||
|
raise Continue(cont(adherent=adherent))
|
||||||
|
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)
|
||||||
|
return cont
|
||||||
|
|
||||||
|
# Sinon, si on accepte l'adhésion
|
||||||
|
elif tag_paiment or self.handle_dialog(cont, box_adherer, finadhesion):
|
||||||
|
self_cont = TailCall(self.adherent_adhesion, cont=cont, adherent=adherent, tag_paiment=tag_paiment, comment_paiement=comment_paiement)
|
||||||
|
# On choisi un mode de paiement
|
||||||
|
if not tag_paiment or not comment_paiement:
|
||||||
|
return self.proprio_choose_paiement(proprio=adherent, cont=self_cont, cancel_cont=cont)
|
||||||
|
else:
|
||||||
|
cancel_cont = self_cont.copy()
|
||||||
|
cancel_cont(comment_paiement=None)
|
||||||
|
return self.handle_dialog_result(
|
||||||
|
code=self.dialog.DIALOG_OK,
|
||||||
|
output=[],
|
||||||
|
cancel_cont=cancel_cont,
|
||||||
|
error_cont=cancel_cont,
|
||||||
|
codes_todo=[([self.dialog.DIALOG_OK], paiement, [tag_paiment, adherent, finadhesion, comment_paiement, cancel_cont, cont])]
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return cont
|
||||||
def adherent_connexion(self, cont, adherent, cancel_cont=None):
|
def adherent_connexion(self, cont, adherent, cancel_cont=None):
|
||||||
self.dialog.msgbox("todo", width=0, height=0)
|
self.dialog.msgbox("todo", width=0, height=0)
|
||||||
return cont
|
return cont
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue