diff --git a/app/Classes/Modules/Exports/Services/ExportsSalesInvoicesReport.php b/app/Classes/Modules/Exports/Services/ExportsSalesInvoicesReport.php index 8355d2fa..5d80cbc3 100644 --- a/app/Classes/Modules/Exports/Services/ExportsSalesInvoicesReport.php +++ b/app/Classes/Modules/Exports/Services/ExportsSalesInvoicesReport.php @@ -72,7 +72,7 @@ class ExportsSalesInvoicesReport implements FromQuery, WithHeadings, WithHeading 'owner.owner.companyModule.employees' ]); - /* + if($this->isUnpaid){ $approvalStatus = ApprovalStatus::COMPLETED; $query->whereIn('type', [TransactionType::SHIPPING_INVOICE, TransactionType::STORAGE_INVOICE]) @@ -104,55 +104,54 @@ class ExportsSalesInvoicesReport implements FromQuery, WithHeadings, WithHeading }); } } - */ - if($this->isUnpaid){ - $approvalStatus = ApprovalStatus::COMPLETED; - $query->whereIn('type', [TransactionType::SHIPPING_INVOICE, TransactionType::STORAGE_INVOICE]) - ->whereNotIn('status', [$approvalStatus]) - ->whereBetween('created_at', [$start_date, $end_date]); - } - else{ - //This will query everything both paid and unpaid unlike previously paid only - // $query->whereIn('type', [TransactionType::SHIPPING_INVOICE, TransactionType::STORAGE_INVOICE]) - // ->whereBetween('created_at', [$start_date, $end_date]); - $approvalStatus = ApprovalStatus::COMPLETED; - $invoiceTypes = [TransactionType::SHIPPING_INVOICE, TransactionType::STORAGE_INVOICE]; + // if($this->isUnpaid){ + // $approvalStatus = ApprovalStatus::COMPLETED; + // $query->whereIn('type', [TransactionType::SHIPPING_INVOICE, TransactionType::STORAGE_INVOICE]) + // ->whereNotIn('status', [$approvalStatus]) + // ->whereBetween('created_at', [$start_date, $end_date]); + // } + // else{ + // //This will query everything both paid and unpaid unlike previously paid only + // // $query->whereIn('type', [TransactionType::SHIPPING_INVOICE, TransactionType::STORAGE_INVOICE]) + // // ->whereBetween('created_at', [$start_date, $end_date]); - $query->whereIn('type', $invoiceTypes) - ->where(function ($q) use ($approvalStatus, $start_date, $end_date) { + // $approvalStatus = ApprovalStatus::COMPLETED; + // $invoiceTypes = [TransactionType::SHIPPING_INVOICE, TransactionType::STORAGE_INVOICE]; - $q->where(function ($sub) use ($approvalStatus, $start_date, $end_date) { - $sub->whereNotIn('status', [$approvalStatus]) - ->whereBetween('created_at', [$start_date, $end_date]); - }) + // $query->whereIn('type', $invoiceTypes) + // ->where(function ($q) use ($approvalStatus, $start_date, $end_date) { - ->orWhere(function ($sub) use ($approvalStatus, $start_date, $end_date) { - $sub->where('status', $approvalStatus); - if ($start_date && $end_date) { - $sub->whereHas('transactions', function($transaction) use ($start_date, $end_date) { - $transaction->where('type', TransactionType::PAYMENT) - ->whereBetween('updated_at', [$start_date, $end_date]) - ->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); - }); - } elseif ($start_date) { - $sub->whereHas('transactions', function($transaction) use ($start_date) { - $transaction->where('type', TransactionType::PAYMENT) - ->where('updated_at', '>=', $start_date) - ->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); - }); - } elseif ($end_date) { - $sub->whereHas('transactions', function($transaction) use ($end_date) { - $transaction->where('type', TransactionType::PAYMENT) - ->where('updated_at', '<=', $end_date) - ->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); - }); - } - }); - }); + // $q->where(function ($sub) use ($approvalStatus, $start_date, $end_date) { + // $sub->whereNotIn('status', [$approvalStatus]) + // ->whereBetween('created_at', [$start_date, $end_date]); + // }) - } + // ->orWhere(function ($sub) use ($approvalStatus, $start_date, $end_date) { + // $sub->where('status', $approvalStatus); + // if ($start_date && $end_date) { + // $sub->whereHas('transactions', function($transaction) use ($start_date, $end_date) { + // $transaction->where('type', TransactionType::PAYMENT) + // ->whereBetween('updated_at', [$start_date, $end_date]) + // ->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); + // }); + // } elseif ($start_date) { + // $sub->whereHas('transactions', function($transaction) use ($start_date) { + // $transaction->where('type', TransactionType::PAYMENT) + // ->where('updated_at', '>=', $start_date) + // ->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); + // }); + // } elseif ($end_date) { + // $sub->whereHas('transactions', function($transaction) use ($end_date) { + // $transaction->where('type', TransactionType::PAYMENT) + // ->where('updated_at', '<=', $end_date) + // ->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); + // }); + // } + // }); + // }); + // } return $query; }