-cur.execute("SELECT sum(montant*quantite) FROM transactions WHERE valide=true AND destinataire=%s AND date<CAST(%s AS timestamp)"
- ,(numcbde,date))
-received=cur.fetchone()[0]
-cur.execute("SELECT sum(montant*quantite) FROM transactions WHERE valide=true AND emetteur=%s AND date<CAST(%s AS timestamp)"
- ,(numcbde,date))
-given=cur.fetchone()[0]
+cur.execute("SELECT sum(montant*quantite) FROM transactions WHERE valide AND destinataire = %s AND date < CAST(%s AS timestamp)"
+ ,(idbde,date))
+received = cur.fetchone()[0]
+cur.execute("SELECT sum(montant*quantite) FROM transactions WHERE valide AND emetteur = %s AND date < CAST(%s AS timestamp)"
+ ,(idbde,date))
+given = cur.fetchone()[0]