From f03d91ba422a1e5d0f29e559b788a66dbbbb3f9d Mon Sep 17 00:00:00 2001 From: edmondlang Date: Fri, 10 May 2024 00:00:01 +0800 Subject: [PATCH] add remarks for refund --- .../General/Abstracts/AbstractRule.php | 4 +-- app/Classes/General/Interfaces/Remarkable.php | 13 ++++++++++ .../CreateBookingRefundLogic.php | 14 ++++++++++- .../Standards/Rules/CanCreateRemark.php | 2 +- .../Standards/Rules/CanDeleteRemark.php | 2 +- .../Standards/Rules/CanFetchRemark.php | 2 +- .../Standards/Rules/CanListRemarks.php | 2 +- .../Standards/Rules/CanUpdateRemark.php | 2 +- app/Http/Resources/TransactionResource.php | 1 + app/Models/Transaction.php | 3 ++- .../elements/PaymentHistoryComponent.vue | 8 ++++++ .../elements/RefundConfirmationComponent.vue | 13 +++++++++- .../general/elements/RemarkComponent.vue | 25 ++++++++++++++++--- .../general/elements/RemarkListComponent.vue | 4 +-- .../forms/RemarkCommentFormComponent.vue | 5 +++- 15 files changed, 83 insertions(+), 17 deletions(-) create mode 100644 app/Classes/General/Interfaces/Remarkable.php diff --git a/app/Classes/General/Abstracts/AbstractRule.php b/app/Classes/General/Abstracts/AbstractRule.php index d2e0568b..8a9b6f86 100644 --- a/app/Classes/General/Abstracts/AbstractRule.php +++ b/app/Classes/General/Abstracts/AbstractRule.php @@ -27,7 +27,7 @@ abstract class AbstractRule public function passes(?DataTransferObject $object = null): bool { try { if(!$this->authorized()){ - throw new AccessForbiddenException('You don\'t have permission to preform this action'); + throw new AccessForbiddenException('You don\'t have permission to perform this action'); } $this->validators($object); @@ -36,7 +36,7 @@ abstract class AbstractRule return true; } catch(AccessForbiddenException $exception){ - throw new AccessForbiddenException('You don\'t have permission to preform this action'); + throw new AccessForbiddenException('You don\'t have permission to perform this action'); } catch(\Exception $exception){ throw new RequestValidationException($exception->getMessage()); } diff --git a/app/Classes/General/Interfaces/Remarkable.php b/app/Classes/General/Interfaces/Remarkable.php new file mode 100644 index 00000000..dcbd94ce --- /dev/null +++ b/app/Classes/General/Interfaces/Remarkable.php @@ -0,0 +1,13 @@ +fetchBookingQuotation = $fetchBookingQuotation; $this->fetchesTransaction = $fetchesTransaction; @@ -69,6 +75,7 @@ class CreateBookingRefundLogic extends AbstractControllerLogic $this->generatesTransactionBillNumber = $generatesTransactionBillNumber; $this->createsTransaction = $createsTransaction; $this->updateRefundTransactionStatusLogic = $updateRefundTransactionStatusLogic; + $this->createRemarkProcessor = $createRemarkProcessor; } /** @@ -132,6 +139,11 @@ class CreateBookingRefundLogic extends AbstractControllerLogic } + if($request->input('refundRemark')){ + $remarkObject = new RemarkObject($request->input('refundRemark'), Auth()->user()->id); + $this->createRemarkProcessor->execute($this->fetchesTransaction->execute(['id' => $refund_transaction->id]), $remarkObject); + } + return $this->resourceResponse(new TransactionResource($refund_transaction)); } diff --git a/app/Classes/Modules/Remarks/Standards/Rules/CanCreateRemark.php b/app/Classes/Modules/Remarks/Standards/Rules/CanCreateRemark.php index a7d2e5b1..fc51178f 100644 --- a/app/Classes/Modules/Remarks/Standards/Rules/CanCreateRemark.php +++ b/app/Classes/Modules/Remarks/Standards/Rules/CanCreateRemark.php @@ -26,7 +26,7 @@ class CanCreateRemark extends AbstractRule /** * @return bool */ - protected function authorized($object): bool + protected function authorized(): bool { // TODO Set Authorization rules return true; diff --git a/app/Classes/Modules/Remarks/Standards/Rules/CanDeleteRemark.php b/app/Classes/Modules/Remarks/Standards/Rules/CanDeleteRemark.php index 1c61ac9d..7ddece31 100644 --- a/app/Classes/Modules/Remarks/Standards/Rules/CanDeleteRemark.php +++ b/app/Classes/Modules/Remarks/Standards/Rules/CanDeleteRemark.php @@ -13,7 +13,7 @@ class CanDeleteRemark extends AbstractRule /** * @return bool */ - protected function authorized($object): bool + protected function authorized(): bool { // TODO Set Authorization rules return true; diff --git a/app/Classes/Modules/Remarks/Standards/Rules/CanFetchRemark.php b/app/Classes/Modules/Remarks/Standards/Rules/CanFetchRemark.php index 31ae8301..6642611c 100644 --- a/app/Classes/Modules/Remarks/Standards/Rules/CanFetchRemark.php +++ b/app/Classes/Modules/Remarks/Standards/Rules/CanFetchRemark.php @@ -13,7 +13,7 @@ class CanFetchRemark extends AbstractRule /** * @return bool */ - protected function authorized($object): bool + protected function authorized(): bool { // TODO Set Authorization rules return true; diff --git a/app/Classes/Modules/Remarks/Standards/Rules/CanListRemarks.php b/app/Classes/Modules/Remarks/Standards/Rules/CanListRemarks.php index b1372049..4911a53b 100644 --- a/app/Classes/Modules/Remarks/Standards/Rules/CanListRemarks.php +++ b/app/Classes/Modules/Remarks/Standards/Rules/CanListRemarks.php @@ -13,7 +13,7 @@ class CanListRemarks extends AbstractRule /** * @return bool */ - protected function authorized($object): bool + protected function authorized(): bool { // TODO Set Authorization rules return true; diff --git a/app/Classes/Modules/Remarks/Standards/Rules/CanUpdateRemark.php b/app/Classes/Modules/Remarks/Standards/Rules/CanUpdateRemark.php index f6fd6587..8a8c10e8 100644 --- a/app/Classes/Modules/Remarks/Standards/Rules/CanUpdateRemark.php +++ b/app/Classes/Modules/Remarks/Standards/Rules/CanUpdateRemark.php @@ -26,7 +26,7 @@ class CanUpdateRemark extends AbstractRule /** * @return bool */ - protected function authorized($object): bool + protected function authorized(): bool { // TODO Set Authorization rules return true; diff --git a/app/Http/Resources/TransactionResource.php b/app/Http/Resources/TransactionResource.php index b431c854..d259d777 100644 --- a/app/Http/Resources/TransactionResource.php +++ b/app/Http/Resources/TransactionResource.php @@ -53,6 +53,7 @@ class TransactionResource extends JsonResource 'value' => $days->gt(Carbon::now()) ? '+' : '-', 'duration' => $days->diff(Carbon::now())->format('%d'), ], + 'remarks' => RemarkResource::collection($this->remarks), 'redemption' => new VoucherRedemptionResource($this->voucherRedemption) ]; } diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index aba5decc..31b67e69 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -3,6 +3,7 @@ namespace App\Models; use App\Classes\General\Interfaces\Documentable; +use App\Classes\General\Interfaces\Remarkable; use App\Classes\General\Interfaces\Transactionable; use App\Classes\General\Interfaces\Voucherifiable; use App\Classes\General\Traits\LogData; @@ -21,7 +22,7 @@ use Staudenmeir\EloquentHasManyDeep\HasTableAlias; use App\Models\StatementTransactionOwner; -class Transaction extends AbstractModel implements Documentable, Transactionable, Voucherifiable +class Transaction extends AbstractModel implements Documentable, Transactionable, Voucherifiable, Remarkable { use HasTableAlias; use SoftDeletes; diff --git a/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue b/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue index 7679b807..ac77bc06 100644 --- a/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue +++ b/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue @@ -332,6 +332,14 @@
{{ refund.status === 1 ? 'Pending Verification' : refund.status === 2 ? 'Approved' : 'Rejected'}}
+
+ + + + + + +
Amount
diff --git a/resources/assets/vue/components/bookings/elements/RefundConfirmationComponent.vue b/resources/assets/vue/components/bookings/elements/RefundConfirmationComponent.vue index c87122a5..3470891a 100644 --- a/resources/assets/vue/components/bookings/elements/RefundConfirmationComponent.vue +++ b/resources/assets/vue/components/bookings/elements/RefundConfirmationComponent.vue @@ -35,6 +35,14 @@
+
+
+ + + + +
+
Paid Amount: {{ paidAmount }}
@@ -71,6 +79,7 @@ export default { data() { return { refundAmount: (Math.round((this.data.original_amount - this.data.refunded_amount + Number.EPSILON) * 100) / 100).toFixed(2), + refundRemark: '', refundMethod: { name: 'Fully Refund', status: false }, refundMethods: [ { name: 'Fully Refund', label: 'Full Refund' }, @@ -82,7 +91,8 @@ export default { return { refundAmount: { maxValue: maxValue(this.refundMaxValue) - } + }, + refundRemark: {} } }, computed: { @@ -96,6 +106,7 @@ export default { methods: { submitForm() { this.parameters.amount = this.refundAmount; + this.parameters.refundRemark = this.refundRemark; this.submit(this.route('api.booking.refund.create', this.data.booking.id, this.data.id), 'post', this.section, true, true) }, updateRefundType(refund) { diff --git a/resources/assets/vue/components/general/elements/RemarkComponent.vue b/resources/assets/vue/components/general/elements/RemarkComponent.vue index f2f9bf30..bd96c5e8 100644 --- a/resources/assets/vue/components/general/elements/RemarkComponent.vue +++ b/resources/assets/vue/components/general/elements/RemarkComponent.vue @@ -3,17 +3,34 @@
-
- +
+

Remarks

- +
+
+
+
+
+
+
+
+
+

Nothing To + Show Here Yet!

+
+
+
+
+
+
+
-
diff --git a/resources/assets/vue/components/general/elements/RemarkListComponent.vue b/resources/assets/vue/components/general/elements/RemarkListComponent.vue index da218ea9..85d8a6a8 100644 --- a/resources/assets/vue/components/general/elements/RemarkListComponent.vue +++ b/resources/assets/vue/components/general/elements/RemarkListComponent.vue @@ -41,12 +41,12 @@

{{item.content}}

- +
- +
diff --git a/resources/assets/vue/components/general/forms/RemarkCommentFormComponent.vue b/resources/assets/vue/components/general/forms/RemarkCommentFormComponent.vue index 7da26ca8..0bada956 100644 --- a/resources/assets/vue/components/general/forms/RemarkCommentFormComponent.vue +++ b/resources/assets/vue/components/general/forms/RemarkCommentFormComponent.vue @@ -1,5 +1,5 @@