Debug v22
This commit is contained in:
parent
3c8be27009
commit
e8de1b62d1
2 changed files with 15 additions and 5 deletions
|
|
@ -2747,15 +2747,17 @@ function pdf_getSizeForImage($realpath)
|
|||
}
|
||||
|
||||
/**
|
||||
* Return line total amount discount
|
||||
* Return line total amount discount.
|
||||
* Calculated by taking the unit price (subprice) * quantity - (total without tax)
|
||||
*
|
||||
* @param Commande|Facture|Propal $object Object
|
||||
* @param int $i Current line number
|
||||
* @param Translate $outputlangs Object langs for output
|
||||
* @param int<0,2> $hidedetails Hide details (0=no, 1=yes, 2=just special lines)
|
||||
* @param int<0,1> $multicurrency 1=Get value in the foreign currency
|
||||
* @return int|float|string Return total of line excl tax
|
||||
*/
|
||||
function pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, $hidedetails = 0)
|
||||
function pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, $hidedetails = 0, $multicurrency = 0)
|
||||
{
|
||||
global $hookmanager;
|
||||
|
||||
|
|
@ -2777,7 +2779,8 @@ function pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, $hidedetails =
|
|||
'i' => $i,
|
||||
'outputlangs' => $outputlangs,
|
||||
'hidedetails' => $hidedetails,
|
||||
'special_code' => $special_code
|
||||
'special_code' => $special_code,
|
||||
'multicurrency' => $multicurrency
|
||||
);
|
||||
|
||||
$action = '';
|
||||
|
|
@ -2792,7 +2795,11 @@ function pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, $hidedetails =
|
|||
}
|
||||
|
||||
if (empty($hidedetails) || $hidedetails > 1) {
|
||||
return (float) price2num($sign * (($object->lines[$i]->subprice * (float) $object->lines[$i]->qty) - $object->lines[$i]->total_ht), 'MT', 1);
|
||||
if (empty($multicurrency)) {
|
||||
return (float) price2num($sign * (($object->lines[$i]->subprice * (float) $object->lines[$i]->qty) - $object->lines[$i]->total_ht), 'MT', 1);
|
||||
} else {
|
||||
return (float) price2num($sign * (($object->lines[$i]->multicurrency_subprice * (float) $object->lines[$i]->qty) - $object->lines[$i]->multicurrency_total_ht), 'MT', 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -1800,16 +1800,19 @@ class pdf_sponge extends ModelePDFFactures
|
|||
|
||||
// Total discount
|
||||
$total_discount_on_lines = 0;
|
||||
$multicurrency_total_discount_on_lines = 0;
|
||||
foreach ($object->lines as $i => $line) {
|
||||
$resdiscount = pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, 2);
|
||||
$multicurrency_resdiscount = pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, 2, 1);
|
||||
|
||||
$total_discount_on_lines += (is_numeric($resdiscount) ? $resdiscount : 0);
|
||||
$multicurrency_total_discount_on_lines += (is_numeric($multicurrency_resdiscount) ? $multicurrency_resdiscount : 0);
|
||||
// If line was a negative line, we do not count the discount as a discount
|
||||
if ($line->total_ht < 0) {
|
||||
$total_discount_on_lines += -$line->total_ht;
|
||||
$multicurrency_total_discount_on_lines += -$line->multicurrency_total_ht;
|
||||
}
|
||||
}
|
||||
$multicurrency_total_discount_on_lines = price2num($total_discount_on_lines * $object->multicurrency_tx, 'CT');
|
||||
|
||||
if ($total_discount_on_lines > 0) {
|
||||
// Show total NET before discount
|
||||
|
|
|
|||
Loading…
Reference in a new issue