Skip to content

Commit

Permalink
add source to demand and allocations (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
baradhili authored Dec 3, 2024
1 parent e6e2665 commit dd6e8ce
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 20 deletions.
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
19 changes: 15 additions & 4 deletions app/Http/Controllers/AllocationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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;
Expand Down Expand Up @@ -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'
]
);

Expand Down
4 changes: 3 additions & 1 deletion app/Http/Controllers/DemandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion app/Models/Allocation.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* @property $resources_id
* @property $projects_id
* @property $status
* @property $source
* @property $created_at
* @property $updated_at
*
Expand All @@ -31,7 +32,7 @@ class Allocation extends Model
*
* @var array<int, string>
*/
protected $fillable = ['allocation_date', 'fte', 'resources_id', 'projects_id', 'status'];
protected $fillable = ['allocation_date', 'fte', 'resources_id', 'projects_id', 'status', 'source'];


/**
Expand Down
3 changes: 2 additions & 1 deletion app/Models/Demand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* @property $status
* @property $resource_type
* @property $projects_id
* @property $source
* @property $created_at
* @property $updated_at
*
Expand All @@ -30,7 +31,7 @@ class Demand extends Model
*
* @var array<int, string>
*/
protected $fillable = ['demand_date', 'fte', 'status', 'resource_type','projects_id'];
protected $fillable = ['demand_date', 'fte', 'status', 'resource_type','projects_id', 'source'];


/**
Expand Down
28 changes: 28 additions & 0 deletions database/migrations/2024_12_03_014051_add_source_to_demands.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('demands', function (Blueprint $table) {
$table->enum('source', ['Imported', 'Manual'])->after('id')->nullable()->index();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('demands', function (Blueprint $table) {
$table->dropColumn('source');
});
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('allocations', function (Blueprint $table) {
$table->enum('source', ['Imported', 'Manual'])->after('id')->nullable()->index();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('allocations', function (Blueprint $table) {
$table->dropColumn('source');
});
}
};

0 comments on commit dd6e8ce

Please sign in to comment.