service report

This commit is contained in:
omair saleh
2021-10-05 20:54:19 +08:00
parent 943ec5f7f7
commit 5aefef5366
3 changed files with 51 additions and 11 deletions
@@ -61,21 +61,21 @@ class MonthlyReportController
return (new ApiResponseObject('fetch service report Successful',
'',
HttpStatus::OK_WITH_MESSAGE, ['data' => [
'received' => Package::warehouseReceiveList()->sum('quantity'),
'pending_shipment' => Package::shippingList()->whereDoesntHave('shippingSchedules', function($schedule){
'received' => (float) Package::warehouseReceiveList()->sum('quantity'),
'pending_shipment' => (float) Package::shippingList()->whereDoesntHave('shippingSchedules', function($schedule){
return $schedule->dispatched()->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
})->sum('quantity'),
'in_transit' => Package::shippingList()->Shipping()->whereHas('shippingSchedules', function($schedule){
'in_transit' => (float) Package::shippingList()->Shipping()->whereHas('shippingSchedules', function($schedule){
return $schedule->dispatched()->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
})->whereDoesntHave('shippingSchedules', function($schedule){
return $schedule->dropped()->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
})->sum('quantity'),
'pending_delivery' => Package::shippingList()->whereHas('shippingSchedules', function($schedule){
'pending_delivery' => (float) Package::shippingList()->whereHas('shippingSchedules', function($schedule){
return $schedule->dropped()->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
})->whereDoesntHave('deliverySchedules', function($schedule){
return $schedule->dispatched()->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
})->sum('quantity'),
'delivered' => Package::shippingList()->whereHas('deliverySchedules', function($schedule){
'delivered' => (float) Package::shippingList()->whereHas('deliverySchedules', function($schedule){
return $schedule->dispatched()->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
})->sum('quantity'),
]]))->handler();