mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
66 lines
2.2 KiB
PHP
66 lines
2.2 KiB
PHP
<?php
|
|
|
|
|
|
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
|
|
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
use App\Classes\Modules\Transactions\DataTransferObjects\WaiveTransactionObject;
|
|
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
|
use App\Classes\Modules\Transactions\Services\UpdatesTransactionIsWaived;
|
|
use App\Classes\Modules\Transactions\Standards\Rules\CanWaiveTransaction;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class WaiveTransactionLogic extends AbstractControllerLogic
|
|
{
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
protected function notification():array {
|
|
return [
|
|
'title' => 'Waive Transaction',
|
|
'message' => 'You have successfully waived the transaction'
|
|
];
|
|
}
|
|
|
|
/** @var FetchesTransaction */
|
|
private $fetchesTransaction;
|
|
|
|
/** @var UpdatesTransactionIsWaived */
|
|
private $updatesTransactionIsWaived;
|
|
|
|
/** @var CanWaiveTransaction */
|
|
private $canWaiveTransaction;
|
|
|
|
|
|
/**
|
|
* WaiveTransactionLogic constructor.
|
|
* @param FetchesTransaction $fetchesTransaction
|
|
* @param UpdatesTransactionIsWaived $updatesTransactionIsWaived
|
|
* @param CanWaiveTransaction $canWaiveTransaction
|
|
*/
|
|
public function __construct(FetchesTransaction $fetchesTransaction, UpdatesTransactionIsWaived $updatesTransactionIsWaived, CanWaiveTransaction $canWaiveTransaction)
|
|
{
|
|
$this->fetchesTransaction = $fetchesTransaction;
|
|
$this->updatesTransactionIsWaived = $updatesTransactionIsWaived;
|
|
$this->canWaiveTransaction = $canWaiveTransaction;
|
|
}
|
|
|
|
|
|
public function logic(Request $request) : JsonResponse
|
|
{
|
|
$transaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]);
|
|
|
|
$object = new WaiveTransactionObject($transaction->id, $transaction->bill_no, $transaction->type, $transaction->status);
|
|
$this->canWaiveTransaction->passes($object);
|
|
|
|
$this->updatesTransactionIsWaived->execute($transaction);
|
|
Log::info(Auth::user()->email." waive storage invoice charges with bill_no: ".$transaction->bill_no);
|
|
|
|
return $this->response([]);
|
|
}
|
|
}
|