Commit dad10fe4 authored by Gabriel Detraz's avatar Gabriel Detraz

Crée une facture aussi ppur le changement de solde

parent 7a6a703e
......@@ -322,14 +322,22 @@ class SoldeView(CableurMixin, RedirectHomeMixin, View):
form = SoldeForm(request.POST)
luser = get_luser(request, uid, ptype, 'w')
if form.is_valid():
with luser as user:
user.solde(float(form.cleaned_data['montant']), comment="mode: " + form.cleaned_data['mode'] + " ,"+form.cleaned_data['commentaire'], login=unicode(request.user))
user.save()
messages.success(request, u"""Modification de solde effectuée""")
return redirect(next)
return render(request, self.template_name, {'form': form, 'ptype': ptype, 'ide': uid})
fact = {
'modePaiement': [form.cleaned_data['mode']],
'article': [u'%s~~%s~~1~~%s' % ('SOLDE', 'Rechargement de solde ' + form.cleaned_data['commentaire'],float(form.cleaned_data['montant']))],
}
with conn_pool.get_conn(request.user).newFacture(luser.dn, fact) as facture:
try:
facture.crediter()
except ValueError as e:
# Cas où le solde n'est pas suffisant
messages.error(request, e)
return render(request, self.template_name, {'form': form, 'ptype': ptype, 'ide': uid, 'articles': articles})
fid = facture['fid'][0]
messages.success(request, u"""Vente effectuée, fid=%s (à conserver)""" % fid )
return redirect(next)
return render(request, self.template_name, {'form': form, 'ptype': ptype, 'ide': uid})
solde = SoldeView.as_view()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment