Jump to content

Invoice - display carrier price before total


Recommended Posts

Hi, i do have this in my PDF.php:

/**            
   * Tax table  / součet všech položek
   */
   public function TaxTab()
   {
       if (!$id_zone = Address::getZoneById(intval(self::$order->id_address_invoice)))
           die(Tools::displayError());

       if (self::$order->total_paid == '0.00' OR !intval(Configuration::get('PS_TAX')))
           return ;

       // Setting products tax
       if (isset(self::$order->products) AND sizeof(self::$order->products))
           $products = self::$order->products;
       else
           $products = self::$order->getProducts();
       $totalWithTax = array();
       $totalWithoutTax = array();
       $amountWithoutTax = 0;
       $taxes = array();
       /* Firstly calculate all prices */
       foreach ($products AS &$product)
       {
           if (!isset($totalWithTax[$product['tax_rate']]))
               $totalWithTax[$product['tax_rate']] = 0;
           if (!isset($totalWithoutTax[$product['tax_rate']]))
               $totalWithoutTax[$product['tax_rate']] = 0;
           if (!isset($taxes[$product['tax_rate']]))
               $taxes[$product['tax_rate']] = 0;
           /* Without tax */
           $product['priceWithoutTax'] = floatval($product['product_price']) * intval($product['product_quantity']);
           $amountWithoutTax += $product['priceWithoutTax'];
           /* With tax */
           $product['priceWithTax'] = $product['priceWithoutTax'] * (1 + (floatval($product['tax_rate']) / 100));
           $amountWithTax += $product['priceWithTax'];
       }

       $tmp = 0;
       $product = &$tmp;

       /* And secondly assign to each tax its own reduction part */
       $discountAmount = floatval(self::$order->total_discounts);
       foreach ($products as $product)
       {
           $ratio = $amountWithoutTax == 0 ? 0 : $product['priceWithoutTax'] / $amountWithoutTax;
           $priceWithTaxAndReduction = $product['priceWithTax'] - ($discountAmount * $ratio);
           $vat = $priceWithTaxAndReduction - ($priceWithTaxAndReduction / ((floatval($product['tax_rate']) / 100) + 1));
           $taxes[$product['tax_rate']] += $vat;
           $totalWithTax[$product['tax_rate']] += $priceWithTaxAndReduction;
           $totalWithoutTax[$product['tax_rate']] += $priceWithTaxAndReduction - $vat;
       }

       $carrier = new Carrier(self::$order->id_carrier);
       $carrierTax = new Tax($carrier->id_tax);
       if (($totalWithoutTax == $totalWithTax) AND (!$carrierTax->rate OR $carrierTax->rate == '0.00') AND (!self::$order->total_wrapping OR self::$order->total_wrapping == '0.00'))
           return ;

       // Displaying header tax
       $header = array(self::l('Tax detail'), self::l('Tax %'), self::l('Pre-Tax Total'), self::l('Total Tax'), self::l('Total with Tax'));
       $w = array(90, 25, 25, 25, 25);
       $this->SetFont(self::fontname(),'', 9);
       //for($i = 0; $i < sizeof($header); $i++)
       //    $this->Cell($w[$i], 5, $header[$i], 0, 0, 'R');

       //$this->Ln();
       //$this->SetFont(self::fontname(), '', 7);

       $nb_tax = 0;


       // 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 == '0.00' OR $totalWithTax[$tax_rate] == '0.00')
                   continue ;
               $totalTax= $totalWithTax[$tax_rate]-$totalWithoutTax[$tax_rate];
               $nb_tax++;
/*            $before = $this->GetY();
               $lineSize = $this->GetY() - $before;
               $this->SetXY($this->GetX(), $this->GetY() - $lineSize);
               $this->Cell($w[0], 9, 'Součet položek', 'L', 0,'L');
               $this->SetFont(self::fontname(), '', 9);
               $this->Cell($w[1], 9, self::convertSign(Tools::displayPrice($totalWithoutTax[$tax_rate], self::$currency, true, false)), '',  'R',0);
               $this->Cell($w[2], 9, self::convertSign(Tools::displayPrice($totalWithTax[$tax_rate], self::$currency, true, false)), '', 'R',0);
               $this->Cell($w[3], 9, self::convertSign(Tools::displayPrice($totalTax, self::$currency, true, false)), 0, 'R',0);
               $this->Cell($w[4], 9, self::convertSign(Tools::displayPrice($totalWithTax[$tax_rate], self::$currency, true, false)),'R', 1,'R');
*/            



     }
       }    


       // Display carrier tax
       if ($carrierTax->rate AND $carrierTax->rate != '0.00' AND self::$order->total_shipping != '0.00' AND Tax::zoneHasTax(intval($carrier->id_tax), intval($id_zone)))
       {
           $nb_tax++;
           $total_shipping_wt = self::$order->total_shipping / (1 + ($carrierTax->rate / 100));
           $before = $this->GetY();
           $lineSize = $this->GetY() - $before;
           $this->SetXY($this->GetX(), $this->GetY() - $lineSize);
           $this->Cell($w[0], $lineSize, self::l('Carrier'), 0, 0, 'L');
           $this->Cell($w[1], $lineSize, self::convertSign(Tools::displayPrice($total_shipping_wt, self::$currency, true, false)), 0, 0, 'R');
           $this->Cell($w[3], $lineSize, self::convertSign(Tools::displayPrice(self::$order->total_shipping - $total_shipping_wt, self::$currency, true, false)), 0, 0, 'R');
     $this->Cell($w[2], $lineSize, ' ', 0, 0, 'R');
           $this->Cell($w[4], $lineSize, self::convertSign(Tools::displayPrice(self::$order->total_shipping, self::$currency, true, false)), 0, 1, 'R');
           $this->Cell(190,4.5,'',LR,1,'C');   
       }



And I would need to display the carrier price before the total... I tried many things, but was not succesful. Anyone could help me?

32472_pUrhOqbbreMAXJs23Hcn_t

Link to comment
Share on other sites

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...