mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-15 05:51:28 +01:00
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:
@@ -607,7 +607,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
|
|||||||
$maskraz=$yearoffsettype; // For backward compatibility
|
$maskraz=$yearoffsettype; // For backward compatibility
|
||||||
else if ($yearoffsettype === '0' || (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $conf->global->SOCIETE_FISCAL_MONTH_START > 1))
|
else if ($yearoffsettype === '0' || (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $conf->global->SOCIETE_FISCAL_MONTH_START > 1))
|
||||||
$maskraz = $conf->global->SOCIETE_FISCAL_MONTH_START;
|
$maskraz = $conf->global->SOCIETE_FISCAL_MONTH_START;
|
||||||
//print "maskraz=".$maskraz;
|
//print "maskraz=".$maskraz; // -1=no reset
|
||||||
|
|
||||||
if ($maskraz > 0) // A reset is required
|
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."')";
|
$sqlwhere.='(SUBSTRING('.$field.', '.(dol_strlen($reg[1])+1).', '.dol_strlen($reg[2]).") = '".$yearcomp."')";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//print "sqlwhere=".$sqlwhere."<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." yearcomp=".$yearcomp."<br>\n";
|
//print "masktri=".$masktri." maskcounter=".$maskcounter." maskraz=".$maskraz." maskoffset=".$maskoffset."<br>\n";
|
||||||
|
|
||||||
// Define $sqlstring
|
// Define $sqlstring
|
||||||
$posnumstart=strpos($maskwithnocode,$maskcounter); // Pos of counter in final string (from 0 to ...)
|
$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;
|
$counter = $obj->val;
|
||||||
}
|
}
|
||||||
else dol_print_error($db);
|
else dol_print_error($db);
|
||||||
|
|
||||||
|
// Check if we must force counter to maskoffset
|
||||||
if (empty($counter) || preg_match('/[^0-9]/i',$counter)) $counter=$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.
|
if ($mode == 'last') // We found value for counter = last counter value. Now need to get corresponding ref of invoice.
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -211,6 +211,10 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase
|
|||||||
print __METHOD__." is_erasable=".$result."\n";
|
print __METHOD__." is_erasable=".$result."\n";
|
||||||
$this->assertEquals(1, $result); // Case 1 can be deleted (because there was a reset for case 2)
|
$this->assertEquals(1, $result); // Case 1 can be deleted (because there was a reset for case 2)
|
||||||
|
|
||||||
|
// Try an offset when an invoice already exists
|
||||||
|
$conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000+9990}';
|
||||||
|
$conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000+9990}';
|
||||||
|
$result=$numbering->getNextValue($mysoc, $localobject2);
|
||||||
|
|
||||||
// Now we try with a different fiscal month (forced by mask)
|
// Now we try with a different fiscal month (forced by mask)
|
||||||
$conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@6}';
|
$conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@6}';
|
||||||
|
|||||||
Reference in New Issue
Block a user