mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
E-Invoice - Update Sales Invoice Report to have paid and unpaid invoices in the report
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user