diff --git a/app/Classes/Modules/Exports/Services/ExportsSalesInvoiceReport.php b/app/Classes/Modules/Exports/Services/ExportsSalesInvoiceReport.php index 46698f59..dc32680f 100644 --- a/app/Classes/Modules/Exports/Services/ExportsSalesInvoiceReport.php +++ b/app/Classes/Modules/Exports/Services/ExportsSalesInvoiceReport.php @@ -5,6 +5,7 @@ namespace App\Classes\Modules\Exports\Services; use App\Classes\ValueObjects\Constants\PaymentMethodType; use App\Classes\ValueObjects\Constants\TransactionType; use App\Classes\ValueObjects\Constants\ApprovalStatus; +use App\Models\Booking; use App\Models\Transaction; use Maatwebsite\Excel\Concerns\Exportable; use Maatwebsite\Excel\Concerns\FromQuery; @@ -69,14 +70,14 @@ class ExportsSalesInvoiceReport implements FromQuery, WithHeadings, WithHeadingR $end_date = Carbon::now()->endOfDay(); } - $query = Transaction::query(); + $query = Booking::where('status', ApprovalStatus::COMPLETED); - $query->where('type', TransactionType::PAYMENT)->where('payment_method', '!=', PaymentMethodType::WALLET); - // $query->where('type', TransactionType::PAYMENT); - $query->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); - $query->whereHas('booking.transactions', function ($query) { - $query->where('type', TransactionType::PURCHASE_ORDER)->complete(); - }); + // $query = Transaction::query(); + // $query->where('type', TransactionType::PAYMENT)->where('payment_method', '!=', PaymentMethodType::WALLET); + // $query->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); + // $query->whereHas('booking.transactions', function ($query) { + // $query->where('type', TransactionType::PURCHASE_ORDER)->complete(); + // }); if($start_date && $end_date) { $query->whereBetween('created_at', [ @@ -95,14 +96,13 @@ class ExportsSalesInvoiceReport implements FromQuery, WithHeadings, WithHeadingR } /** - * @param Transaction $transaction + * @param Booking $booking * @return array */ - public function map($transaction): array + public function map($booking): array { - $booking = $transaction->owner()->first(); + // $transaction = $booking->transactions()->payments()->complete()->first(); $purchaseOrder = $booking->transactions()->where('type', TransactionType::PURCHASE_ORDER)->first(); - //$purchaseOrder = $booking->transactions()->payments()->complete()->first(); $company = $booking->company()->first(); $lastPaymentTransaction = $booking->transactions()->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::COMPLETED, ApprovalStatus::APPROVED])->latest()->first(); diff --git a/routes/export.php b/routes/export.php index 5e3b47b8..ba18002f 100644 --- a/routes/export.php +++ b/routes/export.php @@ -1,10 +1,11 @@ 'export', 'as' => 'export.', 'namespace' => 'Exports'], function () { Route::group(['prefix' => 'transactions', 'as' => 'transaction.'], function () { - Route::get('/sales-invoices', 'ExportController@salesInvoices')->name('sales-invoices'); + Route::get('/sales-invoices', [ExportController::class, 'salesInvoices'])->name('sales-invoices'); }); });