forked from Wavyzz/dolibarr
Fix bad transaction level due to code of situation invoices
This commit is contained in:
@@ -1992,6 +1992,9 @@ class Facture extends CommonInvoice
|
|||||||
$this->brouillon=0;
|
$this->brouillon=0;
|
||||||
$this->date_validation=$now;
|
$this->date_validation=$now;
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
|
if (!empty($conf->global->INVOICE_USE_SITUATION))
|
||||||
|
{
|
||||||
$final = True;
|
$final = True;
|
||||||
while ($i < count($this->lines) && $final == True) {
|
while ($i < count($this->lines) && $final == True) {
|
||||||
$final = ($this->lines[$i]->situation_percent == 100);
|
$final = ($this->lines[$i]->situation_percent == 100);
|
||||||
@@ -2002,6 +2005,7 @@ class Facture extends CommonInvoice
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
@@ -2277,7 +2281,7 @@ class Facture extends CommonInvoice
|
|||||||
|
|
||||||
$this->line->context = $this->context;
|
$this->line->context = $this->context;
|
||||||
|
|
||||||
$this->line->situpation_percent = $situation_percent;
|
$this->line->situation_percent = $situation_percent;
|
||||||
$this->line->fk_facture=$this->id;
|
$this->line->fk_facture=$this->id;
|
||||||
$this->line->label=$label; // deprecated
|
$this->line->label=$label; // deprecated
|
||||||
$this->line->desc=$desc;
|
$this->line->desc=$desc;
|
||||||
@@ -3770,11 +3774,14 @@ class Facture extends CommonInvoice
|
|||||||
function setFinal()
|
function setFinal()
|
||||||
{
|
{
|
||||||
global $conf, $langs, $user;
|
global $conf, $langs, $user;
|
||||||
|
|
||||||
|
$this->db->begin();
|
||||||
|
|
||||||
$this->situation_final = 1;
|
$this->situation_final = 1;
|
||||||
$sql = 'update ' . MAIN_DB_PREFIX . 'facture set situation_final = ' . $this->situation_final . ' where rowid = ' . $this->id;
|
$sql = 'update ' . MAIN_DB_PREFIX . 'facture set situation_final = ' . $this->situation_final . ' where rowid = ' . $this->id;
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
// FIXME: call triggers?
|
// FIXME: call triggers MODIFY because we modify invoice
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase
|
|||||||
public static function setUpBeforeClass()
|
public static function setUpBeforeClass()
|
||||||
{
|
{
|
||||||
global $conf,$user,$langs,$db;
|
global $conf,$user,$langs,$db;
|
||||||
|
|
||||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||||
|
|
||||||
print __METHOD__."\n";
|
print __METHOD__."\n";
|
||||||
@@ -145,10 +146,10 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase
|
|||||||
$result2=$localobject->create($user,1);
|
$result2=$localobject->create($user,1);
|
||||||
$result3=$localobject->validate($user, $result); // create invoice by forcing ref
|
$result3=$localobject->validate($user, $result); // create invoice by forcing ref
|
||||||
print __METHOD__." result=".$result."\n";
|
print __METHOD__." result=".$result."\n";
|
||||||
$this->assertEquals('1915-0001', $result); // counter must start to 1
|
$this->assertEquals('1915-0001', $result, 'Test for {yyyy}-{0000}, 1st invoice'); // counter must start to 1
|
||||||
$result=$localobject->is_erasable();
|
$result=$localobject->is_erasable();
|
||||||
print __METHOD__." is_erasable=".$result."\n";
|
print __METHOD__." is_erasable=".$result."\n";
|
||||||
$this->assertEquals(1, $result, 'Test for {yyyy}-{0000}, 1st invoice'); // Can be deleted
|
$this->assertEquals(1, $result, 'Test for is_erasable, 1st invoice'); // Can be deleted
|
||||||
|
|
||||||
$localobject2=new Facture($this->savdb);
|
$localobject2=new Facture($this->savdb);
|
||||||
$localobject2->initAsSpecimen();
|
$localobject2->initAsSpecimen();
|
||||||
@@ -156,7 +157,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase
|
|||||||
$numbering=new mod_facture_mercure();
|
$numbering=new mod_facture_mercure();
|
||||||
$result=$numbering->getNextValue($mysoc, $localobject2, 'last');
|
$result=$numbering->getNextValue($mysoc, $localobject2, 'last');
|
||||||
print __METHOD__." result=".$result."\n";
|
print __METHOD__." result=".$result."\n";
|
||||||
$this->assertEquals('1915-0001', $result);
|
$this->assertEquals('1915-0001', $result, "Test to get last value with param 'last'");
|
||||||
$result=$numbering->getNextValue($mysoc, $localobject2);
|
$result=$numbering->getNextValue($mysoc, $localobject2);
|
||||||
$result2=$localobject2->create($user,1);
|
$result2=$localobject2->create($user,1);
|
||||||
$result3=$localobject2->validate($user, $result); // create invoice by forcing ref
|
$result3=$localobject2->validate($user, $result); // create invoice by forcing ref
|
||||||
|
|||||||
Reference in New Issue
Block a user