Jump to content

Base price in Invoice ?


sumitbatra

Recommended Posts

  • 5 months later...

Exactly what I'm looking for too. Did you ever get a solution?

 

Never mind after some tinkering I have the solution. I can now add prices to my invoice before the discount reduction (with and without tax).

 

I simpely changed a bit of code in the file classes/PDF/HTMLTemplateInvoice.php

 

from this:

$has_discount = false;
foreach ($order_details as $id => &$order_detail) {
// Find out if column 'price before discount' is required
if ($order_detail['reduction_amount_tax_excl'] > 0) {
 $has_discount = true;
 $order_detail['unit_price_tax_excl_before_specific_price'] = $order_detail['unit_price_tax_excl_including_ecotax'] + $order_detail['reduction_amount_tax_excl'];
} elseif ($order_detail['reduction_percent'] > 0) {
 $has_discount = true;
 $order_detail['unit_price_tax_excl_before_specific_price'] = (100 * $order_detail['unit_price_tax_excl_including_ecotax']) / (100 - $order_detail['reduction_percent']);
} 

to this:

$has_discount = false;
foreach ($order_details as $id => &$order_detail) {
// Find out if column 'price before discount' is required
if ($order_detail['reduction_amount_tax_incl'] > 0) {
$has_discount = true;
$order_detail['unit_price_tax_incl_before_specific_price'] = $order_detail['unit_price_tax_incl_including_ecotax'] + $order_detail['reduction_amount_tax_incl'];
} elseif ($order_detail['reduction_percent'] > 0) {
$has_discount = true;
$order_detail['unit_price_tax_incl_before_specific_price'] = (100 * $order_detail['unit_price_tax_incl_including_ecotax']) / (100 - $order_detail['reduction_percent']);
}
if ($order_detail['reduction_amount_tax_excl'] > 0) {
$has_discount = true;
$order_detail['unit_price_tax_excl_before_specific_price'] = $order_detail['unit_price_tax_excl_including_ecotax'] + $order_detail['reduction_amount_tax_excl'];
} elseif ($order_detail['reduction_percent'] > 0) {
$has_discount = true;
$order_detail['unit_price_tax_excl_before_specific_price'] = (100 * $order_detail['unit_price_tax_excl_including_ecotax']) / (100 - $order_detail['reduction_percent']);
} 

The next step is to edit your PDF/invoice.tpl file

For example you can add the code:

{if isset($layout.before_discount)}
<td style="text-align: right; width: 13%; border-left: 1px solid #9E9F9E; border-top: 1px solid #9E9F9E;">
{if isset($order_detail.unit_price_tax_excl_before_specific_price)}
{displayPrice currency=$order->id_currency price=$order_detail.unit_price_tax_excl_before_specific_price}
{else}
--
{/if}
</td>
{/if}

This will show you the product price before the discounted price ( excl tax)

To show the price incl tax just edit: order_detail.unit_price_tax_excl_before_specific_price to order_detail.unit_price_tax_incl_before_specific_price

 

I hope this helps a bit.

 

I forgot to mention that i'm currently using the newest version of prestashop (1.6.1.1)

Edited by Plika1988 (see edit history)
  • Like 2
  • Thanks 1
Link to comment
Share on other sites

  • 1 year later...
  • 5 months later...

A simpler solution that does not require changes to the class generator is doing a little math in the pdf template during generation:

 

                                {displayPrice currency=$order->id_currency price=($order_detail.unit_price_tax_incl + $order_detail.reduction_amount_tax_incl)}

 

/OhmegaStar

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