Skip to content

Commit

Permalink
FIX is_erasable report bad value when thirdparty was not loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Oct 4, 2017
1 parent 7cf4ec7 commit 436ec93
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
9 changes: 6 additions & 3 deletions htdocs/compta/facture/class/facture.class.php
Expand Up @@ -1753,9 +1753,9 @@ function delete($user, $notrigger=0, $idwarehouse=-1)
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();
Expand Down Expand Up @@ -3227,7 +3227,7 @@ function getNextNumRef($soc,$mode='next')

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;

Expand Down Expand Up @@ -3399,6 +3399,9 @@ function is_erasable()
// 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();

Expand Down
4 changes: 3 additions & 1 deletion htdocs/core/lib/functions2.lib.php
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -1156,6 +1157,7 @@ function get_string_between($string, $start, $end){
$len = strpos($string,$end,$ini) - $ini;
return substr($string,$ini,$len);
}

/**
* Check value
*
Expand Down
1 change: 0 additions & 1 deletion test/phpunit/FactureTest.php
Expand Up @@ -135,7 +135,6 @@ public function testFactureCreate()
$localobject=new Facture($this->savdb);
$localobject->initAsSpecimen();
$result=$localobject->create($user);

$this->assertLessThan($result, 0);
print __METHOD__." result=".$result."\n";
return $result;
Expand Down

0 comments on commit 436ec93

Please sign in to comment.