Beautify instal pg.
Fix: Debian package Restore PHPUnit test (A PHP Unit test that fails should not be removed but fixed and be kept in error until fix is published. Otherwise, PHPUnit are useless). Conflicts: htdocs/install/fileconf.php htdocs/install/inc.php
This commit is contained in:
parent
e3d07621eb
commit
5d27fd61df
@ -1122,6 +1122,7 @@ class CommandeFournisseur extends CommonOrder
|
||||
if (empty($txtva)) $txtva=0;
|
||||
if (empty($txlocaltax1)) $txlocaltax1=0;
|
||||
if (empty($txlocaltax2)) $txlocaltax2=0;
|
||||
if (empty($remise_percent)) $remise_percent=0;
|
||||
|
||||
$remise_percent=price2num($remise_percent);
|
||||
$qty=price2num($qty);
|
||||
@ -1170,7 +1171,7 @@ class CommandeFournisseur extends CommonOrder
|
||||
$this->error="No price found for this quantity. Quantity may be too low ?";
|
||||
$this->db->rollback();
|
||||
dol_syslog(get_class($this)."::addline result=".$result." - ".$this->error, LOG_DEBUG);
|
||||
return -1; // FIXME this return status create an error in jenkins
|
||||
return -1;
|
||||
}
|
||||
if ($result < -1)
|
||||
{
|
||||
@ -1205,7 +1206,7 @@ class CommandeFournisseur extends CommonOrder
|
||||
$subprice = price2num($pu,'MU');
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseurdet";
|
||||
$sql.= " (fk_commande,label, description,";
|
||||
$sql.= " (fk_commande, label, description,";
|
||||
$sql.= " fk_product, product_type,";
|
||||
$sql.= " qty, tva_tx, localtax1_tx, localtax2_tx, remise_percent, subprice, ref,";
|
||||
$sql.= " total_ht, total_tva, total_localtax1, total_localtax2, total_ttc";
|
||||
@ -1806,24 +1807,19 @@ class CommandeFournisseur extends CommonOrder
|
||||
|
||||
$now=dol_now();
|
||||
|
||||
// Charge tableau des produits prodids
|
||||
$prodids = array();
|
||||
|
||||
// Find first product
|
||||
$prodid=0;
|
||||
$product=new ProductFournisseur($db);
|
||||
$sql = "SELECT rowid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product";
|
||||
$sql.= " WHERE entity IN (".getEntity('product', 1).")";
|
||||
|
||||
$sql.=$this->db->order("rowid","ASC");
|
||||
$sql.=$this->db->plimit(1);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num_prods = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num_prods)
|
||||
{
|
||||
$i++;
|
||||
$row = $this->db->fetch_row($resql);
|
||||
$prodids[$i] = $row[0];
|
||||
}
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$prodid = $obj->rowid;
|
||||
}
|
||||
|
||||
// Initialise parametres
|
||||
@ -1865,9 +1861,7 @@ class CommandeFournisseur extends CommonOrder
|
||||
$line->total_tva=19.6;
|
||||
$line->remise_percent=00;
|
||||
}
|
||||
$line->ref_fourn='SUPPLIER_REF_'.$xnbp;
|
||||
$prodid = rand(1, $num_prods);
|
||||
$line->fk_product=$prodids[$prodid];
|
||||
$line->fk_product=$prodid;
|
||||
|
||||
$this->lines[$xnbp]=$line;
|
||||
|
||||
|
||||
@ -30,8 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
|
||||
|
||||
|
||||
/**
|
||||
* \class ProductFournisseur
|
||||
* \brief Class to manage predefined suppliers products
|
||||
* Class to manage predefined suppliers products
|
||||
*/
|
||||
class ProductFournisseur extends Product
|
||||
{
|
||||
@ -146,7 +145,7 @@ class ProductFournisseur extends Product
|
||||
* @param string $charges costs affering to product
|
||||
* @param float $remise_percent Discount regarding qty (percent)
|
||||
* @param float $remise Discount regarding qty (amount)
|
||||
* @return int >0 if KO, >0 if OK
|
||||
* @return int <0 if KO, >=0 if OK
|
||||
*/
|
||||
function update_buyprice($qty, $buyprice, $user, $price_base_type, $fourn, $availability, $ref_fourn, $tva_tx, $charges=0, $remise_percent=0, $remise=0)
|
||||
{
|
||||
|
||||
@ -38,27 +38,27 @@ $langs->load("errors");
|
||||
|
||||
dolibarr_install_syslog("Fileconf: Entering fileconf.php page");
|
||||
|
||||
// You can force preselected values of the config step of Dolibarr by adding a file
|
||||
// install.forced.php into directory htdocs/install (This is the case with some wizard
|
||||
// installer like DoliWamp, DoliMamp or DoliBuntu).
|
||||
// We first init "forced values" to nothing.
|
||||
if (! isset($force_install_noedit)) $force_install_noedit=''; // 1=To block var specific to distrib, 2 to block all technical parameters
|
||||
if (! isset($force_install_type)) $force_install_type='';
|
||||
if (! isset($force_install_dbserver)) $force_install_dbserver='';
|
||||
if (! isset($force_install_port)) $force_install_port='';
|
||||
if (! isset($force_install_database)) $force_install_database='';
|
||||
if (! isset($force_install_prefix)) $force_install_prefix='';
|
||||
if (! isset($force_install_createdatabase)) $force_install_createdatabase='';
|
||||
if (! isset($force_install_databaselogin)) $force_install_databaselogin='';
|
||||
if (! isset($force_install_databasepass)) $force_install_databasepass='';
|
||||
if (! isset($force_install_databaserootlogin)) $force_install_databaserootlogin='';
|
||||
if (! isset($force_install_databaserootpass)) $force_install_databaserootpass='';
|
||||
// Now we load forced value from install.forced.php file.
|
||||
$useforcedwizard=false;
|
||||
$forcedfile="./install.forced.php";
|
||||
if ($conffile == "/etc/dolibarr/conf.php") $forcedfile="/etc/dolibarr/install.forced.php"; // Must be after inc.php
|
||||
if (@file_exists($forcedfile)) {
|
||||
$useforcedwizard=true; include_once $forcedfile;
|
||||
// You can force preselected values of the config step of Dolibarr by adding a file
|
||||
// install.forced.php into directory htdocs/install (This is the case with some wizard
|
||||
// installer like DoliWamp, DoliMamp or DoliBuntu).
|
||||
// We first init "forced values" to nothing.
|
||||
if (! isset($force_install_noedit)) $force_install_noedit=''; // 1=To block var specific to distrib, 2 to block all technical parameters
|
||||
if (! isset($force_install_type)) $force_install_type='';
|
||||
if (! isset($force_install_dbserver)) $force_install_dbserver='';
|
||||
if (! isset($force_install_port)) $force_install_port='';
|
||||
if (! isset($force_install_database)) $force_install_database='';
|
||||
if (! isset($force_install_prefix)) $force_install_prefix='';
|
||||
if (! isset($force_install_createdatabase)) $force_install_createdatabase='';
|
||||
if (! isset($force_install_databaselogin)) $force_install_databaselogin='';
|
||||
if (! isset($force_install_databasepass)) $force_install_databasepass='';
|
||||
if (! isset($force_install_databaserootlogin)) $force_install_databaserootlogin='';
|
||||
if (! isset($force_install_databaserootpass)) $force_install_databaserootpass='';
|
||||
// Now we load forced value from install.forced.php file.
|
||||
$useforcedwizard=false;
|
||||
$forcedfile="./install.forced.php";
|
||||
if ($conffile == "/etc/dolibarr/conf.php") $forcedfile="/etc/dolibarr/install.forced.php"; // Must be after inc.php
|
||||
if (@file_exists($forcedfile)) {
|
||||
$useforcedwizard=true; include_once $forcedfile;
|
||||
}
|
||||
|
||||
//$force_install_message='This is the message';
|
||||
|
||||
@ -30,6 +30,7 @@ if (! defined('DOL_INC_FOR_VERSION_ERROR')) define('DOL_INC_FOR_VERSION_ERROR','
|
||||
require_once '../filefunc.inc.php';
|
||||
|
||||
|
||||
|
||||
// Define DOL_DOCUMENT_ROOT and ADODB_PATH used for install/upgrade process
|
||||
if (! defined('DOL_DOCUMENT_ROOT')) define('DOL_DOCUMENT_ROOT', '..');
|
||||
if (! defined('ADODB_PATH'))
|
||||
@ -316,6 +317,8 @@ function pHeader($subtitle,$next,$action='set',$param='',$forcejqueryurl='')
|
||||
$langs->load("main");
|
||||
$langs->load("admin");
|
||||
|
||||
$jquerytheme='smoothness';
|
||||
|
||||
if ($forcejqueryurl)
|
||||
{
|
||||
$jQueryCustomPath = $forcejqueryurl;
|
||||
@ -327,8 +330,6 @@ function pHeader($subtitle,$next,$action='set',$param='',$forcejqueryurl='')
|
||||
$jQueryUiCustomPath = (defined('JS_JQUERY_UI') && constant('JS_JQUERY_UI')) ? JS_JQUERY_UI : false;
|
||||
}
|
||||
|
||||
$jquerytheme='smoothness';
|
||||
|
||||
// We force the content charset
|
||||
header("Content-type: text/html; charset=".$conf->file->character_set_client);
|
||||
|
||||
|
||||
@ -27,7 +27,8 @@ global $conf,$user,$langs,$db;
|
||||
//define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver
|
||||
require_once 'PHPUnit/Autoload.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/fourn/class/fournisseur.commande.class.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/fourn/class/fournisseur.commande.class.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/fourn/class/fournisseur.product.class.php';
|
||||
|
||||
if (empty($user->id))
|
||||
{
|
||||
@ -128,15 +129,61 @@ class CommandeFournisseurTest extends PHPUnit_Framework_TestCase
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new CommandeFournisseur($this->savdb);
|
||||
$localobject->initAsSpecimen();
|
||||
$result=$localobject->create($user);
|
||||
// Set supplier and product to use
|
||||
$socid=1;
|
||||
$prodid=1;
|
||||
$societe=new Societe($db);
|
||||
$societe->fetch($socid);
|
||||
$product=new ProductFournisseur($db);
|
||||
$product->fetch($prodid);
|
||||
|
||||
$quantity=10;
|
||||
$ref_fourn='SUPPLIER_REF_PHPUNIT';
|
||||
$tva_tx=19.6;
|
||||
|
||||
// Create supplier price
|
||||
$result=$product->add_fournisseur($user, $societe->id, $ref_fourn, $quantity); // This insert record with no value for price. Values are update later with update_buyprice
|
||||
$this->assertGreaterThanOrEqual(1, $result);
|
||||
$result=$product->update_buyprice($quantity, 10, $user, 'HT', $societe, '', $ref_fourn, $tva_tx, 0, 0);
|
||||
$this->assertGreaterThanOrEqual(0, $result);
|
||||
|
||||
// Create supplier order with a too low quantity
|
||||
$localobject=new CommandeFournisseur($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->lines=array(); // Overwrite lines of order
|
||||
$line=new CommandeFournisseurLigne($db);
|
||||
$line->desc=$langs->trans("Description")." specimen line too low";
|
||||
$line->qty=1; // So lower than $quantity
|
||||
$line->fk_product=$product->id;
|
||||
$line->ref_fourn=$ref_fourn;
|
||||
$localobject->lines[]=$line;
|
||||
|
||||
$result=$localobject->create($user);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
return $result;
|
||||
$this->assertEquals(-1, $result); // must be -1 because quantity is lower than minimum of supplier price
|
||||
|
||||
$sql="DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseur where ref=''";
|
||||
$db->query($sql);
|
||||
|
||||
// Create supplier order
|
||||
$localobject2=new CommandeFournisseur($db);
|
||||
$localobject2->initAsSpecimen(); // This create 5 lines of first product found for socid 1
|
||||
$localobject2->lines=array(); // Overwrite lines of order
|
||||
$line=new CommandeFournisseurLigne($db);
|
||||
$line->desc=$langs->trans("Description")." specimen line ok";
|
||||
$line->qty=10; // So enough quantity
|
||||
$line->fk_product=$product->id;
|
||||
$line->ref_fourn=$ref_fourn;
|
||||
$localobject2->lines[]=$line;
|
||||
|
||||
$result=$localobject2->create($user);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertGreaterThanOrEqual(0, $result);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* testCommandeFournisseurFetch
|
||||
*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user