From a1bbc69ec51c87695d7da30eb34bf9c91d4f4d37 Mon Sep 17 00:00:00 2001 From: JiaSheng Date: Mon, 11 Mar 2024 22:13:01 +0800 Subject: [PATCH] -update payment amount under payment history section on booking page -export approved refund payment --- .../elements/PaymentHistoryComponent.vue | 16 +++-- routes/web.php | 59 +++++++++++++++++++ 2 files changed, 66 insertions(+), 9 deletions(-) diff --git a/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue b/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue index 68213ea2..f3b3fb38 100644 --- a/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue +++ b/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue @@ -18,13 +18,13 @@
Payment Amount
- {{item.original_currency.short_code}} {{(Math.round((item.original_amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}} + {{item.original_currency.short_code}} {{(Math.round((item.original_amount - item.refunded_amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
Refunded Amount
- {{item.currency.short_code}} {{(Math.round((totalConvertRefunds + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}} + {{item.original_currency.short_code}} {{(Math.round((item.refunded_amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
@@ -68,15 +68,13 @@
Payment Amount
- {{item.original_currency.short_code}} {{(Math.round((item.original_amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}} + {{item.original_currency.short_code}} {{(Math.round((item.original_amount - item.refunded_amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
-
-
-
Refunded Amount
-
-
-
{{item.original_currency.short_code}} {{(Math.round((totalRefunds + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
+
+
Refunded Amount
+
+ {{item.original_currency.short_code}} {{(Math.round((totalRefunds + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
diff --git a/routes/web.php b/routes/web.php index bc613043..2370a7fc 100644 --- a/routes/web.php +++ b/routes/web.php @@ -433,6 +433,65 @@ Route::get('/pending_orders', function(){ echo ''; })->name('orders.pending'); +Route::get('/approve_refunds', function(){ + $payments = Transaction::where('type', TransactionType::PAYMENT)->where('owner_type', Booking::class)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED, ApprovalStatus::REFUNDED]) + ->whereHas('transactions', function ($query) { + return $query->where('type', TransactionType::REFUND)->where('status', ApprovalStatus::APPROVED); + }) + ->orderBy('updated_at', 'DESC') + ->get(); + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + foreach ($payments as $index => $payment){ + $booking = $payment->owner; + $original_refunds = floatval((App()->make(CalculatesBookingRefundAmount::class))->calculateRefundAmount($payment, $booking->fix_currency_id)); + $refunds = $original_refunds / $payment->currency_rate; + if(!$booking instanceof Booking){ + dd($payment); + } + $bankType = str::length($booking->bank->holder_name) > 4 ? 'Company' : 'Personal'; + + if (!preg_match('/[^A-Za-z0-9]/', $booking->bank->holder_name)) + { + $bankType = str_word_count($booking->bank->holder_name) > 4 ? 'Company' : 'Personal'; + } + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo '
No.Updated AtMarkingPayment MethodRefunded AmountCompany ReferenceRefunded Original AmountServiceLast Updated AtBank TypeBank Holder Name
'.($index + 1).'.'.$payment->updated_at->format('d-M-y').''.$booking->marking.''.\App\Classes\ValueObjects\Constants\PaymentMethodType::PAYMENT_METHODS_ID[$payment->payment_method].''.$payment->currency->short_code.''.number_format($refunds, 5, '.', '').''.$booking->company->reference.''.$payment->original_currency->short_code.''.number_format($original_refunds, 5, '.', '').''.$booking->service->name.''.$payment->updated_at->diffForHumans().''.$bankType.''.$booking->bank->holder_name.'
'; +})->name('orders.refunds'); + Route::get('/group/text/{id}', function($id){ $group = \App\Models\Group::where('id', $id)->first();