[gest_crans,ldap_crans] Vente avec paiement de la facture via solde crans

This commit is contained in:
Valentin Samir 2013-11-29 01:42:59 +01:00
parent 8bd394dbe8
commit 4a7b5a2399
2 changed files with 135 additions and 91 deletions

View file

@ -975,6 +975,7 @@ def set_vente(proprio):
"""
from config.factures import items
def choose_items():
# Construction de la boîte de dialogue
checklist = []
texte = []
@ -1016,11 +1017,24 @@ def set_vente(proprio):
dialog(arg)
f.ajoute({'nombre': nombre, 'code': key, 'designation': items[key]['designation'], 'pu': items[key]['pu']})
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)
return f
def choose_paiement(f):
checklist = []
texte = []
checklist.append(u'"1" "Espèce" "%s"' % (on_off(False)))
checklist.append(u'"2" "Chèque" "%s"' % (on_off(False)))
checklist.append(u'"3" "Solde Crans (actuel : %s€)" "%s"' % (proprio.solde(), on_off(False)))
# Il y a qqch de modifiable, on construit la checklist
@ -1040,20 +1054,31 @@ def set_vente(proprio):
else:
break
print result
# Ajout du commentaire
arg = u'--title "Crédit / débit du compte de %s" ' % proprio.Nom()
arg += u'--inputbox "Commentaire à insérer ?" 0 0'
if "1\n" in result:
f.modePaiement('liquide')
paiement=u"Espèce"
annul, comment = dialog(arg)
elif "2\n" in result:
f.modePaiement('cheque')
paiement=u"Chèque"
annul, comment = dialog(arg)
elif "3\n" in result:
f.modePaiement('solde')
paiement=u"Solde Crans"
comment = None
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)
if comment and comment[0]:
comment = comment[0]
else:
comment = None
return (f,paiement,comment)
def comfirm_and_pay((f,paiement,comment)):
arg = u'--title "Validation du paiement" '
arg += u'--separate-output '
@ -1068,12 +1093,27 @@ def set_vente(proprio):
dialog(arg)
return 1
else:
try:
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)
except ValueError as error:
f.delete()
arg = u'--title "Annulation de la vente" '
arg += u'--msgbox "%s\n" 0 0' % error
dialog(arg)
return 1
f = choose_items()
if isinstance(f, int):
return f
ret = choose_paiement(f)
if isinstance(ret, int):
return ret
return comfirm_and_pay(ret)
def confirm(clas):

View file

@ -3761,7 +3761,7 @@ class Facture(BaseClasseCrans):
if not self._modifiable:
raise NotImplementedError, "La facture n'est pas modifiable"
if new not in ['liquide', 'cheque', 'paypal']:
if new not in ['liquide', 'cheque', 'paypal', 'solde']:
raise ValueError, u'Mode de paiement non accepté'
self._set('modePaiement', [new])
@ -3820,6 +3820,10 @@ class Facture(BaseClasseCrans):
proprio = self.proprietaire()
proprio.solde(operation=art['nombre']*art["pu"], comment="Facture n°%s : %s" % (self.numero(), art['designation']))
proprio.save()
elif self.modePaiement() == 'solde':
proprio = self.proprietaire()
proprio.solde(operation=0.0 - self.total(), comment="Facture n°%s" % self.numero())
proprio.save()
def _frais(self):
"""