mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-31 10:24:00 +00:00
Admin Workflow - API code refactor to fetch booking information
This commit is contained in:
@@ -46,7 +46,8 @@ if (!function_exists('markedProcessing')) {
|
||||
|
||||
Route::group(['prefix' => 'admin-work-flow', 'as' => 'admin_work_flow.', 'namespace' => 'Questionnaires'], function () {
|
||||
|
||||
Route::get('/fetch-oldest-order', [AdminWorkflowBaseController::class, 'fetchOldestOrder'])->name('fetch_oldest_order');
|
||||
Route::get('/fetch-booking', [AdminWorkflowBaseController::class, 'fetchBooking'])->name('fetch_oldest_order');
|
||||
Route::get('{booking_id}/fetch-model-attributes', [AdminWorkflowBaseController::class, 'fetchModelAttributes'])->name('fetch_model_attributes');
|
||||
|
||||
Route::get('/fetch-pending-approved-po', function () {
|
||||
$excludedBookingIds = KeyValuePair::where('owner_type', 'App\Models\Booking')
|
||||
@@ -122,28 +123,6 @@ Route::group(['prefix' => 'admin-work-flow', 'as' => 'admin_work_flow.', 'namesp
|
||||
})->name('fetch_pending_fill_po');
|
||||
|
||||
|
||||
Route::get('{booking_id}/fetch-model-attributes', function ($bookingId) {
|
||||
$booking = Booking::find($bookingId);
|
||||
|
||||
if (!$booking) {
|
||||
return responseJson(null, 'No booking found', 404);
|
||||
}
|
||||
|
||||
$attributes = $booking->modelAttributes()
|
||||
->where('name', BookingAttributeNames::ORDER_REFERENCE_NO)
|
||||
->get(['id', 'value'])
|
||||
->map(fn ($attr) => $attr->only(['id', 'value']));
|
||||
|
||||
$transaction = $booking->bills()->first(); //cief todo: 74 - more than 1 record?
|
||||
return responseJson([
|
||||
'booking' => $booking,
|
||||
'booking_attributes' => $attributes,
|
||||
'reference' =>$transaction->owner->owner->marking,
|
||||
'marking' => $transaction->owner->owner->company->reference,
|
||||
'currency_rate' => $transaction->currency_rate,
|
||||
'total_amount' =>$transaction->currency->short_code . ' ' . number_format((float)$transaction->amount, 2, '.', '')
|
||||
]);
|
||||
})->name('fetch_model_attributes');
|
||||
|
||||
|
||||
// Route::post('/add-workflow-timestamp', function (Request $request) {
|
||||
|
||||
Reference in New Issue
Block a user