diff --git a/include/class/acc_reconciliation.class.php b/include/class/acc_reconciliation.class.php index 4233d7c1e..ed5427c27 100644 --- a/include/class/acc_reconciliation.class.php +++ b/include/class/acc_reconciliation.class.php @@ -515,6 +515,11 @@ j1.j_poste as poste } } $export->write_header($title); + //----------------------------------------- + //Retrieve amount without autoreversed VAT + //----------------------------------------- + $amount=$this->get_amount_noautovat($first['jr_id'],$first['jr_montant']); + // -------------------------- // Print First // -------------------------- @@ -525,7 +530,7 @@ j1.j_poste as poste $export->add($first['jr_pj_number']); $export->add($first['jrn_def_name']); $export->add($first['jrn_def_type']); - $export->add($first['jr_montant'],"number"); + $export->add($amount,"number"); if (count($a_depend) > 0) { // -------------------------------------- @@ -533,20 +538,21 @@ j1.j_poste as poste // -------------------------------------- $depend = $a_depend[0]; $export->add("<->"); - + $amount_dep=$this->get_amount_noautovat($depend['jr_id'],$depend['jr_montant']); $export->add($depend['jr_date']); $export->add($depend['jr_internal']); $export->add($depend['jr_comment']); $export->add($depend['jr_pj_number']); $export->add($depend['jrn_def_name']); $export->add($depend['jrn_def_type']); - $export->add($depend['jr_montant'],"number"); + $export->add($amount_dep,"number"); $export->write(); // -------------------------------------- // print other depending operation if any // -------------------------------------- for ($e = 1; $e < count($a_depend); $e++) { + $amount_dep=$this->get_amount_noautovat($depend['jr_id'],$depend['jr_montant']); $depend = $a_depend[$e]; $export->add(""); $export->add(""); @@ -563,7 +569,7 @@ j1.j_poste as poste $export->add($depend['jr_pj_number']); $export->add($depend['jrn_def_name']); $export->add($depend['jrn_def_type']); - $export->add($depend['jr_montant'],"number"); + $export->add($amount_dep,"number"); $export->write(); } } @@ -605,7 +611,23 @@ j1.j_poste as poste } return $array; } + function get_amount_noautovat($p_jrn_id,$p_default_amount) { + $retdb=$this->db->execute("detail_quant",array($p_jrn_id)); + if ( Database::num_row($retdb) != 0) + { + // then second_amount takes in account the vat_sided + $row=Database::fetch_array($retdb, 0); + $total_price=bcadd($row['price'],$row['vat_amount']); + $total_price=bcsub($total_price,$row['vat_sided']); + $first_amount=$total_price; + } else { + // else take the amount from jrn + $first_amount=$p_default_amount; + } + return $first_amount; + + } static function test_me() { $cn=Dossier::connect(); diff --git a/include/template/impress_reconciliation.php b/include/template/impress_reconciliation.php index d6b3f1954..d0c7d6939 100644 --- a/include/template/impress_reconciliation.php +++ b/include/template/impress_reconciliation.php @@ -24,17 +24,8 @@ execute("detail_quant",array($array[$i]['first']['jr_id'])); - if ( Database::num_row($retdb) != 0) - { - // then second_amount takes in account the vat_sided - $row=Database::fetch_array($retdb, 0); - $total_price=bcadd($row['price'],$row['vat_amount']); - $total_price=bcsub($total_price,$row['vat_sided']); - $tot=$total_price; - - } + $tot=$acc_reconciliation->get_amount_noautovat($array[$i]['first']['jr_id'],$array[$i]['first']['jr_montant']); + $r=''; $r.=td($i); $r.=td(format_date($array[$i]['first']['jr_date'])); @@ -60,20 +51,10 @@ for ($i=0;$iexecute("detail_quant",array($array[$i]['depend'][$e]['jr_id'])); - // if exist in v_quant_detail - if ( Database::num_row($retdb) != 0) - { - // then second_amount takes in account the vat_sided - $row=Database::fetch_array($retdb, 0); - $total_price=bcadd($row['price'],$row['vat_amount']); - $total_price=bcsub($total_price,$row['vat_sided']); - $tot2=bcadd($tot2,$total_price); + + $amount_dep=$acc_reconciliation->get_amount_noautovat($array[$i]['depend'][$e]['jr_id'],$array[$i]['depend'][$e]['jr_montant']); + $tot2=bcadd($tot2,$amount_dep); - } else { - // else take the amount from jrn - $tot2=bcadd($tot2,$array[$i]['depend'][$e]['jr_montant']); - } if ( $e==$limit) echo ''.$r.''; else @@ -81,7 +62,7 @@ for ($i=0;$idb->execute('detail_quant',array($array[$i]['depend'][$e]['jr_id'])); $acc_reconciliation->show_detail($ret); } - echo tr(td(_('Total ')).td(_('operation')).td(nbm($tot)).td(_('operations dépendantes')).td(nbm($tot2)).td(_('Delta')).td(bcsub($tot,$tot2)),' class="highlight"'); + echo tr(td(_('Total ')).td(_('opération')).td(nbm($tot)).td(_('opérations dépendantes')).td(nbm($tot2)).td(_('Delta')).td(bcsub($tot,$tot2)),' class="highlight"'); echo tr(td('
',' colspan="6" style="witdh:auto"')); }