Gest_crans_lc supporte la modification arbitraire de solde
This commit is contained in:
parent
e2141e1043
commit
43cdcc9c6f
1 changed files with 26 additions and 6 deletions
|
@ -411,6 +411,7 @@ class Dialog(machine.Dialog, blacklist.Dialog):
|
||||||
"cheque" : "Chèque",
|
"cheque" : "Chèque",
|
||||||
"carte" : "Par carte bancaire",
|
"carte" : "Par carte bancaire",
|
||||||
"solde" : "Solde Crans (actuel : %s€)",
|
"solde" : "Solde Crans (actuel : %s€)",
|
||||||
|
"arbitraire" : "Ne crée pas de facture",
|
||||||
}
|
}
|
||||||
|
|
||||||
def box_choose_paiment(tag, articles):
|
def box_choose_paiment(tag, articles):
|
||||||
|
@ -419,6 +420,8 @@ class Dialog(machine.Dialog, blacklist.Dialog):
|
||||||
if not "SOLDE" in [art['code'] for art in articles] and proprio["solde"]:
|
if not "SOLDE" in [art['code'] for art in articles] and proprio["solde"]:
|
||||||
box_paiement_order.append("solde")
|
box_paiement_order.append("solde")
|
||||||
box_paiement["solde"] = box_paiement["solde"] % proprio["solde"][0]
|
box_paiement["solde"] = box_paiement["solde"] % proprio["solde"][0]
|
||||||
|
else:
|
||||||
|
box_paiement_order.append("arbitraire")
|
||||||
choices = []
|
choices = []
|
||||||
for key in box_paiement_order:
|
for key in box_paiement_order:
|
||||||
choices.append((key, box_paiement[key], 1 if key == tag else 0))
|
choices.append((key, box_paiement[key], 1 if key == tag else 0))
|
||||||
|
@ -457,6 +460,7 @@ class Dialog(machine.Dialog, blacklist.Dialog):
|
||||||
|
|
||||||
def box_choose_item(tags):
|
def box_choose_item(tags):
|
||||||
choices = []
|
choices = []
|
||||||
|
gestion.config.factures.ITEMS.update(gestion.config.factures.ITEM_SOLDE)
|
||||||
for code, article in gestion.config.factures.ITEMS.items():
|
for code, article in gestion.config.factures.ITEMS.items():
|
||||||
choices.append((code, u"%s%s" % (article['designation'], (u' (%s€)' % article['pu']) if article['pu'] != '*' else ""), 1 if code in tags else 0))
|
choices.append((code, u"%s%s" % (article['designation'], (u' (%s€)' % article['pu']) if article['pu'] != '*' else ""), 1 if code in tags else 0))
|
||||||
return self.dialog.checklist(
|
return self.dialog.checklist(
|
||||||
|
@ -499,11 +503,26 @@ class Dialog(machine.Dialog, blacklist.Dialog):
|
||||||
|
|
||||||
def paiement(have_set, tag, proprio, comment, cancel_cont, cont):
|
def paiement(have_set, tag, proprio, comment, cancel_cont, cont):
|
||||||
articles = copy.deepcopy(have_set)
|
articles = copy.deepcopy(have_set)
|
||||||
|
|
||||||
|
# On formate les articles
|
||||||
for article in articles:
|
for article in articles:
|
||||||
if article['pu'] == '*':
|
if article['pu'] == '*':
|
||||||
article['pu'] = article['nombre']
|
article['pu'] = article['nombre']
|
||||||
article['nombre'] = 1
|
article['nombre'] = 1
|
||||||
|
|
||||||
|
# En arbitraire, on accepte que le solde
|
||||||
|
if tag == u"arbitraire":
|
||||||
|
if len(articles) > 1:
|
||||||
|
raise ValueError("Il n'est possible que de faire une opération de solde en mode arbitraire")
|
||||||
|
else:
|
||||||
|
with self.conn.search(dn=proprio.dn, scope=0, mode='rw')[0] as adh:
|
||||||
|
adh.solde(articles[0]['pu'], comment=unicode(comment))
|
||||||
|
adh.history_gen()
|
||||||
|
adh.save()
|
||||||
|
self.dialog.msgbox(text=u"Le solde de l'adhérent a bien été crédité", title="Solde crédité", width=0, height=0, timeout=self.timeout)
|
||||||
|
raise Continue(cont)
|
||||||
|
|
||||||
|
# Les articles classiques on facture
|
||||||
with self.conn.newFacture(proprio.dn, {}) as facture:
|
with self.conn.newFacture(proprio.dn, {}) as facture:
|
||||||
facture['modePaiement']=unicode(tag, 'utf-8')
|
facture['modePaiement']=unicode(tag, 'utf-8')
|
||||||
facture['article']=articles
|
facture['article']=articles
|
||||||
|
@ -517,13 +536,13 @@ class Dialog(machine.Dialog, blacklist.Dialog):
|
||||||
arts = ["%s %s" % (art['nombre'], art['designation']) for art in facture['article'] if art['code'] != 'SOLDE']
|
arts = ["%s %s" % (art['nombre'], art['designation']) for art in facture['article'] if art['code'] != 'SOLDE']
|
||||||
if arts:
|
if arts:
|
||||||
self.dialog.msgbox(
|
self.dialog.msgbox(
|
||||||
text=u"Vous pouvez remettre à l'adherent les articles (si se sont des articles) suivant :\n * %s" % '\n * '.join(arts),
|
text=u"Vous pouvez remettre à l'adherent les articles (si ce sont des articles) suivant :\n * %s" % '\n * '.join(arts),
|
||||||
title=u"Vente terminée",
|
title=u"Vente terminée",
|
||||||
width=0, height=0, timeout=self.timeout)
|
width=0, height=0, timeout=self.timeout)
|
||||||
if tag == "solde":
|
if tag == "solde":
|
||||||
self.dialog.msgbox(text=u"Le solde de l'adhérent à bien été débité", title="Solde débité", width=0, height=0, timeout=self.timeout)
|
self.dialog.msgbox(text=u"Le solde de l'adhérent a bien été débité", title="Solde débité", width=0, height=0, timeout=self.timeout)
|
||||||
if [a for a in facture['article'] if art['code'] == 'SOLDE']:
|
if [a for a in facture['article'] if art['code'] == 'SOLDE']:
|
||||||
self.dialog.msgbox(text=u"Le solde de l'adhérent à bien été crédité", title="Solde crédité", width=0, height=0, timeout=self.timeout)
|
self.dialog.msgbox(text=u"Le solde de l'adhérent a bien été crédité", title="Solde crédité", width=0, height=0, timeout=self.timeout)
|
||||||
else:
|
else:
|
||||||
if not self.confirm(text=u"Le paiement n'a pas été reçue.\n Annuler la vente ?", title="Annulation de la vente", defaultno=True):
|
if not self.confirm(text=u"Le paiement n'a pas été reçue.\n Annuler la vente ?", title="Annulation de la vente", defaultno=True):
|
||||||
raise Continue(cancel_cont)
|
raise Continue(cancel_cont)
|
||||||
|
@ -553,12 +572,13 @@ class Dialog(machine.Dialog, blacklist.Dialog):
|
||||||
cancel_cont=cancel_cont,
|
cancel_cont=cancel_cont,
|
||||||
error_cont=cancel_cont,
|
error_cont=cancel_cont,
|
||||||
codes_todo=[([self.dialog.DIALOG_OK], paiement, [have_set, tag_paiment, proprio, comment_paiement, cancel_cont, cont])]
|
codes_todo=[([self.dialog.DIALOG_OK], paiement, [have_set, tag_paiment, proprio, comment_paiement, cancel_cont, cont])]
|
||||||
)
|
)
|
||||||
|
|
||||||
# Sinon, on propose des articles à chosir
|
# Sinon, on propose des articles à chosir
|
||||||
else:
|
else:
|
||||||
(code, tags) = self.handle_dialog(cont, box_choose_item, tags)
|
(code, tags) = self.handle_dialog(cont, box_choose_item, tags)
|
||||||
self_cont=self_cont(tags=tags, have_set=[], to_set=[], tag_paiment=None)
|
self_cont=self_cont(tags=tags, have_set=[], to_set=[], tag_paiment=None)
|
||||||
|
gestion.config.factures.ITEMS.update(gestion.config.factures.ITEM_SOLDE)
|
||||||
return self.handle_dialog_result(
|
return self.handle_dialog_result(
|
||||||
code=code,
|
code=code,
|
||||||
output=tags,
|
output=tags,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue