From ed0bcb34c452028892822e8aae66cc847a903268 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Thu, 29 Jun 2023 21:24:21 +0800 Subject: [PATCH] list all customer transactions --- .../FetchCompanyTransactionStatementLogic.php | 61 +++++++++ ...hCompanyTransactionStatementController.php | 21 +++ .../Resources/PaymentTransactionResource.php | 45 +++++++ ...omerTransactionHistorySectionComponent.vue | 120 ++++++++++++++++++ .../pages/transactions/history.blade.php | 8 ++ routes/transaction.php | 1 + routes/web.php | 5 + 7 files changed, 261 insertions(+) create mode 100644 app/Classes/Modules/Transactions/ControllersLogic/FetchCompanyTransactionStatementLogic.php create mode 100644 app/Http/Controllers/Transactions/FetchCompanyTransactionStatementController.php create mode 100644 app/Http/Resources/PaymentTransactionResource.php create mode 100644 resources/assets/vue/components/bookings/elements/CustomerTransactionHistorySectionComponent.vue create mode 100644 resources/views/pages/transactions/history.blade.php diff --git a/app/Classes/Modules/Transactions/ControllersLogic/FetchCompanyTransactionStatementLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/FetchCompanyTransactionStatementLogic.php new file mode 100644 index 00000000..0542e042 --- /dev/null +++ b/app/Classes/Modules/Transactions/ControllersLogic/FetchCompanyTransactionStatementLogic.php @@ -0,0 +1,61 @@ + 'Retrieved Company Balance Account', + 'message' => 'You have successfully retrieved company balance account' + ]; + } + + /** + * FetchCompanyAccountBalanceLogic constructor. + */ + public function __construct() + { + } + + public function logic(Request $request): JsonResponse + { + $companyId = $request->route('id'); + + $transactions = Transaction::where(function ($query) use ($companyId) { + $query + ->where('type', TransactionType::PAYMENT) + ->where('owner_type', Booking::class) + ->whereHas('booking', function ($query) use ($companyId) { + $query->where('company_id', $companyId); + }); + }) + ->orWhere(function ($query) use ($companyId) { + $query->whereHas('owner', function ($query) use ($companyId) { + $query->where('owner_id', $companyId); + $query->where('owner_type', Company::class); + }) + ->where('owner_type', Wallet::class) + ->where('type', '!=', TransactionType::PAYMENT); + }) + ->orderBy('created_at', 'desc') + ->get(); + + return $this->collectionResponse(PaymentTransactionResource::collection($transactions)); + } +} diff --git a/app/Http/Controllers/Transactions/FetchCompanyTransactionStatementController.php b/app/Http/Controllers/Transactions/FetchCompanyTransactionStatementController.php new file mode 100644 index 00000000..a1d8c3cb --- /dev/null +++ b/app/Http/Controllers/Transactions/FetchCompanyTransactionStatementController.php @@ -0,0 +1,21 @@ +execute($request); + } +} diff --git a/app/Http/Resources/PaymentTransactionResource.php b/app/Http/Resources/PaymentTransactionResource.php new file mode 100644 index 00000000..0bdfa86b --- /dev/null +++ b/app/Http/Resources/PaymentTransactionResource.php @@ -0,0 +1,45 @@ +type, [TransactionType::BILL, TransactionType::REFUND])? $this->owner->owner : $this->owner; + + return [ + 'id' => $this->id, + 'booking_marking' => $booking->marking, + 'type' => (int) $this->type, + 'bill_no' => $this->bill_no, + 'payment_reference' => $this->payment_reference, + 'payment_method' => (float) $this->payment_method, + 'recipient_bank_account' => new BankResource($booking->bank), + 'issuer_name' => $this->issuerCompany->name, + 'issuer_id' => $this->issuerCompany->id, + 'amount' => (double) $this->amount, + 'original_amount' => (double) $this->original_amount, + 'currency' => new CurrencyResource($this->currency), + 'original_currency' => new CurrencyResource($this->original_currency), + 'service_charge' => (double) $this->service_charge, + 'tax' => (double) $this->tax, + 'currency_rate' => (double) $this->currency_rate, + 'status' => (int) $this->status, + 'updated_at' => Carbon::parse($this->updated_at)->format('d-m-Y h:i:s A'), + 'created_at' => Carbon::parse($this->created_at)->format('d-m-Y h:i:s A') + ]; + } +} diff --git a/resources/assets/vue/components/bookings/elements/CustomerTransactionHistorySectionComponent.vue b/resources/assets/vue/components/bookings/elements/CustomerTransactionHistorySectionComponent.vue new file mode 100644 index 00000000..9ac3f5b6 --- /dev/null +++ b/resources/assets/vue/components/bookings/elements/CustomerTransactionHistorySectionComponent.vue @@ -0,0 +1,120 @@ + + diff --git a/resources/views/pages/transactions/history.blade.php b/resources/views/pages/transactions/history.blade.php new file mode 100644 index 00000000..49a8145c --- /dev/null +++ b/resources/views/pages/transactions/history.blade.php @@ -0,0 +1,8 @@ +@extends('layouts.base_portal') +@section('inner_content') +
+
+ +
+
+@endsection \ No newline at end of file diff --git a/routes/transaction.php b/routes/transaction.php index b3dd6434..708c2439 100644 --- a/routes/transaction.php +++ b/routes/transaction.php @@ -22,6 +22,7 @@ Route::group(['prefix' => 'transactions', 'namespace' => 'Transactions', 'as' => Route::get('wallet/list', 'ListWalletTransactionsController@list')->name('wallet.list'); Route::get('/company/{id}/account/balance', 'FetchCompanyAccountBalanceController@fetch')->name('company.account.balance'); + Route::get('/company/{id}/transaction/fetch', 'FetchCompanyTransactionStatementController@fetch')->name('company.transaction.fetch'); Route::get('/bank/{id}/account/balance', 'FetchBankAccountBalanceController@fetch')->name('bank.account.balance'); diff --git a/routes/web.php b/routes/web.php index 93a87218..11c727fb 100644 --- a/routes/web.php +++ b/routes/web.php @@ -74,6 +74,11 @@ Route::get('/customer/{marking}', function ($marking) { return view('pages.customers.profile', ['id' => $id]); })->name('customer.profile'); +Route::get('/customer/{marking}/transactions', function ($marking) { + $id = \App\Models\Company::where('reference', '=', $marking)->first()->id; + return view('pages.transactions.history', ['id' => $id]); +})->name('transactions.history'); + Route::get('/payments', function () { return view('pages.payments'); })->name('payments');