From c50c8acd75edc51b39e973f2fed20e329c166a58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Wed, 13 Jan 2021 19:07:13 +0300 Subject: [PATCH] refs #1753 Fixed: Incorrect next number for a new document in the module --- app/Abstracts/View/Components/DocumentForm.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/Abstracts/View/Components/DocumentForm.php b/app/Abstracts/View/Components/DocumentForm.php index 40998a413..56c3b2b02 100644 --- a/app/Abstracts/View/Components/DocumentForm.php +++ b/app/Abstracts/View/Components/DocumentForm.php @@ -550,8 +550,18 @@ abstract class DocumentForm extends Base return $document->document_number; } - $document_number = $this->getNextDocumentNumber($type); - + $next = $type; + + if ($alias = config('type.' . $type . '.alias')) { + $next = $alias . '.' . $type; + } + + $document_number = $this->getNextDocumentNumber($next); + + if (empty($document_number)) { + $document_number = $this->getNextDocumentNumber($type); + } + if (empty($document_number)) { $document_number = $this->getNextDocumentNumber(Document::INVOICE_TYPE); }