diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index f67fd76b3f1..2854ba67606 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -248,6 +248,11 @@ if ($result) { $tablocaltax2[$obj->rowid][$compta_localtax2] = 0; } + // Compensation of data for invoice situation by using $situation_ratio. This works (nearly) for invoice that was not correctly recorded + // but it may introduces an error for situation invoices that were correctly saved. There is still rounding problem that differs between + // real data we should have stored and result obtained with a compensation. + // It also seems that credit notes on situation invoices are correctly saved (but it depends on the version used in fact). + // For credit notes, we hope to have situation_ratio = 1 so the compensation has no effect to avoid introducing troubles with credit notes. $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc * $situation_ratio; $tabht[$obj->rowid][$compta_prod] += $obj->total_ht * $situation_ratio; if (empty($line->tva_npr)) { @@ -255,6 +260,8 @@ if ($result) { } $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1 * $situation_ratio; $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2 * $situation_ratio; + + $tabcompany[$obj->rowid] = array( 'id' => $obj->socid, 'name' => $obj->name, @@ -598,7 +605,8 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! foreach ($tabfac as $key => $val) { $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; - $companystatic->code_compta = $tabcompany[$key]['code_compta']; + $companystatic->code_compta = $tabcompany[$key]['code_compta']; // deprecated + $companystatic->code_compta_client = $tabcompany[$key]['code_compta']; $companystatic->code_client = $tabcompany[$key]['code_client']; $companystatic->client = 3;