La modification du solde crée une facture, et on enlève solde de vente.
This commit is contained in:
parent
a6c38a88bf
commit
7b56a15685
3 changed files with 139 additions and 101 deletions
|
@ -20,11 +20,6 @@ ITEMS = {
|
|||
'designation': u'Reliure plastique',
|
||||
'pu': 0.12,
|
||||
},
|
||||
'SOLDE': {
|
||||
'designation': u'Rechargement du solde',
|
||||
'pu': '*',
|
||||
'imprimeur': True,
|
||||
},
|
||||
'PULL_ZIP_MARK': {
|
||||
'designation': u'Zipper marqué',
|
||||
'pu': 39.18,
|
||||
|
|
|
@ -24,7 +24,7 @@ To = ['root@crans.org']
|
|||
import string
|
||||
import os
|
||||
import sys
|
||||
import dialog
|
||||
import dialog as dialog_module
|
||||
from whos import aff
|
||||
import signal
|
||||
import getopt
|
||||
|
@ -62,13 +62,13 @@ if u'Nounou' in droits:
|
|||
# Sinon on utilise celui du système.
|
||||
DIALOGRC = '/etc/dialog.rc'
|
||||
|
||||
dlg = dialog.Dialog(DIALOGRC=DIALOGRC)
|
||||
dlg = dialog_module.Dialog(DIALOGRC=DIALOGRC)
|
||||
else:
|
||||
# Si on est pas nounou, on est libre de faire ce que l'on veut avec la
|
||||
# variable d'environnement DIALOGRC.
|
||||
DIALOGRC = ''
|
||||
|
||||
dlg = dialog.Dialog()
|
||||
dlg = dialog_module.Dialog()
|
||||
|
||||
|
||||
def dialog(arg):
|
||||
|
@ -664,9 +664,11 @@ def set_droits(adher):
|
|||
# Droits supprimés qui abonnaient à une ML
|
||||
old_mls = []
|
||||
for droit in diff:
|
||||
old_mls.extend([m for m in droits_mls.keys()
|
||||
old_mls.extend([
|
||||
m for m in droits_mls.keys()
|
||||
if m[0] == '+' and droit in droits_mls[m]
|
||||
and m not in old_mls])
|
||||
and m not in old_mls
|
||||
])
|
||||
|
||||
# MLs pour lesquelles un autre droit abonne encore
|
||||
for droit in new:
|
||||
|
@ -689,8 +691,10 @@ def set_droits(adher):
|
|||
del_mls.append(resml.strip())
|
||||
|
||||
if del_mls:
|
||||
db.services_to_restart('desabonner_ml',
|
||||
map(lambda m: "%s$%s" % (adher.mail(), m), resultmls))
|
||||
db.services_to_restart('desabonner_ml', [
|
||||
"%s$%s" % (adher.mail(), mailing_list)
|
||||
for mailing_list in resultmls
|
||||
])
|
||||
|
||||
# On modifie !
|
||||
e = None
|
||||
|
@ -1011,9 +1015,35 @@ def set_solde(clas):
|
|||
annul, res = dialog(arg)
|
||||
if annul: return 1
|
||||
|
||||
_montant = float(res[0])
|
||||
|
||||
menu = []
|
||||
|
||||
menu.append(u'"Liquide" "Espèces" ')
|
||||
menu.append(u'"Cheque" "Chèque" ')
|
||||
menu.append(u'"Carte" "Carte bancaire" ')
|
||||
menu.append(u'"Note" "Note Kfet (attention, moins traçable)" ')
|
||||
|
||||
if _montant > 0:
|
||||
_kword = u"Crédit"
|
||||
_kword2 = u"paiement"
|
||||
else:
|
||||
_kword = u"Débit"
|
||||
_kword2 = u"retrait"
|
||||
|
||||
# Il y a qqch de modifiable, on construit la checklist
|
||||
arg = u'--title "%s du solde de %s" ' % (_kword, clas.Nom())
|
||||
arg += u'--menu "Mode de %s : " 0 0 0 ' % (_kword2,)
|
||||
arg += u''.join(menu)
|
||||
|
||||
annul, result = dialog(arg)
|
||||
if annul: return 1
|
||||
|
||||
_mode = result[0]
|
||||
|
||||
# Ajout du commentaire
|
||||
arg = u'--title "Crédit / débit du compte de %s" ' % clas.Nom()
|
||||
arg += u'--inputbox "Commentaire à insérer ?" 0 0'
|
||||
arg = u'--title "%s du solde de %s" ' % (_kword, clas.Nom())
|
||||
arg += u'--inputbox "Commentaire à insérer (nom de note, …) ?" 0 0'
|
||||
annul, comment = dialog(arg)
|
||||
|
||||
if not annul:
|
||||
|
@ -1022,22 +1052,27 @@ def set_solde(clas):
|
|||
else:
|
||||
comment = None
|
||||
|
||||
f = Facture(clas)
|
||||
f.ajoute({'nombre': 1, 'code':'SOLDE', 'designation': "Solde Crans", 'pu': _montant})
|
||||
f.modePaiement(_mode.lower())
|
||||
|
||||
try:
|
||||
clas._data['uid'][0]
|
||||
except KeyError:
|
||||
arg = u'--title "Opération impossible" '
|
||||
arg += u'--msgbox "Il faut créer un compte Cr@ns pour modifier le solde" 0 0'
|
||||
dialog(arg)
|
||||
return
|
||||
try:
|
||||
clas.solde(res[0], comment)
|
||||
db.services_to_restart('mail_solde', ['%s a fait %s euros pour %s [%s]' %(script_utilisateur, res[0],clas._data['uid'][0], comment)])
|
||||
break
|
||||
# Met aussi à jour le solde.
|
||||
f.recuPaiement(strftime("%Y-%m-%d %H:%M:%S"))
|
||||
f.save()
|
||||
db.services_to_restart('mail_solde', [
|
||||
'%s a fait %s euros pour %s [mode: %s, remarque: %s]' %
|
||||
(script_utilisateur, _montant, clas._data['uid'][0], _mode, comment)
|
||||
])
|
||||
except ValueError, c:
|
||||
arg = u'--title "Opération impossible" '
|
||||
arg += u'--msgbox "%s\n\n\n" 0 0' % to_unicode(c.args[0])
|
||||
dialog(arg)
|
||||
|
||||
arg = u'--title "%s du solde de %s" ' % (_kword, clas.Nom())
|
||||
arg += u'--msgbox "Modification effectuée, merci de noter le numéro de facture %s." 0 0' % (f.numero(),)
|
||||
dialog(arg)
|
||||
|
||||
def set_vente(proprio):
|
||||
u"""
|
||||
Vend un objet à l'adherent : génère la facture associée.
|
||||
|
@ -1124,7 +1159,7 @@ def set_vente(proprio):
|
|||
menu.append(u'"Spc" "Espèces" ')
|
||||
menu.append(u'"Chq" "Chèque" ')
|
||||
menu.append(u'"Cb" "Carte bancaire" ')
|
||||
if isimprimeur:
|
||||
if isimprimeur and proprio.solde() - f.total() > 0:
|
||||
menu.append(u'"Sol" "Solde Crans (actuel : %s€)" ' % (proprio.solde()))
|
||||
|
||||
# Il y a qqch de modifiable, on construit la checklist
|
||||
|
@ -1134,7 +1169,6 @@ def set_vente(proprio):
|
|||
|
||||
annul, result = dialog(arg)
|
||||
if annul: return 1
|
||||
#print result
|
||||
|
||||
# Ajout du commentaire
|
||||
arg = u'--title "Crédit / débit du compte de %s" ' % proprio.Nom()
|
||||
|
@ -1169,7 +1203,7 @@ def set_vente(proprio):
|
|||
no, result = dialog(arg)
|
||||
if no:
|
||||
arg = u'--title "Annulation de la vente" '
|
||||
arg += u'--msgbox "Le paiement n\'ayant pas été reçue\nla vente est annulée\n" 0 0'
|
||||
arg += u'--msgbox "Le paiement n\'ayant pas été reçu\nla vente est annulée\n" 0 0'
|
||||
dialog(arg)
|
||||
return 1
|
||||
else:
|
||||
|
@ -1177,9 +1211,10 @@ def set_vente(proprio):
|
|||
f.recuPaiement(strftime("%Y-%m-%d %H:%M:%S"))
|
||||
f.save()
|
||||
arg = u'--title "Vente terminée" '
|
||||
arg += u'--msgbox "Vous pouvez remettre à l\'adherent les articles suivant :\n%s\n\nMerci de noter la facture: fid=%s" 0 0' % ('\n'.join(
|
||||
["%s %s" % (art['nombre'], art['designation']) for art in f.articles()]),
|
||||
f.numero())
|
||||
arg += u'--msgbox "Vous pouvez remettre à l\'adherent les articles suivant :\n%s\n\nMerci de noter la facture: fid=%s" 0 0' % ('\n'.join([
|
||||
"%s %s" % (art['nombre'], art['designation'])
|
||||
for art in f.articles()
|
||||
]), f.numero())
|
||||
dialog(arg)
|
||||
except ValueError as error:
|
||||
f.delete()
|
||||
|
@ -1470,15 +1505,15 @@ def set_adhesion(proprio):
|
|||
facture._set('debutAdhesion', [])
|
||||
facture.supprime(pop=True)
|
||||
return 1
|
||||
res = res[0]
|
||||
if res in ["Liquide", "Cheque", "Carte"]:
|
||||
_mode = res[0]
|
||||
if _mode in ["Liquide", "Cheque", "Carte"]:
|
||||
arg = u'--title "Avertissement" '
|
||||
arg += u'--msgbox "Une facture sera créée, après validation par le trésorier, l\'adhérent\npourra y accéder via l\'intranet ou la demander." 0 0'
|
||||
dialog(arg)
|
||||
facture.modePaiement(res.lower())
|
||||
facture.modePaiement(_mode.lower())
|
||||
break
|
||||
else:
|
||||
facture.modePaiement(res.lower())
|
||||
facture.modePaiement(_mode.lower())
|
||||
break
|
||||
in_facture = facture
|
||||
|
||||
|
@ -1591,15 +1626,15 @@ def set_connexion(proprio):
|
|||
facture._set('debutConnexion', [])
|
||||
facture.supprime(pop=True)
|
||||
continue
|
||||
res = res[0]
|
||||
if res in ["Liquide", "Cheque", "Carte"]:
|
||||
_mode = res[0]
|
||||
if _mode in ["Liquide", "Cheque", "Carte"]:
|
||||
arg = u'--title "Avertissement" '
|
||||
arg += u'--msgbox "Une facture sera créée, après validation par le trésorier, l\'adhérent\npourra y accéder via l\'intranet ou la demander." 0 0'
|
||||
dialog(arg)
|
||||
facture.modePaiement(res.lower())
|
||||
facture.modePaiement(_mode.lower())
|
||||
break
|
||||
else:
|
||||
facture.modePaiement(res.lower())
|
||||
facture.modePaiement(_mode.lower())
|
||||
break
|
||||
else:
|
||||
break
|
||||
|
@ -1662,7 +1697,7 @@ def modif_club(club):
|
|||
arg += u'"Alias" "Créer ou supprimer un alias mail" '
|
||||
if isdeconnecteur:
|
||||
arg += u'"Blackliste" "Modifier la blackliste du club" '
|
||||
if isimprimeur:
|
||||
if isimprimeur and club.compte():
|
||||
arg += u'"Solde" "Effectuer un débit/crédit pour ce club" '
|
||||
arg += u'"Vente" "Vendre un cable ou adaptateur ethernet ou autre" '
|
||||
|
||||
|
@ -2446,7 +2481,8 @@ def select(clas, quoi, mde=''):
|
|||
s = []
|
||||
for i in result:
|
||||
i = i.strip().decode(encoding)
|
||||
if not i: i= u'*'
|
||||
if not i:
|
||||
i = u'*'
|
||||
s.append(i)
|
||||
|
||||
# Recherche par adresse mail/login
|
||||
|
@ -2707,25 +2743,32 @@ def menu_principal():
|
|||
elif choix == 'dA':
|
||||
# Destruction adhérent
|
||||
proprio = select(db, u'adhérent à détruire a')
|
||||
if not proprio: continue
|
||||
if del_adher(proprio): continue
|
||||
del(proprio) ; proprio= None
|
||||
del(becane) ; becane= None
|
||||
if not proprio:
|
||||
continue
|
||||
if del_adher(proprio):
|
||||
continue
|
||||
del proprio
|
||||
proprio = None
|
||||
del becane
|
||||
becane = None
|
||||
|
||||
elif choix == 'dM':
|
||||
# Destruction machine
|
||||
becane = select(db, u'machine à détruire m')
|
||||
if not becane: continue
|
||||
if del_machine(becane): continue
|
||||
del(becane) ; becane= None
|
||||
del becane
|
||||
becane = None
|
||||
|
||||
elif choix == 'dC':
|
||||
# Destruction club
|
||||
proprio = select_club(db)
|
||||
if not proprio: continue
|
||||
if del_club(proprio): continue
|
||||
del(proprio) ; proprio= None
|
||||
del(becane) ; becane= None
|
||||
del proprio
|
||||
proprio = None
|
||||
del becane
|
||||
becane = None
|
||||
|
||||
elif choix == 'dF':
|
||||
# Destruction machine
|
||||
|
@ -2733,13 +2776,13 @@ def menu_principal():
|
|||
if not facture: continue
|
||||
proprio = facture.proprietaire()
|
||||
if del_facture(facture): continue
|
||||
del(facture)
|
||||
del facture
|
||||
facture = None
|
||||
|
||||
proprio.update_adhesion()
|
||||
proprio.update_connexion()
|
||||
proprio.save()
|
||||
del(proprio)
|
||||
del proprio
|
||||
proprio = None
|
||||
|
||||
elif choix == 'aKM':
|
||||
|
@ -2820,13 +2863,13 @@ def menu_principal():
|
|||
continue
|
||||
if set_machine(becane):
|
||||
# Annulation
|
||||
del(becane)
|
||||
del becane
|
||||
becane = None
|
||||
|
||||
|
||||
if choix == 'mAc':
|
||||
# Modif propriétaire courant
|
||||
del(becane)
|
||||
del becane
|
||||
becane = None
|
||||
# Test club
|
||||
if isinstance(proprio, Club):
|
||||
|
@ -2861,7 +2904,7 @@ def menu_principal():
|
|||
proprio.update_adhesion()
|
||||
proprio.update_connexion()
|
||||
proprio.save()
|
||||
del(proprio)
|
||||
del proprio
|
||||
proprio = None
|
||||
|
||||
elif choix == 'mCc':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue