Jump to content

[Solved]Rounding total price pdf invoice


Recommended Posts

Hi,

 

can anybody give me advice, how to round total amount on pdf invoice in invoice.tpl file. I have this format of prices xxx.xx and I would like to add one more row with rounded price only xxx.

 

for example price is:

 

Total: 456.45 - (I need 456,00)

Total: 256.54 - (I need 257,00)

 

I don't want to switch off decimals, but I need only to round total amount.

 

In old prestashop 1.4.x i had this code in pdf.php

$pdf->SetTextColor(137, 32, 32);
if (self::$order->id_currency == 4){
$pdf->Cell($width, 0, 'Rounded'.' : ', 0, 0, 'R');
$pdf->Cell(0, 0, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice((round($priceBreakDown['totalWithTax'])), self::$currency, true)), 0, 0, 'R');
$pdf->Ln(4);
}else{
}

 

I don't know how to make it through invoice.tpl. I need this rounding only for id_currency 4. I have one another where I don't want rounding. Thank you

Edited by Radek100 (see edit history)
Link to comment
Share on other sites

So I found out solution need to add round to code in invoice.tpl this way

   {if $order->id_currency == 4}
			 <td style="text-align: right; font-weight: bold">{l s='Total' pdf='true'}</td>
    <td style="width: 15%; text-align: right;">{displayPrice currency=$order->id_currency price=$order_invoice->total_paid_tax_incl price=round($order_invoice->total_paid_tax_incl)}</td>
		    {/if}

Edited by Radek100 (see edit history)
Link to comment
Share on other sites

×
×
  • Create New...