Jump to content

Personalisation Facture PDF


Recommended Posts

Bonjour,

 

J'ai transformé la facture automatique en "reçu" en réduisant le nombre d'information sur la TVA.

J'aurai besoin (en cas de remise sur un article) d'afficher le prix AVANT REMISE TVA COMPRISE.

 

Je n'y parviens pas. Quelqu'un aurait-il un solution à ce problème?

 

{if isset($layout.before_discount)}

<td class="product left">
{if isset($order_detail.unit_price_tax_incl_before_specific_price)}
{displayPrice currency=$order->id_currency price=$order_detail.unit_price_tax_incl_before_specific_price}
{else}
--
{/if}
</td>
{/if}
 
<td class="product right">
{displayPrice currency=$order->id_currency price=$order_detail.unit_price_tax_incl_including_ecotax}
{if $order_detail.ecotax_tax_excl > 0}
<br>
<small>[spam-filter]displayPrice currency=$order->id_currency price=$order_detail.ecotax_tax_excl}|string_format:{l s='ecotax: %s' pdf='true'[spam-filter]</small>
{/if}

 

post-1384261-0-80920000-1494762494_thumb.png

Edited by AlexVDB (see edit history)
Link to comment
Share on other sites

Dans classes/pdf/HtmlTemplateInvoice.php, vers la ligne 165 

        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']);
            }

            // Set tax_code
            $taxes = OrderDetail::getTaxListStatic($id);
            $tax_temp = array();
            foreach ($taxes as $tax) {
                $obj = new Tax($tax['id_tax']);
                $tax_temp[] = sprintf($this->l('%1$s%2$s%%'), ($obj->rate + 0), ' ');
            }

            $order_detail['order_detail_tax'] = $taxes;
            $order_detail['order_detail_tax_label'] = implode(', ', $tax_temp);
	    var_dump($order_detail);
        }
        die;

A la fin de la boucle j'ai ajouté un var_dump() et un die() après la boucle.

 

En faisant ça tu vas pouvoir debugger ce que contient chaque ligne de la facture et trouver quelle valeur correspond à ce que tu veux obtenir.

 

Bien sûr une fois que c'est fait tu enlèves le var_dump() et le die()

Link to comment
Share on other sites

J'ai ajouté les ligne, mais j'ai toujours le même affichage sur la facture PDF.

 

 

<!-- PRODUCTS -->

{foreach $order_details as $order_detail}
{cycle values=["color_line_even", "color_line_odd"] assign=bgcolor_class}
<tr class="product {$bgcolor_class}">
 
<td class="product left">
{$order_detail.product_reference}
</td>
<td class="product left">
{if $display_product_images}
<table width="100%">
<tr>
<td width="15%">
{if isset($order_detail.image) && $order_detail.image->id}
{$order_detail.image_tag}
{/if}
</td>
<td width="5%"> </td>
<td width="80%">
{$order_detail.product_name}
</td>
</tr>
</table>
{else}
{$order_detail.product_name}
{/if}
 
</td>
<td class="product left">
{$order_detail.order_detail_tax_label}
</td>
 
{if isset($layout.before_discount)}
<td class="product left">
{if isset($order_detail.unit_price_tax_incl_before_specific_price)}
{displayPrice currency=$order->id_currency price=$order_detail.unit_price_tax_incl_before_specific_price}
{else}
--
{/if}
</td>
{/if}
 
<td class="product right">
{displayPrice currency=$order->id_currency price=$order_detail.unit_price_tax_incl_including_ecotax}
{if $order_detail.ecotax_tax_excl > 0}
<br>
<small>[spam-filter]displayPrice currency=$order->id_currency price=$order_detail.ecotax_tax_excl}|string_format:{l s='ecotax: %s' pdf='true'[spam-filter]</small>
{/if}
</td>
<td class="product center">
{$order_detail.product_quantity}
</td>
<td  class="product right">
{displayPrice currency=$order->id_currency price=$order_detail.total_price_tax_incl_including_ecotax}
</td>
</tr>
 
{foreach $order_detail.customizedDatas as $customizationPerAddress}
{foreach $customizationPerAddress as $customizationId => $customization}
<tr class="customization_data {$bgcolor_class}">
<td class="center">  </td>
 
<td>
{if isset($customization.datas[$smarty.const._CUSTOMIZE_TEXTFIELD_]) && count($customization.datas[$smarty.const._CUSTOMIZE_TEXTFIELD_]) > 0}
<table style="width: 100%;">
{foreach $customization.datas[$smarty.const._CUSTOMIZE_TEXTFIELD_] as $customization_infos}
<tr>
<td style="width: 30%;">
{$customization_infos.name|string_format:{l s='%s:' pdf='true'[spam-filter]
</td>
<td>{$customization_infos.value}</td>
</tr>
{/foreach}
</table>
{/if}
 
{if isset($customization.datas[$smarty.const._CUSTOMIZE_FILE_]) && count($customization.datas[$smarty.const._CUSTOMIZE_FILE_]) > 0}
<table style="width: 100%;">
<tr>
<td style="width: 70%;">{l s='image(s):' pdf='true'}</td>
<td>{count($customization.datas[$smarty.const._CUSTOMIZE_FILE_])}</td>
</tr>
</table>
{/if}
</td>
 
<td class="center">
({if $customization.quantity == 0}1{else}{$customization.quantity}{/if})
</td>
 
{assign var=end value=($layout._colCount-3)}
{for $var=0 to $end}
<td class="center">
--
</td>
{/for}
 
</tr>
<!--if !$smarty.foreach.custo_foreach.last-->
{/foreach}
{/foreach}
{/foreach}
<!-- END PRODUCTS -->

 

HTMLTemplateInvoice.php

Link to comment
Share on other sites

Désolé mais j'ai rien compris 

  1. dans le fichier  HTMLTemplateInvoice.php que tu joins il n'y a ni le var_dump() ni le die()
  2. tu postes une centaine de lignes du template de facture mais on ne sait pas ce qu'il faut chercher
  3. et surtout je doute que tu aies compris la manipulation que je voulais te faire faire

var_dump() est une fonction de PHP qui permet d'afficher tout ce que contient une variable.

die() est une autre fonction PHP qui stoppe brutalement toute l’exécution du code (en gros après un die() le reste du code n'est pas interprété).

 

Si tu avais mis le die() la facture ne se générerait pas. Donc tu ne l'as pas mis.

 

Lis la documentation de ces 2 fonctions pour mieux comprendre à quoi elles servent

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