From a90c79396b2fbe1c3624c62dc4f62dc1cabcafd5 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Thu, 29 Jun 2023 22:00:26 +0800 Subject: [PATCH] update list all customer transactions --- .../FetchCompanyTransactionStatementLogic.php | 7 +++++-- app/Http/Resources/PaymentTransactionResource.php | 13 ++++++++++++- .../CustomerTransactionHistorySectionComponent.vue | 6 +++--- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/app/Classes/Modules/Transactions/ControllersLogic/FetchCompanyTransactionStatementLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/FetchCompanyTransactionStatementLogic.php index 0542e042..c16ac453 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/FetchCompanyTransactionStatementLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/FetchCompanyTransactionStatementLogic.php @@ -6,6 +6,7 @@ namespace App\Classes\Modules\Transactions\ControllersLogic; use Illuminate\Http\Request; use Illuminate\Http\JsonResponse; use App\Classes\General\Abstracts\AbstractControllerLogic; +use App\Classes\ValueObjects\Constants\ApprovalStatus; use App\Classes\ValueObjects\Constants\TransactionType; use App\Http\Resources\PaymentTransactionResource; use App\Models\Booking; @@ -21,8 +22,8 @@ class FetchCompanyTransactionStatementLogic extends AbstractControllerLogic protected function notification(): array { return [ - 'title' => 'Retrieved Company Balance Account', - 'message' => 'You have successfully retrieved company balance account' + 'title' => 'Retrieved Company Transaction Statement', + 'message' => 'You have successfully retrieved company transaction statement' ]; } @@ -41,6 +42,7 @@ class FetchCompanyTransactionStatementLogic extends AbstractControllerLogic $query ->where('type', TransactionType::PAYMENT) ->where('owner_type', Booking::class) + ->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]) ->whereHas('booking', function ($query) use ($companyId) { $query->where('company_id', $companyId); }); @@ -53,6 +55,7 @@ class FetchCompanyTransactionStatementLogic extends AbstractControllerLogic ->where('owner_type', Wallet::class) ->where('type', '!=', TransactionType::PAYMENT); }) + ->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]) ->orderBy('created_at', 'desc') ->get(); diff --git a/app/Http/Resources/PaymentTransactionResource.php b/app/Http/Resources/PaymentTransactionResource.php index 0bdfa86b..456ece3d 100644 --- a/app/Http/Resources/PaymentTransactionResource.php +++ b/app/Http/Resources/PaymentTransactionResource.php @@ -5,6 +5,7 @@ namespace App\Http\Resources; use App\Classes\ValueObjects\Constants\TransactionType; use App\Models\Booking; use Carbon\Carbon; +use App\Models\Wallet; use Illuminate\Http\Resources\Json\JsonResource; class PaymentTransactionResource extends JsonResource @@ -20,9 +21,19 @@ class PaymentTransactionResource extends JsonResource $booking = in_array((int)$this->type, [TransactionType::BILL, TransactionType::REFUND])? $this->owner->owner : $this->owner; + $booking_marking = ''; + switch ($this->owner_type) { + case Booking::class: + $booking_marking = $booking->marking; + break; + case Wallet::class: + $booking_marking = $this->booking->marking; + break; + } + return [ 'id' => $this->id, - 'booking_marking' => $booking->marking, + 'booking_marking' => $booking_marking, 'type' => (int) $this->type, 'bill_no' => $this->bill_no, 'payment_reference' => $this->payment_reference, diff --git a/resources/assets/vue/components/bookings/elements/CustomerTransactionHistorySectionComponent.vue b/resources/assets/vue/components/bookings/elements/CustomerTransactionHistorySectionComponent.vue index 9ac3f5b6..3d441d53 100644 --- a/resources/assets/vue/components/bookings/elements/CustomerTransactionHistorySectionComponent.vue +++ b/resources/assets/vue/components/bookings/elements/CustomerTransactionHistorySectionComponent.vue @@ -14,7 +14,7 @@
Date
Description
-
Type
+
Marking
Incoming
Outgoing
Balance
@@ -22,8 +22,8 @@
{{item.created_at}}
-
{{ item.payment_reference ? item.payment_reference + ' - ' : '' }} {{convertPaymentMethod(item.payment_method)}} - {{item.booking_marking}}
-
{{ convertTransactionType(item.type) }}
+
{{ convertTransactionType(item.type) }} {{ item.payment_reference ? ' - ' + item.payment_reference : '' }}
+
{{[5, 9].includes(parseFloat(item.type)) ? (Math.round((parseFloat(item.amount) + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") : ''}}
{{[1, 11].includes(parseFloat(item.type)) ? '- ' + (Math.round((parseFloat(item.amount) + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") : ''}}
{{remainingBalance(index)}}