diff --git a/app/Http/Controllers/Reports/MonthlyReportController.php b/app/Http/Controllers/Reports/MonthlyReportController.php index 780302d8..cb07f2b5 100644 --- a/app/Http/Controllers/Reports/MonthlyReportController.php +++ b/app/Http/Controllers/Reports/MonthlyReportController.php @@ -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(); diff --git a/app/Models/Package.php b/app/Models/Package.php index b010ea34..40cf09a7 100644 --- a/app/Models/Package.php +++ b/app/Models/Package.php @@ -7,7 +7,9 @@ use App\Classes\ValueObjects\Constants\PackingListType; use Carbon\Carbon; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\HasManyThrough; +use Illuminate\Database\Eloquent\Relations\HasOneThrough; use Illuminate\Database\Eloquent\SoftDeletes; +use Staudenmeir\EloquentHasManyDeep\HasManyDeep; use Staudenmeir\EloquentHasManyDeep\HasOneDeep; use Staudenmeir\EloquentHasManyDeep\HasRelationships; @@ -26,19 +28,26 @@ class Package extends AbstractModel return $this->belongsTo(PackingList::class, 'packing_list_id'); } + /** + * @return hasOneDeep + */ + public function order(): hasOneDeep + { + return $this->hasOneDeep(Order::class, [PackingList::class], ['id', ['owner_type', 'owner_id']], ['packing_list_id', null]); + } /** - * @return HasManyThrough + * @return hasManyDeep */ - public function shippingTransports(): hasManyThrough + public function shippingTransports(): hasManyDeep { return $this->hasManyDeep(Transport::class, [PackingList::class, ContainerPackingList::class, Container::class], ['id', 'packing_list_id', 'id', ['owner_type', 'owner_id']], ['packing_list_id', 'id', 'container_id', null]); } /** - * @return HasManyThrough + * @return hasManyDeep */ - public function shippingSchedules(): hasManyThrough + public function shippingSchedules(): hasManyDeep { return $this->hasManyDeep(Schedule::class, [PackingList::class, ContainerPackingList::class, Container::class, Transport::class], ['id', 'packing_list_id', 'id', ['owner_type', 'owner_id'], ['owner_type', 'owner_id']], ['packing_list_id', 'id', 'container_id', null, null]); } @@ -52,9 +61,9 @@ class Package extends AbstractModel } /** - * @return HasManyThrough + * @return hasManyDeep */ - public function deliverySchedules(): hasManyThrough + public function deliverySchedules(): hasManyDeep { return $this->hasManyDeep(Schedule::class, [PackingList::class, Transport::class], ['id', ['owner_type', 'owner_id'], ['owner_type', 'owner_id']], ['packing_list_id', null, null]); } diff --git a/resources/assets/vue/components/reports/sections/ServiceReportSectionComponent.vue b/resources/assets/vue/components/reports/sections/ServiceReportSectionComponent.vue index ff2e3815..fed4b6ca 100644 --- a/resources/assets/vue/components/reports/sections/ServiceReportSectionComponent.vue +++ b/resources/assets/vue/components/reports/sections/ServiceReportSectionComponent.vue @@ -35,6 +35,37 @@ +
+
+
+
+
+
+
+
+ Pending Packing List +
+
+
+
+
+
+
+

{{report.received - (report.pending_shipment + report.in_transit + report.pending_delivery + report.delivered)}} Packages

+
+
+
+
+
+
+
+
+
+
+
+
+
+