From dd6e8ce27d78c185c91d7b90eeaa2352e8de2d7d Mon Sep 17 00:00:00 2001 From: bret watson <666900+baradhili@users.noreply.github.com> Date: Tue, 3 Dec 2024 10:55:34 +0800 Subject: [PATCH] add source to demand and allocations (#27) --- README.md | 27 +++++++++--------- app/Http/Controllers/AllocationController.php | 19 ++++++++++--- app/Http/Controllers/DemandController.php | 4 ++- app/Models/Allocation.php | 3 +- app/Models/Demand.php | 3 +- ...024_12_03_014051_add_source_to_demands.php | 28 +++++++++++++++++++ ...12_03_015420_add_source_to_allocations.php | 28 +++++++++++++++++++ 7 files changed, 92 insertions(+), 20 deletions(-) create mode 100644 database/migrations/2024_12_03_014051_add_source_to_demands.php create mode 100644 database/migrations/2024_12_03_015420_add_source_to_allocations.php diff --git a/README.md b/README.md index a7c10074..f3f69c62 100644 --- a/README.md +++ b/README.md @@ -10,25 +10,26 @@ Its early stages right now, we are looking for help in: * CRUD expansion, I am only updating cruds as I need them * fancy alogrithms - there are a bunch like controlled annealing to allow some automation in resource allocation, it would be nice to have. +## Features + + - Manage Resources: contracts, leave, skills + - Receive Demands for resources and allocate them accordingly + - View allocations of resources and if necessary remove resources from projects (puts the demand back into the pool) + - Create a Service catalogue with associates required skills and estimated effort + ## Next steps -- [X] Allocation view per resource -- [X] Demand view to see if there are multiple resource requests - [ ] Split out some hard coded things into env or a settings table -- [X] Assign demand to a resource -- [X] De-assign a project back to demand -- [X] Some kind of nicer dashboard -- [X] Collect skill list -- [X] Add skills to a resource -- [X] Add teams and privileges etc -- [X] Manual Demand collection (inc business need, funding etc) +- [ ] Update Allocations view to show percent of availablity - [X] Delete/edit Demands - this probably needs to be more usable than a month by month allocation, but still allow that - [ ] Differentiate manual demand from uploads so we don't delete the wrong stuff - [ ] Allow editing of manual demand, but not uploaded -- [ ] Provide rest of skills allocation crud -- [ ] Surely there is a decent dashboard with tile system that works easily (spatie/laravel-dashboard seems to have a very specific use case) -- [X] Do something with top nav bar -- [X] Add region/office to a resource so we can do bulk leave - [ ] Bulk add leave aka public holidays - to people in a region +- [ ] Make calendar controls consistent +- [ ] Set up teams +- [ ] Filter multiple views/permissions by Team +- [ ] Create a "Senior Manager" role that might oversee one or more Teams +- [ ] Update User admin to assign the user into various function roles such as "Resource", "Team Owner", etc +- [ ] Add ability to release demand from a resource from a date (to handle exits) Yes it is currently Laravel 10 based, not 11. Bleading edge, especially for major changes is not my thing. diff --git a/app/Http/Controllers/AllocationController.php b/app/Http/Controllers/AllocationController.php index a48303dc..4e60ed99 100644 --- a/app/Http/Controllers/AllocationController.php +++ b/app/Http/Controllers/AllocationController.php @@ -196,8 +196,18 @@ public function populateAllocations(Request $request) if ($columnLetter >= 'D' && !is_null($columnValue)) { $monthYear[] = $columnValue; $monthDate = Carbon::parse($columnValue)->startOfMonth()->format('Y-m-d'); - Allocation::where('allocation_date', '=',$monthDate)->delete(); - Demand::where('demand_date', '=',$monthDate)->delete(); + Allocation::where('allocation_date', '=',$monthDate) + ->where(function ($query) { + $query->where('source', '=', 'Imported') + ->orWhereNull('source'); + }) + ->delete(); + Demand::where('demand_date', '=',$monthDate) + ->where(function ($query) { + $query->where('source', '=', 'Imported') + ->orWhereNull('source'); + }) + ->delete(); } } // Log::info("months " . print_r($monthYear, true)); @@ -206,7 +216,7 @@ public function populateAllocations(Request $request) continue; } elseif ($rowData['B'] != null) { //ignore empty lines $resourceName = $rowData['A'] ?? $resourceName; - if (strpos($resourceName, 'rchitect') == false) { + if (strpos($resourceName, 'rchitect') == false) { //TODO: make this part of Team $resource = Resource::where('empowerID', $resourceName)->first(); $resourceID = $resource->id ?? null; @@ -279,7 +289,8 @@ public function populateAllocations(Request $request) [ 'fte' => $fte, 'status' => 'Proposed', // or any other default status you want to set - 'resource_type' => $resourceName + 'resource_type' => $resourceName, + 'source' => 'Imported' ] ); diff --git a/app/Http/Controllers/DemandController.php b/app/Http/Controllers/DemandController.php index 7f63ecee..65fb0d79 100644 --- a/app/Http/Controllers/DemandController.php +++ b/app/Http/Controllers/DemandController.php @@ -121,6 +121,7 @@ public function create(): View $demand->resource_type = ''; $demand->fte = 0.00; $demand->projects_id = null; + $demand->source = 'Manual'; $projects = Project::all(); @@ -194,7 +195,8 @@ public function edit($project_id, Request $request): RedirectResponse $allocation->resources_id = $request->resource_id; $allocation->fte = $demand->fte; $allocation->projects_id = $demand->projects_id; - $allocation->status = "Proposed"; + $allocation->status = $demand->status; + $allocation->source = $demand->source; $allocation->save(); $demand->delete(); diff --git a/app/Models/Allocation.php b/app/Models/Allocation.php index be9e1949..311f4902 100644 --- a/app/Models/Allocation.php +++ b/app/Models/Allocation.php @@ -13,6 +13,7 @@ * @property $resources_id * @property $projects_id * @property $status + * @property $source * @property $created_at * @property $updated_at * @@ -31,7 +32,7 @@ class Allocation extends Model * * @var array */ - protected $fillable = ['allocation_date', 'fte', 'resources_id', 'projects_id', 'status']; + protected $fillable = ['allocation_date', 'fte', 'resources_id', 'projects_id', 'status', 'source']; /** diff --git a/app/Models/Demand.php b/app/Models/Demand.php index dae8ec20..8c146790 100644 --- a/app/Models/Demand.php +++ b/app/Models/Demand.php @@ -13,6 +13,7 @@ * @property $status * @property $resource_type * @property $projects_id + * @property $source * @property $created_at * @property $updated_at * @@ -30,7 +31,7 @@ class Demand extends Model * * @var array */ - protected $fillable = ['demand_date', 'fte', 'status', 'resource_type','projects_id']; + protected $fillable = ['demand_date', 'fte', 'status', 'resource_type','projects_id', 'source']; /** diff --git a/database/migrations/2024_12_03_014051_add_source_to_demands.php b/database/migrations/2024_12_03_014051_add_source_to_demands.php new file mode 100644 index 00000000..c8e925ba --- /dev/null +++ b/database/migrations/2024_12_03_014051_add_source_to_demands.php @@ -0,0 +1,28 @@ +enum('source', ['Imported', 'Manual'])->after('id')->nullable()->index(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('demands', function (Blueprint $table) { + $table->dropColumn('source'); + }); + } +}; diff --git a/database/migrations/2024_12_03_015420_add_source_to_allocations.php b/database/migrations/2024_12_03_015420_add_source_to_allocations.php new file mode 100644 index 00000000..43a00079 --- /dev/null +++ b/database/migrations/2024_12_03_015420_add_source_to_allocations.php @@ -0,0 +1,28 @@ +enum('source', ['Imported', 'Manual'])->after('id')->nullable()->index(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('allocations', function (Blueprint $table) { + $table->dropColumn('source'); + }); + } +};