From 919a7cd4a616371aa31d141ba4022e098c478fde Mon Sep 17 00:00:00 2001 From: Peter Fontaine Date: Sun, 19 Jan 2014 14:21:11 +0100 Subject: [PATCH 1/5] Fix: add civilite_id field in contact when create new third party. --- htdocs/societe/class/societe.class.php | 1 + htdocs/societe/soc.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 941a5445ff1..4f00cef5f9f 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -303,6 +303,7 @@ class Societe extends CommonObject $contact->name = $this->name_bis; $contact->firstname = $this->firstname; + $contact->civilite_id = $this->civility_id; $contact->socid = $this->id; // fk_soc $contact->statut = 1; $contact->priv = 0; diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 5e1a6ed40d7..5b1cca98c77 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -118,7 +118,7 @@ if (empty($reshook)) $object->particulier = GETPOST("private"); $object->name = dolGetFirstLastname(GETPOST('firstname'),GETPOST('nom')?GETPOST('nom'):GETPOST('name')); - $object->civilite_id = GETPOST('civilite_id'); + $object->civility_id = GETPOST('civilite_id'); // Add non official properties $object->name_bis = GETPOST('name')?GETPOST('name'):GETPOST('nom'); $object->firstname = GETPOST('firstname'); From 5b6b8f1d5b0bef45e8bf93d2e20fbe93be29d2ee Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 20 Jan 2014 11:20:38 +0100 Subject: [PATCH 2/5] Fix: Support for reset everymonth (@99 into numbering mask) was ko when changing year. --- htdocs/core/lib/functions2.lib.php | 2 +- test/phpunit/NumberingModulesTest.php | 47 ++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 22b90ef52e0..3fc40f8c8fe 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -629,7 +629,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m if ($maskraz > 0) // A reset is required { if ($maskraz == 99) { - $maskraz = date('m'); + $maskraz = date('m', $date); $resetEveryMonth = true; } if ($maskraz > 12) return 'ErrorBadMaskBadRazMonth'; diff --git a/test/phpunit/NumberingModulesTest.php b/test/phpunit/NumberingModulesTest.php index 66110c1f683..6d52e65910c 100644 --- a/test/phpunit/NumberingModulesTest.php +++ b/test/phpunit/NumberingModulesTest.php @@ -490,12 +490,57 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $localobject=new Facture($this->savdb); $localobject->initAsSpecimen(); - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1971); // we use different discal year but same year + $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1971); // we use different fiscal year but same year $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); print __METHOD__." result=".$result."\n"; $this->assertEquals('197212-0001', $result); // counter must be reset to 1 + // Now we try with a reset every month (@99) + $conf->global->SOCIETE_FISCAL_MONTH_START=6; + $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@99}'; + $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@99}'; + + $localobject=new Facture($this->savdb); + $localobject->initAsSpecimen(); + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1980); // we use year 1980 to be sure to not have existing invoice for this year + $numbering=new mod_facture_mercure(); + $result=$numbering->getNextValue($mysoc, $localobject); + $result2=$localobject->create($user,1); + $result3=$localobject->validate($user, $result); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('198001-0001', $result); // counter must start to 1 + + $localobject=new Facture($this->savdb); + $localobject->initAsSpecimen(); + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1980); // we use year 1980 to be sure to not have existing invoice for this year + $numbering=new mod_facture_mercure(); + $result=$numbering->getNextValue($mysoc, $localobject); + $result2=$localobject->create($user,1); + $result3=$localobject->validate($user, $result); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('198001-0002', $result); // counter must start to 2 + + $localobject=new Facture($this->savdb); + $localobject->initAsSpecimen(); + $localobject->date=dol_mktime(12, 0, 0, 2, 1, 1980); // we use year 1980 to be sure to not have existing invoice for this year + $numbering=new mod_facture_mercure(); + $result=$numbering->getNextValue($mysoc, $localobject); + $result2=$localobject->create($user,1); + $result3=$localobject->validate($user, $result); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('198002-0001', $result); // counter must start to 1 + + $localobject=new Facture($this->savdb); + $localobject->initAsSpecimen(); + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1981); // we use year 1981 to be sure to not have existing invoice for this year + $numbering=new mod_facture_mercure(); + $result=$numbering->getNextValue($mysoc, $localobject); + $result2=$localobject->create($user,1); + $result3=$localobject->validate($user, $result); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('198101-0001', $result); // counter must start to 1 + return $result; } From 60e616f63eaac96c23a12707f8b178c8c2133dea Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Tue, 21 Jan 2014 10:29:35 +0100 Subject: [PATCH 3/5] Fix : big bug while importing thirds, codes were not properly set or not imported --- htdocs/core/modules/import/import_csv.modules.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index e0741c26cef..f0766e271e5 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -443,7 +443,7 @@ class ImportCsv extends ModeleImports } elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getcustomercodeifnull') { - if (empty($newval) || $newval='auto') + if (empty($newval) || $newval=='auto') { $this->thirpartyobject->get_codeclient(0,0); $newval=$this->thirpartyobject->code_client; @@ -452,7 +452,7 @@ class ImportCsv extends ModeleImports } elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getsuppliercodeifnull') { - if (empty($newval) || $newval='auto') + if (empty($newval) || $newval=='auto') { $newval=$this->thirpartyobject->get_codefournisseur(0,1); $newval=$this->thirpartyobject->code_fournisseur; @@ -461,7 +461,7 @@ class ImportCsv extends ModeleImports } elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getcustomeraccountancycodeifnull') { - if (empty($newval) || $newval='auto') + if (empty($newval) || $newval=='auto') { $this->thirpartyobject->get_codecompta('customer'); $newval=$this->thirpartyobject->code_compta; @@ -470,7 +470,7 @@ class ImportCsv extends ModeleImports } elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getsupplieraccountancycodeifnull') { - if (empty($newval) || $newval='auto') + if (empty($newval) || $newval=='auto') { $this->thirpartyobject->get_codecompta('supplier'); $newval=$this->thirpartyobject->code_compta_fournisseur; From d7e111b3bda409038eaf1310e56277bbb79cc52f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 21 Jan 2014 12:53:27 +0100 Subject: [PATCH 4/5] Fix: Missing parent tables --- htdocs/product/class/product.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 715bbcbdba8..faa7223daea 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -36,7 +36,7 @@ class Product extends CommonObject public $element='product'; public $table_element='product'; public $fk_element='fk_product'; - protected $childtables=array('propaldet','commandedet','facturedet','contratdet'); // To test if we can delete object + protected $childtables=array('propaldet','commandedet','facturedet','contratdet','facture_fourn_det','commande_fournisseurdet'); // To test if we can delete object protected $isnolinkedbythird = 1; // No field fk_soc protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe From 46926aa6855eb3107c56afeaab0cd5ff8bd2cbd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o?= Date: Tue, 21 Jan 2014 00:54:26 +0100 Subject: [PATCH 5/5] Fix: modBarcode issue with blank list in conf (?) Custom DB prefix not working with barcode module ? Might help. --- htdocs/core/modules/modBarcode.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/modules/modBarcode.class.php b/htdocs/core/modules/modBarcode.class.php index 856f4251e9c..0564adb762b 100644 --- a/htdocs/core/modules/modBarcode.class.php +++ b/htdocs/core/modules/modBarcode.class.php @@ -111,12 +111,12 @@ class modBarcode extends DolibarrModules $this->remove($options); $sql = array( - array('sql'=>"INSERT INTO llx_c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN8', 'EAN8', 0, '1234567', __ENTITY__)",'ignoreerror'=>1), - array('sql'=>"INSERT INTO llx_c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN13', 'EAN13', 0, '123456789012', __ENTITY__)",'ignoreerror'=>1), - array('sql'=>"INSERT INTO llx_c_barcode_type (code, libelle, coder, example, entity) VALUES ('UPC', 'UPC', 0, '123456789012', __ENTITY__)",'ignoreerror'=>1), - array('sql'=>"INSERT INTO llx_c_barcode_type (code, libelle, coder, example, entity) VALUES ('ISBN', 'ISBN', 0, '123456789', __ENTITY__)",'ignoreerror'=>1), - array('sql'=>"INSERT INTO llx_c_barcode_type (code, libelle, coder, example, entity) VALUES ('C39', 'Code 39', 0, '1234567890', __ENTITY__)",'ignoreerror'=>1), - array('sql'=>"INSERT INTO llx_c_barcode_type (code, libelle, coder, example, entity) VALUES ('C128', 'Code 128', 0, 'ABCD1234567890', __ENTITY__)",'ignoreerror'=>1) + array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN8', 'EAN8', 0, '1234567', __ENTITY__)",'ignoreerror'=>1), + array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN13', 'EAN13', 0, '123456789012', __ENTITY__)",'ignoreerror'=>1), + array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('UPC', 'UPC', 0, '123456789012', __ENTITY__)",'ignoreerror'=>1), + array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('ISBN', 'ISBN', 0, '123456789', __ENTITY__)",'ignoreerror'=>1), + array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('C39', 'Code 39', 0, '1234567890', __ENTITY__)",'ignoreerror'=>1), + array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('C128', 'Code 128', 0, 'ABCD1234567890', __ENTITY__)",'ignoreerror'=>1) ); return $this->_init($sql, $options);