From 6822763d3c7f8bde704c7cbedef3b22cedc6ab21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Thu, 14 Jan 2021 00:33:48 +0300 Subject: [PATCH] refs #1753 move trait for setting number.. --- app/Abstracts/View/Components/DocumentForm.php | 12 +----------- app/Traits/Documents.php | 8 ++++++++ 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/app/Abstracts/View/Components/DocumentForm.php b/app/Abstracts/View/Components/DocumentForm.php index c0cf2bd37..2d6d1c26c 100644 --- a/app/Abstracts/View/Components/DocumentForm.php +++ b/app/Abstracts/View/Components/DocumentForm.php @@ -550,17 +550,7 @@ abstract class DocumentForm extends Base return $document->document_number; } - $next = $type; - - if ($alias = config('type.' . $type . '.alias')) { - $next = $alias . '.' . str_replace('-', '_', $type); - } - - $document_number = $this->getNextDocumentNumber($next); - - if (empty($document_number)) { - $document_number = $this->getNextDocumentNumber($type); - } + $document_number = $this->getNextDocumentNumber($type); if (empty($document_number)) { $document_number = $this->getNextDocumentNumber(Document::INVOICE_TYPE); diff --git a/app/Traits/Documents.php b/app/Traits/Documents.php index d4e7137dc..6caeaacab 100644 --- a/app/Traits/Documents.php +++ b/app/Traits/Documents.php @@ -11,6 +11,10 @@ trait Documents { public function getNextDocumentNumber(string $type): string { + if ($alias = config('type.' . $type . '.alias')) { + $type = $alias . '.' . str_replace('-', '_', $type); + } + $prefix = setting("$type.number_prefix"); $next = setting("$type.number_next"); $digit = setting("$type.number_digit"); @@ -20,6 +24,10 @@ trait Documents public function increaseNextDocumentNumber(string $type): void { + if ($alias = config('type.' . $type . '.alias')) { + $type = $alias . '.' . str_replace('-', '_', $type); + } + $next = setting("$type.number_next", 1) + 1; setting(["$type.number_next" => $next]);