[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,105 +975,145 @@ def set_vente(proprio):
|
||||||
"""
|
"""
|
||||||
from config.factures import items
|
from config.factures import items
|
||||||
|
|
||||||
# Construction de la boîte de dialogue
|
def choose_items():
|
||||||
checklist = []
|
# Construction de la boîte de dialogue
|
||||||
texte = []
|
checklist = []
|
||||||
|
texte = []
|
||||||
|
|
||||||
for key,value in items.items():
|
for key,value in items.items():
|
||||||
checklist.append(u'"%s" "%s (%s€)" "%s"' % (key, value['designation'], value['pu'], on_off(False)))
|
checklist.append(u'"%s" "%s (%s€)" "%s"' % (key, value['designation'], value['pu'], on_off(False)))
|
||||||
|
|
||||||
if not checklist:
|
if not checklist:
|
||||||
# Il n'y a rien de modifiable
|
# 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 ')
|
dialog(u'--title "Rien n\'est en vente pour le moment" --msgbox "Rien n\'est en vente pour le moment\n" 0 0 ')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
# Il y a qqch de modifiable, on construit la checklist
|
# Il y a qqch de modifiable, on construit la checklist
|
||||||
arg = u'--title "Vente de consomables à %s" ' % proprio.Nom()
|
arg = u'--title "Vente de consomables à %s" ' % proprio.Nom()
|
||||||
arg += u'--separate-output '
|
arg += u'--separate-output '
|
||||||
arg += u'--checklist "%s\n" 0 0 0 ' % '\n'.join(texte)
|
arg += u'--checklist "%s\n" 0 0 0 ' % '\n'.join(texte)
|
||||||
arg += u' '.join(checklist)
|
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)
|
annul, result = dialog(arg)
|
||||||
if annul: return 1
|
if annul: return 1
|
||||||
|
|
||||||
if len(result) != 1 or not result[0]:
|
f = Facture(proprio)
|
||||||
arg_err = u'--title "Opération impossible" '
|
# Traitement
|
||||||
arg_err += u'--msgbox "Merci de choisir un seul mode de paiement\n\n\n" 0 0'
|
for key in items.keys():
|
||||||
dialog(arg_err)
|
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']})
|
||||||
|
|
||||||
|
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
|
||||||
|
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
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
if comment and comment[0]:
|
||||||
|
comment = comment[0]
|
||||||
else:
|
else:
|
||||||
break
|
comment = None
|
||||||
print result
|
|
||||||
if "1\n" in result:
|
return (f,paiement,comment)
|
||||||
f.modePaiement('liquide')
|
|
||||||
paiement=u"Espèce"
|
def comfirm_and_pay((f,paiement,comment)):
|
||||||
elif "2\n" in result:
|
|
||||||
f.modePaiement('cheque')
|
arg = u'--title "Validation du paiement" '
|
||||||
paiement=u"Chèque"
|
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
|
||||||
|
|
||||||
texte = []
|
if not "P\n" in result:
|
||||||
for art in f.articles():
|
arg = u'--title "Annulation de la vente" '
|
||||||
texte.append(u"%dx %s à %s€" % (art['nombre'], art['designation'], art['pu']))
|
arg += u'--msgbox "Le paiement n\'ayant pas été reçue\nla vente est annulée\n" 0 0'
|
||||||
texte.append(u"Total à payer: %s€" % f.total())
|
dialog(arg)
|
||||||
arg = u'--title "Résumé de la facture à payer" '
|
return 1
|
||||||
arg += u'--msgbox "%s\n" 0 0' % '\n'.join(texte)
|
else:
|
||||||
dialog(arg)
|
try:
|
||||||
|
f.recuPaiement(strftime("%Y-%m-%d %H:%M:%S"))
|
||||||
arg = u'--title "Validation du paiement" '
|
f.save()
|
||||||
arg += u'--separate-output '
|
arg = u'--title "Vente terminée" '
|
||||||
arg += u'--checklist "Le paiement de %s€ a-t-il bien été reçu en %s ?\n" 0 0 0 ' % (f.total(), paiement)
|
arg += u'--msgbox "Vous pouvez remettre à l\'adherent les articles suivant :\n%s" 0 0' % '\n'.join(
|
||||||
arg += ' '.join([u'"P" "Paiement de %s€ reçu" "%s"' % (f.total(), on_off(False))])
|
["%s %s" % (art['nombre'], art['designation']) for art in f.articles()])
|
||||||
annul, result = dialog(arg)
|
dialog(arg)
|
||||||
if annul: return 1
|
except ValueError as error:
|
||||||
|
f.delete()
|
||||||
if not "P\n" in result:
|
arg = u'--title "Annulation de la vente" '
|
||||||
arg = u'--title "Annulation de la vente" '
|
arg += u'--msgbox "%s\n" 0 0' % error
|
||||||
arg += u'--msgbox "Le paiement n\'ayant pas été reçue\nla vente est annulée\n" 0 0'
|
dialog(arg)
|
||||||
dialog(arg)
|
return 1
|
||||||
return 1
|
|
||||||
else:
|
f = choose_items()
|
||||||
f.recuPaiement(strftime("%Y-%m-%d %H:%M:%S"))
|
if isinstance(f, int):
|
||||||
f.save()
|
return f
|
||||||
arg = u'--title "Vente terminée" '
|
ret = choose_paiement(f)
|
||||||
arg += u'--msgbox "Vous pouvez remettre à l\'adherent les articles suivant :\n%s" 0 0' % '\n'.join(
|
if isinstance(ret, int):
|
||||||
["%s %s" % (art['nombre'], art['designation']) for art in f.articles()])
|
return ret
|
||||||
dialog(arg)
|
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