2
0
forked from Wavyzz/dolibarr

Fix: Pb of offset in numbering. Add also phpunit test to detect and test

fix.

Conflicts:
	test/phpunit/NumberingModulesTest.php
This commit is contained in:
Laurent Destailleur
2013-06-06 21:25:10 +02:00
parent 4bc8cbc993
commit 693f4f3b8b
2 changed files with 15 additions and 8 deletions

View File

@@ -607,7 +607,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
$maskraz=$yearoffsettype; // For backward compatibility
else if ($yearoffsettype === '0' || (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $conf->global->SOCIETE_FISCAL_MONTH_START > 1))
$maskraz = $conf->global->SOCIETE_FISCAL_MONTH_START;
//print "maskraz=".$maskraz;
//print "maskraz=".$maskraz; // -1=no reset
if ($maskraz > 0) // A reset is required
{
@@ -699,8 +699,8 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
$sqlwhere.='(SUBSTRING('.$field.', '.(dol_strlen($reg[1])+1).', '.dol_strlen($reg[2]).") = '".$yearcomp."')";
}
}
//print "sqlwhere=".$sqlwhere."<br>\n";
//print "masktri=".$masktri." maskcounter=".$maskcounter." maskraz=".$maskraz." maskoffset=".$maskoffset." yearcomp=".$yearcomp."<br>\n";
//print "sqlwhere=".$sqlwhere." yearcomp=".$yearcomp."<br>\n"; // sqlwhere and yearcomp defined only if we ask a reset
//print "masktri=".$masktri." maskcounter=".$maskcounter." maskraz=".$maskraz." maskoffset=".$maskoffset."<br>\n";
// Define $sqlstring
$posnumstart=strpos($maskwithnocode,$maskcounter); // Pos of counter in final string (from 0 to ...)
@@ -739,7 +739,10 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
$counter = $obj->val;
}
else dol_print_error($db);
// Check if we must force counter to maskoffset
if (empty($counter) || preg_match('/[^0-9]/i',$counter)) $counter=$maskoffset;
else if ($counter < $maskoffset && empty($conf->global->MAIN_NUMBERING_OFFSET_ONLY_FOR_FIRST)) $counter=$maskoffset;
if ($mode == 'last') // We found value for counter = last counter value. Now need to get corresponding ref of invoice.
{
@@ -824,7 +827,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
}
else dol_print_error($db);
if (empty($maskrefclient_counter) || preg_match('/[^0-9]/i',$maskrefclient_counter)) $maskrefclient_counter=$maskrefclient_maskoffset;
$maskrefclient_counter++;
$maskrefclient_counter++;
}
// Build numFinal