Fix module Intracomm

This commit is contained in:
Alexandre SPANGARO 2020-12-17 06:02:28 +01:00
parent b7876f54cf
commit 440c9e4840
3 changed files with 15 additions and 17 deletions

View File

@ -62,10 +62,10 @@ class modIntracommreport extends DolibarrModules
$this->config_page_url = array("intracommreport.php@intracommreport"); $this->config_page_url = array("intracommreport.php@intracommreport");
// Dependencies // 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->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->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->need_dolibarr_version = array(13, 0, -5); // Minimum version of Dolibarr required by module
$this->langfiles = array("intracommreport"); $this->langfiles = array("intracommreport");

View File

@ -159,9 +159,8 @@ print "</tr>\n";
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("INTRACOMMREPORT_CATEG_FRAISDEPORT").'</td>'; print '<td>'.$langs->trans("INTRACOMMREPORT_CATEG_FRAISDEPORT").'</td>';
$arraychoices = array(3=>'Seuil de 460 000 €', 4=>'En dessous de 460 000 €');
print '<td>'; print '<td>';
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 '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
@ -193,10 +192,8 @@ foreach ($list_DES as $key)
print '</table>'; print '</table>';
print '<div class="tabsAction">'; print '<div class="center">';
print '<div class="inline-block divButAction">'; print '<input type="submit" name="bt_save" class="butAction button-save" value="'.$langs->trans("Update").'" />';
print '<input type="submit" name="bt_save" class="butAction button-save" value="'.$langs->trans("Save").'" />';
print '</div>';
print '</div>'; print '</div>';
print '</form>'; print '</form>';

View File

@ -286,13 +286,13 @@ class IntracommReport extends CommonObject
global $mysoc, $conf; global $mysoc, $conf;
if ($type == 'expedition' || $exporttype == 'des') { 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 = 'facture';
$table_extraf = 'facture_extrafields'; $table_extraf = 'facture_extrafields';
$tabledet = 'facturedet'; $tabledet = 'facturedet';
$field_link = 'fk_facture'; $field_link = 'fk_facture';
} else { // Introduction } 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 = 'facture_fourn';
$table_extraf = 'facture_fourn_extrafields'; $table_extraf = 'facture_fourn_extrafields';
$tabledet = 'facture_fourn_det'; $tabledet = 'facture_fourn_det';
@ -338,14 +338,15 @@ class IntracommReport extends CommonObject
$code_douane = $code_douane_spe; $code_douane = $code_douane_spe;
} }
$cn8->addChild('CN8Code', $code_douane); $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('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('netMass', $res->weight * $res->qty); // Poids du produit
$item->addChild('quantityInSU', $res->qty); // Quantité de produit dans la ligne $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('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'); $item->addChild('statisticalProcedureCode', '11');
$nature_of_transaction = $item->addChild('NatureOfTransaction'); $nature_of_transaction = $item->addChild('NatureOfTransaction');
$nature_of_transaction->addChild('natureOfTransactionACode', 1); $nature_of_transaction->addChild('natureOfTransactionACode', 1);
@ -389,7 +390,7 @@ class IntracommReport extends CommonObject
$table = 'facture'; $table = 'facture';
$tabledet = 'facturedet'; $tabledet = 'facturedet';
$field_link = 'fk_facture'; $field_link = 'fk_facture';
$more_sql = 'f.facnumber'; $more_sql = 'f.ref';
} else { // Introduction } else { // Introduction
$table = 'facture_fourn'; $table = 'facture_fourn';
$tabledet = 'facture_fourn_det'; $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) INNER JOIN '.MAIN_DB_PREFIX.'product p ON (p.rowid = d.fk_product)
WHERE d.fk_product IS NOT NULL WHERE d.fk_product IS NOT NULL
AND f.entity = '.$conf->entity.' AND f.entity = '.$conf->entity.'
AND '.$more_sql.' = "'.$res->facnumber.'" AND '.$more_sql.' = "'.$res->refinvoice.'"
AND d.total_ht = AND d.total_ht =
( (
SELECT MAX(d.total_ht) SELECT MAX(d.total_ht)
FROM '.MAIN_DB_PREFIX.$tabledet.' d FROM '.MAIN_DB_PREFIX.$tabledet.' d
INNER JOIN '.MAIN_DB_PREFIX.$table.' f ON (f.rowid = d.'.$field_link.') INNER JOIN '.MAIN_DB_PREFIX.$table.' f ON (f.rowid = d.'.$field_link.')
WHERE d.fk_product IS NOT NULL WHERE d.fk_product IS NOT NULL
AND '.$more_sql.' = "'.$res->facnumber.'" AND '.$more_sql.' = "'.$res->refinvoice.'"
AND d.fk_product NOT IN AND d.fk_product NOT IN
( (
SELECT fk_product SELECT fk_product