Re changement de categorie

darcs-hash:20070603221924-c992d-3093fb63e27d67b6caaa9506890d1ecbb8babb20.gz
This commit is contained in:
bos 2007-06-04 00:19:24 +02:00
parent dd1744999a
commit 28a49731f5

View file

@ -1,31 +1,60 @@
#! /usr/bin/env python
# -*- coding: iso-8859-15 -*-
# ##################################################################################################### #
# Factures
# Mes Sous
# ##################################################################################################### #
# Description:
# Affiche la liste des factures et l'historique de débits/crédits de l'adhérent.
# Affiche la liste des factures et l'historique de debits/credits de l'adherent.
# Fait aussi les rechargements Paypal
# Informations:
#
# Pages:
# index:liste des factures
# historique: historique des débits/crédits
# rechargementPaypal: Comme son nom l'indique
#
# ##################################################################################################### #
import cherrypy, sys, os, datetime
if (cherrypy.config.configMap["global"]["server.environment"] == "development"):
from ldap_crans_test import *
# print("monCompte : unsing test ldap : env=" + cherrypy.config.configMap["global"]["server.environment"])
else:
from ldap_crans import *
# print("monCompte : unsing prod ldap : env=" + cherrypy.config.configMap["global"]["server.environment"])
from ClassesIntranet.ModuleBase import ModuleBase
class main(ModuleBase):
def title(self):
return "Factures"
return "Mon Solde"
def category(self):
return "Services"
return "Personnel"
def icon(self):
return "icon.png"
_club = True
def getCurrentAdministrativeYear(self):
'''
premiere partie de l''annee scolaire en cours
ex : le 5 juin 2006 retourne 2005
'''
now = datetime.datetime.now()
currentYear = int(now.strftime("%Y"))
currentMonth = int(now.strftime("%m"))
if currentMonth > 8:
administrativeYear = currentYear
else:
administrativeYear = currentYear - 1
return administrativeYear
def index(self, message = '', error = ''):
adh = cherrypy.session['LDAP'].getProprio(cherrypy.session['uid'])
t = {}
@ -121,3 +150,98 @@ class main(ModuleBase):
cherrypy.log(str(e), "FACTURES", 1)
return self.index()
delFacture.exposed = True
##########################
# paypal
##########################
#
# methode qui affiche successivement les
# templates du popup pour recharger son compte impression
# via paypal
#
def rechargerCompteImpression(self, etape = '1', combien = None):
adh = cherrypy.session['LDAP'].getProprio(cherrypy.session['uid'])
if (etape == "1"): # Introduction
return {
'template' :'MonCompteRechargePaypal1',
'standalone' :True,
'values' :{},
}
elif (etape == "2"): # choix montant
return {
'template' :'MonCompteRechargePaypal2',
'standalone' :True,
'values' :{},
}
elif (etape == "3"): # confirmer facture
# creer objet facture
f = Facture(adh)
# /!\ verifier que combien est un nombre
# et qu'il n'y a pas plus de 2 chiffres apres le point...
# (ce serait bien aussi si on pouvait mettre une virgue a la place du point)
try:
# remplacage des virgules
combien = combien.replace(u',', u'.')
# convertissage
combien = float(combien)
# arrondissage-tronquage :
combien = float(int(combien*100)/100.0)
# nombre positif
if combien < 0:
raise ValueError
except Exception:
return {
'template' :'MonCompteRechargePaypal2',
'standalone' :True,
'values' :{'error':"Le montant doit &ecirc;tre un nombre positif !", 'combien':combien},
}
f.ajoute({'nombre': 1, 'code': 'SOLDE', 'designation': 'Credit du compte impression (intranet)', 'pu': combien})
cherrypy.session['freshFacture'] = f
pageData = {}
pageData['details'] = [
{
'intitule':art['designation'],
'quantite':art['nombre'],
'prixUnitaire':art['pu'],
'prixTotal':art['pu']*art['nombre'],
} for art in f.articles()]
pageData['total'] = f.total()
return {
'template' :'MonCompteRechargePaypal3',
'standalone' :True,
'values' :pageData,
}
elif (etape == "4"):# payer maintenant ?
# sauver objet facture
f = cherrypy.session['freshFacture']
f.save()
return {
'template' :'MonCompteRechargePaypal4',
'standalone' :True,
'values' :{'lienPaypal' : f.urlPaypal(useSandbox = cherrypy.config.get("paypal.useSandbox", False),
businessMail = cherrypy.config.get("paypal.businessAdress", "paypal@crans.org"),
return_page = "https://intranet.crans.org/monCompte/paypalReturn",
cancel_return_page = "https://intranet.crans.org/monCompte/paypalCancel",
)},
}
rechargerCompteImpression.exposed = True
def paypalReturn(self, **kw):
_crans_cp.log("retour de paypal avec les infos : %s" % " ".join( [ "[%s: %s]" % (str(a), str(kw[a])) for a in kw] ) )
return {
'template' :'MonComptePaypalReturn',
'standalone' :True,
'values' :{},
}
paypalReturn.exposed = True
def paypalCancel(self, **kw):
_crans_cp.log("annulation de paypal avec les infos : %s" % " ".join( [ "[%s: %s]" % (str(a), str(kw[a])) for a in kw] ) )
return {
'template' :'MonComptePaypalCancel',
'standalone' :True,
'values' :{},
}
paypalCancel.exposed = True