Task #0001443: opérations rapprochées : bug quand on utilise des tva avec autoliquidation
1. Correct export CSV 2. Improve code : new function Acc_Reconciliation:get_amount_noautovat
This commit is contained in:
parent
7b1aa42529
commit
d3a04efd68
2 changed files with 32 additions and 29 deletions
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -24,17 +24,8 @@
|
|||
</tr>
|
||||
<?php
|
||||
for ($i=0;$i<count($array);$i++) {
|
||||
$tot=$array[$i]['first']['jr_montant'];
|
||||
$retdb=$cn->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;$i<count($array);$i++) {
|
|||
$r.=td($array[$i]['depend'][$e]['jr_pj_number']);
|
||||
$r.=td($array[$i]['depend'][$e]['jr_comment']);
|
||||
$r.=td(nbm($array[$i]['depend'][$e]['jr_montant']),'style="text-align:right"');
|
||||
$retdb=$cn->execute("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 '<tr>'.$r.'</tr>';
|
||||
else
|
||||
|
|
@ -81,7 +62,7 @@ for ($i=0;$i<count($array);$i++) {
|
|||
$ret=$acc_reconciliation->db->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('<hr>',' colspan="6" style="witdh:auto"'));
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue