[gest_crans] Possibilité de vendre des trucs et ça crée une facture
This commit is contained in:
parent
6141b0de2a
commit
0bb0a6c8bd
2 changed files with 118 additions and 1 deletions
7
gestion/config/factures.py
Normal file
7
gestion/config/factures.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
|
||||
items = {
|
||||
'CABLE' : {'designation': u'Cable Ethernet 5m', 'pu': 3},
|
||||
'ADAPTATEUR' : {'designation': u'Adaptateur Ethernet/USB', 'pu': 17},
|
||||
}
|
|
@ -32,7 +32,7 @@ import affich_tools, config
|
|||
from affich_tools import cprint, to_encoding, to_unicode
|
||||
from lock import make_lock, remove_lock
|
||||
from ldap_crans import crans_ldap, blacklist_items, ann_scol, droits_possibles, droits_critiques, smtpserv, script_utilisateur
|
||||
from ldap_crans import Adherent, AssociationCrans, Club
|
||||
from ldap_crans import Adherent, AssociationCrans, Club, Facture
|
||||
from ldap_crans import Machine, MachineFixe, MachineWifi, MachineCrans, BorneWifi
|
||||
import user_tests
|
||||
|
||||
|
@ -969,6 +969,113 @@ def set_solde(clas):
|
|||
arg += u'--msgbox "%s\n\n\n" 0 0' % to_unicode(c.args[0])
|
||||
dialog(arg)
|
||||
|
||||
def set_vente(proprio):
|
||||
u"""
|
||||
Vent un objet à l'adherent : génère la facture associée.
|
||||
"""
|
||||
from config.factures import items
|
||||
|
||||
# Construction de la boîte de dialogue
|
||||
checklist = []
|
||||
texte = []
|
||||
|
||||
for key,value in items.items():
|
||||
checklist.append(u'"%s" "%s (%s€)" "%s"' % (key, value['designation'], value['pu'], on_off(False)))
|
||||
|
||||
if not checklist:
|
||||
# Il n'y a rien de modifiable
|
||||
dialog(u'--title "Rien n\'est en vente pour le moment" --msgbox "Rien n\'est en vente pour le moment\n" 0 0 ')
|
||||
return
|
||||
|
||||
|
||||
# Il y a qqch de modifiable, on construit la checklist
|
||||
arg = u'--title "Vente de consomables à %s" ' % proprio.Nom()
|
||||
arg += u'--separate-output '
|
||||
arg += u'--checklist "%s\n" 0 0 0 ' % '\n'.join(texte)
|
||||
arg += u' '.join(checklist)
|
||||
|
||||
annul, result = dialog(arg)
|
||||
if annul: return 1
|
||||
|
||||
f = Facture(proprio)
|
||||
# Traitement
|
||||
for key in items.keys():
|
||||
if '%s\n' % key in result:
|
||||
while 1:
|
||||
arg = u'--title "Nombre de %s ?" ' % items[key]['designation']
|
||||
arg += u'--inputbox "" 0 0 "1" '
|
||||
annul, res = dialog(arg)
|
||||
if annul: return 1
|
||||
|
||||
try:
|
||||
nombre=int(res[0])
|
||||
break
|
||||
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)
|
||||
f.ajoute({'nombre': nombre, 'code': key, 'designation': items[key]['designation'], 'pu': items[key]['pu']})
|
||||
|
||||
checklist = []
|
||||
texte = []
|
||||
|
||||
checklist.append(u'"1" "Espèce" "%s"' % (on_off(False)))
|
||||
checklist.append(u'"2" "Chèque" "%s"' % (on_off(False)))
|
||||
|
||||
|
||||
# Il y a qqch de modifiable, on construit la checklist
|
||||
arg = u'--title "Vente de consomables à %s" ' % proprio.Nom()
|
||||
arg += u'--separate-output '
|
||||
arg += u'--checklist "" 0 0 0 '
|
||||
arg += u' '.join(checklist)
|
||||
|
||||
while True:
|
||||
annul, result = dialog(arg)
|
||||
if annul: return 1
|
||||
|
||||
if len(result) != 1 or not result[0]:
|
||||
arg_err = u'--title "Opération impossible" '
|
||||
arg_err += u'--msgbox "Merci de choisir un seul mode de paiement\n\n\n" 0 0'
|
||||
dialog(arg_err)
|
||||
else:
|
||||
break
|
||||
print result
|
||||
if "1\n" in result:
|
||||
f.modePaiement('liquide')
|
||||
paiement=u"Espèce"
|
||||
elif "2\n" in result:
|
||||
f.modePaiement('cheque')
|
||||
paiement=u"Chèque"
|
||||
|
||||
texte = []
|
||||
for art in f.articles():
|
||||
texte.append(u"%dx %s à %s€" % (art['nombre'], art['designation'], art['pu']))
|
||||
texte.append(u"Total à payer: %s€" % f.total())
|
||||
arg = u'--title "Résumé de la facture à payer" '
|
||||
arg += u'--msgbox "%s\n" 0 0' % '\n'.join(texte)
|
||||
dialog(arg)
|
||||
|
||||
arg = u'--title "Validation du paiement" '
|
||||
arg += u'--separate-output '
|
||||
arg += u'--checklist "Le paiement de %s€ a-t-il bien été reçu en %s ?\n" 0 0 0 ' % (f.total(), paiement)
|
||||
arg += ' '.join([u'"P" "Paiement de %s€ reçu" "%s"' % (f.total(), on_off(False))])
|
||||
annul, result = dialog(arg)
|
||||
if annul: return 1
|
||||
|
||||
if not "P\n" in result:
|
||||
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'
|
||||
dialog(arg)
|
||||
return 1
|
||||
else:
|
||||
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" 0 0' % '\n'.join(
|
||||
["%s %s" % (art['nombre'], art['designation']) for art in f.articles()])
|
||||
dialog(arg)
|
||||
|
||||
|
||||
def confirm(clas):
|
||||
u""" Demande confirmation avant enregistrement"""
|
||||
# On va faire en texte, les couleurs ne passent pas en curses
|
||||
|
@ -1716,6 +1823,7 @@ def modif_adher(adher):
|
|||
arg += u'"Blackliste" "Modifier la blackliste de cet adhérent" '
|
||||
if isimprimeur:
|
||||
arg += u'"Solde" "Effectuer un débit/crédit pour cet adhérent" '
|
||||
arg += u'"Vente" "Vendre un cable ou adaptateur ethernet ou autre" '
|
||||
|
||||
annul, res = dialog(arg)
|
||||
|
||||
|
@ -1845,6 +1953,8 @@ def modif_adher(adher):
|
|||
|
||||
elif res[0] == 'Solde':
|
||||
set_solde(adher)
|
||||
elif res[0] == 'Vente':
|
||||
set_vente(adher)
|
||||
|
||||
if adher.modifs:
|
||||
return confirm(adher)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue