mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-09-01 19:04:08 +00:00
updates on the customers endpoint
This commit is contained in:
@@ -307,7 +307,7 @@ class MonthlyReportController
|
||||
return $query->where('packing_lists.type', PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('transports', function ($query) use ($active_start, $active_end) {
|
||||
return $query->whereDate('drop_date', '>=', Carbon::parse($active_start))->whereDate('drop_date', '<=', Carbon::parse($active_end)->addDay());
|
||||
});
|
||||
})->whereNotIn('id', $activeCompanies)->get();*/
|
||||
})->whereNotIn('id', $activeCompanies)->get();
|
||||
|
||||
$companies = getActiveCompanies($inactive_start, $inactive_end, $active_start, $active_end);
|
||||
|
||||
@@ -317,7 +317,7 @@ class MonthlyReportController
|
||||
foreach ($companies as $key => $company) {
|
||||
$connection = $company->inviters()->withPivot('invitee_reference')->first();
|
||||
$marking = $connection ? $connection->pivot->invitee_reference : '';
|
||||
$packingList = $company->orderPackingLists()->where('packing_lists.type', \App\Classes\ValueObjects\Constants\PackingListType::SHIPPING_PACKING_LIST)->get();
|
||||
$packingList = $company->orderPackingLists()->where('packing_lists.type', PackingListType::SHIPPING_PACKING_LIST)->get();
|
||||
$totalCbm = $packingList->flatMap(function ($packingList) {
|
||||
return $packingList->packages;
|
||||
})->sum(function ($package) {
|
||||
@@ -341,6 +341,53 @@ class MonthlyReportController
|
||||
$counter++;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
$companies = getActiveCompanies($inactive_start, $inactive_end, $active_start, $active_end);
|
||||
|
||||
$customerActivityData = [];
|
||||
|
||||
$packingListType = PackingListType::SHIPPING_PACKING_LIST;
|
||||
|
||||
$companies->load([
|
||||
'inviters' => function ($query) {
|
||||
$query->withPivot('invitee_reference')->first();
|
||||
},
|
||||
'orderPackingLists' => function ($query) use ($packingListType) {
|
||||
$query->where('packing_lists.type', $packingListType)->with('packages');
|
||||
},
|
||||
]);
|
||||
|
||||
$counter = 1;
|
||||
|
||||
foreach ($companies as $company) {
|
||||
$connection = $company->inviters->first();
|
||||
$marking = $connection ? $connection->pivot->invitee_reference : '';
|
||||
$packingList = $company->orderPackingLists;
|
||||
|
||||
$totalCbm = $packingList->flatMap->packages->sum(function ($package) {
|
||||
return (((float)$package->width / 100) * ((float)$package->length / 100) * ((float)$package->height / 100)) * $package->quantity;
|
||||
});
|
||||
|
||||
if ($minCbm !== null && $totalCbm < $minCbm) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($minOrders !== null && $packingList->count() < $minOrders) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$customerActivityData[] = [
|
||||
'key' => $counter,
|
||||
'marking' => $marking,
|
||||
'packingListCount' => $packingList->count(),
|
||||
'totalCbm' => $totalCbm,
|
||||
];
|
||||
|
||||
$counter++;
|
||||
}
|
||||
|
||||
|
||||
return (new ApiResponseObject('fetch service report Successful',
|
||||
'',
|
||||
HttpStatus::OK_WITH_MESSAGE, ['data' => [
|
||||
|
||||
Reference in New Issue
Block a user