[Solved]Need to change Invoice to apply to german law

Before you ask about IDnR Addon see the VirtueMart - Invoice, Delivery Note and Receipt Addon
Nukem36
Phoca Enthusiast
Phoca Enthusiast
Posts: 65
Joined: 08 Sep 2008, 19:34

[Solved]Need to change Invoice to apply to german law

Post by Nukem36 »

Hi!

I'm using the IDnR plugin quiet a long time now and have to change the invoice, cause of german laws:

If a customer order 2 items (1 with 19% ax and another 1 book with 7% tax) this must be visible one the invoice. I found out, that in plugins/phocapdf/virtuemart/ file virtuemartpdfoutput.php should be changed. I think lines 140-145 should be the right ones, looking like this:

Code: Select all

			if($type == 'invoice' || $type == 'receipt') {
				$i[$j]['price_without_tax']['item']	= $CURRENCY_DISPLAY->getFullValue($price_without_tax['item'], '', $c);
				$i[$j]['price_without_tax']['sum']	= $CURRENCY_DISPLAY->getFullValue($price_without_tax['sum'], '', $c);
				$i[$j]['price_tax']['sum']			= $CURRENCY_DISPLAY->getFullValue($price_tax['sum'], '', $c);
				$i[$j]['price_with_tax']['sum']		= $CURRENCY_DISPLAY->getFullValue($price_with_tax['sum'], '', $c);
What I couldn't find out is: what code do I have to add/change to get the pricetax f.e. 1,45€ and a text like; (7% tax)

It would be greate if anyone could give me a solution or a hint

Regards
Nukem36
Last edited by Nukem36 on 09 Apr 2012, 20:07, edited 1 time in total.
Nukem36
Phoca Enthusiast
Phoca Enthusiast
Posts: 65
Joined: 08 Sep 2008, 19:34

Re: Need to change Invoice to apply to german law

Post by Nukem36 »

Hi!

just to inform what I did up to here: I made an update to the newest com_phocainstall_vm, what went fine. Unfortunatly my problem is not solved.

Thanks for any help or hint!

Regards
Nukem36
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48403
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Need to change Invoice to apply to german law

Post by Jan »

Did you try to change it directly on the server?
If you find Phoca extensions useful, please support the project
Nukem36
Phoca Enthusiast
Phoca Enthusiast
Posts: 65
Joined: 08 Sep 2008, 19:34

Re: Need to change Invoice to apply to german law

Post by Nukem36 »

Hi!

after searching around for hours and with a hint from Jan I did the changes by myself:

Edit file /plugins/phocapdf/virtuemart/virtuemartpdfoutput.php

search the following lines:

Code: Select all

$price_with_tax['item']		= $value->product_final_price;
				$price_with_tax['sum'] 		= $value->product_final_price * $value->product_quantity_delivered;
				$price_without_tax['item'] 	= $value->product_item_price;
				$price_without_tax['sum'] 	= $value->product_item_price * $value->product_quantity_delivered;
				$price_tax['item'] 		= $price_with_tax['item'] - $price_without_tax['item'];
				$price_tax['sum'] 		= $price_with_tax['sum'] - $price_without_tax['sum'];
				$without_tax['item_total'] 	+= $price_without_tax['sum'];
				$with_tax['item_total'] 	+= $price_with_tax['sum'];
				$tax['item_total'] 		+= $price_tax['sum'];
and change it to:

Code: Select all

$price_with_tax['item']		= $value->product_final_price;
				$price_with_tax['sum'] 		= $value->product_final_price * $value->product_quantity_delivered;
				$price_without_tax['item'] 	= $value->product_item_price;
				$price_without_tax['sum'] 	= $value->product_item_price * $value->product_quantity_delivered;
				$price_tax['item'] 		= $price_with_tax['item'] - $price_without_tax['item'];
				$price_tax['sum'] 		= $price_with_tax['sum'] - $price_without_tax['sum'];

[b]$price_taxrate = 100 * $price_tax['item'] / $price_without_tax['item'];[/b]

				$without_tax['item_total'] 	+= $price_without_tax['sum'];
				$with_tax['item_total'] 	+= $price_with_tax['sum'];
				$tax['item_total'] 		+= $price_tax['sum'];
The output to invoice is in line ~150. Search for this code:

Code: Select all

				$i[$j]['price_without_tax']['item']	= $CURRENCY_DISPLAY->getFullValue($price_without_tax['item'], '', $c);
				$i[$j]['price_without_tax']['sum']	= $CURRENCY_DISPLAY->getFullValue($price_without_tax['sum'], '', $c);
				$i[$j]['price_tax']['sum']			= $CURRENCY_DISPLAY->getFullValue($price_tax['sum'], '', $c);
				$i[$j]['price_with_tax']['sum']		= $CURRENCY_DISPLAY->getFullValue($price_with_tax['sum'], '', $c);
and change it to:

Code: Select all

				$i[$j]['price_without_tax']['item']	= $CURRENCY_DISPLAY->getFullValue($price_without_tax['item'], '', $c);
				$i[$j]['price_without_tax']['sum']	= $CURRENCY_DISPLAY->getFullValue($price_without_tax['sum'], '', $c);
				$i[$j]['price_tax']['sum']			= $CURRENCY_DISPLAY->getFullValue($price_tax['sum'], '', $c);
[b]				$i[$j]['price_tax']['sum']		.= "\n(".round($price_taxrate)."%)";[/b]
				$i[$j]['price_with_tax']['sum']		= $CURRENCY_DISPLAY->getFullValue($price_with_tax['sum'], '', $c);

The highlighted line CALCULATES the taxrate, so its a hack and not really pretty, but should work for most cases. I used this cause otherwise I would have to change a lot of code, to read out the taxrate-id from VM database and searching with that ID in a new table for the value.

The output is rounded with no decimals and formatted to the german form, f.e. (7%)

Maybe this helps somebody out

Nukem36
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48403
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: [Solved]Need to change Invoice to apply to german law

Post by Jan »

Hi, thank you very much for the guide.

Jan
If you find Phoca extensions useful, please support the project
Kevin
Phoca Newbie
Phoca Newbie
Posts: 1
Joined: 10 Jan 2013, 20:29

Re: [Solved]Need to change Invoice to apply to german law

Post by Kevin »

Hi Nukem, Hi Jan,

ich habe das selbe Problem. Mein Shop muss ebenfalls Rechnungen mit zwei verschiedenen MwSt. Sätzen generieren.
Leider funktioniert deine Anleitung bei mir nicht. Sobald ich die Codes wie angegeben abändere, habe ich einen Fehler und es werden keine PDF`s mehr erstellt.

Gibt es vielleicht noch eine andere Lösung für dieses Problem?

Gruß Kevin
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48403
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: [Solved]Need to change Invoice to apply to german law

Post by Jan »

Ja, leider muss da der Fehler identifiert, sonst weiss niemand was da passiert :-( :-(

Jan
If you find Phoca extensions useful, please support the project
Post Reply