From 440c9e48404dd38330235c2670967a8cb6591b19 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 17 Dec 2020 06:02:28 +0100 Subject: [PATCH] Fix module Intracomm --- .../core/modules/modIntracommreport.class.php | 4 ++-- .../intracommreport/admin/intracommreport.php | 9 +++------ .../class/intracommreport.class.php | 19 ++++++++++--------- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/htdocs/core/modules/modIntracommreport.class.php b/htdocs/core/modules/modIntracommreport.class.php index 668cf7af875..da1bda58c48 100644 --- a/htdocs/core/modules/modIntracommreport.class.php +++ b/htdocs/core/modules/modIntracommreport.class.php @@ -62,10 +62,10 @@ class modIntracommreport extends DolibarrModules $this->config_page_url = array("intracommreport.php@intracommreport"); // Dependencies - $this->depends = array("modFacture", "modTax"); // List of modules id that must be enabled if this module is enabled + $this->depends = array("modFacture", "modTax", "modCategorie"); // List of modules id that must be enabled if this module is enabled $this->requiredby = array(); // List of modules id to disable if this one is disabled $this->conflictwith = array(); // List of modules id this module is in conflict with - $this->phpmin = array(5, 5); // Minimum version of PHP required by module + $this->phpmin = array(5, 6); // Minimum version of PHP required by module $this->need_dolibarr_version = array(13, 0, -5); // Minimum version of Dolibarr required by module $this->langfiles = array("intracommreport"); diff --git a/htdocs/intracommreport/admin/intracommreport.php b/htdocs/intracommreport/admin/intracommreport.php index 9947e844e40..16e24503959 100644 --- a/htdocs/intracommreport/admin/intracommreport.php +++ b/htdocs/intracommreport/admin/intracommreport.php @@ -159,9 +159,8 @@ print "\n"; print ''; print ''.$langs->trans("INTRACOMMREPORT_CATEG_FRAISDEPORT").''; -$arraychoices = array(3=>'Seuil de 460 000 €', 4=>'En dessous de 460 000 €'); print ''; -print $formother->select_categories(0, $conf->global->INTRACOMMREPORT_CATEG_FRAISDEPORT, 'INTRACOMMREPORT_CATEG_FRAISDEPORT'); +print $formother->select_categories('product', $conf->global->INTRACOMMREPORT_CATEG_FRAISDEPORT, 'INTRACOMMREPORT_CATEG_FRAISDEPORT'); print ''; print "\n"; @@ -193,10 +192,8 @@ foreach ($list_DES as $key) print ''; -print '
'; -print '
'; -print ''; -print '
'; +print '
'; +print ''; print '
'; print ''; diff --git a/htdocs/intracommreport/class/intracommreport.class.php b/htdocs/intracommreport/class/intracommreport.class.php index 0cf5a71c27a..1c5cf3d0a29 100644 --- a/htdocs/intracommreport/class/intracommreport.class.php +++ b/htdocs/intracommreport/class/intracommreport.class.php @@ -286,13 +286,13 @@ class IntracommReport extends CommonObject global $mysoc, $conf; if ($type == 'expedition' || $exporttype == 'des') { - $sql = 'SELECT f.facnumber, f.total as total_ht'; + $sql = 'SELECT f.ref as refinvoice, f.total as total_ht'; $table = 'facture'; $table_extraf = 'facture_extrafields'; $tabledet = 'facturedet'; $field_link = 'fk_facture'; } else { // Introduction - $sql = 'SELECT f.ref_supplier as facnumber, f.total_ht'; + $sql = 'SELECT f.ref_supplier as refinvoice, f.total_ht'; $table = 'facture_fourn'; $table_extraf = 'facture_fourn_extrafields'; $tabledet = 'facture_fourn_det'; @@ -338,14 +338,15 @@ class IntracommReport extends CommonObject $code_douane = $code_douane_spe; } $cn8->addChild('CN8Code', $code_douane); - if (!empty($res->tva_intra)) { - $item->addChild('partnerId', $res->tva_intra); - } $item->addChild('MSConsDestCode', $res->code); // code iso pays client + $item->addChild('countryOfOriginCode', substr($res->zip, 0, 2)); // code iso pays d'origine $item->addChild('netMass', $res->weight * $res->qty); // Poids du produit $item->addChild('quantityInSU', $res->qty); // Quantité de produit dans la ligne $item->addChild('invoicedAmount', round($res->total_ht)); // Montant total ht de la facture (entier attendu) - $item->addChild('invoicedNumber', $res->facnumber); // Numéro facture + // $item->addChild('invoicedNumber', $res->refinvoice); // Numéro facture + if (!empty($res->tva_intra)) { + $item->addChild('partnerId', $res->tva_intra); + } $item->addChild('statisticalProcedureCode', '11'); $nature_of_transaction = $item->addChild('NatureOfTransaction'); $nature_of_transaction->addChild('natureOfTransactionACode', 1); @@ -389,7 +390,7 @@ class IntracommReport extends CommonObject $table = 'facture'; $tabledet = 'facturedet'; $field_link = 'fk_facture'; - $more_sql = 'f.facnumber'; + $more_sql = 'f.ref'; } else { // Introduction $table = 'facture_fourn'; $tabledet = 'facture_fourn_det'; @@ -404,14 +405,14 @@ class IntracommReport extends CommonObject INNER JOIN '.MAIN_DB_PREFIX.'product p ON (p.rowid = d.fk_product) WHERE d.fk_product IS NOT NULL AND f.entity = '.$conf->entity.' - AND '.$more_sql.' = "'.$res->facnumber.'" + AND '.$more_sql.' = "'.$res->refinvoice.'" AND d.total_ht = ( SELECT MAX(d.total_ht) FROM '.MAIN_DB_PREFIX.$tabledet.' d INNER JOIN '.MAIN_DB_PREFIX.$table.' f ON (f.rowid = d.'.$field_link.') WHERE d.fk_product IS NOT NULL - AND '.$more_sql.' = "'.$res->facnumber.'" + AND '.$more_sql.' = "'.$res->refinvoice.'" AND d.fk_product NOT IN ( SELECT fk_product