diff --git a/html/js/anc_script.js b/html/js/anc_script.js index 2530d49bd..5087109f2 100644 --- a/html/js/anc_script.js +++ b/html/js/anc_script.js @@ -31,7 +31,7 @@ function add_row(p_table, p_seq) { var mytable = g(p_table).tBodies[0]; - var max = parseFloat(g('amount_t' + p_seq).value); + var max =Math.abs( parseFloat(g('amount_t' + p_seq).value)); if (!mytable) { return; @@ -102,7 +102,7 @@ function anc_refresh_remain(p_table, p_seq) { try { - var tot_line = parseFloat(g('amount_t' + p_seq).value); + var tot_line =Math.abs( parseFloat(g('amount_t' + p_seq).value)); var tot_table = compute_total_table(p_table, p_seq); var remain = tot_line - tot_table; remain = Math.round(remain * 100) / 100; @@ -155,7 +155,7 @@ function verify_ca(div) total_amount += parseFloat(array_value[i].value); } - var amount = parseFloat(g('amount_t' + idx).value); + var amount = Math.abs(parseFloat(g('amount_t' + idx).value)); var diff = amount - total_amount; if (Math.round(diff, 2) != 0.0) diff --git a/include/class_anc_account.php b/include/class_anc_account.php index 65962f7b1..1d9da5f7f 100644 --- a/include/class_anc_account.php +++ b/include/class_anc_account.php @@ -172,7 +172,8 @@ class Anc_Account $sql="delete from poste_analytique where po_id=".$this->id; $this->db->exec_sql($sql); } - /*! \brief return an array of object Poste_Analytique + /*! + * \brief return an array of object Poste_Analytique * */ function get_list() diff --git a/include/class_anc_operation.php b/include/class_anc_operation.php index c5e48a337..20c90cc28 100644 --- a/include/class_anc_operation.php +++ b/include/class_anc_operation.php @@ -88,6 +88,18 @@ class Anc_Operation if ( $this->j_id == 0 ) { $this->j_id=null; + } else { + // must be the same side than the operation + if ( $this->oa_jrnx_id_source == null) + { + $side=$this->db->get_value('select j_debit from jrnx where j_id=$1', + array($this->j_id)); + } else + { + $side=$this->db->get_value('select j_debit from jrnx where j_id=$1', + array($this->oa_jrnx_id_source)); + } + $this->oa_debit=$side; } @@ -97,8 +109,9 @@ class Anc_Operation if ( $this->oa_amount< 0) { - $this->oa_debit=($this->oa_debit=='t')?'f':'t'; + // if negatif must be oa_positive='N' $this->oa_positive='N'; + $this->oa_debit=($this->oa_debit=='t')?'f':'t'; } $oa_row=(isset($this->oa_row))?$this->oa_row:null; @@ -544,8 +557,8 @@ class Anc_Operation $nb_row=(isset($val[$p_seq]))?count($val[$p_seq]):1; $count=0; - $remain=$p_amount; - $ctrl_remain="remain".$this->in_div.$table_id; + $remain=abs($p_amount); + $ctrl_remain="remain".$this->in_div.$table_id; for ( $i=0; $i < $nb_row;$i++) { @@ -591,9 +604,9 @@ class Anc_Operation $value->javascript='onchange="format_number(this);anc_refresh_remain(\''.$this->in_div.$table_id.'\',\''.$p_seq.'\')"'; $value->name="val[".$p_seq."][]"; $value->size=6; - $value->value=(isset($val[$p_seq][$i]))?$val[$p_seq][$i]:$p_amount; + $value->value=(isset($val[$p_seq][$i]))?$val[$p_seq][$i]:abs($p_amount); $value->readOnly=($p_mode==1)?false:true; - $remain=bcsub($remain,$value->value); + $remain=bcsub($remain,$value->value); $result.='