formatting

This commit is contained in:
Denis Duliçi 2023-04-29 01:43:48 +03:00
parent 7173466ed2
commit 678bc84603
10 changed files with 54 additions and 54 deletions

View File

@ -3,7 +3,7 @@
namespace App\Abstracts\View\Components\Documents;
use App\Abstracts\View\Component;
use App\Interfaces\Service\DocumentNumberService;
use App\Interfaces\Utility\DocumentNumber;
use App\Models\Common\Contact;
use App\Models\Document\Document;
use App\Models\Setting\Currency;
@ -267,7 +267,7 @@ abstract class Form extends Component
* @return void
*/
public function __construct(
protected DocumentNumberService $documentNumberService,
protected DocumentNumber $documentNumberUtility,
string $type, $model = false, $document = false, $currencies = false, $currency = false, $currency_code = false,
string $formId = 'document', $formRoute = '', $formMethod = '',
bool $hideCompany = false, string $textSectionCompaniesTitle = '', string $textSectionCompaniesDescription = '',
@ -819,10 +819,10 @@ abstract class Form extends Component
$contact = ($this->contact instanceof \stdClass) ? null : $this->contact;
$document_number = $this->documentNumberService->getNextDocumentNumber($type, $contact);
$document_number = $this->documentNumberUtility->getNextNumber($type, $contact);
if (empty($document_number)) {
$document_number = $this->documentNumberService->getNextDocumentNumber(Document::INVOICE_TYPE, $contact);
$document_number = $this->documentNumberUtility->getNextNumber(Document::INVOICE_TYPE, $contact);
}
return $document_number;

View File

@ -1,12 +0,0 @@
<?php
namespace App\Interfaces\Service;
use App\Models\Common\Contact;
interface DocumentNumberService
{
public function getNextDocumentNumber(string $type, ?Contact $contact): string;
public function increaseNextDocumentNumber(string $type, ?Contact $contact): void;
}

View File

@ -0,0 +1,12 @@
<?php
namespace App\Interfaces\Utility;
use App\Models\Common\Contact;
interface DocumentNumber
{
public function getNextNumber(string $type, ?Contact $contact): string;
public function increaseNextNumber(string $type, ?Contact $contact): void;
}

View File

@ -3,7 +3,7 @@
namespace App\Models\Document;
use App\Abstracts\Model;
use App\Interfaces\Service\DocumentNumberService;
use App\Interfaces\Utility\DocumentNumber;
use App\Models\Common\Media as MediaModel;
use App\Models\Setting\Tax;
use App\Scopes\Document as Scope;
@ -252,7 +252,7 @@ class Document extends Model
}
$this->status = 'draft';
$this->document_number = app(DocumentNumberService::class)->getNextDocumentNumber($type, $src->contact);
$this->document_number = app(DocumentNumber::class)->getNextNumber($type, $src->contact);
}
public function getSentAtAttribute(string $value = null)

19
app/Providers/Binding.php Normal file
View File

@ -0,0 +1,19 @@
<?php
namespace App\Providers;
use App\Interfaces\Utility\DocumentNumber as DocumentNumberInterface;
use App\Utilities\DocumentNumber;
use Illuminate\Support\ServiceProvider;
class Binding extends ServiceProvider
{
/**
* All container bindings that should be registered.
*
* @var array
*/
public array $bindings = [
DocumentNumberInterface::class => DocumentNumber::class,
];
}

View File

@ -1,19 +0,0 @@
<?php
namespace App\Providers;
use App\Interfaces\Service\DocumentNumberService;
use App\Services\Document\CoreDocumentNumberService;
use Illuminate\Support\ServiceProvider;
class Service extends ServiceProvider
{
/**
* All container bindings that should be registered.
*
* @var array
*/
public array $bindings = [
DocumentNumberService::class => CoreDocumentNumberService::class,
];
}

View File

@ -2,7 +2,7 @@
namespace App\Traits;
use App\Interfaces\Service\DocumentNumberService;
use App\Interfaces\Utility\DocumentNumber;
use App\Models\Document\Document;
use App\Abstracts\View\Components\Documents\Document as DocumentComponent;
use App\Utilities\Date;
@ -46,23 +46,23 @@ trait Documents
}
/**
* Deprecated. Use the DocumentNumberService::getNextDocumentNumber() method instead.
* Deprecated. Use the DocumentNumber::getNextNumber() method instead.
*
* @deprecated This method is deprecated and will be removed in future versions.
*/
public function getNextDocumentNumber(string $type): string
{
return app(DocumentNumberService::class)->getNextDocumentNumber($type, null);
return app(DocumentNumber::class)->getNextNumber($type, null);
}
/**
* Deprecated. Use the DocumentNumberService::increaseNextDocumentNumber() method instead.
* Deprecated. Use the DocumentNumber::increaseNextNumber() method instead.
*
* @deprecated This method is deprecated and will be removed in future versions.
*/
public function increaseNextDocumentNumber(string $type): void
{
app(DocumentNumberService::class)->increaseNextDocumentNumber($type, null);
app(DocumentNumber::class)->increaseNextNumber($type, null);
}
public function getDocumentStatuses(string $type): Collection

View File

@ -1,24 +1,24 @@
<?php
namespace App\Services\Document;
namespace App\Utilities;
use App\Interfaces\Service\DocumentNumberService;
use App\Interfaces\Utility\DocumentNumber as DocumentNumberInterface;
use App\Models\Common\Contact;
class CoreDocumentNumberService implements DocumentNumberService
class DocumentNumber implements DocumentNumberInterface
{
public function getNextDocumentNumber(string $type, ?Contact $contact): string
public function getNextNumber(string $type, ?Contact $contact): string
{
$type = $this->resolveTypeAlias($type);
$prefix = setting($type . '.number_prefix');
$next = (string)setting($type . '.number_next');
$digit = (int)setting($type . '.number_digit');
$next = (string) setting($type . '.number_next');
$digit = (int) setting($type . '.number_digit');
return $prefix . str_pad($next, $digit, '0', STR_PAD_LEFT);
}
public function increaseNextDocumentNumber(string $type, ?Contact $contact): void
public function increaseNextNumber(string $type, ?Contact $contact): void
{
$type = $this->resolveTypeAlias($type);

View File

@ -188,6 +188,7 @@ return [
*/
App\Providers\App::class,
App\Providers\Auth::class,
App\Providers\Binding::class,
App\Providers\Blade::class,
// App\Providers\Broadcast::class,
App\Providers\Event::class,
@ -195,7 +196,6 @@ return [
App\Providers\Observer::class,
App\Providers\Queue::class,
App\Providers\Route::class,
App\Providers\Service::class,
App\Providers\Validation::class,
App\Providers\ViewComposer::class,

View File

@ -9,7 +9,7 @@ use App\Events\Document\DocumentReceived;
use App\Events\Document\DocumentSent;
use App\Events\Document\DocumentViewed;
use App\Events\Document\PaymentReceived;
use App\Interfaces\Service\DocumentNumberService;
use App\Interfaces\Utility\DocumentNumber;
use App\Jobs\Document\UpdateDocument;
use App\Models\Common\Contact;
use App\Models\Common\Item;
@ -268,11 +268,11 @@ class Document extends AbstractFactory
*/
public function getDocumentNumber($type, Contact $contact)
{
$document_number_service = app(DocumentNumberService::class);
$utility = app(DocumentNumber::class);
$document_number = $document_number_service->getNextDocumentNumber($type, $contact);
$document_number = $utility->getNextNumber($type, $contact);
$document_number_service->increaseNextDocumentNumber($type, $contact);
$utility->increaseNextNumber($type, $contact);
return $document_number;
}