diff --git a/app/Classes/Modules/Exports/Services/ExportsAnalyticBookingTransactions.php b/app/Classes/Modules/Exports/Services/ExportsAnalyticBookingTransactions.php index c1e2af71..f30b2a35 100644 --- a/app/Classes/Modules/Exports/Services/ExportsAnalyticBookingTransactions.php +++ b/app/Classes/Modules/Exports/Services/ExportsAnalyticBookingTransactions.php @@ -51,8 +51,8 @@ class ExportsAnalyticBookingTransactions implements FromQuery, WithHeadings, Wit * @return \Illuminate\Support\Collection|mixed */ public function query() - { - return Booking::query(); + { + return Booking::query()->whereBetween('created_at', [Carbon::now()->subMonths(3), Carbon::now()]); //Limit, 'expensive' query; } /** @@ -66,12 +66,12 @@ class ExportsAnalyticBookingTransactions implements FromQuery, WithHeadings, Wit $companyType[companyType::PERSONAL_BUSINESS] = 'PERSONAL_BUSINESS'; $payments = $booking->transactions()->where('type', 1)->whereIn('status', [2, 3]); - + $paymentmethondArray = PaymentMethodType::PAYMENT_METHODS_ID; $paymentmethondArray[0] = 'Hybrid'; $paymentMethod = ''; foreach ($payments->get() as $payment) { - if ( $paymentMethod == '' ) { + if ( $paymentMethod == '' ) { $paymentMethod = $payment->payment_method; } else if ( $payment->payment_method != $paymentMethod ) { $paymentMethod = 0; // set it to Hybrid @@ -104,4 +104,4 @@ class ExportsAnalyticBookingTransactions implements FromQuery, WithHeadings, Wit '', ]; } -} \ No newline at end of file +} diff --git a/app/Classes/Modules/Exports/Services/ExportsCustomers.php b/app/Classes/Modules/Exports/Services/ExportsCustomers.php index 9f314030..18498b4c 100644 --- a/app/Classes/Modules/Exports/Services/ExportsCustomers.php +++ b/app/Classes/Modules/Exports/Services/ExportsCustomers.php @@ -5,6 +5,7 @@ namespace App\Classes\Modules\Exports\Services; use App\Classes\ValueObjects\Constants\BusinessType; use App\Classes\ValueObjects\Constants\CompanyType; use App\Models\Company; +use Carbon\Carbon; use Maatwebsite\Excel\Concerns\Exportable; use Maatwebsite\Excel\Concerns\FromQuery; use Maatwebsite\Excel\Concerns\ShouldAutoSize; @@ -38,7 +39,8 @@ class ExportsCustomers implements FromQuery, WithHeadings, WithHeadingRow, WithM */ public function query() { - return Company::where('business_type', '=', 2); + return Company::where('business_type', '=', 2) + ->whereBetween('created_at', [Carbon::now()->subMonths(12), Carbon::now()]); //Limit, 'expensive' query; } /** @@ -66,4 +68,4 @@ class ExportsCustomers implements FromQuery, WithHeadings, WithHeadingRow, WithM count($company->segments()->where('segment_id', '=', 5)->get()) ? 'Exchange 1.0' : 'Exchange 2.0' ]; } -} \ No newline at end of file +} diff --git a/app/Classes/Modules/Exports/Services/ExportsTransactions.php b/app/Classes/Modules/Exports/Services/ExportsTransactions.php index 6d6751bf..a6072e38 100644 --- a/app/Classes/Modules/Exports/Services/ExportsTransactions.php +++ b/app/Classes/Modules/Exports/Services/ExportsTransactions.php @@ -9,6 +9,7 @@ use App\Models\Booking; use App\Models\Company; use App\Models\Transaction; use App\Models\Wallet; +use Carbon\Carbon; use Maatwebsite\Excel\Concerns\Exportable; use Maatwebsite\Excel\Concerns\FromQuery; use Maatwebsite\Excel\Concerns\WithHeadingRow; @@ -26,7 +27,9 @@ class ExportsTransactions implements FromQuery, WithHeadingRow, WithMapping, Sho */ public function query() { - return Transaction::whereIn('type', [TransactionType::PAYMENT, TransactionType::BILL])->where('owner_type', '!=',Wallet::class); + return Transaction::whereIn('type', [TransactionType::PAYMENT, TransactionType::BILL]) + ->where('owner_type', '!=',Wallet::class) + ->whereBetween('created_at', [Carbon::now()->subMonths(3), Carbon::now()]); //Limit, 'expensive' query; } /** @@ -87,7 +90,7 @@ class ExportsTransactions implements FromQuery, WithHeadingRow, WithMapping, Sho $transaction->currency_rate, $transaction->tax, $transaction->service_charge, - $transactionStatus[$transaction->status], + isset($transactionStatus[$transaction->status]) ? $transactionStatus[$transaction->status] : 'Unknown Status', \PhpOffice\PhpSpreadsheet\Shared\Date::dateTimeToExcel($transaction->created_at), \PhpOffice\PhpSpreadsheet\Shared\Date::dateTimeToExcel($transaction->updated_at), // $marking diff --git a/resources/views/pages/downloads/index.blade.php b/resources/views/pages/downloads/index.blade.php index ec621f16..47c338dd 100644 --- a/resources/views/pages/downloads/index.blade.php +++ b/resources/views/pages/downloads/index.blade.php @@ -9,7 +9,10 @@
(last 12 months)
+(last 3 months)
+(last 3 months)
+