diff --git a/html/annulation.php b/html/annulation.php index 4cd52c22c..f39e4c620 100644 --- a/html/annulation.php +++ b/html/annulation.php @@ -101,21 +101,28 @@ if ($p_id != -1 ) { // A // the operation is voided thanks the opposite operation StartSql($cn); $p_internal=SetInternalCode($cn,$p_id,$l_array['jr_id']); - $grp_new=NextSequence($cn,'s_jrn_'.$l_array['jr_id']); + $grp_new=NextSequence($cn,'s_grpt'); $sql= "insert into jrn ( jr_def_id,jr_montant,jr_comment, jr_date,jr_grpt_id,jr_internal ,jr_tech_per, jr_valid ) select jr_def_id,jr_montant,'Annulation '||jr_comment, now(),$grp_new,'$p_internal', - $period, true - from + $period, true + from jrn where jr_grpt_id=".$_POST['p_id']; $Res=ExecSql($cn,$sql); // Check return code if ( $Res == false ) { Rollback($cn);exit(-1);} - // Make also the change into jrnx + // Mark the operation invalid into the ledger + // to avoid to nullify twice the same op. + $sql="update jrn set jr_valid=false where jr_grpt_id=".$_POST['p_id']; + $Res=ExecSql($cn,$sql); + // Check return code + if ( $Res == false ) { Rollback($cn);exit(-1);} + + // Make also the change into jrnx $sql= "insert into jrnx ( j_date,j_montant,j_poste,j_grpt, j_jrn_def,j_debit,j_text,j_internal,j_tech_user diff --git a/include/form_input.php b/include/form_input.php index 33fd60ff5..1a63279c2 100644 --- a/include/form_input.php +++ b/include/form_input.php @@ -1102,9 +1102,7 @@ function RecordAchat($p_cn,$p_array,$p_user,$p_jrn) // First we add in jrnx // Compute the j_grpt - // NOTE STAN: pourquoi "+1" à la ligne suivante? Je pense que le GetNextId retourne déja un truc incrémenté, non? - // en effet non, car je vois dans la table "jrnx" que le j_grpt n'est incrémenté que de un. - $seq=GetNextId($p_cn,'j_grpt')+1; + $seq=NextSequence($p_cn,'j_grpt'); // Debit = client @@ -1417,7 +1415,7 @@ function RecordFin($p_cn,$p_array,$p_user,$p_jrn) { // $type=( ${"e_other$i"."_amount"} < 0 )?'d':'c'; // Compute the j_grpt - $seq=GetNextId($p_cn,'j_grpt')+1; + $seq=NextSequence($p_cn,'j_grpt'); if ( InsertJrnx($p_cn,'d',$p_user,$p_jrn,$poste_bq,$e_date,${"e_other$i"."_amount"},$seq,$periode) == false ) { $Rollback($p_cn);exit("error __FILE__ __LINE__"); @@ -1667,7 +1665,7 @@ function RecordODS($p_cn,$p_array,$p_user,$p_jrn) $sum_cred=0.0; // Compute the j_grpt - $seq=GetNextId($p_cn,'j_grpt')+1; + $seq=NextSequence($p_cn,'j_grpt'); StartSql($p_cn); // store into the database diff --git a/include/jrn.php b/include/jrn.php index 0f54f73c9..f819f48f5 100644 --- a/include/jrn.php +++ b/include/jrn.php @@ -562,48 +562,6 @@ function GetJrnProp($p_dossier,$p_jrn,$is_connected=0) } return pg_fetch_array($Res,0); } -/* function GetNextId($p_cn,$p_name) - * Purpose : - * - * parm : - * - - * gen : - * - - * return: - * - - * - */ -function GetNextId($p_cn,$p_name) { - include_once("postgres.php"); - - $Res=ExecSql($p_cn,"select max($p_name) as result from jrnx"); - echo_debug(__FILE__,__LINE__,"$Res=ExecSql($p_cn,"."select max($p_name) as result from jrnx"); - if (pg_NumRows($Res) == 0 ) - return 0; - $l_res=pg_fetch_array($Res,0); - return $l_res['result']; -} -/* function GetNextJrnId($p_cn,$p_name) - * Purpose : - * - * parm : - * - - * gen : - * - - * return: - * - - * - */ -function GetNextJrnId($p_cn,$p_name) { - include_once("postgres.php"); - $Res=ExecSql($p_cn,"select max($p_name) as result from jrn "); - echo_debug(__FILE__,__LINE__,"$Res=ExecSql($p_cn,"."select max($p_name) as result from jrn "); - - if (pg_NumRows($Res) == 0 ) - return 0; - $l_res=pg_fetch_array($Res,0); - return $l_res['result']; -} /* function ViewJrn * Purpose : Vue des écritures comptables *