Ajout des modules initiaux
darcs-hash:20070124114812-f46e9-171ef12f1e1b89ae005adf4aab6f6535fb9289e6.gz
This commit is contained in:
parent
8713311bc1
commit
ed3ab40ccd
80 changed files with 4852 additions and 5 deletions
140
intranet/modules/gestionFactures/main.py
Executable file
140
intranet/modules/gestionFactures/main.py
Executable file
|
@ -0,0 +1,140 @@
|
|||
#! /usr/bin/env python
|
||||
# -*- coding: iso-8859-15 -*-
|
||||
# ##################################################################################################### #
|
||||
# Factures (gestion)
|
||||
# ##################################################################################################### #
|
||||
# Description:
|
||||
# Permet de chercher dans les facture, d'en créditer et d'en supprimer
|
||||
# Informations:
|
||||
#
|
||||
# Pages:
|
||||
# index:afiche le formulaire et les factures
|
||||
#
|
||||
# ##################################################################################################### #
|
||||
import cherrypy, sys, os, datetime
|
||||
import crans.cp
|
||||
from ClassesIntranet.ModuleBase import ModuleBase
|
||||
|
||||
class main(ModuleBase):
|
||||
_droits = ["Imprimeur"]
|
||||
def title(self):
|
||||
return "Gestion factures"
|
||||
def category(self):
|
||||
return "Imprimeur"
|
||||
|
||||
def index(self, message = '', erreur = ''):
|
||||
if cherrypy.session.has_key('gestion_factures-current_search'):
|
||||
del cherrypy.session['gestion_factures-current_search']
|
||||
return self.displayTemplate()
|
||||
index.exposed = True
|
||||
|
||||
def search(self, fid=None, uid=None, aid=None):
|
||||
cherrypy.session['gestion_factures-current_search'] = {
|
||||
"fid":fid,
|
||||
"uid":uid,
|
||||
"aid":aid,
|
||||
}
|
||||
return self.displayTemplate()
|
||||
search.exposed = True
|
||||
|
||||
|
||||
|
||||
def displayTemplate(self, message = '', erreur = ''):
|
||||
t = {}
|
||||
t['message'] = message
|
||||
t['error'] = erreur
|
||||
if cherrypy.session.has_key('gestion_factures-current_search'):
|
||||
fid = cherrypy.session['gestion_factures-current_search']['fid']
|
||||
uid = cherrypy.session['gestion_factures-current_search']['uid']
|
||||
aid = cherrypy.session['gestion_factures-current_search']['aid']
|
||||
t['listeFactures'] = self.buildInvoiceList(
|
||||
fid = fid,
|
||||
uid = uid,
|
||||
aid = aid,
|
||||
)
|
||||
|
||||
else:
|
||||
fid = ""
|
||||
uid = ""
|
||||
aid = ""
|
||||
t["form"] = []
|
||||
t["form"]+= [{'name':'fid', 'label':'fid', 'value':fid}]
|
||||
t["form"]+= [{'name':'uid', 'label':'login', 'value':uid}]
|
||||
t["form"]+= [{'name':'aid', 'label':'aid', 'value':aid}]
|
||||
|
||||
return {
|
||||
'template' :'factures-gestion',
|
||||
'values' :t,
|
||||
'stylesheets' :['cransFactures.css'],
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
def buildInvoiceList(self, fid=None, uid=None, aid=None):
|
||||
############## liste des factures ##############
|
||||
if fid:
|
||||
search_string = "fid=%s" % str(fid)
|
||||
liste_factures_ldap = cherrypy.session['LDAP'].search(search_string)['facture']
|
||||
elif uid:
|
||||
search_string = "uid=%s" % str(uid)
|
||||
try:
|
||||
liste_factures_ldap = cherrypy.session['LDAP'].search(search_string)['adherent'][0].factures()
|
||||
except:
|
||||
liste_factures_ldap = []
|
||||
elif aid:
|
||||
search_string = "aid=%s" % str(aid)
|
||||
try:
|
||||
liste_factures_ldap = cherrypy.session['LDAP'].search(search_string)['adherent'][0].factures()
|
||||
except:
|
||||
liste_factures_ldap = []
|
||||
else:
|
||||
return []
|
||||
liste_factures_affichees = []
|
||||
for f in liste_factures_ldap:
|
||||
try:
|
||||
facture = {}
|
||||
facture['no'] = f.numero()
|
||||
facture['adherent'] = f.proprietaire().mail()
|
||||
facture['montant'] = f.total()
|
||||
facture['payee'] = f.recuPaiement()
|
||||
facture['intitule'] = f.articles()[0]['designation']
|
||||
facture['details'] = [
|
||||
{
|
||||
'intitule':art['designation'],
|
||||
'quantite':art['nombre'],
|
||||
'prixUnitaire':art['pu'],
|
||||
'prixTotal':art['pu']*art['nombre'],
|
||||
} for art in f.articles()]
|
||||
liste_factures_affichees.append(facture)
|
||||
except:
|
||||
crans.cp.log("Facture non affichable : fid=%s" % str(f.numero()), "GESTION FACTURES", 1)
|
||||
|
||||
return liste_factures_affichees
|
||||
|
||||
def delFacture(self, fid):
|
||||
try:
|
||||
# trrouver la factures
|
||||
fact = cherrypy.session['LDAP'].search('fid=' + fid, 'w')['facture'][0]
|
||||
# la supprimer
|
||||
fact.delete()
|
||||
except Exception, e:
|
||||
crans.cp.log(unicode(e), "GESTION FACTURES", 1)
|
||||
return self.index(erreur=u"Probleme lors de la suppression")
|
||||
crans.cp.log(u"Facture supprimee [fid=%s]" % fid, "GESTION FACTURES")
|
||||
return self.displayTemplate(message=u"Facture suprimée")
|
||||
delFacture.exposed = True
|
||||
|
||||
def crediteFacture(self, fid):
|
||||
try:
|
||||
# trrouver la factures
|
||||
fact = cherrypy.session['LDAP'].search('fid=' + fid, 'w')['facture'][0]
|
||||
# la supprimer
|
||||
fact.recuPaiement(cherrypy.session['uid'])
|
||||
fact.save()
|
||||
except Exception, e:
|
||||
crans.cp.log("pb crédit", "GESTION FACTURES", 1)
|
||||
return self.index(erreur=u"Problème lors du crédit")
|
||||
crans.cp.log("Facture creditee [fid=%s]" % fid, "GESTION FACTURES")
|
||||
return self.displayTemplate(message=u"Facture créditée")
|
||||
crediteFacture.exposed = True
|
Loading…
Add table
Add a link
Reference in a new issue