[gest_crans,ldap_crans] Vente avec paiement de la facture via solde crans
This commit is contained in:
parent
8bd394dbe8
commit
4a7b5a2399
2 changed files with 135 additions and 91 deletions
|
@ -975,6 +975,7 @@ def set_vente(proprio):
|
||||||
"""
|
"""
|
||||||
from config.factures import items
|
from config.factures import items
|
||||||
|
|
||||||
|
def choose_items():
|
||||||
# Construction de la boîte de dialogue
|
# Construction de la boîte de dialogue
|
||||||
checklist = []
|
checklist = []
|
||||||
texte = []
|
texte = []
|
||||||
|
@ -1016,11 +1017,24 @@ def set_vente(proprio):
|
||||||
dialog(arg)
|
dialog(arg)
|
||||||
f.ajoute({'nombre': nombre, 'code': key, 'designation': items[key]['designation'], 'pu': items[key]['pu']})
|
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 = []
|
checklist = []
|
||||||
texte = []
|
texte = []
|
||||||
|
|
||||||
checklist.append(u'"1" "Espèce" "%s"' % (on_off(False)))
|
checklist.append(u'"1" "Espèce" "%s"' % (on_off(False)))
|
||||||
checklist.append(u'"2" "Chèque" "%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
|
# Il y a qqch de modifiable, on construit la checklist
|
||||||
|
@ -1040,20 +1054,31 @@ def set_vente(proprio):
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
print result
|
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:
|
if "1\n" in result:
|
||||||
f.modePaiement('liquide')
|
f.modePaiement('liquide')
|
||||||
paiement=u"Espèce"
|
paiement=u"Espèce"
|
||||||
|
annul, comment = dialog(arg)
|
||||||
elif "2\n" in result:
|
elif "2\n" in result:
|
||||||
f.modePaiement('cheque')
|
f.modePaiement('cheque')
|
||||||
paiement=u"Chèque"
|
paiement=u"Chèque"
|
||||||
|
annul, comment = dialog(arg)
|
||||||
|
elif "3\n" in result:
|
||||||
|
f.modePaiement('solde')
|
||||||
|
paiement=u"Solde Crans"
|
||||||
|
comment = None
|
||||||
|
|
||||||
texte = []
|
if comment and comment[0]:
|
||||||
for art in f.articles():
|
comment = comment[0]
|
||||||
texte.append(u"%dx %s à %s€" % (art['nombre'], art['designation'], art['pu']))
|
else:
|
||||||
texte.append(u"Total à payer: %s€" % f.total())
|
comment = None
|
||||||
arg = u'--title "Résumé de la facture à payer" '
|
|
||||||
arg += u'--msgbox "%s\n" 0 0' % '\n'.join(texte)
|
return (f,paiement,comment)
|
||||||
dialog(arg)
|
|
||||||
|
def comfirm_and_pay((f,paiement,comment)):
|
||||||
|
|
||||||
arg = u'--title "Validation du paiement" '
|
arg = u'--title "Validation du paiement" '
|
||||||
arg += u'--separate-output '
|
arg += u'--separate-output '
|
||||||
|
@ -1068,12 +1093,27 @@ def set_vente(proprio):
|
||||||
dialog(arg)
|
dialog(arg)
|
||||||
return 1
|
return 1
|
||||||
else:
|
else:
|
||||||
|
try:
|
||||||
f.recuPaiement(strftime("%Y-%m-%d %H:%M:%S"))
|
f.recuPaiement(strftime("%Y-%m-%d %H:%M:%S"))
|
||||||
f.save()
|
f.save()
|
||||||
arg = u'--title "Vente terminée" '
|
arg = u'--title "Vente terminée" '
|
||||||
arg += u'--msgbox "Vous pouvez remettre à l\'adherent les articles suivant :\n%s" 0 0' % '\n'.join(
|
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()])
|
["%s %s" % (art['nombre'], art['designation']) for art in f.articles()])
|
||||||
dialog(arg)
|
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):
|
def confirm(clas):
|
||||||
|
|
|
@ -3761,7 +3761,7 @@ class Facture(BaseClasseCrans):
|
||||||
if not self._modifiable:
|
if not self._modifiable:
|
||||||
raise NotImplementedError, "La facture n'est pas 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é'
|
raise ValueError, u'Mode de paiement non accepté'
|
||||||
|
|
||||||
self._set('modePaiement', [new])
|
self._set('modePaiement', [new])
|
||||||
|
@ -3820,6 +3820,10 @@ class Facture(BaseClasseCrans):
|
||||||
proprio = self.proprietaire()
|
proprio = self.proprietaire()
|
||||||
proprio.solde(operation=art['nombre']*art["pu"], comment="Facture n°%s : %s" % (self.numero(), art['designation']))
|
proprio.solde(operation=art['nombre']*art["pu"], comment="Facture n°%s : %s" % (self.numero(), art['designation']))
|
||||||
proprio.save()
|
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):
|
def _frais(self):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue