Jump to content

Doubtful: Modify the invoice to appear two taxes


realseik

Recommended Posts

Good afternoon. First of all say I'm Spanish so I apologize for my bad English (google translator).
In my country there is a very small group of companies to be two tax bills (18% +4%) and should appear separately on the invoice. What I had tried to assign it to that group (so dirty) and two taxes in Canada. This way all customers with a VAT invoice with 18% and the other to 22%. There was any way that these people came out two sections in the bill, one with 18% and another 4%?

I put a code I found online that was part of what I want, but do not fit me and prestashop 1.4.2


(not prestashop 1.4.2) PDF.php

        // Display product tax
       if (intval(Configuration::get('PS_TAX')) AND self::$order->total_paid != '0.00')
       {
           foreach ($taxes AS $tax_rate => $vat)
           {
               if ($tax_rate == "5") // CANADA : TPS seulement
               {
               $before = $this->GetY();
               $lineSize = $this->GetY() - $before;
               $this->SetXY($this->GetX(), $this->GetY() - $lineSize + 3);
               $this->Cell($w[0], $lineSize, self::l('Products'), 0, 0, 'R');
               $this->Cell($w[1], $lineSize, self::convertSign(Tools::displayPrice($totalWithoutTax[$tax_rate], self::$currency, true, false)), 0, 0, 'R');
               $this->Cell($w[2], $lineSize, self::convertSign(Tools::displayPrice($totalWithoutTax[$tax_rate]*0.05, self::$currency, true, false)), 0, 0, 'R');
               $this->Cell($w[3], $lineSize, self::l('N/A'), 0, 0, 'R');
               $this->Cell($w[4], $lineSize, self::convertSign(Tools::displayPrice($totalWithoutTax[$tax_rate]*0.05, self::$currency, true, false)), 0, 0, 'R');
               $this->Cell($w[5], $lineSize, self::convertSign(Tools::displayPrice($totalWithTax[$tax_rate], self::$currency, true, false)), 0, 0, 'R');
               $this->Ln();
               }

               elseif    ($tax_rate == "12.87")    // QUEBEC : TVQ TPS
               {
               $before = $this->GetY();
               $lineSize = $this->GetY() - $before;
               $this->SetXY($this->GetX(), $this->GetY() - $lineSize + 3);
               $this->Cell($w[0], $lineSize, self::l('Products'), 0, 0, 'R');
               $this->Cell($w[1], $lineSize, self::convertSign(Tools::displayPrice($totalWithoutTax[$tax_rate], self::$currency, true, false)), 0, 0, 'R');
               $this->Cell($w[2], $lineSize, self::convertSign(Tools::displayPrice($totalWithoutTax[$tax_rate]*0.05, self::$currency, true, false)), 0, 0, 'R');
               $this->Cell($w[3], $lineSize, self::convertSign(Tools::displayPrice($totalWithoutTax[$tax_rate]*0.0787, self::$currency, true, false)), 0, 0, 'R');
               $this->Cell($w[4], $lineSize, self::convertSign(Tools::displayPrice($totalWithoutTax[$tax_rate]*0.1287, self::$currency, true, false)), 0, 0, 'R');
               $this->Cell($w[5], $lineSize, self::convertSign(Tools::displayPrice($totalWithTax[$tax_rate], self::$currency, true, false)), 0, 0, 'R');
               $this->Ln();
               }
               else     // AUTRE PAS DE TAXE
                   {
               $before = $this->GetY();
               $lineSize = $this->GetY() - $before;
               $this->SetXY($this->GetX(), $this->GetY() - $lineSize + 3);
               $this->Cell($w[0], $lineSize, self::l('Products'), 0, 0, 'R');
               $this->Cell($w[1], $lineSize, self::convertSign(Tools::displayPrice($totalWithoutTax[$tax_rate], self::$currency, true, false)), 0, 0, 'R');
               $this->Cell($w[2],$lineSize, self::l('N/A'), 0, 0, 'R');
               $this->Cell($w[3],$lineSize, self::l('N/A'), 0, 0, 'R');
               $this->Cell($w[4], $lineSize, number_format($tax_rate, 2, ',', ' '), 0, 0, 'R');
               $this->Cell($w[5], $lineSize, self::convertSign(Tools::displayPrice($totalWithTax[$tax_rate], self::$currency, true, false)), 0, 0, 'R');
               $this->Ln();
               }
           }

       }



A greeting and thanks to all.

Link to comment
Share on other sites

  • 3 weeks later...

of course. I have PrestaShop™ 1.4.2.5

i dont know the exact version of the pdf I've attached because I found it on the internet, only it is a 1.3.x version, sorry.

What I tried was adapted to 1.4.2 with the following code (in PDF.php):

foreach ($priceBreakDown['taxes'] AS $tax_rate => $vat)
       {

           if ($tax_rate == "4") // R.E
               {
               $before = $this->GetY();
               $lineSize = $this->GetY() - $before;
               $this->SetXY($this->GetX(), $this->GetY() - $lineSize + 3);
               $this->Cell($w[0], $lineSize, self::l('Products'), 0, 0, 'R');
               $this->Cell($w[1], $lineSize, self::convertSign(Tools::displayPrice($totalWithoutTax[$tax_rate]*0.18, self::$currency, true, false)), 0, 0, 'R');
               $this->Cell($w[2], $lineSize, self::convertSign(Tools::displayPrice($totalWithoutTax[$tax_rate]*0.04, self::$currency, true, false)), 0, 0, 'R');
               $this->Cell($w[3], $lineSize, self::convertSign(Tools::displayPrice($totalWithoutTax[$tax_rate], self::$currency, true, false)), 0, 0, 'R');
               $this->Cell($w[4], $lineSize, self::convertSign(Tools::displayPrice($totalWithoutTax[$tax_rate]*0.22, self::$currency, true, false)), 0, 0, 'R');
               $this->Cell($w[5], $lineSize, self::convertSign(Tools::displayPrice($totalWithTax[$tax_rate], self::$currency, true, false)), 0, 0, 'R');
               $this->Ln();
               }

           if ($tax_rate != '0.00' AND $priceBreakDown['totalsProductsWithTax'][$tax_rate] != '0.00')
           {
               $nb_tax++;
               $before = $this->GetY();
               $lineSize = $this->GetY() - $before;
               $this->SetXY($this->GetX(), $this->GetY() - $lineSize + 3);
               $this->Cell($w[0], $lineSize, self::l('Products'), 0, 0, 'R');
               $this->Cell($w[1], $lineSize, number_format($tax_rate, 3, ',', ' ').' %', 0, 0, 'R');
               $this->Cell($w[2],$lineSize, self::l('N/A'), 0, 0, 'R');
               $this->Cell($w[2], $lineSize, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice($priceBreakDown['totalsProductsWithoutTax'][$tax_rate], self::$currency, true, false)), 0, 0, 'R');
               $this->Cell($w[4], $lineSize, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice($priceBreakDown['totalsProductsWithTax'][$tax_rate] - $priceBreakDown['totalsProductsWithoutTax'][$tax_rate], self::$currency, true, false)), 0, 0, 'R');
               if ($priceBreakDown['hasEcotax'])
                   $this->Cell($w[5], $lineSize, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice($priceBreakDown['totalsEcotax'][$tax_rate], self::$currency, true, false)), 0, 0, 'R');
               $this->Cell($w[$priceBreakDown['hasEcotax'] ? 5 : 4], $lineSize, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice($priceBreakDown['totalsProductsWithTax'][$tax_rate], self::$currency, true, false)), 0, 0, 'R');
               $this->Ln();
           }
       } 




As a result I did not get it to work properly, I leave as it came in an image.

http://www.prestashop.com/?ACT=29&fid=86&aid=47643_UkAdoWWW8vAMUCqP2xOu&board_id=1

Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...