From 0c21e6bd91dd349f7c9a7800e5f24b3dddc3044c Mon Sep 17 00:00:00 2001 From: edmondlang Date: Wed, 22 Feb 2023 10:47:28 +0800 Subject: [PATCH] delete 1688 po --- .../DeletePurchaseOrderPdfLogic.php | 75 +++++++++++++++++++ .../DeletePurchaseOrderPdfController.php | 16 ++++ .../bookings/forms/DeletePoFormComponent.vue | 33 ++++++++ .../BookingDetailsSectionComponent.vue | 9 +++ routes/booking.php | 1 + 5 files changed, 134 insertions(+) create mode 100644 app/Classes/Modules/Bookings/ControllersLogic/DeletePurchaseOrderPdfLogic.php create mode 100644 app/Http/Controllers/Bookings/DeletePurchaseOrderPdfController.php create mode 100644 resources/assets/vue/components/bookings/forms/DeletePoFormComponent.vue diff --git a/app/Classes/Modules/Bookings/ControllersLogic/DeletePurchaseOrderPdfLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/DeletePurchaseOrderPdfLogic.php new file mode 100644 index 00000000..a4dd30a1 --- /dev/null +++ b/app/Classes/Modules/Bookings/ControllersLogic/DeletePurchaseOrderPdfLogic.php @@ -0,0 +1,75 @@ + 'Purchase Order PDF Deleted', + 'message' => 'You have successfully deleted the Purchase order PDF' + ]; + } + + /** @var FetchesBooking */ + private $fetchesBooking; + + /** @var DeletesDocument */ + private $deletesDocument; + + /** @var CanDeleteDocument */ + private $canDeleteDocument; + + + /** + * DeletePurchaseOrderPdfLogic constructor. + * @param FetchesBooking $fetchesBooking + * @param DeletesDocument $deletesDocument + * @param CanDeleteDocument $canDeleteDocument + */ + public function __construct(fetchesBooking $fetchesBooking, DeletesDocument $deletesDocument, CanDeleteDocument $canDeleteDocument) + { + $this->fetchesBooking = $fetchesBooking; + $this->deletesDocument = $deletesDocument; + $this->canDeleteDocument = $canDeleteDocument; + } + + + /** + * @param Request $request + * @return JsonResponse + * @throws \App\Classes\Exceptions\MalformedRequestException + */ + public function logic(Request $request) : JsonResponse + { + + $booking = $this->fetchesBooking->execute(['id' => $request->route('id')]); + + $document = $booking->documents()->where('document_type', DocumentType::ECOMMERCE_PURCHASE_ORDER)->first(); + + $this->canDeleteDocument->passes(); + + $this->deletesDocument->execute($document); + + // todo: delete purchaseOrderFor1688 + // if(in_array($booking->company->id, [199, 510])){ + // $this->createPurchaseOrderFor1688OrderProcessor->execute($booking); + // } + + return $this->response([]); + } + +} diff --git a/app/Http/Controllers/Bookings/DeletePurchaseOrderPdfController.php b/app/Http/Controllers/Bookings/DeletePurchaseOrderPdfController.php new file mode 100644 index 00000000..0113c0d5 --- /dev/null +++ b/app/Http/Controllers/Bookings/DeletePurchaseOrderPdfController.php @@ -0,0 +1,16 @@ +execute($request); + } + +} \ No newline at end of file diff --git a/resources/assets/vue/components/bookings/forms/DeletePoFormComponent.vue b/resources/assets/vue/components/bookings/forms/DeletePoFormComponent.vue new file mode 100644 index 00000000..b8701f85 --- /dev/null +++ b/resources/assets/vue/components/bookings/forms/DeletePoFormComponent.vue @@ -0,0 +1,33 @@ + + \ No newline at end of file diff --git a/resources/assets/vue/components/bookings/sections/BookingDetailsSectionComponent.vue b/resources/assets/vue/components/bookings/sections/BookingDetailsSectionComponent.vue index fe2826e4..073d7741 100644 --- a/resources/assets/vue/components/bookings/sections/BookingDetailsSectionComponent.vue +++ b/resources/assets/vue/components/bookings/sections/BookingDetailsSectionComponent.vue @@ -261,6 +261,15 @@ + +
+
+
Delete PO
+
+ + + +
diff --git a/routes/booking.php b/routes/booking.php index b645345c..81db27b6 100644 --- a/routes/booking.php +++ b/routes/booking.php @@ -28,6 +28,7 @@ Route::group(['prefix' => 'booking', 'as' => 'booking.', 'namespace' => 'Booking Route::post('{id}/purchase_order/verification', 'ApprovePurchaseOrderController@approve')->name('po.approval'); Route::post('{id}/purchase_order/pdf', 'UploadPurchaseOrderController@upload')->name('po.pdf'); + Route::delete('{id}/purchase_order/pdf', 'DeletePurchaseOrderPdfController@delete')->name('po.pdf.delete'); Route::put('{id}/updateAmount', 'UpdateBookingAmountController@update')->name('booking_amount.update');