Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
<PackageReference Include="Azure.AI.OpenAI" Version="2.1.0" />
<PackageReference Include="QuestPDF" Version="2025.12.1" />
<PackageReference Include="QuestPDF.Markdown" Version="1.45.0" />
Comment thread
MWG-Logan marked this conversation as resolved.
</ItemGroup>

<ItemGroup>
Expand Down
9 changes: 5 additions & 4 deletions Bezalu.ProjectReporting.API/Functions/ReportFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using QuestPDF;
using QuestPDF.Fluent;
using QuestPDF.Infrastructure;
using QuestPDF.Markdown;

namespace Bezalu.ProjectReporting.API.Functions;

Expand Down Expand Up @@ -172,7 +173,7 @@ private static Action<IContainer> BudgetSection(ProjectCompletionReportResponse
c.Column(col =>
{
col.Item().Text("Budget Analysis").FontSize(14).Bold();
col.Item().Text($"Estimated Hours: {b?.EstimatedHours}").FontSize(10);
col.Item().Text($"Budget Hours: {b?.BudgetHours}").FontSize(10);
col.Item().Text($"Actual Hours: {b?.ActualHours}").FontSize(10);
col.Item().Text($"Variance Hours: {b?.VarianceHours}").FontSize(10);
col.Item().Text($"Budget Adherence: {b?.BudgetAdherence}").FontSize(10);
Expand All @@ -188,7 +189,7 @@ private static Action<IContainer> AISummarySection(ProjectCompletionReportRespon
c.Column(col =>
{
col.Item().Text("AI Generated Summary").FontSize(14).Bold();
col.Item().Text(report.AiGeneratedSummary ?? string.Empty).FontSize(10);
col.Item().DefaultTextStyle(x => x.FontSize(10)).Markdown(report.AiGeneratedSummary ?? string.Empty);
});
};
}
Expand All @@ -207,7 +208,7 @@ private static Action<IContainer> PhasesSection(ProjectCompletionReportResponse
if (phase is { ActualStart: not null, ActualEnd: not null })
inner.Item().Text($"Actual: {phase.ActualStart:yyyy-MM-dd} > {phase.ActualEnd:yyyy-MM-dd}")
.FontSize(9);
inner.Item().Text($"Hours est/actual: {phase.EstimatedHours}/{phase.ActualHours}").FontSize(9);
inner.Item().Text($"Hours budget/actual: {phase.BudgetHours}/{phase.ActualHours}").FontSize(9);
});
});
};
Expand All @@ -226,7 +227,7 @@ private static Action<IContainer> TicketsSection(ProjectCompletionReportResponse
{
inner.Item().Text($"#{ticket.TicketNumber} {ticket.Summary} ({ticket.Status})").SemiBold();
inner.Item().Text($"Type: {ticket.Type}/{ticket.SubType}").FontSize(9);
inner.Item().Text($"Hours est/actual: {ticket.EstimatedHours}/{ticket.ActualHours}")
inner.Item().Text($"Hours budget/actual: {ticket.BudgetHours}/{ticket.ActualHours}")
.FontSize(9);
if (ticket.ClosedDate != null)
inner.Item().Text($"Closed: {ticket.ClosedDate:yyyy-MM-dd}").FontSize(9);
Expand Down
3 changes: 3 additions & 0 deletions Bezalu.ProjectReporting.API/Models/ConnectWiseModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class CWProject
public DateTime? EstimatedStart { get; set; }
public DateTime? EstimatedEnd { get; set; }
public decimal? EstimatedHours { get; set; }
public decimal? BudgetHours { get; set; }
Comment thread
MWG-Logan marked this conversation as resolved.
public decimal? ActualHours { get; set; }
public CWReference? Manager { get; set; }
public CWReference? Company { get; set; }
Expand All @@ -32,6 +33,7 @@ public class CWTicket
public CWReference? Type { get; set; }
public CWReference? SubType { get; set; }
public decimal? EstimatedHours { get; set; }
public decimal? BudgetHours { get; set; }
Comment thread
MWG-Logan marked this conversation as resolved.
public decimal? ActualHours { get; set; }
public DateTime? ClosedDate { get; set; }
public CWReference? AssignedTo { get; set; }
Expand All @@ -53,6 +55,7 @@ public class CWPhase
public DateTime? ActualStart { get; set; }
public DateTime? ActualEnd { get; set; }
public decimal? EstimatedHours { get; set; }
public decimal? BudgetHours { get; set; }
Comment thread
MWG-Logan marked this conversation as resolved.
public decimal? ActualHours { get; set; }
}

Expand Down
20 changes: 10 additions & 10 deletions Bezalu.ProjectReporting.API/Services/ProjectReportingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,20 +131,20 @@ private ProjectCompletionReportResponse BuildReport(
};
}

var estimatedHours = project.EstimatedHours ?? 0;
var budgetHours = project.BudgetHours ?? 0;
var actualHours = project.ActualHours ?? 0;
var hoursVariance = actualHours - estimatedHours;
var hoursVariance = actualHours - budgetHours;

report.Budget = new BudgetAnalysis
{
EstimatedHours = estimatedHours,
BudgetHours = budgetHours,
ActualHours = actualHours,
VarianceHours = hoursVariance,
EstimatedCost = 0,
ActualCost = 0,
VarianceCost = 0,
BudgetAdherence = hoursVariance <= 0 ? "Under Budget" : hoursVariance <= estimatedHours * 0.1m ? "Slightly Over" : "Over Budget",
CostPerformance = estimatedHours > 0 ? $"{(double)(actualHours / estimatedHours) * 100:F1}%" : "N/A"
BudgetAdherence = hoursVariance <= 0 ? "Under Budget" : hoursVariance <= budgetHours * 0.1m ? "Slightly Over" : "Over Budget",
CostPerformance = budgetHours > 0 ? $"{(double)(actualHours / budgetHours) * 100:F1}%" : "N/A"
};

report.Phases = phases.Select(phase => new PhaseDetail
Expand All @@ -154,7 +154,7 @@ private ProjectCompletionReportResponse BuildReport(
Status = phase.Status?.Name,
ActualStart = phase.ActualStart,
ActualEnd = phase.ActualEnd,
EstimatedHours = phase.EstimatedHours ?? 0,
BudgetHours = phase.BudgetHours ?? 0,
ActualHours = phase.ActualHours ?? 0,
Notes = new List<string>()
}).ToList();
Expand All @@ -167,7 +167,7 @@ private ProjectCompletionReportResponse BuildReport(
Status = ticket.Status?.Name,
Type = ticket.Type?.Name,
SubType = ticket.SubType?.Name,
EstimatedHours = ticket.EstimatedHours ?? 0,
BudgetHours = ticket.BudgetHours ?? 0,
ActualHours = ticket.ActualHours ?? 0,
Notes = ticketNotes.TryGetValue(ticket.Id ?? 0, out var notes)
? notes.OrderBy(n => n.DateCreated).Select(n => n.Text ?? "").ToList()
Expand Down Expand Up @@ -205,7 +205,7 @@ private string PrepareDataForAI(ProjectCompletionReportResponse report, List<CWP
sb.AppendLine("BUDGET:");
if (report.Budget != null)
{
sb.AppendLine($"- Estimated: {report.Budget.EstimatedHours} hours");
sb.AppendLine($"- Budget: {report.Budget.BudgetHours} hours");
sb.AppendLine($"- Actual: {report.Budget.ActualHours} hours");
sb.AppendLine($"- Variance: {report.Budget.VarianceHours} hours ({report.Budget.BudgetAdherence})");
}
Expand All @@ -223,15 +223,15 @@ private string PrepareDataForAI(ProjectCompletionReportResponse report, List<CWP
sb.AppendLine($"PHASES ({report.Phases?.Count ?? 0}):");
foreach (var phase in report.Phases ?? new List<PhaseDetail>())
{
sb.AppendLine($"- {phase.PhaseName}: {phase.Status}; Hours est/actual {phase.EstimatedHours}/{phase.ActualHours}");
sb.AppendLine($"- {phase.PhaseName}: {phase.Status}; Hours budget/actual {phase.BudgetHours}/{phase.ActualHours}");
}
sb.AppendLine();

// Ticket + notes content (truncate per ticket)
sb.AppendLine($"TICKETS ({report.Tickets?.Count ?? 0}):");
foreach (var ticket in report.Tickets ?? new List<TicketSummary>())
{
sb.AppendLine($"- Ticket #{ticket.TicketNumber} {ticket.Summary} (Status: {ticket.Status}, Type: {ticket.Type}/{ticket.SubType}, Hours est/actual {ticket.EstimatedHours}/{ticket.ActualHours})");
sb.AppendLine($"- Ticket #{ticket.TicketNumber} {ticket.Summary} (Status: {ticket.Status}, Type: {ticket.Type}/{ticket.SubType}, Hours budget/actual {ticket.BudgetHours}/{ticket.ActualHours})");
if (ticketNotes.TryGetValue(ticket.TicketId, out var notes) && notes.Any())
{
var limited = notes.OrderBy(n => n.DateCreated).ToList(); // cap to 20 per ticket
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class TimelineAnalysis

public class BudgetAnalysis
{
public decimal EstimatedHours { get; set; }
public decimal BudgetHours { get; set; }
public decimal ActualHours { get; set; }
public decimal VarianceHours { get; set; }
public decimal EstimatedCost { get; set; }
Expand All @@ -66,7 +66,7 @@ public class PhaseDetail
public string? Status { get; set; }
public DateTime? ActualStart { get; set; }
public DateTime? ActualEnd { get; set; }
public decimal EstimatedHours { get; set; }
public decimal BudgetHours { get; set; }
public decimal ActualHours { get; set; }
public List<string>? Notes { get; set; }
public string? Summary { get; set; }
Expand All @@ -80,7 +80,7 @@ public class TicketSummary
public string? Status { get; set; }
public string? Type { get; set; }
public string? SubType { get; set; }
public decimal EstimatedHours { get; set; }
public decimal BudgetHours { get; set; }
public decimal ActualHours { get; set; }
public List<string>? Notes { get; set; }
public DateTime? ClosedDate { get; set; }
Expand Down
15 changes: 10 additions & 5 deletions Bezalu.ProjectReporting.Web/Pages/Home.razor
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ else
</p>
<p><b>Manager:</b> @Report.Summary?.Manager | <b>Company:</b> @Report.Summary?.Company</p>
<p><b>Timeline:</b> @Report.Timeline?.PlannedDays d planned / @Report.Timeline?.TotalDays d actual (Var: @Report.Timeline?.VarianceDays)</p>
<p><b>Budget:</b> @Report.Budget?.EstimatedHours h est / @Report.Budget?.ActualHours h actual (Var: @Report.Budget?.VarianceHours)</p>
<p><b>Budget:</b> @Report.Budget?.BudgetHours h budget / @Report.Budget?.ActualHours h actual (Var: @Report.Budget?.VarianceHours)</p>

@if (!string.IsNullOrWhiteSpace(Report.AiGeneratedSummary))
{
<FluentAccordion>
<FluentAccordionItem Heading="AI Summary">
<FluentIcon Value="@(new Icons.Regular.Size20.Globe())" Color="Color.Neutral" Slot="start" />
<div>@(new MarkupString(AiSummaryHtml))</div>
<div class="markdown-content">@(new MarkupString(AiSummaryHtml))</div>
</FluentAccordionItem>
</FluentAccordion>
}
Expand All @@ -99,7 +99,7 @@ else
<FluentDataGrid Items="@Report.Phases.AsQueryable()" GenerateFooter="false">
<PropertyColumn Property="@(p => p.PhaseName)" Title="Name" />
<PropertyColumn Property="@(p => p.Status)" Title="Status" />
<PropertyColumn Property="@(p => p.EstimatedHours)" Title="Est Hrs" />
<PropertyColumn Property="@(p => p.BudgetHours)" Title="Budget Hrs" />
<PropertyColumn Property="@(p => p.ActualHours)" Title="Actual Hrs" />
</FluentDataGrid>
}
Expand All @@ -115,7 +115,7 @@ else
<PropertyColumn Property="@(t => t.TicketNumber)" Title="Number" />
<PropertyColumn Property="@(t => t.Summary)" Title="Summary" />
<PropertyColumn Property="@(t => t.Status)" Title="Status" />
<PropertyColumn Property="@(t => t.EstimatedHours)" Title="Est Hrs" />
<PropertyColumn Property="@(t => t.BudgetHours)" Title="Budget Hrs" />
<PropertyColumn Property="@(t => t.ActualHours)" Title="Actual Hrs" />
</FluentDataGrid>
}
Expand All @@ -125,6 +125,11 @@ else
}

@code {
static readonly MarkdownPipeline MdPipeline = new MarkdownPipelineBuilder()
.UseAdvancedExtensions() // enables tables, pipe tables
.UseSoftlineBreakAsHardlineBreak()
.Build();

List<ProjectListItem>? Projects;
ProjectCompletionReportResponse? Report;
bool IsLoadingProjects;
Expand All @@ -134,7 +139,7 @@ else
bool ShowLoginPrompt;
string LoginPromptText = "Please sign in to continue.";
string? ErrorMessage;
string AiSummaryHtml => Report?.AiGeneratedSummary is null ? string.Empty : Markdown.ToHtml(Report.AiGeneratedSummary);
string AiSummaryHtml => Report?.AiGeneratedSummary is null ? string.Empty : Markdown.ToHtml(Report.AiGeneratedSummary, MdPipeline);

protected override async Task OnInitializedAsync()
{
Expand Down
2 changes: 1 addition & 1 deletion Bezalu.ProjectReporting.Web/staticwebapp.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"allowedRoles": [ "anonymous" ]
},
{
"route": "/*",
"route": "*",
"allowedRoles": [ "editor" ]
Comment thread
MWG-Logan marked this conversation as resolved.
}
],
Expand Down
26 changes: 26 additions & 0 deletions Bezalu.ProjectReporting.Web/wwwroot/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,29 @@ code {
right: unset;
}
}

.markdown-content table {
border-collapse: collapse;
width: 100%;
margin: 0.5rem 0 1rem 0;
}

.markdown-content th,
.markdown-content td {
border: 1px solid #d2d6dc;
padding: 4px 6px;
text-align: left;
}

.markdown-content th {
background: #f6f7f9;
font-weight: 600;
}

.markdown-content tbody tr:nth-child(odd) {
background: #fafafa;
}

.markdown-content p {
margin: 0.25rem 0 0.5rem;
}
6 changes: 3 additions & 3 deletions docs/contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"schedulePerformance": "121.6%"
},
"budget": {
"estimatedHours":500.0,
"budgetHours":500.0,
"actualHours":550.0,
"varianceHours":50.0,
"estimatedCost":0,
Expand All @@ -45,7 +45,7 @@
"status": "Complete",
"actualStart": "2024-01-01T00:00:00Z",
"actualEnd": "2024-01-05T00:00:00Z",
"estimatedHours":40.0,
"budgetHours":40.0,
"actualHours":42.5,
"notes": ["Initial kickoff done"],
"summary": null
Expand All @@ -59,7 +59,7 @@
"status": "Closed",
"type": "Development",
"subType": "Enhancement",
"estimatedHours":16.0,
"budgetHours":16.0,
"actualHours":18.25,
"notes": ["Reviewed by QA", "Minor fixes"]
}
Expand Down
Loading