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); }