diff --git a/app/Classes/Modules/Questionnaires/ControllersLogic/FetchAdminWFBookingLogic.php b/app/Classes/Modules/Questionnaires/ControllersLogic/FetchAdminWFBookingLogic.php index 3d3b75a4..855c770c 100644 --- a/app/Classes/Modules/Questionnaires/ControllersLogic/FetchAdminWFBookingLogic.php +++ b/app/Classes/Modules/Questionnaires/ControllersLogic/FetchAdminWFBookingLogic.php @@ -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)); } - } diff --git a/app/Classes/Modules/Questionnaires/ControllersLogic/FetchAdminWFModelAttributesLogic.php b/app/Classes/Modules/Questionnaires/ControllersLogic/FetchAdminWFModelAttributesLogic.php index 456f51cf..6727fde9 100644 --- a/app/Classes/Modules/Questionnaires/ControllersLogic/FetchAdminWFModelAttributesLogic.php +++ b/app/Classes/Modules/Questionnaires/ControllersLogic/FetchAdminWFModelAttributesLogic.php @@ -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)); } } diff --git a/database/seeds/QAWorkFlowSeeder.php b/database/seeds/QAWorkFlowSeeder.php index c57ad4b1..26db2de7 100644 --- a/database/seeds/QAWorkFlowSeeder.php +++ b/database/seeds/QAWorkFlowSeeder.php @@ -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' => [ diff --git a/resources/assets/vue/components/general/forms/AdminWorkFlowFormComponent.vue b/resources/assets/vue/components/general/forms/AdminWorkFlowFormComponent.vue index 91a0d549..e9d4af0e 100644 --- a/resources/assets/vue/components/general/forms/AdminWorkFlowFormComponent.vue +++ b/resources/assets/vue/components/general/forms/AdminWorkFlowFormComponent.vue @@ -73,19 +73,19 @@ {{ externalApiResponse.data.marking }} -
+

- Reference: {{ externalApiResponse.data.reference }} + Reference: {{ externalApiResponse.data.marking }}

- Marking: {{ externalApiResponse.data.marking }} + Marking: {{ externalApiResponse.data.company.reference }}

- Currency Rate: {{ externalApiResponse.data.currency_rate }} + Currency Rate: {{ externalApiResponse.data.payment_history[0].currency_rate }}

- Total Amount: {{ externalApiResponse.data.total_amount }} + 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, ",")}}