fix daily cbm report

This commit is contained in:
omair saleh
2021-10-12 13:57:35 +08:00
parent c33649fda2
commit b355df27db
@@ -38,6 +38,10 @@ class MonthlyReportController
return (( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100)) * $package->quantity;
});
$newCustomers = CompanyModule::where('type', BusinessType::IMPORTER)->whereBetween('created_at', [$from, $to])->count();
$newConvertedCustomers = CompanyModule::where('type', BusinessType::IMPORTER)->whereBetween('created_at', [$from, $to])->whereHas('orders', function($order){
return $order->whereHas('packingLists');
})->count();
$startDay = $request->route('to') ? Carbon::parse($request->route('to')) : Carbon::now();
$days = $startDay->addDay()->diffInDaysFiltered(function (Carbon $date) {
@@ -52,10 +56,8 @@ class MonthlyReportController
'containers' => count($containers),
'activated_orders' => count($orders),
'active_customers' => count($customers),
'new_customers' => CompanyModule::where('type', BusinessType::IMPORTER)->whereBetween('created_at', [$from, $to])->count(),
'new_converted_customers' => CompanyModule::where('type', BusinessType::IMPORTER)->whereBetween('created_at', [$from, $to])->whereHas('orders', function($order){
return $order->whereHas('packingLists');
})->count(),
'new_customers' => $newCustomers,
'new_converted_customers' => $newConvertedCustomers,
'total_customers' => CompanyModule::where('type', BusinessType::IMPORTER)->count(),
'total_cbm' => $totalCbm,
'daily_cbm' => $days ? (800 - $totalCbm) / $days : (800 - $totalCbm),