Order tax details in invoice

Before you ask about IDnR Addon see the VirtueMart - Invoice, Delivery Note and Receipt Addon
josbregman
Phoca Newbie
Phoca Newbie
Posts: 2
Joined: 12 Aug 2009, 14:43

Order tax details in invoice

Post by josbregman »

Hi,

So far I managed to modify the invoice pretty much the way I wanted, except for one detail, I can't get the order tax details in the invoice pdf.
I think it's configured in ps_checkout.php.
In account.order.details.php it's reffered like this: ps_checkout::show_tax_details( $db->f('order_tax_details'), $db->f('order_currency') );
Now the big question: how can I get this in delivery.pdf.php? Just copy-paste doesn't do the job...

Thanks!

Jos
rosder
Phoca Newbie
Phoca Newbie
Posts: 5
Joined: 13 Aug 2009, 05:56

Re: Order tax details in invoice

Post by rosder »

I also have this problem. So help us, please.
josbregman
Phoca Newbie
Phoca Newbie
Posts: 2
Joined: 12 Aug 2009, 14:43

Re: Order tax details in invoice

Post by josbregman »

I just got one step closer to the solution:

First you have to include the ps_checkout.php, because there's the calculation of the taxes made:

Code: Select all

include(CLASSPATH.'ps_checkout.php');
After that, you can easily tell the pdf to use it:

Code: Select all

$pdf->Cell(50,10,(ps_checkout::show_tax_details($dbo->f('order_tax_details'), $dbo->f('order_currency'))),0,0,'L');
(Please note the () in which the " ps_checkout::show_tax_details($dbo->f('order_tax_details'), $dbo->f('order_currency')) " should be placed.)

Now, I have one little problem remaining, the output is like this:
<br />De totale belasting (BTW) omvat:<br />€380,00 (19% Belasting (BTW))<br />

I need to remove the ' <br /> ' somehow. Or, better, to tell the pdf to actually put a line break instead.

Can someone help me with this?

Thanks!
rosder
Phoca Newbie
Phoca Newbie
Posts: 5
Joined: 13 Aug 2009, 05:56

Re: Order tax details in invoice

Post by rosder »

First of all, thank you.
But I have another problem.
How can I get more product information (produkt name AND description) on the PDF-document?
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47887
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Order tax details in invoice

Post by Jan »

This needs to be customized in the code :-( (so you will load the data from database and will change the pdf template, so this information will be displayed)

Jan
If you find Phoca extensions useful, please support the project
rosder
Phoca Newbie
Phoca Newbie
Posts: 5
Joined: 13 Aug 2009, 05:56

Re: Order tax details in invoice

Post by rosder »

I changed in delivery.pdf.php the following lines from

Code: Select all

	
$pdf->SetFont($pdfFont,'',7);
$pdf->Cell(70,4,$db->f('order_item_name'),0,0,'L');
to

Code: Select all

	
$pdf->SetFont($pdfFont,'',5);
$pdf->Cell(70,4,$db->f('order_item_name')[b]." ".ereg_replace("<br/>"," ",$db->f('product_attribute'))[/b],0,0,'L');
Now I want to have a linebreak between $db->f('order_item_name') and $db->f('product_attribute').

How to do this?
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47887
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Order tax details in invoice

Post by Jan »

Hi, see tcpdf site (examples) to see how to add page break to site.

Jan
If you find Phoca extensions useful, please support the project
rosder
Phoca Newbie
Phoca Newbie
Posts: 5
Joined: 13 Aug 2009, 05:56

Re: Order tax details in invoice

Post by rosder »

Thx.

I took this:

Code: Select all

$pdf->Cell(70,4,$db->f('order_item_name').$pdf->writeHTML('<br>', true, 0, true, 0).ereg_replace("<br/>"," ",$db->f('product_attribute')),0,0,'L');
But it doesn't work the right way. The break is shown after productnumber:

productnumber
productname product_attribute product_quantity price etc.


I want a break after produktname:

productnumber produktname __________product_quantity price etc.
_____________product_attribute
gmarin
Phoca Newbie
Phoca Newbie
Posts: 2
Joined: 25 Sep 2009, 15:37

Re: Order tax details in invoice

Post by gmarin »

Hi all,
I want to reply to the original post.
You have to add a fonction to phoca.tcpdf.php
It's a copy of the original function show_tax_details.
Modified like this :

function show_tax_details( $details, $currency = '' ) {
global $discount_factor, $CURRENCY_DISPLAY, $VM_LANG;

if( !isset( $discount_factor) || !empty($_REQUEST['discount_factor'])) {
$discount_factor = 1;
}
$auth = $_SESSION['auth'];
if( !is_array( $details )) {
$details = @unserialize( $details );
if( !is_array($details)) {
return false;
}
}
if( sizeof( $details) > 1 ) {
$this->Ln(5);
$this->SetX(110);
$this->SetFont($fD['font'],'B',9);
$this->Cell(40,5,$VM_LANG->_('VM_TAXDETAILS_LABEL'),0,0,'R');
foreach ($details as $rate => $value ) {
if( !$auth['show_price_including_tax']) {
$value /= $discount_factor;
}
$this->Ln(5);
$this->SetFont($pdfFont,'',9);
$this->SetX(130);
$rate = str_replace( '-', $CURRENCY_DISPLAY->decimal, $rate )*100;
$this->Cell(40,5,$CURRENCY_DISPLAY->getFullValue( $value, 5, $currency ).' ('.$rate.'% '.$VM_LANG->_('PHPSHOP_CART_TAX').')',0,0,'R');
}
}
}


You have to call it from delivery.pdf.php
$pdf->Cell(40,5,($pdf->show_tax_details($dbo->f('order_tax_details'), $dbo->f('order_currency'))),0,0,'R');


you can custumize the function to apply to your invoice
Bye
Gilbert
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47887
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Order tax details in invoice

Post by Jan »

Ok, thank you for this guide. Jan
If you find Phoca extensions useful, please support the project
Post Reply