mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-01-05 16:42:53 +01:00
Add retained warranty for all invoice for crabe PDF
This commit is contained in:
@@ -1377,47 +1377,33 @@ class pdf_crabe extends ModelePDFFactures
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, price($sign * $total_ttc, 0, $outputlangs), $useborder, 'R', 1);
|
||||
|
||||
// Retained warranty
|
||||
if (!empty($object->situation_final) && ($object->type == Facture::TYPE_SITUATION && (!empty($object->retained_warranty))))
|
||||
if ($object->displayRetainedWarranty())
|
||||
{
|
||||
$displayWarranty = false;
|
||||
$pdf->SetTextColor(40, 40, 40);
|
||||
$pdf->SetFillColor(255, 255, 255);
|
||||
|
||||
// Check if this situation invoice is 100% for real
|
||||
if (!empty($object->lines)) {
|
||||
$displayWarranty = true;
|
||||
foreach ($object->lines as $i => $line) {
|
||||
if ($line->product_type < 2 && $line->situation_percent < 100) {
|
||||
$displayWarranty = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$retainedWarranty = $object->getRetainedWarrantyAmount();
|
||||
$billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty;
|
||||
|
||||
if ($displayWarranty) {
|
||||
$pdf->SetTextColor(40, 40, 40);
|
||||
$pdf->SetFillColor(255, 255, 255);
|
||||
// Billed - retained warranty
|
||||
$index++;
|
||||
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
|
||||
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("ToPayOn", dol_print_date($object->date_lim_reglement, 'day')), $useborder, 'L', 1);
|
||||
|
||||
$retainedWarranty = $object->total_ttc * $object->retained_warranty / 100;
|
||||
$billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty;
|
||||
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, price($billedWithRetainedWarranty), $useborder, 'R', 1);
|
||||
|
||||
// Billed - retained warranty
|
||||
$index++;
|
||||
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
|
||||
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("ToPayOn", dol_print_date($object->date_lim_reglement, 'day')), $useborder, 'L', 1);
|
||||
// retained warranty
|
||||
$index++;
|
||||
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
|
||||
|
||||
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, price($billedWithRetainedWarranty), $useborder, 'R', 1);
|
||||
$retainedWarrantyToPayOn = $outputlangs->transnoentities("RetainedWarranty").' ('.$object->retained_warranty.'%)';
|
||||
$retainedWarrantyToPayOn .= !empty($object->retained_warranty_date_limit) ? ' '.$outputlangs->transnoentities("toPayOn", dol_print_date($object->retained_warranty_date_limit, 'day')) : '';
|
||||
|
||||
// retained warranty
|
||||
$index++;
|
||||
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
|
||||
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder, 'L', 1);
|
||||
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, price($retainedWarranty), $useborder, 'R', 1);
|
||||
|
||||
$retainedWarrantyToPayOn = $outputlangs->transnoentities("RetainedWarranty").' ('.$object->retained_warranty.'%)';
|
||||
$retainedWarrantyToPayOn .= !empty($object->retained_warranty_date_limit) ? ' '.$outputlangs->transnoentities("toPayOn", dol_print_date($object->retained_warranty_date_limit, 'day')) : '';
|
||||
|
||||
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder, 'L', 1);
|
||||
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, price($retainedWarranty), $useborder, 'R', 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user