Merge branch 'dillon/74-admin-workflow' into vapor/development

This commit is contained in:
Dillon Ngo
2025-01-11 04:02:38 +08:00
4 changed files with 36 additions and 23 deletions
@@ -6,7 +6,8 @@ namespace App\Classes\Modules\Questionnaires\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Questionnaires\Standards\Rules\CanFetchQuestion;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Http\Resources\BookingBaseResource;
use App\Classes\Modules\Bookings\Services\FetchesBooking;
use App\Http\Resources\BookingResource;
use App\Models\Booking;
use App\Models\KeyValuePair;
use Carbon\Carbon;
@@ -30,13 +31,18 @@ class FetchAdminWFBookingLogic extends AbstractControllerLogic
/** @var CanFetchQuestion */
private $canFetchQuestion;
/** @var FetchesBooking */
private $fetchesBooking;
/**
* FetchAdminWFBookingLogic constructor.
* @param CanFetchQuestion $canFetchQuestion
* @param FetchesBooking $fetchesBooking
*/
public function __construct(CanFetchQuestion $canFetchQuestion)
public function __construct(CanFetchQuestion $canFetchQuestion, FetchesBooking $fetchesBooking)
{
$this->canFetchQuestion = $canFetchQuestion;
$this->fetchesBooking = $fetchesBooking;
}
@@ -84,6 +90,8 @@ class FetchAdminWFBookingLogic extends AbstractControllerLogic
return responseJson(null, 'No booking found', 404);
}
$booking = $this->fetchesBooking->execute(['id' => $booking->id, 'with_transactions' => true, 'order_by_id_desc' => true]);
markedProcessing($booking, '1688_admin_workflow_processing');
// return responseJson([
@@ -98,8 +106,6 @@ class FetchAdminWFBookingLogic extends AbstractControllerLogic
// 'booking' => new BookingBaseResource($booking)
// ]);
return $this->resourceResponse(new BookingBaseResource($booking));
return $this->resourceResponse(new BookingResource($booking));
}
}
@@ -6,7 +6,9 @@ namespace App\Classes\Modules\Questionnaires\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Questionnaires\Standards\Rules\CanFetchQuestion;
use App\Classes\ValueObjects\Constants\BookingAttributeNames;
use App\Classes\Modules\Bookings\Services\FetchesBooking;
use App\Http\Resources\BookingBaseResource;
use App\Http\Resources\BookingResource;
use App\Models\Booking;
use ErrorException;
use Illuminate\Http\JsonResponse;
@@ -28,14 +30,18 @@ class FetchAdminWFModelAttributesLogic extends AbstractControllerLogic
/** @var CanFetchQuestion */
private $canFetchQuestion;
/** @var FetchesBooking */
private $fetchesBooking;
/**
* FetchAdminWFModelAttributesLogic constructor.
* @param CanFetchQuestion $canFetchQuestion
* @param FetchesBooking $fetchesBooking
*/
public function __construct(CanFetchQuestion $canFetchQuestion)
public function __construct(CanFetchQuestion $canFetchQuestion, FetchesBooking $fetchesBooking)
{
$this->canFetchQuestion = $canFetchQuestion;
$this->fetchesBooking = $fetchesBooking;
}
@@ -48,7 +54,8 @@ class FetchAdminWFModelAttributesLogic extends AbstractControllerLogic
{
$this->canFetchQuestion->passes();
$booking = Booking::find($request->route('booking_id'));
// $booking = Booking::find($request->route('booking_id'));
$booking = $this->fetchesBooking->execute(['id' => $request->route('booking_id'), 'with_transactions' => true, 'order_by_id_desc' => true]);
if (!$booking) {
return responseJson(null, 'No booking found', 404);
@@ -60,16 +67,16 @@ class FetchAdminWFModelAttributesLogic extends AbstractControllerLogic
->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, '.', '')
]);
// 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, '.', '')
// ]);
return $this->resourceResponse(new BookingBaseResource($booking));
return $this->resourceResponse(new BookingResource($booking));
}
}
+2 -2
View File
@@ -89,7 +89,7 @@ class QAWorkFlowSeeder extends Seeder
'question_number' => '1688_login_successful',
'question_title' => '1688_login_successful',
'question_type' => QAType::MULTIPLE_CHOICES,
'url' => 'api.admin_work_flow.fetch_model_attributes', //'http://localhost:8082/api/v1/admin-work-flow/{booking_id}/fetch-model-attributes',
//'url' => 'api.admin_work_flow.fetch_model_attributes', //'http://localhost:8082/api/v1/admin-work-flow/{booking_id}/fetch-model-attributes',
'is_start' => false,
'is_end' => false,
'answer_options' => [
@@ -128,7 +128,7 @@ class QAWorkFlowSeeder extends Seeder
'question_description' => 'Please key in the order amount',
'question_' => 'Order Amount',
'question_type' => QAType::MULTIPLE_CHOICES,
'url' => 'api.admin_work_flow.fetch_model_attributes',
//'url' => 'api.admin_work_flow.fetch_model_attributes',
'is_start' => false,
'is_end' => false,
'answer_options' => [
@@ -73,19 +73,19 @@
{{ externalApiResponse.data.marking }}
</a>
</h3>
<div v-if="externalApiResponse.data.reference" class="row bg-master-light m-t-15 m-b-15 rounded padding-30 justify-content-center">
<div v-if="externalApiResponse" class="row bg-master-light m-t-15 m-b-15 rounded padding-30 justify-content-center">
<div class="col-auto text-left">
<h4>
<span class="bold d-inline-block m-r-15">Reference: {{ externalApiResponse.data.reference }}</span>
<span class="bold d-inline-block m-r-15">Reference: {{ externalApiResponse.data.marking }}</span>
</h4>
<h4>
<span class="bold d-inline-block m-r-15">Marking: {{ externalApiResponse.data.marking }} </span>
<span class="bold d-inline-block m-r-15">Marking: {{ externalApiResponse.data.company.reference }} </span>
</h4>
<h4>
<span class="bold d-inline-block m-r-15">Currency Rate: {{ externalApiResponse.data.currency_rate }} </span>
<span class="bold d-inline-block m-r-15">Currency Rate: {{ externalApiResponse.data.payment_history[0].currency_rate }} </span>
</h4>
<h4>
<span class="bold d-inline-block m-r-15">Total Amount: {{ externalApiResponse.data.total_amount }}</span>
<span class="bold d-inline-block m-r-15">Total Amount: {{externalApiResponse.data.payment_history[0].currency.short_code}} {{((Math.round(( externalApiResponse.data.payment_history[0].amount + Number.EPSILON) * 100) / 100)).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}</span>
</h4>
</div>
</div>