FIX is_erasable report bad value when thirdparty was not loaded

This commit is contained in:
Laurent Destailleur 2017-10-04 03:22:41 +02:00
parent 7cf4ec772a
commit 436ec93084
3 changed files with 9 additions and 5 deletions

View File

@ -1753,9 +1753,9 @@ class Facture extends CommonInvoice
global $langs,$conf;
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
if (empty($rowid)) $rowid=$this->id;
$rowid=$this->id;
dol_syslog(get_class($this)."::delete rowid=".$rowid, LOG_DEBUG);
dol_syslog(get_class($this)."::delete rowid=".$rowid.", ref=".$this->ref.", thirdparty=".$this->thirdparty->name, LOG_DEBUG);
// Test to avoid invoice deletion (allowed if draft)
$test = $this->is_erasable();
@ -3227,7 +3227,7 @@ class Facture extends CommonInvoice
if (! empty($conf->global->FACTURE_ADDON))
{
dol_syslog("Call getNextNumRef with FACTURE_ADDON = ".$conf->global->FACTURE_ADDON);
dol_syslog("Call getNextNumRef with FACTURE_ADDON = ".$conf->global->FACTURE_ADDON.", thirdparty=".$soc->nom.", type=".$soc->typent_code, LOG_DEBUG);
$mybool=false;
@ -3399,6 +3399,9 @@ class Facture extends CommonInvoice
// If not a draft invoice and not temporary invoice
if ($tmppart !== 'PROV')
{
// We need to have this->thirdparty defined, in case of numbering rule use tags that depend on thirdparty (like {t} tag).
if (empty($this->thirdparty)) $this->fetch_thirdparty();
$maxfacnumber = $this->getNextNumRef($this->thirdparty,'last');
$ventilExportCompta = $this->getVentilExportCompta();

View File

@ -723,7 +723,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
// but we should use local year and month of user
// For debugging
dol_syslog("mask=".$mask);
//dol_syslog("mask=".$mask, LOG_DEBUG);
//include_once(DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php');
//$mask='FA{yy}{mm}-{0000@99}';
//$date=dol_mktime(12, 0, 0, 1, 1, 1900);
@ -1148,6 +1148,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
dol_syslog("functions2::get_next_value return ".$numFinal,LOG_DEBUG);
return $numFinal;
}
function get_string_between($string, $start, $end){
$string = " ".$string;
$ini = strpos($string,$start);
@ -1156,6 +1157,7 @@ function get_string_between($string, $start, $end){
$len = strpos($string,$end,$ini) - $ini;
return substr($string,$ini,$len);
}
/**
* Check value
*

View File

@ -135,7 +135,6 @@ class FactureTest extends PHPUnit_Framework_TestCase
$localobject=new Facture($this->savdb);
$localobject->initAsSpecimen();
$result=$localobject->create($user);
$this->assertLessThan($result, 0);
print __METHOD__." result=".$result."\n";
return $result;