Added Functionality for approving the reported task

This commit is contained in:
ashutosh.nehete 2025-06-16 15:57:04 +05:30
parent 9d5535edf1
commit dc21b9d2c6
13 changed files with 4355 additions and 270 deletions

View File

@ -69,6 +69,7 @@ namespace Marco.Pms.DataAccess.Data
public DbSet<Document> Documents { get; set; }
public DbSet<TicketTag> TicketTags { get; set; }
public DbSet<WorkCategoryMaster> WorkCategoryMasters { get; set; }
public DbSet<WorkStatusMaster> WorkStatusMasters { get; set; }
public DbSet<Contact> Contacts { get; set; }
public DbSet<ContactCategoryMaster> ContactCategoryMasters { get; set; }
public DbSet<ContactEmail> ContactsEmails { get; set; }
@ -429,6 +430,32 @@ namespace Marco.Pms.DataAccess.Data
TenantId = Guid.Parse("b3466e83-7e11-464c-b93a-daf047838b26")
}
);
modelBuilder.Entity<WorkStatusMaster>().HasData(
new WorkStatusMaster
{
Id = new Guid("030bb085-e230-4370-aec7-9a74d652864e"),
Name = "Approve",
Description = "Confirm the tasks are actually finished as reported",
IsSystem = true,
TenantId = Guid.Parse("b3466e83-7e11-464c-b93a-daf047838b26")
},
new WorkStatusMaster
{
Id = new Guid("2a1a5b96-cf93-4111-b4b1-76c19d6333b4"),
Name = "Partially Approve",
Description = "Not all tasks are actually finished as reported",
IsSystem = true,
TenantId = Guid.Parse("b3466e83-7e11-464c-b93a-daf047838b26")
},
new WorkStatusMaster
{
Id = new Guid("00a062e6-62e6-42c5-b6b1-024328651b72"),
Name = "NCR",
Description = "Tasks are not finished as reported or have any issues in al the tasks",
IsSystem = true,
TenantId = Guid.Parse("b3466e83-7e11-464c-b93a-daf047838b26")
}
);
}

View File

@ -0,0 +1,188 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace Marco.Pms.DataAccess.Migrations
{
/// <inheritdoc />
public partial class Added_Apporved_By_In_TaskAllocation_Table : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "ApprovedById",
table: "TaskAllocations",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
migrationBuilder.AddColumn<DateTime>(
name: "ApprovedDate",
table: "TaskAllocations",
type: "datetime(6)",
nullable: true);
migrationBuilder.AddColumn<Guid>(
name: "ParentTaskId",
table: "TaskAllocations",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
migrationBuilder.AddColumn<Guid>(
name: "ReportedById",
table: "TaskAllocations",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
migrationBuilder.AddColumn<double>(
name: "ReportedTask",
table: "TaskAllocations",
type: "double",
nullable: false,
defaultValue: 0.0);
migrationBuilder.AddColumn<Guid>(
name: "WorkStatusId",
table: "TaskAllocations",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
migrationBuilder.CreateTable(
name: "WorkStatusMasters",
columns: table => new
{
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Name = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Description = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
IsSystem = table.Column<bool>(type: "tinyint(1)", nullable: false),
TenantId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_WorkStatusMasters", x => x.Id);
table.ForeignKey(
name: "FK_WorkStatusMasters_Tenants_TenantId",
column: x => x.TenantId,
principalTable: "Tenants",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.InsertData(
table: "WorkStatusMasters",
columns: new[] { "Id", "Description", "IsSystem", "Name", "TenantId" },
values: new object[,]
{
{ new Guid("00a062e6-62e6-42c5-b6b1-024328651b72"), "Tasks are not finished as reported or have any issues in al the tasks", true, "NCR", new Guid("b3466e83-7e11-464c-b93a-daf047838b26") },
{ new Guid("030bb085-e230-4370-aec7-9a74d652864e"), "Confirm the tasks are actually finished as reported", true, "Approve", new Guid("b3466e83-7e11-464c-b93a-daf047838b26") },
{ new Guid("2a1a5b96-cf93-4111-b4b1-76c19d6333b4"), "Not all tasks are actually finished as reported", true, "Partially Approve", new Guid("b3466e83-7e11-464c-b93a-daf047838b26") }
});
migrationBuilder.CreateIndex(
name: "IX_TaskAllocations_ApprovedById",
table: "TaskAllocations",
column: "ApprovedById");
migrationBuilder.CreateIndex(
name: "IX_TaskAllocations_ReportedById",
table: "TaskAllocations",
column: "ReportedById");
migrationBuilder.CreateIndex(
name: "IX_TaskAllocations_WorkStatusId",
table: "TaskAllocations",
column: "WorkStatusId");
migrationBuilder.CreateIndex(
name: "IX_WorkStatusMasters_TenantId",
table: "WorkStatusMasters",
column: "TenantId");
migrationBuilder.AddForeignKey(
name: "FK_TaskAllocations_Employees_ApprovedById",
table: "TaskAllocations",
column: "ApprovedById",
principalTable: "Employees",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_TaskAllocations_Employees_ReportedById",
table: "TaskAllocations",
column: "ReportedById",
principalTable: "Employees",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_TaskAllocations_WorkStatusMasters_WorkStatusId",
table: "TaskAllocations",
column: "WorkStatusId",
principalTable: "WorkStatusMasters",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_TaskAllocations_Employees_ApprovedById",
table: "TaskAllocations");
migrationBuilder.DropForeignKey(
name: "FK_TaskAllocations_Employees_ReportedById",
table: "TaskAllocations");
migrationBuilder.DropForeignKey(
name: "FK_TaskAllocations_WorkStatusMasters_WorkStatusId",
table: "TaskAllocations");
migrationBuilder.DropTable(
name: "WorkStatusMasters");
migrationBuilder.DropIndex(
name: "IX_TaskAllocations_ApprovedById",
table: "TaskAllocations");
migrationBuilder.DropIndex(
name: "IX_TaskAllocations_ReportedById",
table: "TaskAllocations");
migrationBuilder.DropIndex(
name: "IX_TaskAllocations_WorkStatusId",
table: "TaskAllocations");
migrationBuilder.DropColumn(
name: "ApprovedById",
table: "TaskAllocations");
migrationBuilder.DropColumn(
name: "ApprovedDate",
table: "TaskAllocations");
migrationBuilder.DropColumn(
name: "ParentTaskId",
table: "TaskAllocations");
migrationBuilder.DropColumn(
name: "ReportedById",
table: "TaskAllocations");
migrationBuilder.DropColumn(
name: "ReportedTask",
table: "TaskAllocations");
migrationBuilder.DropColumn(
name: "WorkStatusId",
table: "TaskAllocations");
}
}
}

View File

@ -28,6 +28,12 @@ namespace Marco.Pms.DataAccess.Migrations
.ValueGeneratedOnAdd()
.HasColumnType("char(36)");
b.Property<Guid?>("ApprovedById")
.HasColumnType("char(36)");
b.Property<DateTime?>("ApprovedDate")
.HasColumnType("datetime(6)");
b.Property<Guid>("AssignedBy")
.HasColumnType("char(36)");
@ -40,26 +46,44 @@ namespace Marco.Pms.DataAccess.Migrations
b.Property<string>("Description")
.HasColumnType("longtext");
b.Property<Guid?>("ParentTaskId")
.HasColumnType("char(36)");
b.Property<double>("PlannedTask")
.HasColumnType("double");
b.Property<Guid?>("ReportedById")
.HasColumnType("char(36)");
b.Property<DateTime?>("ReportedDate")
.HasColumnType("datetime(6)");
b.Property<double>("ReportedTask")
.HasColumnType("double");
b.Property<Guid>("TenantId")
.HasColumnType("char(36)");
b.Property<Guid>("WorkItemId")
.HasColumnType("char(36)");
b.Property<Guid?>("WorkStatusId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.HasIndex("ApprovedById");
b.HasIndex("AssignedBy");
b.HasIndex("ReportedById");
b.HasIndex("TenantId");
b.HasIndex("WorkItemId");
b.HasIndex("WorkStatusId");
b.ToTable("TaskAllocations");
});
@ -1920,6 +1944,59 @@ namespace Marco.Pms.DataAccess.Migrations
});
});
modelBuilder.Entity("Marco.Pms.Model.Master.WorkStatusMaster", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("longtext");
b.Property<bool>("IsSystem")
.HasColumnType("tinyint(1)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
b.Property<Guid>("TenantId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.HasIndex("TenantId");
b.ToTable("WorkStatusMasters");
b.HasData(
new
{
Id = new Guid("030bb085-e230-4370-aec7-9a74d652864e"),
Description = "Confirm the tasks are actually finished as reported",
IsSystem = true,
Name = "Approve",
TenantId = new Guid("b3466e83-7e11-464c-b93a-daf047838b26")
},
new
{
Id = new Guid("2a1a5b96-cf93-4111-b4b1-76c19d6333b4"),
Description = "Not all tasks are actually finished as reported",
IsSystem = true,
Name = "Partially Approve",
TenantId = new Guid("b3466e83-7e11-464c-b93a-daf047838b26")
},
new
{
Id = new Guid("00a062e6-62e6-42c5-b6b1-024328651b72"),
Description = "Tasks are not finished as reported or have any issues in al the tasks",
IsSystem = true,
Name = "NCR",
TenantId = new Guid("b3466e83-7e11-464c-b93a-daf047838b26")
});
});
modelBuilder.Entity("Marco.Pms.Model.Projects.Building", b =>
{
b.Property<Guid>("Id")
@ -2429,12 +2506,20 @@ namespace Marco.Pms.DataAccess.Migrations
modelBuilder.Entity("Marco.Pms.Model.Activities.TaskAllocation", b =>
{
b.HasOne("Marco.Pms.Model.Employees.Employee", "ApprovedBy")
.WithMany()
.HasForeignKey("ApprovedById");
b.HasOne("Marco.Pms.Model.Employees.Employee", "Employee")
.WithMany()
.HasForeignKey("AssignedBy")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Marco.Pms.Model.Employees.Employee", "ReportedBy")
.WithMany()
.HasForeignKey("ReportedById");
b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant")
.WithMany()
.HasForeignKey("TenantId")
@ -2447,11 +2532,21 @@ namespace Marco.Pms.DataAccess.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Marco.Pms.Model.Master.WorkStatusMaster", "WorkStatus")
.WithMany()
.HasForeignKey("WorkStatusId");
b.Navigation("ApprovedBy");
b.Navigation("Employee");
b.Navigation("ReportedBy");
b.Navigation("Tenant");
b.Navigation("WorkItem");
b.Navigation("WorkStatus");
});
modelBuilder.Entity("Marco.Pms.Model.Activities.TaskComment", b =>
@ -3052,6 +3147,17 @@ namespace Marco.Pms.DataAccess.Migrations
b.Navigation("Tenant");
});
modelBuilder.Entity("Marco.Pms.Model.Master.WorkStatusMaster", b =>
{
b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant")
.WithMany()
.HasForeignKey("TenantId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Tenant");
});
modelBuilder.Entity("Marco.Pms.Model.Projects.Building", b =>
{
b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant")

View File

@ -1,5 +1,6 @@
using System.ComponentModel.DataAnnotations.Schema;
using Marco.Pms.Model.Employees;
using Marco.Pms.Model.Master;
using Marco.Pms.Model.Projects;
using Marco.Pms.Model.Utilities;
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
@ -10,29 +11,43 @@ namespace Marco.Pms.Model.Activities
public class TaskAllocation : TenantRelation
{
public Guid Id { get; set; }
public Guid? ParentTaskId { get; set; }
public DateTime AssignmentDate { get; set; }
public double PlannedTask { get; set; }
public double CompletedTask { get; set; }
public double ReportedTask { get; set; }
public DateTime? ReportedDate { get; set; }
public DateTime? ApprovedDate { get; set; }
public string? Description { get; set; }
//public int? WorkItemMappingId { get; set; }
//[ForeignKey("WorkItemMappingId")]
//[ValidateNever]
//public WorkItemMapping? WorkItemMapping { get; set; }
public Guid AssignedBy { get; set; } //Employee Id
public Guid AssignedBy { get; set; } //Employee Id
[ForeignKey("AssignedBy")]
[ValidateNever]
public Employee? Employee { get; set; }
public Guid? ReportedById { get; set; } //Employee Id
[ForeignKey("ReportedById")]
[ValidateNever]
public Employee? ReportedBy { get; set; }
public Guid? ApprovedById { get; set; } //Employee Id
[ForeignKey("ApprovedById")]
[ValidateNever]
public Employee? ApprovedBy { get; set; }
public Guid WorkItemId { get; set; }
[ForeignKey("WorkItemId")]
[ValidateNever]
public WorkItem? WorkItem { get; set; }
public Guid? WorkStatusId { get; set; }
[ForeignKey("WorkStatusId")]
[ValidateNever]
public WorkStatusMaster? WorkStatus { get; set; }
}
}

View File

@ -0,0 +1,12 @@
using Marco.Pms.Model.Utilities;
namespace Marco.Pms.Model.Master
{
public class WorkStatusMaster : TenantRelation
{
public Guid Id { get; set; }
public string Name { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public bool IsSystem { get; set; } = false;
}
}

View File

@ -0,0 +1,13 @@
using Marco.Pms.Model.Utilities;
namespace Marco.Pms.Model.Dtos.Activities
{
public class ApproveTaskDto
{
public Guid Id { get; set; }
public Guid WorkStatus { get; set; }
public long ApprovedTask { get; set; }
public string? Comment { get; set; }
public List<FileUploadModel>? Images { get; set; }
}
}

View File

@ -3,6 +3,7 @@
public class AssignTaskDto
{
public DateTime AssignmentDate { get; set; }
public Guid? ParentTaskId { get; set; }
public double PlannedTask { get; set; }
public string? Description { get; set; }
public List<Guid>? TaskTeam { get; set; } //Employee Ids

View File

@ -5,6 +5,7 @@ namespace Marco.Pms.Model.Dtos.Activities
public class ReportTaskDto
{
public Guid Id { get; set; }
public Guid? ParentTaskId { get; set; }
public double CompletedTask { get; set; }
public DateTime ReportedDate { get; set; }
public string? Comment { get; set; }

View File

@ -13,6 +13,7 @@ namespace Marco.Pms.Model.Mapper
return new TaskAllocation
{
AssignmentDate = assignTask.AssignmentDate,
ParentTaskId = assignTask.ParentTaskId,
PlannedTask = assignTask.PlannedTask,
CompletedTask = 0,
Description = assignTask.Description,
@ -43,18 +44,23 @@ namespace Marco.Pms.Model.Mapper
TenantId = tenantId
};
}
public static TaskVM TaskAllocationToTaskVM(this TaskAllocation taskAllocation, string employeeName)
public static TaskVM TaskAllocationToTaskVM(this TaskAllocation taskAllocation)
{
return new TaskVM
{
Id = taskAllocation.Id,
AssignmentDate = taskAllocation.AssignmentDate,
ReportedDate = taskAllocation.ReportedDate,
ApprovedDate = taskAllocation.ApprovedDate,
PlannedTask = taskAllocation.PlannedTask,
CompletedTask = taskAllocation.CompletedTask,
ReportedDate = taskAllocation.ReportedDate,
NotApprovedTask = taskAllocation.ApprovedById == null ? taskAllocation.CompletedTask : (taskAllocation.ReportedTask - taskAllocation.CompletedTask),
Description = taskAllocation.Description,
AssignBy = employeeName,
WorkItem = taskAllocation.WorkItem
AssignedBy = taskAllocation.Employee?.ToBasicEmployeeVMFromEmployee(),
ReportedBy = taskAllocation.ReportedBy?.ToBasicEmployeeVMFromEmployee(),
ApprovedBy = taskAllocation.ApprovedBy?.ToBasicEmployeeVMFromEmployee(),
WorkItem = taskAllocation.WorkItem,
WorkStatus = taskAllocation.WorkStatus
};
}
public static AssignedTaskVM ToAssignTaskVMFromTaskAllocation(this TaskAllocation taskAllocation)
@ -100,12 +106,18 @@ namespace Marco.Pms.Model.Mapper
return new ListTaskVM
{
Id = taskAllocation.Id,
ParentTaskId = taskAllocation.ParentTaskId,
AssignmentDate = taskAllocation.AssignmentDate,
ApprovedDate = taskAllocation.ApprovedDate,
Description = taskAllocation.Description,
PlannedTask = taskAllocation.PlannedTask,
ReportedDate = taskAllocation.ReportedDate,
WorkStatus = taskAllocation.WorkStatus,
CompletedTask = taskAllocation.CompletedTask,
AssignedBy = taskAllocation.Employee != null ? taskAllocation.Employee.ToBasicEmployeeVMFromEmployee() : new BasicEmployeeVM(),
NotApprovedTask = taskAllocation.ApprovedById == null ? taskAllocation.CompletedTask : (taskAllocation.ReportedTask - taskAllocation.CompletedTask),
AssignedBy = taskAllocation.Employee?.ToBasicEmployeeVMFromEmployee(),
ReportedBy = taskAllocation.ReportedBy?.ToBasicEmployeeVMFromEmployee(),
ApprovedBy = taskAllocation.ApprovedBy?.ToBasicEmployeeVMFromEmployee(),
WorkItemId = taskAllocation.WorkItemId,
WorkItem = taskAllocation.WorkItem
};

View File

@ -1,15 +1,22 @@
using Marco.Pms.Model.Projects;
using Marco.Pms.Model.Master;
using Marco.Pms.Model.Projects;
namespace Marco.Pms.Model.ViewModels.Activities
{
public class ListTaskVM
{
public Guid Id { get; set; }
public Guid? ParentTaskId { get; set; }
public DateTime AssignmentDate { get; set; }
public DateTime? ReportedDate { get; set; }
public DateTime? ApprovedDate { get; set; }
public double PlannedTask { get; set; }
public double CompletedTask { get; set; }
public double NotApprovedTask { get; set; }
public BasicEmployeeVM? AssignedBy { get; set; }
public BasicEmployeeVM? ReportedBy { get; set; }
public BasicEmployeeVM? ApprovedBy { get; set; }
public WorkStatusMaster? WorkStatus { get; set; }
public string? Description { get; set; }
public Guid WorkItemId { get; set; }
public List<string>? ReportedPreSignedUrls { get; set; }

View File

@ -1,5 +1,5 @@
using Marco.Pms.Model.Projects;
using Marco.Pms.Model.ViewModels.Employee;
using Marco.Pms.Model.Master;
using Marco.Pms.Model.Projects;
namespace Marco.Pms.Model.ViewModels.Activities
{
@ -7,14 +7,19 @@ namespace Marco.Pms.Model.ViewModels.Activities
{
public Guid Id { get; set; }
public DateTime AssignmentDate { get; set; }
public DateTime? ReportedDate { get; set; }
public DateTime? ApprovedDate { get; set; }
public double PlannedTask { get; set; }
public double CompletedTask { get; set; }
public DateTime? ReportedDate { get; set; }
public double NotApprovedTask { get; set; }
public string? Description { get; set; }
public string? AssignBy { get; set; }
public BasicEmployeeVM? AssignedBy { get; set; }
public BasicEmployeeVM? ReportedBy { get; set; }
public BasicEmployeeVM? ApprovedBy { get; set; }
public WorkStatusMaster? WorkStatus { get; set; }
public WorkItem? WorkItem { get; set; }
public List<string>? PreSignedUrls { get; set; }
public List<CommentVM>? Comments { get; set; }
public List<EmployeeVM>? TeamMembers { get; set; }
public List<BasicEmployeeVM>? TeamMembers { get; set; }
}
}

File diff suppressed because it is too large Load Diff