Merge branch 'unstable' into stable

* unstable:
  Button hide and close for DGBox
  Correct Bug : receipt not computed with extourne
  FOLLOWUP Card: show 20 last action, even closed
  with the plugin , there are several autoloader
This commit is contained in:
sparkyx 2024-03-09 13:44:36 +01:00
commit f83907a538
4 changed files with 32 additions and 9 deletions

View file

@ -353,6 +353,7 @@ class Acc_Ledger extends jrn_def_sql
}
$old_receipt=$this->db->get_row("select jr_pj_number,jr_def_id from jrn where jr_id=$1",[$this->jr_id]);
$sql="insert into jrn (
jr_id,
jr_def_id,
@ -373,14 +374,24 @@ class Acc_Ledger extends jrn_def_sql
$5, true,'EXT',currency_id,currency_rate,currency_rate_ref
from
jrn
where jr_id=$6";
$Res=$this->db->exec_sql($sql,
where jr_id=$6 returning jr_id";
try {
$reverse_id=$this->db->get_value($sql,
array($seq, $p_date, $grp_new, $p_internal, $per->p_id, $this->jr_id,$p_label));
$reverse_accOp=new Acc_Operation($this->db);
$reverse_accOp->set_id($reverse_id);
$reverse_accOp->pj=$old_receipt['jr_pj_number'];
$reverse_accOp->jrn=$old_receipt['jr_def_id'];
$reverse_accOp->set_pj();
// Check return code
if ($Res==false)
{
throw (new Exception(__FILE__.__LINE__."SQL ERROR [ $sql ]"));
} catch (\Exception $e){
throw new \Exception('Echec extourne');
}
// reverse in QUANT_FIN table
$Res=$this->db->exec_sql(" INSERT INTO quant_fin(
qf_bank, qf_other, qf_amount,jr_id,j_id)

View file

@ -266,15 +266,19 @@ EOF;
{
if ( noalyss_strlentrim($this->pj) == 0 )
{
echo __LINE__."debug {$this->pj} est vide";
$sql="update jrn set jr_pj_number=$1 where jr_id=$2";
$this->db->exec_sql($sql,array(null,$this->jr_id));
return '';
}
/* is pj uniq ? */
if ( $this->db->count_sql("select jr_id from jrn where jr_pj_number=$1 and jr_def_id=$2",
array($this->pj,$this->jrn)
if ( $this->db->count_sql("select jr_id from jrn
where jr_pj_number=$1 and jr_def_id=$2
and jr_id !=$3",
array($this->pj,$this->jrn,$this->jr_id)
) == 0 )
{
echo __LINE__."debug {$this->pj} est unique";
$sql="update jrn set jr_pj_number=$1 where jr_id=$2";
$this->db->exec_sql($sql,array($this->pj,$this->jr_id));
}
@ -300,8 +304,9 @@ EOF;
$this->pj=$pref.$seq;
/* check if the new pj numb exist */
$c=$this->db->count_sql("select jr_id from jrn where jr_pj_number=$1 and jr_def_id=$2",
array($this->pj,$this->jrn)
$c=$this->db->count_sql("select jr_id from jrn where jr_pj_number=$1 and jr_def_id=$2
and jr_id !=$3",
array($this->pj,$this->jrn,$this->jr_id)
);
if ( $c == 0 )
{
@ -947,6 +952,7 @@ EOF;
$r.=HtmlInput::simple_array_to_hidden($array);
$r.=HtmlInput::hidden("e_comm",$operation->det->jr_comment);
$r.=HtmlInput::submit(uniqid(), _("Dupliquer"));
$r.=HtmlInput::button_close("duplicate_operation_div");
$r.='</form>';

View file

@ -396,6 +396,7 @@ echo '</form>';
$r.='<p style="text-align:center">';
$r.=HtmlInput::submit('x','accepter',
'onclick="confirm_box($(\'form_'.$div.'\'),content[50],function () {$(\'form_'.$div.'\').divname=\''.$div.'\';reverseOperation($(\'form_'.$div.'\'))}); return false"');
$r.=HtmlInput::button_hide( "ext".$div);
$r.="</p>";
$r.='</form>';
echo $r;

View file

@ -198,6 +198,11 @@ class Acc_LedgerTest extends TestCase
$this->object->reverse($date,'unit test'.$date);
$check=$g_connection->get_value("select jr_id from jrn where jr_comment=$1",["unit test".$date]);
$this->assertFalse(empty($check),"NOT REVERSED" );
// check that the receipt number is correct
$receipt=$g_connection->get_value("select jr_pj_number from jrn where jr_id=$1",[$check]);
$this->assertFalse(empty($receipt)," no receipt number computed");
$orig_receipt=$g_connection->get_value("select jr_pj_number from jrn where jr_id=$1",[$this->object->jr_id]);
$this->assertNotEquals($receipt, $orig_receipt,"Wrong Receipt number ");
$this->object->jr_id=$check;
$this->object->delete();
}