create proforma invoice transaction

This commit is contained in:
edmondlang
2021-11-28 20:51:30 +08:00
parent 1b8e8722c8
commit bcbb3f53f6
4 changed files with 117 additions and 2 deletions
@@ -0,0 +1,76 @@
<?php
namespace App\Classes\Modules\Bookings\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Bookings\Services\FetchesBooking;
use App\Classes\Modules\Bookings\Standards\Rules\CanFetchBooking;
use App\Classes\Modules\Bookings\Services\UpdatesBookingStatus;
use App\Classes\Modules\Transactions\Services\DeletesTransaction;
use App\Classes\Modules\Documents\Services\DeletesDocument;
use App\Classes\Modules\Transactions\Processors\CreatePerformaInvoiceTransactionProcessor;
use App\Http\Resources\BookingResource;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\TransactionType;
class CreatePerformaInvoiceTransactionLogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Create Perfoma Invoice Transaction',
'message' => 'You have successfully create performa invoice transaction'
];
}
/** @var CanFetchBooking */
private $canFetchBooking;
/** @var FetchesBooking */
private $fetchesBooking;
/** @var CreatePerformaInvoiceTransactionProcessor */
private $CreatePerformaInvoiceTransactionProcessor;
/**
* FetchBookingLogic constructor.
* @param CanFetchBooking $canFetchBooking
* @param FetchesBooking $fetchesBooking
* @param CreatePerformaInvoiceTransactionProcessor $CreatePerformaInvoiceTransactionProcessor
*/
public function __construct(
CanFetchBooking $canFetchBooking,
FetchesBooking $fetchesBooking,
CreatePerformaInvoiceTransactionProcessor $CreatePerformaInvoiceTransactionProcessor
)
{
$this->canFetchBooking = $canFetchBooking;
$this->fetchesBooking = $fetchesBooking;
$this->CreatePerformaInvoiceTransactionProcessor = $CreatePerformaInvoiceTransactionProcessor;
}
/**
* @param Request $request
* @return JsonResponse
* @throws \App\Classes\Exceptions\AccessForbiddenException
* @throws \App\Classes\Exceptions\RequestValidationException
*/
public function logic(Request $request) : JsonResponse
{
$this->canFetchBooking->passes();
$booking = $this->fetchesBooking->execute(['id' => $request->route('id')]);
$this->CreatePerformaInvoiceTransactionProcessor->execute($booking);
return $this->resourceResponse(new BookingResource($booking));
}
}
@@ -0,0 +1,20 @@
<?php
namespace App\Http\Controllers\Bookings;
use App\Classes\Modules\Bookings\ControllersLogic\CreatePerformaInvoiceTransactionLogic;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class CreatePerformaInvoiceTransaction
{
/**
* @param Request $request
* @param CreatePerformaInvoiceTransactionLogic $logic
* @return JsonResponse
*/
public function create(Request $request, CreatePerformaInvoiceTransactionLogic $logic): JsonResponse {
return $logic->execute($request);
}
}
File diff suppressed because one or more lines are too long
+1
View File
@@ -30,4 +30,5 @@ Route::group(['prefix' => 'booking', 'as' => 'booking.', 'namespace' => 'Booking
Route::post('/merge', 'MergeBookingController@merge')->name('merge');
Route::post('{id}/performa/create', 'CreatePerformaInvoiceTransaction@create')->name('performa.create');
});