Skip to content

Commit

Permalink
Ajout de la liste des reversements
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgu74 committed May 2, 2014
1 parent 3c8b195 commit e4ba8e9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
33 changes: 28 additions & 5 deletions src/Payutc/Bom/Reversement.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,19 @@ public static function getById($revId, $funId=null) {
return self::getByQb($qb);
}

public static function getAll($funId=null, $step='V') {
$qb = self::getQbBase()
->where("rev.rev_step = :step")
->setParameter('step', $step)
->orderBy('rev.rev_date_updated', 'DESC');

if($funId) {
$qb->andWhere('rev.fun_id = :fun_id')
->setParameter('fun_id', $funId);
}
return self::getByQb($qb);
}

protected static function getQbBase(){
return Dbal::createQueryBuilder()
->select('*')
Expand All @@ -161,14 +174,24 @@ protected static function getQbBase(){
protected static function getByQb($qb){
$query = $qb->execute();

$count = $query->rowCount();
// Check that the transaction exists
if ($query->rowCount() == 0) {
if ($count == 0) {
throw new ReversementNotFound("Le reversement n'existe pas");
} else if($count == 1) {
// Get remaining data from the database
$don = $query->fetch();
return self::fromArray($don);
} else {
$ret = array();
while($don = $query->fetch()) {
$ret[] = self::fromArray($don);
}
return $ret;
}

// Get remaining data from the database
$don = $query->fetch();

}

protected static function fromArray($don){
$reversement = new Reversement();
$reversement->id = $don['rev_id'];
$reversement->funId = $don['fun_id'];
Expand Down
4 changes: 3 additions & 1 deletion src/Payutc/Service/TRESO.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,16 @@ public function getDetails($fun_id = null) {
"account_total" => User::getSumCredit(), // Montant total présent sur les comptes
"reversement_total" => Reversement::getTotal(), // Montant total reversé
"reversement_wait" => Reversement::getWait(), // Montant total en attente
"reversements" => Reversement::getAll(), // Tout les reversements
"fundations" => $fundations
);
} else {
return array(
"amount_total" => Purchase::getRevenue($fun_id), // Montant total encaissé par la fundation
"reversement_total" => Reversement::getTotal($fun_id), // Montant total déjà reversé
"reversement_wait" => Reversement::getLast($fun_id, 'W'), // Montant total en attente
"reversement_last" => Reversement::getLast($fun_id) // Date et montant du dernier reversement
"reversement_last" => Reversement::getLast($fun_id), // Date et montant du dernier reversement
"reversements" => Reversement::getAll($fun_id)
);
}
}
Expand Down

0 comments on commit e4ba8e9

Please sign in to comment.