diff --git a/include/class_acc_ledger.php b/include/class_acc_ledger.php index 3eb429840..bf1ed4e0b 100644 --- a/include/class_acc_ledger.php +++ b/include/class_acc_ledger.php @@ -559,7 +559,7 @@ class Acc_Ledger extends jrn_def_sql { $a_ParmCode = $this->db->get_array('select p_code,p_value from parm_code'); $a_TVA = $this->db->get_array('select tva_id,tva_label,tva_poste - from tva_rate where tva_rate != 0 order by tva_id'); + from tva_rate where tva_rate != 0 order by tva_rate,tva_label,tva_id '); for ($i = 0; $i < $Max; $i++) { $array[$i] = Database::fetch_array($Res, $i); @@ -1049,10 +1049,10 @@ class Acc_Ledger extends jrn_def_sql * * @paramp_array the structure is set in get_rowSimple, this array is * modified, - * @param$trunc if the data must be truncated, usefull for pdf export + * @param $trunc if the data must be truncated, usefull for pdf export * @paramp_jrn_type is the type of the ledger (ACH or VEN) - * @param$a_TVA TVA Array (default null) - * @param$a_ParmCode Array (default null) + * @param $a_TVA TVA Array (default null) + * @param $a_ParmCode Array (default null) * \return p_array */ @@ -1062,7 +1062,7 @@ class Acc_Ledger extends jrn_def_sql { //Load TVA array $a_TVA = $this->db->get_array('select tva_id,tva_label,tva_poste - from tva_rate where tva_rate != 0 order by tva_id'); + from tva_rate where tva_rate != 0 order by tva_rate,tva_label,tva_id'); } if ($a_ParmCode == null) { @@ -1078,6 +1078,7 @@ class Acc_Ledger extends jrn_def_sql $p_array['dna'] = 0; $p_array['tva_dna'] = 0; $dep_priv = 0.0; + // // Retrieve data from jrnx $sql = "select j_id,j_poste,j_montant, j_debit,j_qcode from jrnx where " . @@ -1186,8 +1187,8 @@ class Acc_Ledger extends jrn_def_sql $purchase->load(); $dep_priv+=$purchase->qp_dep_priv; $p_array['dep_priv'] = $dep_priv; - $p_array['dna']=$purchase->qp_nd_amount; - $p_array['tva_dna']=$purchase->qp_nd_tva; + $p_array['dna']=bcadd($p_array['dna'],$purchase->qp_nd_amount); + $p_array['tva_dna']=bcadd($p_array['tva_dna'],bcadd($purchase->qp_nd_tva,$purchase->qp_nd_tva_recup)); } } diff --git a/include/export_ledger_csv.php b/include/export_ledger_csv.php index a214a15e4..12c30c90a 100644 --- a/include/export_ledger_csv.php +++ b/include/export_ledger_csv.php @@ -189,16 +189,16 @@ else if ($_GET['p_simple'] == 1) if ( $own->MY_TVA_USE=='Y') { - $a_Tva=$cn->get_array("select tva_id,tva_label from tva_rate where tva_rate != 0.0000 order by tva_rate"); + $a_Tva=$cn->get_array("select tva_id,tva_label from tva_rate where tva_rate != 0.0000 order by tva_rate,tva_label,tva_id"); foreach($a_Tva as $line_tva) { $col_tva.='"Tva '.$line_tva['tva_label'].'";'; } } - echo '"Date";"Paiement";"operation";"Client/Fourn.";"Commentaire";"inter.";"HTVA";privé;DNA;tva non ded.;opérations liées'.$col_tva.'"TVAC"'."\n\r"; + echo '"Date";"Paiement";"operation";"Client/Fourn.";"Commentaire";"inter.";"HTVA";privé;DNA;tva non ded.;'.$col_tva.'"TVAC";"opérations liées"'."\n\r"; foreach ($Row as $line) { - printf('"%s";"%s";"%s";"%s";"%s";%s;%s;%s;%s;', + printf('"%s";"%s";"%s";"%s";"%s";%s;%s;%s;%s;%s;', $line['date'], $line['date_paid'], $line['num'], @@ -211,27 +211,22 @@ else if ($_GET['p_simple'] == 1) nb($line['tva_dna']) ); $a_tva_amount=array(); + //- set all TVA to 0 + foreach ($a_Tva as $l) { + $t_id=$l["tva_id"]; + $a_tva_amount[$t_id]=0; + } foreach ($line['TVA'] as $lineTVA) { - foreach ($a_Tva as $idx=>$line_tva) - { - - if ($line_tva['tva_id'] == $lineTVA[1][0]) - { - $a=$line_tva['tva_id']; - $a_tva_amount[$a]=$lineTVA[1][2]; - } - } - } + $idx_tva=$lineTVA[1][0]; + $a_tva_amount[$idx_tva]=$lineTVA[1][2]; + } if ($own->MY_TVA_USE == 'Y' ) { foreach ($a_Tva as $line_tva) { $a=$line_tva['tva_id']; - if ( isset($a_tva_amount[$a])) - echo nb($a_tva_amount[$a]).';'; - else - printf("0;"); + echo nb($a_tva_amount[$a]).';'; } } echo nb ($line['TVAC']);