diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CancelBillGroupLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CancelBillGroupLogic.php new file mode 100644 index 00000000..615ae342 --- /dev/null +++ b/app/Classes/Modules/Transactions/ControllersLogic/CancelBillGroupLogic.php @@ -0,0 +1,66 @@ + 'Cancel Bill Group Transaction', + 'message' => 'You have successfully cancelled this Bill Group Transaction' + ]; + } + + /** @var FetchesBillGroup */ + private $fetchesBillGroup; + + /** @var UpdatesTransactionStatus */ + private $updatesTransactionStatus; + + /** + * CancelBillGroupLogic constructor. + * @param FetchesBillGroup $fetchesBillGroup + * @param UpdatesTransactionStatus $updatesTransactionStatus + */ + public function __construct(FetchesBillGroup $fetchesBillGroup, UpdatesTransactionStatus $updatesTransactionStatus) + { + $this->fetchesBillGroup = $fetchesBillGroup; + $this->updatesTransactionStatus = $updatesTransactionStatus; + } + + /** + * @param Request $request + * @return JsonResponse + * @throws \App\Classes\Exceptions\MalformedRequestException + */ + public function logic(Request $request) : JsonResponse + { + $billGroup = $this->fetchesBillGroup->execute(['id' => $request->route('id')]); + + $transactions = $billGroup->transactions()->get(); + + foreach($transactions as $transaction) { + if ($transaction->status === ApprovalStatus::APPROVED || $transaction->status === ApprovalStatus::COMPLETED) { + $this->updatesTransactionStatus->execute($transaction, ApprovalStatus::PENDING_VERIFICATION); + } + } + + $billGroup->status = ApprovalStatus::PENDING_VERIFICATION; + $billGroup->save(); + + return $this->resourceResponse(new BillGroupResource($billGroup)); + } + +} \ No newline at end of file diff --git a/app/Http/Controllers/Transactions/CancelBillGroupController.php b/app/Http/Controllers/Transactions/CancelBillGroupController.php new file mode 100644 index 00000000..2eab79c8 --- /dev/null +++ b/app/Http/Controllers/Transactions/CancelBillGroupController.php @@ -0,0 +1,20 @@ +execute($request); + } +} diff --git a/resources/assets/vue/components/bookings/elements/BillGroupComponent.vue b/resources/assets/vue/components/bookings/elements/BillGroupComponent.vue index 9a309cde..6bde1a01 100644 --- a/resources/assets/vue/components/bookings/elements/BillGroupComponent.vue +++ b/resources/assets/vue/components/bookings/elements/BillGroupComponent.vue @@ -50,6 +50,22 @@ +
+
+ Cancel +
+ + + + +
diff --git a/resources/assets/vue/components/general/forms/GeneralConfirmationFormComponent.vue b/resources/assets/vue/components/general/forms/GeneralConfirmationFormComponent.vue index 6d6ad557..0cb9435b 100644 --- a/resources/assets/vue/components/general/forms/GeneralConfirmationFormComponent.vue +++ b/resources/assets/vue/components/general/forms/GeneralConfirmationFormComponent.vue @@ -61,7 +61,7 @@ successHandler(){ this.closeModal(); this.formHandler(); - if (this.section && (this.section === 'paymentInProgressBillGroupList' || this.section === 'paymentVerificationBillGroupList')) { + if (this.section && (this.section === 'paymentInProgressBillGroupList' || this.section === 'paymentVerificationBillGroupList' || this.section === 'paidBillGroupList')) { this.$store.dispatch('toggleSection', {name: 'paymentInProgressBillGroupList', status: !this.$store.getters.isShowing('paymentInProgressBillGroupList')}); this.$store.dispatch('toggleSection', {name: 'paymentVerificationBillGroupList', status: !this.$store.getters.isShowing('paymentVerificationBillGroupList')}); this.$store.dispatch('toggleSection', {name: 'paidBillGroupList', status: !this.$store.getters.isShowing('paidBillGroupList')}); diff --git a/routes/transaction.php b/routes/transaction.php index 654b3fb8..51e9ab34 100644 --- a/routes/transaction.php +++ b/routes/transaction.php @@ -41,6 +41,7 @@ Route::group(['prefix' => 'transactions', 'namespace' => 'Transactions', 'as' => Route::post('/transaction/{id}', 'CreateBillGroupPaymentProofDocumentController@create')->name('payment_proof.create'); Route::post('/transaction/{id}/approval/{status}', 'ApproveBillGroupPaymentVerificationController@approve')->where('status', 'approve|reject')->name('payment_proof.approval'); Route::delete('/{id}/delete', 'DeleteBillGroupController@delete')->name('delete'); + Route::put('/{id}/cancel', 'CancelBillGroupController@cancel')->name('cancel'); Route::post('/{id}/pay', 'CreateBillGroupPaymentTransactionController@pay')->name('pay'); // Route::post('/bulk/po', 'CreateBulkPurchaseOrderDocumentController@create')->name('bulk.po'); });