FIX PDF output was sharing 2 different currencies in same total

Conflicts:
	htdocs/core/modules/commande/doc/pdf_einstein.modules.php
	htdocs/core/modules/facture/doc/pdf_crabe.modules.php
	htdocs/core/modules/product/doc/pdf_standard.modules.php
	htdocs/core/modules/propale/doc/pdf_azur.modules.php
This commit is contained in:
Laurent Destailleur 2017-09-13 17:57:41 +02:00
parent 863c575580
commit e0eef2080e
6 changed files with 130 additions and 110 deletions

View File

@ -838,6 +838,8 @@ class pdf_einstein extends ModelePDFCommandes
// Show VAT by rates and total // Show VAT by rates and total
$pdf->SetFillColor(248,248,248); $pdf->SetFillColor(248,248,248);
$total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
$this->atleastoneratenotnull=0; $this->atleastoneratenotnull=0;
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
{ {
@ -1011,7 +1013,6 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->SetFillColor(224,224,224); $pdf->SetFillColor(224,224,224);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
$total_ttc = ($conf->multicurrency->enabled && $object->multiccurency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1); $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
} }
@ -1024,7 +1025,7 @@ class pdf_einstein extends ModelePDFCommandes
//$creditnoteamount=$object->getSumCreditNotesUsed(); //$creditnoteamount=$object->getSumCreditNotesUsed();
//$depositsamount=$object->getSumDepositsUsed(); //$depositsamount=$object->getSumDepositsUsed();
//print "x".$creditnoteamount."-".$depositsamount;exit; //print "x".$creditnoteamount."-".$depositsamount;exit;
$resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
if (! empty($object->paye)) $resteapayer=0; if (! empty($object->paye)) $resteapayer=0;
if ($deja_regle > 0) if ($deja_regle > 0)

View File

@ -548,7 +548,7 @@ class pdf_rouget extends ModelePdfExpedition
} }
// Affiche zone totaux // Affiche zone totaux
$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); $posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
// Pied de page // Pied de page
$this->_pagefoot($pdf,$object,$outputlangs); $this->_pagefoot($pdf,$object,$outputlangs);

View File

@ -214,9 +214,9 @@ class pdf_crabe extends ModelePDFFactures
{ {
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$deja_regle = $object->getSommePaiement(); $deja_regle = $object->getSommePaiement(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
$amount_credit_notes_included = $object->getSumCreditNotesUsed(); $amount_credit_notes_included = $object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
$amount_deposits_included = $object->getSumDepositsUsed(); $amount_deposits_included = $object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
// Definition of $dir and $file // Definition of $dir and $file
if ($object->specimen) if ($object->specimen)
@ -771,7 +771,7 @@ class pdf_crabe extends ModelePDFFactures
// Loop on each deposits and credit notes included // Loop on each deposits and credit notes included
$sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; $sql = "SELECT re.rowid, re.amount_ht, re.multicurrency_amount_ht, re.amount_tva, re.multicurrency_amount_tva, re.amount_ttc, re.multicurrency_amount_ttc,";
$sql.= " re.description, re.fk_facture_source,"; $sql.= " re.description, re.fk_facture_source,";
$sql.= " f.type, f.datef"; $sql.= " f.type, f.datef";
$sql.= " FROM ".MAIN_DB_PREFIX ."societe_remise_except as re, ".MAIN_DB_PREFIX ."facture as f"; $sql.= " FROM ".MAIN_DB_PREFIX ."societe_remise_except as re, ".MAIN_DB_PREFIX ."facture as f";
@ -796,7 +796,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetXY($tab3_posx, $tab3_top+$y); $pdf->SetXY($tab3_posx, $tab3_top+$y);
$pdf->MultiCell(20, 3, dol_print_date($obj->datef,'day',false,$outputlangs,true), 0, 'L', 0); $pdf->MultiCell(20, 3, dol_print_date($obj->datef,'day',false,$outputlangs,true), 0, 'L', 0);
$pdf->SetXY($tab3_posx+21, $tab3_top+$y); $pdf->SetXY($tab3_posx+21, $tab3_top+$y);
$pdf->MultiCell(20, 3, price($obj->amount_ttc, 0, $outputlangs), 0, 'L', 0); $pdf->MultiCell(20, 3, price(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0, 'L', 0);
$pdf->SetXY($tab3_posx+40, $tab3_top+$y); $pdf->SetXY($tab3_posx+40, $tab3_top+$y);
$pdf->MultiCell(20, 3, $text, 0, 'L', 0); $pdf->MultiCell(20, 3, $text, 0, 'L', 0);
$pdf->SetXY($tab3_posx+58, $tab3_top+$y); $pdf->SetXY($tab3_posx+58, $tab3_top+$y);
@ -815,7 +815,7 @@ class pdf_crabe extends ModelePDFFactures
// Loop on each payment // Loop on each payment
// TODO Call getListOfPaymentsgetListOfPayments instead of hard coded sql // TODO Call getListOfPaymentsgetListOfPayments instead of hard coded sql
$sql = "SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount,"; $sql = "SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
$sql.= " cp.code"; $sql.= " cp.code";
$sql.= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p"; $sql.= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id";
@ -835,7 +835,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetXY($tab3_posx, $tab3_top+$y); $pdf->SetXY($tab3_posx, $tab3_top+$y);
$pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date),'day',false,$outputlangs,true), 0, 'L', 0); $pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date),'day',false,$outputlangs,true), 0, 'L', 0);
$pdf->SetXY($tab3_posx+21, $tab3_top+$y); $pdf->SetXY($tab3_posx+21, $tab3_top+$y);
$pdf->MultiCell(20, 3, price($sign * $row->amount, 0, $outputlangs), 0, 'L', 0); $pdf->MultiCell(20, 3, price($sign * (($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0, 'L', 0);
$pdf->SetXY($tab3_posx+40, $tab3_top+$y); $pdf->SetXY($tab3_posx+40, $tab3_top+$y);
$oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->code); $oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->code);
@ -1060,6 +1060,8 @@ class pdf_crabe extends ModelePDFFactures
// Show VAT by rates and total // Show VAT by rates and total
$pdf->SetFillColor(248,248,248); $pdf->SetFillColor(248,248,248);
$total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
$this->atleastoneratenotnull=0; $this->atleastoneratenotnull=0;
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
{ {
@ -1270,7 +1272,6 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetFillColor(224,224,224); $pdf->SetFillColor(224,224,224);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
$total_ttc = ($conf->multicurrency->enabled && $object->multiccurency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($sign * $total_ttc, 0, $outputlangs), $useborder, 'R', 1); $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $total_ttc, 0, $outputlangs), $useborder, 'R', 1);
} }
@ -1278,10 +1279,10 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$creditnoteamount=$object->getSumCreditNotesUsed(); $creditnoteamount=$object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
$depositsamount=$object->getSumDepositsUsed(); $depositsamount=$object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
//print "x".$creditnoteamount."-".$depositsamount;exit; //print "x".$creditnoteamount."-".$depositsamount;exit;
$resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
if ($object->paye) $resteapayer=0; if ($object->paye) $resteapayer=0;
if ($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) if ($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0)

View File

@ -1010,6 +1010,8 @@ class pdf_azur extends ModelePDFPropales
// Show VAT by rates and total // Show VAT by rates and total
$pdf->SetFillColor(248,248,248); $pdf->SetFillColor(248,248,248);
$total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
$this->atleastoneratenotnull=0; $this->atleastoneratenotnull=0;
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
{ {
@ -1186,7 +1188,6 @@ class pdf_azur extends ModelePDFPropales
$pdf->SetFillColor(224,224,224); $pdf->SetFillColor(224,224,224);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
$total_ttc = ($conf->multicurrency->enabled && $object->multiccurency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1); $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
} }

View File

@ -717,6 +717,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$useborder=0; $useborder=0;
// Total TTC
$index++; $index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->SetTextColor(0,0,60); $pdf->SetTextColor(0,0,60);
@ -727,6 +728,14 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc), $useborder, 'R', 1); $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc), $useborder, 'R', 1);
$creditnoteamount=0;
$depositsamount=0;
//$creditnoteamount=$object->getSumCreditNotesUsed();
//$depositsamount=$object->getSumDepositsUsed();
//print "x".$creditnoteamount."-".$depositsamount;exit;
$resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
if (! empty($object->paye)) $resteapayer=0;
if ($deja_regle > 0) if ($deja_regle > 0)
{ {
$index++; $index++;
@ -743,7 +752,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle), $useborder, 'R', 1); $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1);
$pdf->SetFont('','', $default_font_size - 1); $pdf->SetFont('','', $default_font_size - 1);
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
} }
@ -877,6 +886,11 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
*/ */
function _tableau_versements(&$pdf, $object, $posy, $outputlangs) function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
{ {
global $conf;
$sign=1;
if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
$tab3_posx = 120; $tab3_posx = 120;
$tab3_top = $posy + 8; $tab3_top = $posy + 8;
$tab3_width = 80; $tab3_width = 80;
@ -910,8 +924,11 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$pdf->SetFont('','', $default_font_size - 4); $pdf->SetFont('','', $default_font_size - 4);
// Loop on each deposits and credit notes included
//
// Loop on each payment // Loop on each payment
$sql = "SELECT p.datep as date, p.fk_paiement as type, p.num_paiement as num, pf.amount as amount,"; $sql = "SELECT p.datep as date, p.fk_paiement as type, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
$sql.= " cp.code"; $sql.= " cp.code";
$sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf, ".MAIN_DB_PREFIX."paiementfourn as p"; $sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf, ".MAIN_DB_PREFIX."paiementfourn as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id";
@ -929,7 +946,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$pdf->SetXY($tab3_posx, $tab3_top+$y); $pdf->SetXY($tab3_posx, $tab3_top+$y);
$pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date),'day',false,$outputlangs,true), 0, 'L', 0); $pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date),'day',false,$outputlangs,true), 0, 'L', 0);
$pdf->SetXY($tab3_posx+21, $tab3_top+$y); $pdf->SetXY($tab3_posx+21, $tab3_top+$y);
$pdf->MultiCell(20, 3, price($row->amount), 0, 'L', 0); $pdf->MultiCell(20, 3, price($sign * (($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount)), 0, 'L', 0);
$pdf->SetXY($tab3_posx+40, $tab3_top+$y); $pdf->SetXY($tab3_posx+40, $tab3_top+$y);
$oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->code); $oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->code);

View File

@ -840,7 +840,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
//$creditnoteamount=$object->getSumCreditNotesUsed(); //$creditnoteamount=$object->getSumCreditNotesUsed();
//$depositsamount=$object->getSumDepositsUsed(); //$depositsamount=$object->getSumDepositsUsed();
//print "x".$creditnoteamount."-".$depositsamount;exit; //print "x".$creditnoteamount."-".$depositsamount;exit;
$resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
if (! empty($object->paye)) $resteapayer=0; if (! empty($object->paye)) $resteapayer=0;
if ($deja_regle > 0) if ($deja_regle > 0)