From 1a58f9c984dcd163c502c6f1ceb4bac21543ef8d Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Thu, 7 Nov 2024 05:54:41 +0800 Subject: [PATCH 1/5] Laravel Vapor - Fix a problem on downloading Wallet Transaction History --- .../Services/ExportsCustomersWalletTransactionHistory.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/Classes/Modules/Exports/Services/ExportsCustomersWalletTransactionHistory.php b/app/Classes/Modules/Exports/Services/ExportsCustomersWalletTransactionHistory.php index 745539f5..3121f9ea 100644 --- a/app/Classes/Modules/Exports/Services/ExportsCustomersWalletTransactionHistory.php +++ b/app/Classes/Modules/Exports/Services/ExportsCustomersWalletTransactionHistory.php @@ -20,10 +20,14 @@ class ExportsCustomersWalletTransactionHistory implements FromQuery, WithHeading private $request; private $runningBalance = 0; + protected $startDate; + protected $endDate; - public function __construct(Request $request) + public function __construct(Request $request, $startDate = null, $endDate = null) { $this->request = $request; + $this->startDate = $startDate ? Carbon::parse($startDate)->startOfDay() : Carbon::now()->subMonths(12); + $this->endDate = $endDate ? Carbon::parse($endDate)->endOfDay() : Carbon::now(); } public function headings(): array @@ -43,7 +47,7 @@ class ExportsCustomersWalletTransactionHistory implements FromQuery, WithHeading public function query() { $company = Company::where('reference', $this->request->route('marking'))->first(); - $transactions = $company->wallets()->first()->transactions()->whereIn('transactions.status', [2, 3])->orderBy('id'); + $transactions = $company->wallets()->first()->transactions()->whereIn('transactions.status', [2, 3])->whereBetween('created_at', [$this->startDate, $this->endDate])->orderBy('id'); // dd($transactions->get()->toArray()); return $transactions; From c539edb710476f5cb36c1c1f2811ac280dccf3b3 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Thu, 7 Nov 2024 06:21:21 +0800 Subject: [PATCH 2/5] Laravel Vapor - Fix a problem on downloading Wallet Transaction History --- .../Services/ExportsCustomersWalletTransactionHistory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Classes/Modules/Exports/Services/ExportsCustomersWalletTransactionHistory.php b/app/Classes/Modules/Exports/Services/ExportsCustomersWalletTransactionHistory.php index 3121f9ea..20323b00 100644 --- a/app/Classes/Modules/Exports/Services/ExportsCustomersWalletTransactionHistory.php +++ b/app/Classes/Modules/Exports/Services/ExportsCustomersWalletTransactionHistory.php @@ -26,7 +26,7 @@ class ExportsCustomersWalletTransactionHistory implements FromQuery, WithHeading public function __construct(Request $request, $startDate = null, $endDate = null) { $this->request = $request; - $this->startDate = $startDate ? Carbon::parse($startDate)->startOfDay() : Carbon::now()->subMonths(12); + $this->startDate = $startDate ? Carbon::parse($startDate)->startOfDay() : Carbon::now()->subMonths(6); $this->endDate = $endDate ? Carbon::parse($endDate)->endOfDay() : Carbon::now(); } From 59ddc26a619af0b4cb8f9dfd912d509ec1067174 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Thu, 7 Nov 2024 06:37:19 +0800 Subject: [PATCH 3/5] Laravel Vapor - Fix a problem on downloading Wallet Transaction History --- .../Services/ExportsCustomersWalletTransactionHistory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Classes/Modules/Exports/Services/ExportsCustomersWalletTransactionHistory.php b/app/Classes/Modules/Exports/Services/ExportsCustomersWalletTransactionHistory.php index 20323b00..cb328f46 100644 --- a/app/Classes/Modules/Exports/Services/ExportsCustomersWalletTransactionHistory.php +++ b/app/Classes/Modules/Exports/Services/ExportsCustomersWalletTransactionHistory.php @@ -26,7 +26,7 @@ class ExportsCustomersWalletTransactionHistory implements FromQuery, WithHeading public function __construct(Request $request, $startDate = null, $endDate = null) { $this->request = $request; - $this->startDate = $startDate ? Carbon::parse($startDate)->startOfDay() : Carbon::now()->subMonths(6); + $this->startDate = $startDate ? Carbon::parse($startDate)->startOfDay() : Carbon::now()->subMonths(3); $this->endDate = $endDate ? Carbon::parse($endDate)->endOfDay() : Carbon::now(); } From 92347350cf4fe047bd9f190c51faf2894697ecdb Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Thu, 7 Nov 2024 06:56:13 +0800 Subject: [PATCH 4/5] Laravel Vapor - Fix a problem on downloading Wallet Transaction History --- .../Services/ExportsCustomersWalletTransactionHistory.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/app/Classes/Modules/Exports/Services/ExportsCustomersWalletTransactionHistory.php b/app/Classes/Modules/Exports/Services/ExportsCustomersWalletTransactionHistory.php index cb328f46..745539f5 100644 --- a/app/Classes/Modules/Exports/Services/ExportsCustomersWalletTransactionHistory.php +++ b/app/Classes/Modules/Exports/Services/ExportsCustomersWalletTransactionHistory.php @@ -20,14 +20,10 @@ class ExportsCustomersWalletTransactionHistory implements FromQuery, WithHeading private $request; private $runningBalance = 0; - protected $startDate; - protected $endDate; - public function __construct(Request $request, $startDate = null, $endDate = null) + public function __construct(Request $request) { $this->request = $request; - $this->startDate = $startDate ? Carbon::parse($startDate)->startOfDay() : Carbon::now()->subMonths(3); - $this->endDate = $endDate ? Carbon::parse($endDate)->endOfDay() : Carbon::now(); } public function headings(): array @@ -47,7 +43,7 @@ class ExportsCustomersWalletTransactionHistory implements FromQuery, WithHeading public function query() { $company = Company::where('reference', $this->request->route('marking'))->first(); - $transactions = $company->wallets()->first()->transactions()->whereIn('transactions.status', [2, 3])->whereBetween('created_at', [$this->startDate, $this->endDate])->orderBy('id'); + $transactions = $company->wallets()->first()->transactions()->whereIn('transactions.status', [2, 3])->orderBy('id'); // dd($transactions->get()->toArray()); return $transactions; From f11adef938c23c3e8f8f9f1c032d56557d5600f2 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Thu, 7 Nov 2024 07:16:04 +0800 Subject: [PATCH 5/5] Laravel Vapor - Fix a problem on downloading Wallet Transaction History --- ..._reference_index_to_transactions_table.php | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 database/migrations/2024_11_07_071500_add_payment_reference_index_to_transactions_table.php diff --git a/database/migrations/2024_11_07_071500_add_payment_reference_index_to_transactions_table.php b/database/migrations/2024_11_07_071500_add_payment_reference_index_to_transactions_table.php new file mode 100644 index 00000000..eb0d26aa --- /dev/null +++ b/database/migrations/2024_11_07_071500_add_payment_reference_index_to_transactions_table.php @@ -0,0 +1,32 @@ +index('payment_reference', 'idx_transactions_payment_reference'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('transactions', function (Blueprint $table) { + $table->dropIndex('idx_transactions_payment_reference'); + }); + } +}