mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-23 14:34:04 +00:00
54 lines
1.7 KiB
PHP
54 lines
1.7 KiB
PHP
<?php
|
|
|
|
|
|
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
|
|
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
|
use App\Classes\Modules\Transactions\Processors\CreateStorageEInvoiceDocProcessor;
|
|
use App\Classes\ValueObjects\Constants\DocumentType;
|
|
|
|
class RegenerateSingleStorageEInvoiceLogic extends AbstractControllerLogic
|
|
{
|
|
/**
|
|
* @return array
|
|
*/
|
|
protected function notification():array {
|
|
return [
|
|
'title' => 'Regenerate Storage E-Invoice',
|
|
'message' => 'You have successfully regenerated storage e-invoice'
|
|
];
|
|
}
|
|
|
|
|
|
/** @var FetchesTransaction */
|
|
private $fetchesTransaction;
|
|
|
|
/** @var CreateStorageEInvoiceDocProcessor */
|
|
private $createStorageEInvoiceDocProcessor;
|
|
|
|
/**
|
|
* @param FetchesTransaction $fetchesTransaction
|
|
* @param CreateStorageEInvoiceDocProcessor $createStorageEInvoiceDocProcessor
|
|
*/
|
|
public function __construct(FetchesTransaction $fetchesTransaction, CreateStorageEInvoiceDocProcessor $createStorageEInvoiceDocProcessor)
|
|
{
|
|
$this->fetchesTransaction = $fetchesTransaction;
|
|
$this->createStorageEInvoiceDocProcessor = $createStorageEInvoiceDocProcessor;
|
|
}
|
|
|
|
public function logic(Request $request) : JsonResponse
|
|
{
|
|
$invoice = $this->fetchesTransaction->execute(['id' => $request->route('invoice_id')]);
|
|
|
|
$invoice->documents()->where('document_type', DocumentType::STORAGE_EINVOICE)->delete();
|
|
|
|
$this->createStorageEInvoiceDocProcessor->execute($invoice);
|
|
|
|
return $this->response([]);
|
|
}
|
|
|
|
}
|