diff --git a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php index 75334583..74e92fa6 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php @@ -78,22 +78,18 @@ class CreateBookingRefundLogic extends AbstractControllerLogic public function logic(Request $request) : JsonResponse { - $booking = Booking::find($request->route('id')); - $transaction = $this->fetchesTransaction->execute(['id' => $request->route('payment_id')]); + $booking = $transaction->owner; + $billNumber = $this->generatesTransactionBillNumber->execute('RFD-'); - if((int) $transaction->type === TransactionType::BILL){ - $customerBooking = $booking->transactions()->payments()->complete()->where('original_amount', '=', $transaction->original_amount)->where('id', '<', $transaction->id)->orderByDesc('id')->first(); - } - $refund = $this->calculatesBookingRefundAmount->execute($booking, $booking->fix_currency_id, $transaction->bill_no); - // dd($refund); + $refund = $transaction->transactions()->refunds()->sum('amount'); if($refund + $request->input('amount') > $transaction->original_amount) throw new MalformedRequestException('Your refund must not be greater than '. $transaction->original_amount .'.'); - $transactionRefundCalculationObject = new TransactionRefundCalculationObject($booking, (int) $transaction->type === TransactionType::BILL ? $customerBooking : $transaction, $request->input('amount')); + $transactionRefundCalculationObject = new TransactionRefundCalculationObject($booking, $transaction, $request->input('amount')); $transactionRefundCalculationObject->init(); $object = new TransactionObject($billNumber, TransactionType::REFUND, 1, $booking->company->id, @@ -102,7 +98,7 @@ class CreateBookingRefundLogic extends AbstractControllerLogic $transactionRefundCalculationObject->getConversionObject()->getCurrencyId(), $transactionRefundCalculationObject->getTransaction()->currency_rate, $transactionRefundCalculationObject->getRefundTax(), $transactionRefundCalculationObject->getRefundServiceCharge(), null, ApprovalStatus::PENDING_VERIFICATION, [], $transaction->bill_no); - $transaction = $this->createsTransaction->execute($booking, $object); + $transaction = $this->createsTransaction->execute($transaction, $object); return $this->resourceResponse(new TransactionResource($transaction)); } diff --git a/app/Classes/Modules/Transactions/ControllersLogic/UpdateRefundTransactionStatusLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/UpdateRefundTransactionStatusLogic.php index d760b05d..b86e4878 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/UpdateRefundTransactionStatusLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/UpdateRefundTransactionStatusLogic.php @@ -71,14 +71,15 @@ class UpdateRefundTransactionStatusLogic extends AbstractControllerLogic $transaction = $this->updatesTransactionStatus->execute($transaction, $request->input('status')); - $company = $this->fetchesCompany->execute(['id' => $transaction->booking->company_id]); + $booking = $transaction->owner->owner; - $reference = 'Refund for booking reference '.$transaction->booking->marking; + $reference = 'Credit Voucher for Overpaid for Ref. '.$booking->marking; if ($transaction->status == ApprovalStatus::APPROVED) { - // add to credit wallet - $this->creditWalletProcessor->execute($company, $transaction->type, $transaction->amount, $reference); - } + $this->creditWalletProcessor->execute($booking->company, $transaction->type, $transaction->amount, $reference); + } + + return $this->response([]); } diff --git a/app/Classes/Modules/Wallets/Processors/CreditWalletProcessor.php b/app/Classes/Modules/Wallets/Processors/CreditWalletProcessor.php index 2b303938..d86a4465 100644 --- a/app/Classes/Modules/Wallets/Processors/CreditWalletProcessor.php +++ b/app/Classes/Modules/Wallets/Processors/CreditWalletProcessor.php @@ -68,9 +68,10 @@ class CreditWalletProcessor { if (!$company->wallets()->first()) { $object = new WalletObject($company->id, 1, $this->generatesWalletCode->execute()); - $wallet = $this->createsWallet->execute($object, $company); + $this->createsWallet->execute($object, $company); } + /** @var Wallet $wallet */ $wallet = $company->wallets()->first(); $billNumber = $this->generatesTransactionBillNumber->execute($transactionType === 2 ? 'DEBIT-NOTE-' : 'CREDIT-NOTE-'); diff --git a/app/Http/Resources/TransactionResource.php b/app/Http/Resources/TransactionResource.php index 37971b36..8bb30512 100644 --- a/app/Http/Resources/TransactionResource.php +++ b/app/Http/Resources/TransactionResource.php @@ -17,7 +17,7 @@ class TransactionResource extends JsonResource public function toArray($request) { - $booking = (int)$this->type === TransactionType::BILL ? $this->owner->owner : $this->owner; + $booking = in_array((int)$this->type, [TransactionType::BILL, TransactionType::REFUND])? $this->owner->owner : $this->owner; $days = $this->updated_at->endOfDay()->addWeekdays($booking->service_id === 3 ? 3 : 1); return [ @@ -39,7 +39,8 @@ class TransactionResource extends JsonResource 'status' => (int) $this->status, 'details' => TransactionDetailResource::collection($this->transactionDetails), 'documents' => new DocumentResource($this->documents()->first()), - 'transaction_bill' => new TransactionResource($this->when((int) $this->type === TransactionType::PAYMENT, $this->transactions()->first())), + 'transaction_bill' => new TransactionResource($this->when((int) $this->type === TransactionType::PAYMENT, $this->transactions()->bills()->first())), + 'transaction_refunds' => TransactionResource::collection($this->when((int) $this->type === TransactionType::PAYMENT, $this->transactions()->refunds()->get())), 'expires_on' => Carbon::parse($this->expires_on)->format('d-m-Y h:i:s A'), 'updated_at' => Carbon::parse($this->updated_at)->format('d-m-Y h:i:s A'), 'interval' => [ diff --git a/resources/assets/vue/components/bookings/elements/RefundConfirmationComponent.vue b/resources/assets/vue/components/bookings/elements/RefundConfirmationComponent.vue index c954a374..a2d3b277 100644 --- a/resources/assets/vue/components/bookings/elements/RefundConfirmationComponent.vue +++ b/resources/assets/vue/components/bookings/elements/RefundConfirmationComponent.vue @@ -24,16 +24,16 @@
Refund Type:
-
- Partially Refund +
+ Full Refund
-
- Fully Refund +
+ Partial Refund
-
+
diff --git a/resources/assets/vue/components/bookings/elements/RefundVerificationComponent.vue b/resources/assets/vue/components/bookings/elements/RefundVerificationComponent.vue index 914cb47a..e78a14f6 100644 --- a/resources/assets/vue/components/bookings/elements/RefundVerificationComponent.vue +++ b/resources/assets/vue/components/bookings/elements/RefundVerificationComponent.vue @@ -28,7 +28,7 @@
Amount
- {{(Math.round((data.booking.amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}} + {{(Math.round((data.amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
diff --git a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue index 643cd29a..14947ef8 100644 --- a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue +++ b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue @@ -238,6 +238,18 @@

Wallet Credit

(Better Rate)

+ + + + + +
diff --git a/resources/views/pages/dashboards/admin.blade.php b/resources/views/pages/dashboards/admin.blade.php index 40ffa8ff..d998c745 100644 --- a/resources/views/pages/dashboards/admin.blade.php +++ b/resources/views/pages/dashboards/admin.blade.php @@ -92,175 +92,6 @@ -
-
-
-
-
-
    -
  • -
  • -
-
-
-
-
-

webarch

-

Today's sales

-
-

- MYR - 102,967 -

-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Purchase CODE #2345 - Qty 1 - - 27 RM -
Purchase CODE #2345 - Qty 1 - - 27 RM -
Purchase CODE #2345 - Qty 1 - - 27 RM -
Purchase CODE #2345 - Qty 1 - - 27 RM -
Purchase CODE #2345 - Qty 1 - - 27 RM -
Purchase CODE #2345 - Qty 1 - - 27 RM -
Purchase CODE #2345 - Qty 1 - - 27 RM -
Purchase CODE #2345 - Qty 1 - - 27 RM -
Purchase CODE #2345 - Qty 1 - - 27 RM -
Purchase CODE #2345 - Qty 1 - - 27 RM -
-
-
-
-
-
-
-
-
-
-
- {{----}} - {{----}} - {{----}} -
-
-
-
-
-