Skip to content
Snippets Groups Projects
Commit 6749e600 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Fix: Test to manage corrupted data

parent a669b61b
No related branches found
No related tags found
No related merge requests found
...@@ -163,7 +163,7 @@ if (empty($reshook)) ...@@ -163,7 +163,7 @@ if (empty($reshook))
// Change status of invoice // Change status of invoice
else if ($action == 'reopen' && $user->rights->facture->creer) { else if ($action == 'reopen' && $user->rights->facture->creer) {
$result = $object->fetch($id); $result = $object->fetch($id);
if ($object->statut == 2 || ($object->statut == 3 && $object->close_code != 'replaced')) { if ($object->statut == 2 || ($object->statut == 3 && $object->close_code != 'replaced') || ($object->statut == 1 && $object->paye == 1)) { // ($object->statut == 1 && $object->paye == 1) should not happened but can be found when data are corrupted
$result = $object->set_unpaid($user); $result = $object->set_unpaid($user);
if ($result > 0) { if ($result > 0) {
header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id);
...@@ -3905,8 +3905,8 @@ else if ($id > 0 || ! empty($ref)) ...@@ -3905,8 +3905,8 @@ else if ($id > 0 || ! empty($ref))
if ((($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) if ((($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT)
|| ($object->type == Facture::TYPE_CREDIT_NOTE && empty($discount->id)) || ($object->type == Facture::TYPE_CREDIT_NOTE && empty($discount->id))
|| ($object->type == Facture::TYPE_DEPOSIT && empty($discount->id))) || ($object->type == Facture::TYPE_DEPOSIT && empty($discount->id)))
&& ($object->statut == 2 || $object->statut == 3) && ($object->statut == 2 || $object->statut == 3 || ($object->statut == 1 && $object->paye == 1)) // Condition ($object->statut == 1 && $object->paye == 1) should not happened but can be found due to corrupted data
&& $user->rights->facture->creer) // A paid invoice (partially or completely) && $user->rights->facture->creer) // A paid invoice (partially or completely)
{ {
if (! $objectidnext && $object->close_code != 'replaced') // Not replaced by another invoice if (! $objectidnext && $object->close_code != 'replaced') // Not replaced by another invoice
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment