temp show specific report period

This commit is contained in:
omair saleh
2021-10-11 14:35:15 +08:00
parent f1edf72fb8
commit 0a32d64e8d
@@ -21,7 +21,10 @@ class MonthlyReportController
public function salesReport(Request $request): JsonResponse {
$today = Carbon::now()->subMonth();
$containers = Container::whereDay('loading_date', '>=', 1)->whereDay('loading_date', '<=', 5)->whereMonth('loading_date', $today->format('m'))->whereYear('loading_date', $today->format('Y'))->orderBy('loading_date')->get();
$start_day = 1;
$end_day = 5;
$containers = Container::whereDay('loading_date', '>=', $start_day)->whereDay('loading_date', '<=', $end_day)->whereMonth('loading_date', $today->format('m'))->whereYear('loading_date', $today->format('Y'))->orderBy('loading_date')->get();
$packages = $containers->flatMap(function ($container) {
@@ -52,15 +55,15 @@ class MonthlyReportController
'containers' => count($containers),
'activated_orders' => count($orders),
'active_customers' => count($customers),
'new_customers' => CompanyModule::where('type', BusinessType::IMPORTER)->whereDay('created_at', '>=', 1)->whereDay('created_at', '<=', 5)->whereMonth('created_at', $today->format('m'))->whereYear('created_at', $today->format('Y'))->count(),
'new_converted_customers' => CompanyModule::where('type', BusinessType::IMPORTER)->whereMonth('created_at', $today->format('m'))->whereYear('created_at', $today->format('Y'))->whereHas('orders', function($order){
'new_customers' => CompanyModule::where('type', BusinessType::IMPORTER)->whereDay('created_at', '>=', $start_day)->whereDay('created_at', '<=', $end_day)->whereMonth('created_at', $today->format('m'))->whereYear('created_at', $today->format('Y'))->count(),
'new_converted_customers' => CompanyModule::where('type', BusinessType::IMPORTER)->whereDay('created_at', '>=', $start_day)->whereDay('created_at', '<=', $end_day)->whereMonth('created_at', $today->format('m'))->whereYear('created_at', $today->format('Y'))->whereHas('orders', function($order){
return $order->whereHas('packingLists');
})->count(),
'total_customers' => CompanyModule::where('type', BusinessType::IMPORTER)->count(),
'total_cbm' => $totalCbm,
'daily_cbm' => (800 - $totalCbm) / $days,
'packages' => $packages->sum('quantity'),
'total_orders' => Order::whereMonth('created_at', $today->format('m'))->whereYear('created_at', $today->format('Y'))->count()
'total_orders' => Order::whereDay('created_at', '>=', $start_day)->whereDay('created_at', '<=', $end_day)->whereMonth('created_at', $today->format('m'))->whereYear('created_at', $today->format('Y'))->count()
]]))->handler();
}