Skip to content

Commit

Permalink
Merge pull request #377 from sancsoft/374-psr-closed-generation
Browse files Browse the repository at this point in the history
PSR Generation
  • Loading branch information
rmaffitsancsoft authored Jan 13, 2025
2 parents e2c8897 + f51ea0e commit 0a7d42c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/dotnet/HQ.Server/Data/Models/ProjectStatusReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class ProjectStatusReport : Base
public decimal? BilledTime { get; set; }
public decimal? PercentComplete { get; set; }
// Project status at time PSR was generated
[Obsolete]
public ProjectStatus Status { get; set; }
public DateOnly BookingStartDate { get; set; }
public DateOnly BookingEndDate { get; set; }
Expand Down
14 changes: 8 additions & 6 deletions src/dotnet/HQ.Server/Services/ProjectStatusReportServiceV1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,15 @@ public async Task BackgroundAutoSubmitWeeklyProjectStatusReportsV1(CancellationT
int createdCount = 0;
int skippedCount = 0;

var projects = await _context.Projects
.Where(t => t.ChargeCode != null && t.ChargeCode.Active && (t.Status == ProjectStatus.InProduction || t.Status == ProjectStatus.Ongoing))
.ToListAsync(ct);

DateOnly startDate = request.ForDate.GetPeriodStartDate(Period.Week);
DateOnly endDate = request.ForDate.GetPeriodEndDate(Period.Week);

var projects = await _context.Projects
.Where(t =>
(t.ChargeCode != null && t.ChargeCode.Active && (t.Status == ProjectStatus.InProduction || t.Status == ProjectStatus.Ongoing)) ||
(t.ChargeCode != null && t.ChargeCode.Times.Any(x => x.Date >= startDate && x.Date <= endDate)))
.ToListAsync(ct);

foreach (var project in projects)
{
if (await _context.ProjectStatusReports.AnyAsync(t => t.ProjectId == project.Id && t.StartDate == startDate && t.EndDate == endDate, ct))
Expand All @@ -135,7 +137,7 @@ public async Task BackgroundAutoSubmitWeeklyProjectStatusReportsV1(CancellationT
psr.ProjectId = project.Id;
psr.ProjectManagerId = project.ProjectManagerId;
psr.BookingPeriod = project.BookingPeriod;
psr.Status = project.Status;
psr.Project.Status = project.Status;

switch (project.BookingPeriod)
{
Expand Down Expand Up @@ -256,7 +258,7 @@ public async Task BackgroundAutoSubmitWeeklyProjectStatusReportsV1(CancellationT
ClientName = t.Row.Project.Client.Name,
ProjectManagerId = t.Row.ProjectManagerId,
ProjectManagerName = t.Row.Project.ProjectManager != null ? t.Row.Project.ProjectManager.Name : null,
Status = t.Row.Status,
Status = t.Row.Project.Status,
IsLate = t.Row.SubmittedAt == null,
ProjectType = t.Row.Project.Type,

Expand Down

0 comments on commit 0a7d42c

Please sign in to comment.