mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
Laravel Vapor - Fix a 504 error at /bookings/urgent page
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transactions\Services\ListsTransactions;
|
||||
use App\Http\Resources\TransactionUrgentResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListUrgentTransactionsLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* ListUrgentTransactionsLogic constructor.
|
||||
* @param ListsTransactions $listsTransactions
|
||||
*/
|
||||
public function __construct(ListsTransactions $listsTransactions)
|
||||
{
|
||||
$this->listsTransactions = $listsTransactions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Transactions Urgent',
|
||||
'message' => 'You have successfully retrieved a list of transactions'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var ListsTransactions */
|
||||
private $listsTransactions;
|
||||
|
||||
|
||||
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$query = $this->listsTransactions->execute($this->listsTransactions->deserializeFilters($request->input('filters')));
|
||||
|
||||
return $this->collectionResponse(TransactionUrgentResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers\Transactions;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\Modules\Transactions\ControllersLogic\ListUrgentTransactionsLogic;
|
||||
|
||||
|
||||
class ListUrgentTransactionsController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param ListTransactionsLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function list(Request $request, ListUrgentTransactionsLogic $logic) : JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Classes\Modules\Bookings\Services\CalculatesBookingRefundAmount;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Booking;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class TransactionUrgentResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$booking = null; //cief todo: 66
|
||||
$bank = null;
|
||||
//Check if Transaction of type PAYMENT has an override for recipient bank - starts
|
||||
if(in_array((int)$this->type, [TransactionType::BILL, TransactionType::REFUND, TransactionType::SUPPLIER_REFUND])){
|
||||
$booking = $this->owner->owner;
|
||||
$bank = $this->owner->bank ?? $booking->bank;
|
||||
}
|
||||
else{
|
||||
$booking = $this->owner;
|
||||
$bank = $this->bank ?? $booking->bank;
|
||||
}
|
||||
//Check if Transaction of type PAYMENT has an override for recipient bank - ends
|
||||
$days = $this->created_at->endOfDay()->addWeekdays($booking->service_id === 3 ? 3 : 1);
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'booking' => new BookingResource($booking),
|
||||
// 'type' => (int) $this->type,
|
||||
// 'bill_no' => $this->bill_no,
|
||||
// 'payment_reference' => $this->payment_reference,
|
||||
// 'payment_method' => (float) $this->payment_method,
|
||||
'recipient_bank_account' => new BankResource($bank),
|
||||
// 'issuer_name' => $this->issuerCompany->name,
|
||||
// 'issuer_id' => $this->issuerCompany->id,
|
||||
// 'amount' => (double) ($this->type === TransactionType::SUPPLIER_REFUND ? $this->amount - $this->transactions()->where('type', TransactionType::BILL_REFUND)->where('status', ApprovalStatus::APPROVED)->sum('amount') : $this->amount),
|
||||
'original_amount' => (double) ($this->type === TransactionType::SUPPLIER_REFUND ? $this->original_amount - $this->transactions()->where('type', TransactionType::BILL_REFUND)->where('status', ApprovalStatus::APPROVED)->sum('original_amount') : $this->original_amount),
|
||||
// 'currency' => new CurrencyResource($this->currency),
|
||||
// 'original_currency' => new CurrencyResource($this->original_currency),
|
||||
// 'service_charge' => (double) $this->service_charge,
|
||||
// 'tax' => (double) $this->tax,
|
||||
// 'currency_rate' => (double) $this->currency_rate,
|
||||
// 'status' => (int) $this->status,
|
||||
//'details' => TransactionDetailResource::collection($this->transactionDetails),
|
||||
'documents' => new DocumentResource($this->documents()->first()),
|
||||
//'transaction_bill' => new TransactionResource($this->when((int) $this->type === TransactionType::PAYMENT, $this->transactions()->bills()->first())),
|
||||
//'transaction_refunds' => TransactionResource::collection($this->when((int) $this->type === TransactionType::PAYMENT, $this->transactions()->refunds()->get())),
|
||||
//'refunded_amount' => $this->booking ? floatval((App()->make(CalculatesBookingRefundAmount::class))->calculateRefundAmount($this->resource, $this->booking->fix_currency_id)) : null,
|
||||
// 'expires_on' => Carbon::parse($this->expires_on)->format('d-m-Y h:i:s A'),
|
||||
'updated_at' => Carbon::parse($this->updated_at)->format('d-m-Y h:i:s A'),
|
||||
// 'created_at' => Carbon::parse($this->created_at)->format('d-m-Y h:i:s A'),
|
||||
'interval' => [
|
||||
'value' => $days->gt(Carbon::now()) ? '+' : '-',
|
||||
'duration' => $days->diff(Carbon::now())->format('%d'),
|
||||
],
|
||||
//'remarks' => RemarkResource::collection($this->remarks),
|
||||
//'redemption' => new VoucherRedemptionResource($this->voucherRedemption),
|
||||
// 'bank' => ((int) $this->type === TransactionType::PAYMENT) ? new BankResource($bank) : null, //When a transaction (of type payment) has an override recipient bank details on booking, this is NOT null
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,7 @@
|
||||
},
|
||||
methods: {
|
||||
fetchList(Page = 1){
|
||||
this.submit(route('api.transaction.list') + '?page='+ Page +'&filters=' + JSON.stringify({status: 2, type: 1, owner_type: 'App\\Models\\Booking', per_page: 50, order_by: {
|
||||
this.submit(route('api.transaction.list.urgent') + '?page='+ Page +'&filters=' + JSON.stringify({status: 2, type: 1, owner_type: 'App\\Models\\Booking', per_page: 50, order_by: {
|
||||
column: 'created_at',
|
||||
DESC: true
|
||||
}}), 'get', 'urgentListSection', false, true)
|
||||
@@ -59,4 +59,4 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
|
||||
@@ -6,6 +6,7 @@ Route::group(['prefix' => 'transactions', 'namespace' => 'Transactions', 'as' =>
|
||||
|
||||
Route::get('/list', 'ListTransactionsController@list')->name('list');
|
||||
Route::get('/list/job', 'ListTransactionsJobController@list')->name('list.job');
|
||||
Route::get('/list/urgent', 'ListUrgentTransactionsController@list')->name('list.urgent');
|
||||
Route::delete('/suspend/{id}', 'SuspendTransactionController@suspend')->name('suspend');
|
||||
|
||||
route::post('/supplier/{id}/bill/create', 'CreateSupplierTransactionController@create')->name('supplier.create');
|
||||
|
||||
Reference in New Issue
Block a user