Skip to content

Commit b365f87

Browse files
author
Jani Giannoudis
committed
report: added support for json report documents
payrun job: added job period info main layout and nav menu: fixed update of culture change updated verion to 0.9.0-beta.5
1 parent da40f93 commit b365f87

23 files changed

+272
-91
lines changed

Core/PayrollEngine.WebApp.Core.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</PropertyGroup>
1313

1414
<ItemGroup>
15-
<PackageReference Include="PayrollEngine.Client.Core" Version="0.9.0-beta.4" />
15+
<PackageReference Include="PayrollEngine.Client.Core" Version="0.9.0-beta.5" />
1616
<PackageReference Include="Microsoft.AspNetCore.Components" Version="9.0.3" />
1717
<PackageReference Include="Blazored.LocalStorage" Version="4.5.0" />
1818
<PackageReference Include="Microsoft.JSInterop" Version="9.0.3" />

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>net9.0</TargetFramework>
5-
<Version>0.9.0-beta.4</Version>
5+
<Version>0.9.0-beta.5</Version>
66
<FileVersion>0.9.0</FileVersion>
77
<InformationalVersion></InformationalVersion>
88
<Authors>Jani Giannoudis</Authors>

Presentation/LocalizerService.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ public Localizer Localizer
4545
}
4646
}
4747

48+
/// <inheritdoc />
49+
public void Invalidate() =>
50+
localizer = null;
51+
4852
private bool BuildLocalizer()
4953
{
5054
if (localizer != null)

Presentation/PayrollEngine.WebApp.Presentation.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<ItemGroup>
1010
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="9.0.3" />
11-
<PackageReference Include="PayrollEngine.Document" Version="0.9.0-beta.4" />
11+
<PackageReference Include="PayrollEngine.Document" Version="0.9.0-beta.5" />
1212
<PackageReference Include="MudBlazor" Version="8.3.0" />
1313
<PackageReference Include="NPOI" Version="2.7.2" />
1414
</ItemGroup>

Presentation/Payrun/PayrunJobDialog.razor

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
@using PayrollEngine.WebApp.ViewModel
1+
@using System.Globalization
22
@using PayrollEngine.WebApp.Shared
3-
@using System.Globalization
3+
@using PayrollEngine.WebApp.ViewModel
44

55
<MudDialog Style="min-width: 30em;" TitleClass="mud-theme-primary pe-dialog-title">
66
<DialogContent>
@@ -13,7 +13,7 @@
1313
{
1414
@* legal job: new *@
1515
<MudPaper Class="pa-4"
16-
Style="min-width: 25em; max-width: 40em">
16+
Style="min-width: 25em; max-width: 40em">
1717
<MudStack Spacing="0">
1818
<MudText Typo="Typo.h6">@Localizer.PayrunJob.New</MudText>
1919

@@ -24,7 +24,7 @@
2424
<MudText Class="pr-4">@GetUserName(PayrunJob.CreatedUserId)</MudText>
2525

2626
<MudInputLabel Class="pt-4">@Localizer.PayrunJob.JobPeriod</MudInputLabel>
27-
<MudText Class="pr-4">@PayrunJob.PeriodStart.ToCompactString()</MudText>
27+
<MudText Class="pr-4">@Period</MudText>
2828

2929
@if (PayrunJob.EvaluationDate != null)
3030
{
@@ -33,22 +33,22 @@
3333
}
3434

3535
<PayrunEmployeeInfo Class="pt-4" Employees="@Employees"
36-
SelectedEmployees="@(PayrunJob.Employees?.Select(x => x.EmployeeId).ToList() ?? [])" />
36+
SelectedEmployees="@(PayrunJob.Employees?.Select(x => x.EmployeeId).ToList() ?? [])" />
3737

3838
<MudInputLabel Class="pt-4">@Localizer.PayrunJob.JobReason</MudInputLabel>
3939
<MudText Class="pr-4">@PayrunJob.CreatedReason</MudText>
4040

4141
@if (PayrunJob.Attributes != null && PayrunJob.Attributes.Any())
4242
{
4343
<PayrunParameterInfo Class="pt-4" Culture="@Culture"
44-
ParameterAttributes="PayrunJob.Attributes" />
44+
ParameterAttributes="PayrunJob.Attributes" />
4545
}
4646
</MudStack>
4747
</MudPaper>
4848

4949
@* legal job: draft *@
5050
<MudPaper Class="pa-4" Elevation="@(PayrunJob.JobStatus.IsDraft() ? 4 : 1)"
51-
Style="min-width: 15em; max-width: 25em">
51+
Style="min-width: 15em; max-width: 25em">
5252
<MudStack Spacing="0">
5353
<MudText Typo="Typo.h6" Color="@(PayrunJob.JobStatus.IsDraft() ? Color.Tertiary : Color.Default)">
5454
@Localizer.Enum(PayrunJobStatus.Draft)
@@ -66,10 +66,10 @@
6666
@if (PayrunJob.Released.HasValue)
6767
{
6868
<MudPaper Class="pa-4" Elevation="@(PayrunJob.JobStatus.IsRelease() ? 4 : 1)"
69-
Style="min-width: 15em; max-width: 25em">
69+
Style="min-width: 15em; max-width: 25em">
7070
<MudStack Spacing="0">
7171
<MudText Typo="Typo.h6"
72-
Color="@(PayrunJob.JobStatus == PayrunJobStatus.Release ? Color.Tertiary : Color.Default)">
72+
Color="@(PayrunJob.JobStatus == PayrunJobStatus.Release ? Color.Tertiary : Color.Default)">
7373
@Localizer.Enum(PayrunJobStatus.Release)
7474
</MudText>
7575

@@ -86,10 +86,10 @@
8686
@if (PayrunJob.Processed.HasValue)
8787
{
8888
<MudPaper Class="pa-4" Elevation="@(PayrunJob.JobStatus.IsProcess() ? 4 : 1)"
89-
Style="min-width: 15em; max-width: 25em">
89+
Style="min-width: 15em; max-width: 25em">
9090
<MudStack Spacing="0">
9191
<MudText Typo="Typo.h6"
92-
Color="@(PayrunJob.JobStatus == PayrunJobStatus.Process ? Color.Tertiary : Color.Default)">
92+
Color="@(PayrunJob.JobStatus == PayrunJobStatus.Process ? Color.Tertiary : Color.Default)">
9393
@Localizer.Enum(PayrunJobStatus.Process)
9494
</MudText>
9595

@@ -106,10 +106,10 @@
106106
@if (PayrunJob.Finished.HasValue && PayrunJob.JobStatus is PayrunJobStatus.Complete)
107107
{
108108
<MudPaper Class="pa-4" Elevation="@(PayrunJob.JobStatus.IsComplete() ? 4 : 1)"
109-
Style="min-width: 15em; max-width: 25em">
109+
Style="min-width: 15em; max-width: 25em">
110110
<MudStack Spacing="0">
111111
<MudText Typo="Typo.h6"
112-
Color="@(PayrunJob.JobStatus == PayrunJobStatus.Complete ? Color.Tertiary : Color.Default)">
112+
Color="@(PayrunJob.JobStatus == PayrunJobStatus.Complete ? Color.Tertiary : Color.Default)">
113113
@Localizer.Enum(PayrunJobStatus.Complete)
114114
</MudText>
115115

@@ -126,7 +126,7 @@
126126
@if (PayrunJob.Finished.HasValue && PayrunJob.JobStatus is PayrunJobStatus.Cancel or PayrunJobStatus.Abort)
127127
{
128128
<MudPaper Class="pa-4" Elevation="4"
129-
Style="min-width: 15em; max-width: 25em">
129+
Style="min-width: 15em; max-width: 25em">
130130
<MudStack Spacing="0">
131131
<MudText Typo="Typo.h6" Color="Color.Error">@PayrunJob.JobStatus</MudText>
132132

@@ -143,7 +143,7 @@
143143
{
144144
@* forecast job *@
145145
<MudPaper Class="pa-4" Elevation="4"
146-
Style="min-width: 35em; max-width: 50em">
146+
Style="min-width: 35em; max-width: 50em">
147147
<MudStack Spacing="0">
148148
<MudText Typo="Typo.h6">@Localizer.PayrunJob.New</MudText>
149149
<MudInputLabel Class="pt-4">@Localizer.PayrunJob.JobDate</MudInputLabel>
@@ -157,7 +157,7 @@
157157
<MudInputLabel Class="pt-4">@Localizer.PayrunJob.JobReason</MudInputLabel>
158158
<MudText Class="pr-4">@PayrunJob.CreatedReason</MudText>
159159
<PayrunEmployeeInfo Class="pt-4" Employees="@Employees"
160-
SelectedEmployees="@(PayrunJob.Employees?.Select(x => x.EmployeeId).ToList() ?? [])" />
160+
SelectedEmployees="@(PayrunJob.Employees?.Select(x => x.EmployeeId).ToList() ?? [])" />
161161
@if (PayrunJob.Attributes != null && PayrunJob.Attributes.Any())
162162
{
163163
<PayrunParameterInfo Class="pt-4" ParameterAttributes="@PayrunJob.Attributes" />
@@ -181,9 +181,11 @@
181181
[Parameter] public PayrunJob PayrunJob { get; set; }
182182
[Parameter] public List<PayrollEngine.WebApp.User> Users { get; set; } = [];
183183
[Parameter] public List<Employee> Employees { get; set; } = [];
184+
184185
[Inject] private ILocalizerService LocalizerService { get; set; }
185186

186187
private Localizer Localizer => LocalizerService.Localizer;
188+
private DatePeriod Period => new(PayrunJob.PeriodStart, PayrunJob.PeriodEnd);
187189

188190
private void Close() => MudDialog.Close(DialogResult.Ok(true));
189191

Presentation/Payrun/PayrunJobSetup.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ public class PayrunJobSetup
1010
/// <summary>
1111
/// The payrun period date
1212
/// </summary>
13-
public DateTime? PeriodStart { get; set; }
13+
public DateTime? PeriodDate { get; set; }
14+
15+
/// <summary>
16+
/// The payrun period
17+
/// </summary>
18+
public DatePeriod Period { get; set; }
1419

1520
/// <summary>
1621
/// The payrun evaluation date
@@ -52,7 +57,7 @@ public class PayrunJobSetup
5257
/// </summary>
5358
/// <returns>True for a valid legal job</returns>
5459
public bool IsValidLegalJob() =>
55-
PeriodStart.HasValue &&
60+
PeriodDate.HasValue &&
5661
!string.IsNullOrWhiteSpace(JobName) &&
5762
!string.IsNullOrWhiteSpace(Reason) &&
5863
ValidParameters();

Presentation/Payrun/PayrunStartDialog.razor

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
@* job period *@
3232
<tr>
3333
<td style="width: 20%">@Localizer.PayrunJob.JobPeriod</td>
34-
<td>@Setup.PeriodStart?.ToCompactString()</td>
34+
<td>@Period</td>
3535
</tr>
3636

3737
@* job evaluation *@
@@ -124,12 +124,13 @@
124124
@code {
125125

126126
[CascadingParameter] IMudDialogInstance MudDialog { get; set; }
127-
[Parameter] public List<Employee> Employees { get; set; }
128127
[Parameter] public Client.Model.Tenant Tenant { get; set; }
129128
[Parameter] public User User { get; set; }
130129
[Parameter] public Client.Model.Payroll Payroll { get; set; }
130+
[Parameter] public List<Employee> Employees { get; set; }
131131
[Parameter] public int PayrunId { get; set; }
132132
[Parameter] public PayrunJobSetup Setup { get; set; }
133+
[Parameter] public DatePeriod Period { get; set; }
133134

134135
[Inject] private IPayrunJobService PayrunJobService { get; set; }
135136
[Inject] private IUserNotificationService UserNotification { get; set; }
@@ -165,7 +166,7 @@
165166

166167
private async Task Start()
167168
{
168-
if (!Setup.PeriodStart.HasValue)
169+
if (!Setup.PeriodDate.HasValue)
169170
{
170171
return;
171172
}
@@ -176,7 +177,7 @@
176177
StateHasChanged();
177178

178179
// ensure UTC without the same date and time
179-
var jobPeriod = DateTime.SpecifyKind(Setup.PeriodStart.Value, DateTimeKind.Utc);
180+
var jobPeriod = DateTime.SpecifyKind(Setup.PeriodDate.Value, DateTimeKind.Utc);
180181

181182
// employees
182183
List<string> employeeIdentifiers = null;

Presentation/Report/ReportBuildDialog.razor

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,19 @@
8080
@* download buttons *@
8181
@if (!Completed && !Failed)
8282
{
83+
@* Json *@
84+
@if (SupportedDocumentType(DocumentType.Json))
85+
{
86+
<MudButton Variant="@Globals.ButtonVariant"
87+
Color="Color.Tertiary"
88+
Disabled="@(!Valid || Started)"
89+
OnClick="@(() => StartAsync(DocumentType.Json))">
90+
@Localizer.Report.Json
91+
</MudButton>
92+
}
93+
8394
@* Xml *@
84-
@if (SupportedDocumentType(DocumentType.Excel))
95+
@if (SupportedDocumentType(DocumentType.Xml))
8596
{
8697
<MudButton Variant="@Globals.ButtonVariant"
8798
Color="Color.Tertiary"

Presentation/Report/ReportBuildDialog.razor.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ private bool HasVisibleParameters() =>
7272
EditReport.ViewParameters.Count(x => x.Attributes?.GetHidden(Culture) ?? false) != EditReport.ViewParameters.Count;
7373

7474
private bool SupportedDocumentType(DocumentType documentType) =>
75-
documentType == DocumentType.Excel || DataMerge.IsMergeable(documentType);
75+
documentType is DocumentType.Json or DocumentType.Excel || DataMerge.IsMergeable(documentType);
7676

7777
/// <summary>
7878
/// Case info from build and validate
@@ -172,8 +172,12 @@ await UserNotification.ShowErrorMessageBoxAsync(Localizer, Localizer.Report.Repo
172172
new MemoryStream(Encoding.ASCII.GetBytes(ReportTemplate.Content)),
173173
dataSet, documentType, documentMetadata, mergeParameters);
174174
break;
175+
case DocumentType.Json:
176+
// serialize data set as dictionary
177+
var json = dataSet.Json();
178+
documentStream = new MemoryStream(Encoding.UTF8.GetBytes(json));
179+
break;
175180
case DocumentType.Xml:
176-
case DocumentType.XmlRaw:
177181
// xml
178182
var xml = XmlTool.IsContentTypeXsl(ReportTemplate.ContentType) ?
179183
// xsl report
@@ -183,7 +187,7 @@ await UserNotification.ShowErrorMessageBoxAsync(Localizer, Localizer.Report.Repo
183187
if (string.IsNullOrWhiteSpace(xml))
184188
{
185189
await UserNotification.ShowErrorMessageBoxAsync(Localizer, Localizer.Report.Report,
186-
Localizer.Report.EmptyXmlRaw(reportName));
190+
Localizer.Report.EmptyXml(reportName));
187191
break;
188192
}
189193

Presentation/UserSession.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ public void SetDefaultFeatures(IEnumerable<Feature> defaultFeatures) =>
9696
/// </summary>
9797
public AsyncEvent<User> UserChanged { get; set; }
9898

99+
/// <summary>
100+
/// User state changed event
101+
/// </summary>
102+
public AsyncEvent<User> UserStateChanged { get; set; }
103+
99104
/// <summary>
100105
/// User login
101106
/// </summary>
@@ -129,17 +134,21 @@ public async Task LoginAsync(Tenant userTenant, User user)
129134
await ChangeTenantAsync(userTenant, user);
130135

131136
// update state
132-
UpdateUserState();
137+
await UpdateUserStateAsync();
133138
}
134139

135140
/// <summary>
136141
/// Update the current user state, including culture and value formatter
137142
/// </summary>
138-
public void UpdateUserState()
143+
public async Task UpdateUserStateAsync()
139144
{
140-
var cultureName = GetUserCulture() ?? CultureInfo.CurrentCulture.Name;
145+
var cultureName = GetUserCulture() ?? CultureInfo.CurrentCulture.Name;
141146
var culture = CultureService.GetCulture(cultureName).CultureInfo;
142147
ValueFormatter = new ValueFormatter(culture);
148+
if (User != null)
149+
{
150+
await (UserStateChanged?.InvokeAsync(this, User) ?? Task.CompletedTask);
151+
}
143152
}
144153

145154
/// <summary>

0 commit comments

Comments
 (0)