Skip to content

Commit

Permalink
Merge pull request #5420 from atm-alexis/FIX_3.8_bug_5170
Browse files Browse the repository at this point in the history
FIX #5170 tva sign with INVOICE_POSITIVE_CREDIT_NOTE option
  • Loading branch information
eldy committed Jul 1, 2016
2 parents c9300ba + 22bc446 commit 3645bd8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
14 changes: 10 additions & 4 deletions htdocs/core/lib/pdf.lib.php
Expand Up @@ -1342,7 +1342,10 @@ function pdf_getlineupexcltax($object,$i,$outputlangs,$hidedetails=0)
*/
function pdf_getlineupwithtax($object,$i,$outputlangs,$hidedetails=0)
{
global $hookmanager;
global $hookmanager,$conf;

$sign=1;
if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;

if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line)))
{
Expand All @@ -1355,7 +1358,7 @@ function pdf_getlineupwithtax($object,$i,$outputlangs,$hidedetails=0)
}
else
{
if (empty($hidedetails) || $hidedetails > 1) return price(($object->lines[$i]->subprice) + ($object->lines[$i]->subprice)*($object->lines[$i]->tva_tx)/100, 0, $outputlangs);
if (empty($hidedetails) || $hidedetails > 1) return price($sign * (($object->lines[$i]->subprice) + ($object->lines[$i]->subprice)*($object->lines[$i]->tva_tx)/100), 0, $outputlangs);
}
}

Expand Down Expand Up @@ -1629,7 +1632,10 @@ function pdf_getlinetotalexcltax($object,$i,$outputlangs,$hidedetails=0)
*/
function pdf_getlinetotalwithtax($object,$i,$outputlangs,$hidedetails=0)
{
global $hookmanager;
global $hookmanager,$conf;

$sign=1;
if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;

if ($object->lines[$i]->special_code == 3)
{
Expand All @@ -1648,7 +1654,7 @@ function pdf_getlinetotalwithtax($object,$i,$outputlangs,$hidedetails=0)
}
else
{
if (empty($hidedetails) || $hidedetails > 1) return price(($object->lines[$i]->total_ht) + ($object->lines[$i]->total_ht)*($object->lines[$i]->tva_tx)/100, 0, $outputlangs);
if (empty($hidedetails) || $hidedetails > 1) return price($sign * (($object->lines[$i]->total_ht) + ($object->lines[$i]->total_ht)*($object->lines[$i]->tva_tx)/100), 0, $outputlangs);
}
}
return '';
Expand Down
7 changes: 5 additions & 2 deletions htdocs/core/modules/facture/doc/pdf_crabe.modules.php
Expand Up @@ -539,13 +539,16 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
$pdf->SetXY($this->postotalht, $curY);
$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0);


$sign=1;
if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
$prev_progress = $object->lines[$i]->get_prev_progress();
if ($prev_progress > 0) // Compute progress from previous situation
{
$tvaligne = $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
$tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
} else {
$tvaligne = $object->lines[$i]->total_tva;
$tvaligne = $sign * $object->lines[$i]->total_tva;
}
$localtax1ligne=$object->lines[$i]->total_localtax1;
$localtax2ligne=$object->lines[$i]->total_localtax2;
Expand Down

0 comments on commit 3645bd8

Please sign in to comment.