issue #0001265 : Controle des postes du bilan
This commit is contained in:
parent
6939cf6f75
commit
38dc915281
@ -1279,8 +1279,9 @@ class Saisie extends WsScore
|
||||
$this->sendError('1010');
|
||||
}
|
||||
|
||||
//Controle des valeurs
|
||||
$tabPostes = array();
|
||||
|
||||
//Control des valeurs
|
||||
if (!preg_match('/[0-9]{8}/', $data->dateCloture)) {
|
||||
throw new SoapFault('MSG', "Erreur Date de cloture");
|
||||
}
|
||||
@ -1301,11 +1302,72 @@ class Saisie extends WsScore
|
||||
throw new SoapFault('MSG', "Erreur poste ".$itemPoste[0]);
|
||||
break;
|
||||
}
|
||||
$tabPostes[$itemPoste[0]] = intval($itemPoste[1]);
|
||||
}
|
||||
} else {
|
||||
throw new SoapFault('MSG', "Aucun poste saisi");
|
||||
}
|
||||
|
||||
//Mathematic control
|
||||
if (count($tabPostes)>0) {
|
||||
require_once 'Metier/classMBilans.php';
|
||||
|
||||
$tabFormules = array();
|
||||
//Parcourir les formules
|
||||
foreach ( $tabCtrl as $formule => $lib ) {
|
||||
$posEgal = strpos($formule, '=');
|
||||
$partLeft = substr($formule, 0, $posEgal);
|
||||
preg_match_all('/([A-Z0-9]+|(\+|\-))/', $partLeft, $matches);
|
||||
$total = susbtr($formule, $posEgal+1);
|
||||
$tabFormules = array(
|
||||
'operation' => $matches[0],
|
||||
'total' => $total,
|
||||
);
|
||||
}
|
||||
//Effectuer le calcul
|
||||
if ( count($tabFormules)>0 ) {
|
||||
foreach ( $tabFormules as $formule ) {
|
||||
$checkPostes = array();
|
||||
|
||||
//Réaliser le calcul
|
||||
$calc = 0;
|
||||
$signe = null;
|
||||
foreach ( $formule['operation'] as $operation ) {
|
||||
if ( $operation == '-' ) {
|
||||
$signe = '-';
|
||||
} elseif ( $operation == '+' ) {
|
||||
$signe = '+';
|
||||
} else {
|
||||
$checkPostes[] = $operation;
|
||||
//Vérification valeur poste
|
||||
if ( !array_key_exists($operation, $tabPostes) ) {
|
||||
$tabPostes[$operation] = 0;
|
||||
}
|
||||
//Calcul
|
||||
if ( empty($signe) ) {
|
||||
$calc = $tabPostes[$operation];
|
||||
} elseif ( $signe == '+' ) {
|
||||
$calc+= $tabPostes[$operation];
|
||||
} elseif ( $signe == '-' ) {
|
||||
$calc-= $tabPostes[$operation];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$checkPostes[] = $formule['total'];
|
||||
//Effecteur la vérification avec le total
|
||||
if ( !array_key_exists($formule['total'], $tabPostes) ) {
|
||||
$total = 0;
|
||||
} else {
|
||||
$total = $tabPostes[$formule['total']];
|
||||
}
|
||||
if ($calc != $total) {
|
||||
throw new SoapFault('ERR', join(';',$checkPostes));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Connect to the database
|
||||
try {
|
||||
$db = Zend_Db::factory($this->dbConfig->db->jo);
|
||||
|
Loading…
Reference in New Issue
Block a user