From 43cdcc9c6fdb31e75faf038ad9bc9f97c9c39ad2 Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Fri, 13 Nov 2015 16:26:56 +0100 Subject: [PATCH] Gest_crans_lc supporte la modification arbitraire de solde --- gestion/dialog/proprio.py | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/gestion/dialog/proprio.py b/gestion/dialog/proprio.py index e1daeabb..b387c42a 100644 --- a/gestion/dialog/proprio.py +++ b/gestion/dialog/proprio.py @@ -411,6 +411,7 @@ class Dialog(machine.Dialog, blacklist.Dialog): "cheque" : "Chèque", "carte" : "Par carte bancaire", "solde" : "Solde Crans (actuel : %s€)", + "arbitraire" : "Ne crée pas de facture", } 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"]: box_paiement_order.append("solde") box_paiement["solde"] = box_paiement["solde"] % proprio["solde"][0] + else: + box_paiement_order.append("arbitraire") choices = [] for key in box_paiement_order: 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): choices = [] + gestion.config.factures.ITEMS.update(gestion.config.factures.ITEM_SOLDE) 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)) return self.dialog.checklist( @@ -499,11 +503,26 @@ class Dialog(machine.Dialog, blacklist.Dialog): def paiement(have_set, tag, proprio, comment, cancel_cont, cont): articles = copy.deepcopy(have_set) + + # On formate les articles for article in articles: if article['pu'] == '*': article['pu'] = article['nombre'] 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: facture['modePaiement']=unicode(tag, 'utf-8') 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'] if arts: self.dialog.msgbox( - text=u"Vous pouvez remettre à l'adherent les articles (si se sont des articles) suivant :\n * %s" % '\n * '.join(arts), - title=u"Vente terminée", - width=0, height=0, timeout=self.timeout) + 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", + width=0, height=0, timeout=self.timeout) 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']: - 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: 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) @@ -553,12 +572,13 @@ class Dialog(machine.Dialog, blacklist.Dialog): cancel_cont=cancel_cont, error_cont=cancel_cont, codes_todo=[([self.dialog.DIALOG_OK], paiement, [have_set, tag_paiment, proprio, comment_paiement, cancel_cont, cont])] - ) + ) # Sinon, on propose des articles à chosir else: (code, tags) = self.handle_dialog(cont, box_choose_item, tags) 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( code=code, output=tags,