From 655d55eae66c75e00b6863e7ce6c3938da21f6ef Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 7 Jul 2018 02:46:56 +0200 Subject: [PATCH 1/5] Add customer accountancy code on deposit slips export --- htdocs/core/modules/modBanque.class.php | 32 ++++++++++++------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/htdocs/core/modules/modBanque.class.php b/htdocs/core/modules/modBanque.class.php index 6b25e2c8254..602085b9f5a 100644 --- a/htdocs/core/modules/modBanque.class.php +++ b/htdocs/core/modules/modBanque.class.php @@ -63,9 +63,9 @@ class modBanque extends DolibarrModules // Data directories to create when module is enabled $this->dirs = array("/banque/temp"); - // Config pages - //------------- - $this->config_page_url = array("bank.php"); + // Config pages + //------------- + $this->config_page_url = array("bank.php"); // Dependancies $this->depends = array(); @@ -160,11 +160,11 @@ class modBanque extends DolibarrModules 'b.datec'=>"account","bu.url_id"=>"company","s.nom"=>"company","s.code_compta"=>"company","s.code_compta_fournisseur"=>"company" ); $this->export_special_array[$r]=array('-b.amount'=>'NULLIFNEG','b.amount'=>'NULLIFNEG'); - if (empty($conf->fournisseur->enabled)) - { - unset($this->export_fields_array[$r]['s.code_compta_fournisseur']); - unset($this->export_entities_array[$r]['s.code_compta_fournisseur']); - } + if (empty($conf->fournisseur->enabled)) + { + unset($this->export_fields_array[$r]['s.code_compta_fournisseur']); + unset($this->export_entities_array[$r]['s.code_compta_fournisseur']); + } $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'bank_account as ba, '.MAIN_DB_PREFIX.'bank as b)'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."bank_url as bu ON (bu.fk_bank = b.rowid AND bu.type = 'company')"; @@ -178,10 +178,10 @@ class modBanque extends DolibarrModules $this->export_label[$r]='Bordereaux remise Chq/Fact'; $this->export_permission[$r]=array(array("banque","export")); $this->export_fields_array[$r]=array("bch.rowid"=>"DepositId","bch.ref"=>"Numero","bch.ref_ext"=>"RefExt",'ba.ref'=>'AccountRef','ba.label'=>'AccountLabel','b.datev'=>'DateValue','b.num_chq'=>'ChequeOrTransferNumber','b.amount'=>'Credit','b.num_releve'=>'AccountStatement','b.datec'=>"DateCreation", - "bch.date_bordereau"=>"Date","bch.amount"=>"Total","bch.nbcheque"=>"NbCheque","bu.url_id"=>"IdThirdParty","s.nom"=>"ThirdParty","f.facnumber"=>"InvoiceRef" + "bch.date_bordereau"=>"Date","bch.amount"=>"Total","bch.nbcheque"=>"NbCheque","bu.url_id"=>"IdThirdParty","s.nom"=>"ThirdParty","s.code_compta"=>"CustomerAccountancyCode","f.facnumber"=>"InvoiceRef" ); $this->export_TypeFields_array[$r]=array('ba.ref'=>'Text','ba.label'=>'Text','b.datev'=>'Date','b.num_chq'=>'Text','b.amount'=>'Numeric','b.num_releve'=>'Text','b.datec'=>"Date", - "bch.date_bordereau"=>"Date","bch.rowid"=>"Numeric","bch.ref"=>"Numeric","bch.ref_ext"=>"Text","bch.amount"=>"Numeric","bch.nbcheque"=>"Numeric","bu.url_id"=>"Text","s.nom"=>"Text","f.facnumber"=>"Text" + "bch.date_bordereau"=>"Date","bch.rowid"=>"Numeric","bch.ref"=>"Numeric","bch.ref_ext"=>"Text","bch.amount"=>"Numeric","bch.nbcheque"=>"Numeric","bu.url_id"=>"Text","s.nom"=>"Text","s.code_compta"=>"Text","f.facnumber"=>"Text" ); $this->export_entities_array[$r]=array('ba.ref'=>'account','ba.label'=>'account','b.datev'=>'account','b.num_chq'=>'account','b.amount'=>'account','b.num_releve'=>'account','b.datec'=>"account", "bu.url_id"=>"company","s.nom"=>"company","s.code_compta"=>"company","s.code_compta_fournisseur"=>"company","f.facnumber"=>"invoice"); @@ -203,12 +203,12 @@ class modBanque extends DolibarrModules } - /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories. - * - * @param string $options Options when enabling module ('', 'noboxes') + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories. + * + * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ function init($options='') From 1522a5b22d5a89f37015dd0af293e96afbe4371f Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 7 Jul 2018 08:43:59 +0200 Subject: [PATCH 2/5] Fix: differentiate customer prices from supplier prices sharing --- htdocs/core/class/html.form.class.php | 2 +- htdocs/fourn/class/fournisseur.product.class.php | 2 +- htdocs/product/class/product.class.php | 4 ++-- htdocs/product/class/productcustomerprice.class.php | 4 ++++ htdocs/product/stock/productlot_list.php | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 8e28e77d185..e89801563c3 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2654,7 +2654,7 @@ class Form $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON pfp.fk_soc = s.rowid"; - $sql.= " WHERE pfp.entity IN (".getEntity('productprice').")"; + $sql.= " WHERE pfp.entity IN (".getEntity('productresellerprice').")"; $sql.= " AND p.tobuy = 1"; $sql.= " AND s.fournisseur = 1"; $sql.= " AND p.rowid = ".$productid; diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 050d2867cf4..8ff31609b54 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -530,7 +530,7 @@ class ProductFournisseur extends Product $sql.= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql.= ", ".MAIN_DB_PREFIX."societe as s"; - $sql.= " WHERE pfp.entity IN (".getEntity('productprice').")"; + $sql.= " WHERE pfp.entity IN (".getEntity('productresellerprice').")"; $sql.= " AND pfp.fk_soc = s.rowid"; $sql.= " AND s.status=1"; // only enabled company selected $sql.= " AND pfp.fk_product = ".$prodid; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 7d7cbf7c282..eb959b06493 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3081,7 +3081,7 @@ class Product extends CommonObject $sql.= " WHERE fk_soc = ".$id_fourn; $sql.= " AND ref_fourn = '".$this->db->escape($ref_fourn)."'"; $sql.= " AND fk_product != ".$this->id; - $sql.= " AND entity IN (".getEntity('productprice').")"; + $sql.= " AND entity IN (".getEntity('productresellerprice').")"; $resql=$this->db->query($sql); if ($resql) @@ -3104,7 +3104,7 @@ class Product extends CommonObject else $sql.= " AND (ref_fourn = '' OR ref_fourn IS NULL)"; $sql.= " AND quantity = '".$quantity."'"; $sql.= " AND fk_product = ".$this->id; - $sql.= " AND entity IN (".getEntity('productprice').")"; + $sql.= " AND entity IN (".getEntity('productresellerprice').")"; $resql=$this->db->query($sql); if ($resql) diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index 5b41cb0f02b..096b4725531 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -341,6 +341,8 @@ class Productcustomerprice extends CommonObject $sql .= " WHERE soc.rowid=t.fk_soc "; $sql .= " AND prod.rowid=t.fk_product "; $sql .= " AND prod.entity IN (" . getEntity('product') . ")"; + $sql .= " AND t.entity IN (" . getEntity('productprice') . ")"; + $sql .= " AND soc.entity IN (" . getEntity('societe') . ")"; // Manage filter if (count($filter) > 0) { @@ -450,6 +452,8 @@ class Productcustomerprice extends CommonObject $sql .= " WHERE soc.rowid=t.fk_soc "; $sql .= " AND prod.rowid=t.fk_product "; $sql .= " AND prod.entity IN (" . getEntity('product') . ")"; + $sql .= " AND t.entity IN (" . getEntity('productprice') . ")"; + $sql .= " AND soc.entity IN (" . getEntity('societe') . ")"; // Manage filter if (count($filter) > 0) { diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 7c15b3fa7c5..874d5676e1f 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -218,7 +218,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."product_lot as t"; if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot_extrafields as ef on (t.rowid = ef.fk_object)"; $sql.= ", ".MAIN_DB_PREFIX."product as p"; $sql.= " WHERE p.rowid = t.fk_product"; -//$sql.= " WHERE u.entity IN (".getEntity('productlot').")"; +$sql.= " WHERE p.entity IN (".getEntity('product').")"; if ($search_entity) $sql.= natural_search("entity",$search_entity); if ($search_product) $sql.= natural_search("p.ref",$search_product); From e8afd7e833ca4ffb77d638da0a278d011cc7ed9d Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 7 Jul 2018 08:48:26 +0200 Subject: [PATCH 3/5] Fix: use "supplier" instead "reseller" --- htdocs/core/class/html.form.class.php | 2 +- htdocs/fourn/class/fournisseur.product.class.php | 2 +- htdocs/product/class/product.class.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index e89801563c3..c03de343489 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2654,7 +2654,7 @@ class Form $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON pfp.fk_soc = s.rowid"; - $sql.= " WHERE pfp.entity IN (".getEntity('productresellerprice').")"; + $sql.= " WHERE pfp.entity IN (".getEntity('productsupplierprice').")"; $sql.= " AND p.tobuy = 1"; $sql.= " AND s.fournisseur = 1"; $sql.= " AND p.rowid = ".$productid; diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 8ff31609b54..5c50597195a 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -530,7 +530,7 @@ class ProductFournisseur extends Product $sql.= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql.= ", ".MAIN_DB_PREFIX."societe as s"; - $sql.= " WHERE pfp.entity IN (".getEntity('productresellerprice').")"; + $sql.= " WHERE pfp.entity IN (".getEntity('productsupplierprice').")"; $sql.= " AND pfp.fk_soc = s.rowid"; $sql.= " AND s.status=1"; // only enabled company selected $sql.= " AND pfp.fk_product = ".$prodid; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index eb959b06493..c271346d4bc 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3081,7 +3081,7 @@ class Product extends CommonObject $sql.= " WHERE fk_soc = ".$id_fourn; $sql.= " AND ref_fourn = '".$this->db->escape($ref_fourn)."'"; $sql.= " AND fk_product != ".$this->id; - $sql.= " AND entity IN (".getEntity('productresellerprice').")"; + $sql.= " AND entity IN (".getEntity('productsupplierprice').")"; $resql=$this->db->query($sql); if ($resql) @@ -3104,7 +3104,7 @@ class Product extends CommonObject else $sql.= " AND (ref_fourn = '' OR ref_fourn IS NULL)"; $sql.= " AND quantity = '".$quantity."'"; $sql.= " AND fk_product = ".$this->id; - $sql.= " AND entity IN (".getEntity('productresellerprice').")"; + $sql.= " AND entity IN (".getEntity('productsupplierprice').")"; $resql=$this->db->query($sql); if ($resql) From 551e2efe8666ee9dfe2b2f6a64f8e92d549d0f0b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Jul 2018 17:03:55 +0200 Subject: [PATCH 4/5] Update productcustomerprice.class.php --- htdocs/product/class/productcustomerprice.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index 096b4725531..c5f5a1a0e6b 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -342,8 +342,7 @@ class Productcustomerprice extends CommonObject $sql .= " AND prod.rowid=t.fk_product "; $sql .= " AND prod.entity IN (" . getEntity('product') . ")"; $sql .= " AND t.entity IN (" . getEntity('productprice') . ")"; - $sql .= " AND soc.entity IN (" . getEntity('societe') . ")"; - + // Manage filter if (count($filter) > 0) { foreach ( $filter as $key => $value ) { From d5cb2fc4cdec8d813f033f25b0429692fd1b3a55 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Jul 2018 17:04:50 +0200 Subject: [PATCH 5/5] Update productcustomerprice.class.php --- htdocs/product/class/productcustomerprice.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index c5f5a1a0e6b..fdff7b1fe6d 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -452,7 +452,6 @@ class Productcustomerprice extends CommonObject $sql .= " AND prod.rowid=t.fk_product "; $sql .= " AND prod.entity IN (" . getEntity('product') . ")"; $sql .= " AND t.entity IN (" . getEntity('productprice') . ")"; - $sql .= " AND soc.entity IN (" . getEntity('societe') . ")"; // Manage filter if (count($filter) > 0) {