Improve : when nullify an operation thanks a reversed operation

both operations are now bound thanks the "concerned operation"
          mechanisme ("rapprochement")
This commit is contained in:
sparkyx 2005-09-28 10:36:00 +00:00
parent f2038205a8
commit 645129da4b
2 changed files with 15 additions and 4 deletions

View file

@ -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

View file

@ -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)
**************************************************