[Skip to main content](#vessel-content)

#   Récupérer le CA hors taxe

##

- **[lapinrouge](/forum/user/11909-lapinrouge "View lapinrouge's Profile")**
- [![lapinrouge's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/11909-lapinrouge "View lapinrouge's Profile") Topic Author
- [ Offline](/forum/user/11909-lapinrouge)

Less More

- Posts: 26
- Thank you received: 1
-
-

3 years 2 months ago -  2 years 10 months ago [\#354885](#354885) by [lapinrouge](/forum/user/11909-lapinrouge "View lapinrouge's Profile")  *[Récupérer le CA hors taxe](/forum/5-support-en-francais-french-support-/906963-recuperer-le-ca-hors-taxe#354885 "-- HikaShop version -- : 4.7.5 -- Joomla version -- : 4.3.4 -- PHP version -- : 8.2  Bonjour,  Je suis actuellement en train de développer un module complémentaire pour Hikashop afin de réaliser des exports clients sur mesure, au format CSV. Cependant, je rencontre des difficultés pour récupérer le chiffre d'affaires hors taxe d'un client sur une période donnée. Pourriez-vous m'indiquer s'il existe des méthodes déjà mises en place qui pourraient faciliter cette tâche et m'indiquer comment les utiliser ?  Cordialement")* was created by *[lapinrouge](/forum/user/11909-lapinrouge "View lapinrouge's Profile")*

-- HikaShop version -- : 4.7.5
-- Joomla version -- : 4.3.4
-- PHP version -- : 8.2

Bonjour,

Je suis actuellement en train de développer un module complémentaire pour Hikashop afin de réaliser des exports clients sur mesure, au format CSV. Cependant, je rencontre des difficultés pour récupérer le chiffre d'affaires hors taxe d'un client sur une période donnée. Pourriez-vous m'indiquer s'il existe des méthodes déjà mises en place qui pourraient faciliter cette tâche et m'indiquer comment les utiliser ?

Cordialement

Last edit: 2 years 10 months ago by [lapinrouge](/forum/user/11909-lapinrouge "View lapinrouge's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzUtc3VwcG9ydC1lbi1mcmFuY2Fpcy1mcmVuY2gtc3VwcG9ydC0vOTA2OTYzLXJlY3VwZXJlci1sZS1jYS1ob3JzLXRheGU/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86587
- Thank you received: 14325
-
-

3 years 2 months ago -  3 years 2 months ago [\#354892](#354892) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Récupérer le CA hors taxe](/forum/5-support-en-francais-french-support-/906963-recuperer-le-ca-hors-taxe#354892 "-- HikaShop version -- : 4.7.5 -- Joomla version -- : 4.3.4 -- PHP version -- : 8.2  Bonjour,  Je suis actuellement en train de développer un module complémentaire pour Hikashop afin de réaliser des exports clients sur mesure, au format CSV. Cependant, je rencontre des difficultés pour récupérer le chiffre d'affaires hors taxe d'un client sur une période donnée. Pourriez-vous m'indiquer s'il existe des méthodes déjà mises en place qui pourraient faciliter cette tâche et m'indiquer comment les utiliser ?  Cordialement")*

Bonjour,

Lorsque HikaShop fourni les montants hors taxes pour les commandes (dans le gestionnaire des taux de taxes par exemple), il calcule dynamiquement cette valeur.
Vous pouvez vous inspirez du code dans la fonction listing du fichier administrator/components/com_hikashop/views/tax/view.html.php : Code:

//load the taxes for the orders $database-&gt;setQuery('SELECT order_tax_info, order_currency_id, order_discount_price, order_discount_tax, order_full_price, order_number FROM '.hikashop_table('order').$filters_txt); $orders_taxes = $database-&gt;loadObjectList(); //load the currencies $config = hikashop_config(); $main_currency = $config-&gt;get('main_currency'); $currencyClass = hikashop_get('class.currency'); $currency_ids = array($main_currency=&gt;$main_currency); $currencies = array(); if(count($orders_taxes)){ foreach($orders_taxes as $k =&gt; $v){ $currency_ids[$v-&gt;order_currency_id] = $v-&gt;order_currency_id; } } $null = null; $currencies = $currencyClass-&gt;getCurrencies($currency_ids,$null); //convert the currency of the tax amounts if not in the main currency of the store and round the tax amounts if(count($orders_taxes)){ foreach($orders_taxes as $k =&gt; $v){ $orders_taxes[$k]-&gt;order_tax_info = hikashop_unserialize($v-&gt;order_tax_info); $info =&amp; $orders_taxes[$k]-&gt;order_tax_info; if(!$info) continue; foreach($info as $k2 =&gt; $taxes_info){ $tax_amount = $taxes_info-&gt;tax_amount; if(!isset($taxes_info-&gt;tax_rate)) { if(!isset($rows[$taxes_info-&gt;tax_namekey])) { if(!empty($taxes_info-&gt;tax_namekey)) $app-&gt;enqueueMessage(JText::sprintf('THE_ORDER_X_HAS_A_TAX_RATE_WHICH_COULD_NOT_BE_FOUND', $v-&gt;order_number, $taxes_info-&gt;tax_namekey)); continue; } $taxes_info-&gt;tax_rate = $rows[$taxes_info-&gt;tax_namekey]-&gt;tax_rate; } // for the amount we either take: // - the pre calculated amount // - we recalculate it from the tax amount and the tax rate when the tax rate is not 0 // - we use the order full price when the order doesn't have other tax rates and the tax rate is 0 // - we set it to 0 in other cases if(isset($taxes_info-&gt;amount)) { $info[$k2]-&gt;amount = $taxes_info-&gt;amount; } else { if($taxes_info-&gt;tax_rate != 0) $info[$k2]-&gt;amount = $currencyClass-&gt;round($tax_amount/$taxes_info-&gt;tax_rate,$currencyClass-&gt;getRounding($v-&gt;order_currency_id)); elseif(count($info) == 1) $info[$k2]-&gt;amount = $v-&gt;order_full_price; else $info[$k2]-&gt;amount = 0; } $info[$k2]-&gt;tax_amount = $currencyClass-&gt;round($tax_amount,$currencyClass-&gt;getRounding($v-&gt;order_currency_id)); if($main_currency!=$v-&gt;order_currency_id){ $info[$k2]-&gt;tax_amount_main_currency = $currencyClass-&gt;convertUniquePrice($info[$k2]-&gt;tax_amount,$v-&gt;order_currency_id,$main_currency); $info[$k2]-&gt;amount_main_currency = $currencyClass-&gt;convertUniquePrice($info[$k2]-&gt;amount,$v-&gt;order_currency_id,$main_currency); }else{ $info[$k2]-&gt;tax_amount_main_currency = $info[$k2]-&gt;tax_amount; $info[$k2]-&gt;amount_main_currency = $info[$k2]-&gt;amount; } } } } if($pageInfo-&gt;elements-&gt;page){ foreach($rows as $k =&gt; $tax){ //fill the taxes with the tax amounts for each currency $tax_amounts = array(); $amounts = array(); foreach($currencies as $currency_id =&gt; $currency){ $tax_amount = 0; $amount = 0; if(count($orders_taxes)){ foreach($orders_taxes as $order_taxes){ if($order_taxes-&gt;order_currency_id != $currency_id &#124;&#124; !$order_taxes-&gt;order_tax_info) continue; foreach($order_taxes-&gt;order_tax_info as $order_tax){ if($order_tax-&gt;tax_namekey != $tax-&gt;tax_namekey) continue; $tax_amount += $order_tax-&gt;tax_amount; $amount += $order_tax-&gt;amount; } } } $tax_amounts[$currency_id] = $tax_amount; $amounts[$currency_id] = $amount; } $rows[$k]-&gt;tax_amounts = $tax_amounts; $rows[$k]-&gt;amounts = $amounts; //fill the taxes with the tax amounts converted in the main currency $tax_amount_main_currency = 0; $amount_main_currency = 0; if(count($orders_taxes)){ foreach($orders_taxes as $order_taxes){ if(!$order_taxes-&gt;order_tax_info) continue; foreach($order_taxes-&gt;order_tax_info as $order_tax){ if($order_tax-&gt;tax_namekey != $tax-&gt;tax_namekey) continue; $tax_amount_main_currency += $order_tax-&gt;tax_amount_main_currency; $amount_main_currency += $order_tax-&gt;amount_main_currency; } } } $rows[$k]-&gt;tax_amount = $tax_amount_main_currency; $rows[$k]-&gt;amount = $amount_main_currency; } }

Comme vous pouvez le voir, il faut récupérer le order_full_price et le order_tax_info de chaque commande.
Le order_full_price contient directement le montant total TTC.
Et le order_tax_info contient les données sérializées des taxes appliquées à la commande.
A partir d'elles, il est possible de récupérer le montant total des taxes (il peut y avoir plusieurs taux des taxes pour une même commande et différentes devises pour différentes commandes donc le code ci-dessus est surement plus complexe que ce dont vous avez besoin) et du coup de soustraire ce montant au total TTC pour obtenir le total HT et ensuite il ne reste qu'à faire la somme pour obtenir le CA hors taxes.

Last edit: 3 years 2 months ago by [nicolas](/forum/user/63-nicolas "View nicolas's Profile").

The following user(s) said Thank You: [lapinrouge](/forum/user/11909-lapinrouge "View lapinrouge's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzUtc3VwcG9ydC1lbi1mcmFuY2Fpcy1mcmVuY2gtc3VwcG9ydC0vOTA2OTYzLXJlY3VwZXJlci1sZS1jYS1ob3JzLXRheGU/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.042 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
