From e966d11356865dcf4be7ff11d1c4184da6e5c419 Mon Sep 17 00:00:00 2001 From: John Date: Thu, 5 Apr 2018 09:46:55 +0200 Subject: [PATCH] Fix credit note card apparence --- htdocs/compta/facture/card.php | 1 + htdocs/compta/facture/class/facture.class.php | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index cb181b8b1b9..41e2dcc4a52 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4586,6 +4586,7 @@ else if ($id > 0 || ! empty($ref)) // remove situation from cycle if ($object->statut == Facture::STATUS_VALIDATED + && $object->type == Facture::TYPE_SITUATION && $user->rights->facture->creer && !$objectidnext && $object->situation_counter > 1 diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index cd3fdefc554..93f57f98a3c 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1530,8 +1530,16 @@ class Facture extends CommonInvoice $invoice = new Facture($this->db); if ($invoice->fetch($objp->rowid) > 0) { - if ($objp->situation_counter < $this->situation_counter) $this->tab_previous_situation_invoice[] = $invoice; - else $this->tab_next_situation_invoice[] = $invoice; + if ($objp->situation_counter < $this->situation_counter + || ($objp->situation_counter == $this->situation_counter && $objp->rowid < $this->id) // This case appear when there are credit notes + ) + { + $this->tab_previous_situation_invoice[] = $invoice; + } + else + { + $this->tab_next_situation_invoice[] = $invoice; + } } } }