diff --git a/html/annulation.php b/html/annulation.php
index 58b2fcd01..ec4044f74 100644
--- a/html/annulation.php
+++ b/html/annulation.php
@@ -100,13 +100,15 @@ if ($p_id != -1 ) { // A
// if the operation is in a closed or centralized period
// the operation is voided thanks the opposite operation
StartSql($cn);
- $p_internal=SetInternalCode($cn,$p_id,$l_array['jr_def_id']);
$grp_new=NextSequence($cn,'s_grpt');
+ $seq=NextSequence($cn,"s_jrn_".$l_array['jr_def_id']);
+ $p_internal=SetInternalCode($cn,$seq,$l_array['jr_def_id']);
+
$sql= "insert into jrn (
- jr_def_id,jr_montant,jr_comment,
+ jr_id,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,
+ ) select $seq,jr_def_id,jr_montant,'Annulation '||jr_comment,
now(),$grp_new,'$p_internal',
$period, true
from
@@ -128,6 +130,7 @@ if ($p_id != -1 ) { // A
$Res=ExecSql($cn,$sql);
// Check return code
if ( $Res == false ) { Rollback($cn);exit(-1);}
+
// Mark the operation invalid into the ledger
// to avoid to nullify twice the same op.
$sql="update jrn set jr_comment='Annule : '||jr_comment where jr_grpt_id=".$_POST['p_id'];
@@ -135,6 +138,13 @@ if ($p_id != -1 ) { // A
// Check return code
if ( $Res == false ) { Rollback($cn);exit(-1);}
+ // Add a "concerned operation to bound these op.together
+ //
+ $Res=InsertRapt($cn,$seq,$l_array['jr_id']);
+ // Check return code
+ if ( $Res == false ) { Rollback($cn);exit(-1);}
+
+
// the table stock must updated
// also in the stock table
$sql="delete from stock_goods where sg_id = any ( select sg_id
diff --git a/include/user_common.php b/include/user_common.php
index 3a5568581..4b54600c7 100644
--- a/include/user_common.php
+++ b/include/user_common.php
@@ -559,7 +559,7 @@ function InsertRapt($p_cn,$jr_id,$jr_id2) {
{
echo_error(" InsertRapt : invalid jr_id $jr_id, jr_id2 $jr_id2");
echo_debug(__FILE__,__LINE__," InsertRapt : invalid jr_id $jr_id, jr_id2 $jr_id2");
- return;
+ return false;
}
// verify if exists
if ( CountSql($p_cn,"select jra_id from jrn_rapt where jra_concerned=$jr_id and jr_id=$jr_id2
@@ -569,6 +569,7 @@ function InsertRapt($p_cn,$jr_id,$jr_id2) {
// Ok we can insert
$Res=ExecSql($p_cn,"insert into jrn_rapt(jr_id,jra_concerned) values ($jr_id,$jr_id2)");
}
+ return true;
}
/* function DeleteRapt($p_cn,$jr_id,$jr_id2)
**************************************************