Skip to content

Commit

Permalink
Merge branch 'master' into fix-transactions-and-financial-years
Browse files Browse the repository at this point in the history
  • Loading branch information
BerendWouters authored Oct 7, 2023
2 parents 3890d75 + 796070e commit e0bb5bf
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 19 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
with:
fetch-depth: 0
- name: Log in to the Container registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
Expand All @@ -32,7 +32,7 @@ jobs:
uses: gittools/actions/gitversion/execute@v0.10.2
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/brixel/haspman-main
tags: type=semver,pattern={{version}},value=${{ steps.gitversion.outputs.semVer }}
Expand All @@ -44,7 +44,7 @@ jobs:
GITVERSION_SEMVER: ${{ steps.gitversion.outputs.semVer }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: .
push: true
Expand Down
2 changes: 1 addition & 1 deletion Commands.Test/Commands.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<ItemGroup>
<PackageReference Include="AutoMapper" Version="12.0.1" />
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.11" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="Moq" Version="4.20.69" />
<PackageReference Include="xunit" Version="2.5.1" />
Expand Down
2 changes: 1 addition & 1 deletion Domain/Domain.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="AutoMapper" Version="12.0.1" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.17.0" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.18.0" />
</ItemGroup>
</Project>
6 changes: 3 additions & 3 deletions Persistence/Persistence.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.10">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.11">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
32 changes: 32 additions & 0 deletions Web/Extensions/CultureExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System.Globalization;

using Microsoft.AspNetCore.Localization;

namespace Web.Extensions;

public static class CultureExtensions
{
public static IServiceCollection AddLocalizationAndConfiguration(this IServiceCollection services)
{
services.AddLocalization();
return services;
}

public static IApplicationBuilder UseRequestLocalizationWithSupportedCultures(this IApplicationBuilder app)
{
var supportedCultures = CultureInfo.GetCultures(CultureTypes.AllCultures & ~CultureTypes.NeutralCultures)
.Where(cul => !string.IsNullOrEmpty(cul.Name))
.ToArray();

var localizationOptions = new RequestLocalizationOptions()
{
DefaultRequestCulture = new RequestCulture("nl-BE"),
SupportedCultures = supportedCultures,
SupportedUICultures = supportedCultures
};

app.UseRequestLocalization(localizationOptions);

return app;
}
}
25 changes: 25 additions & 0 deletions Web/Pages/Public/About.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
@using System.Security.Claims
@using System.Reflection
@using Microsoft.AspNetCore.Components.Authorization
@using System.Globalization

@inject AuthenticationStateProvider AuthenticationStateProvider

Expand Down Expand Up @@ -30,10 +31,28 @@
}
</p>

<h2>Culture info</h2>

<p>Available cultures:</p>
<select T="System.Globalization.CultureInfo" @bind="Culture" AnchorOrigin="Origin.BottomCenter">
@foreach (var culture in _supportedCultures)
{
<option Value="@culture">@culture.DisplayName</option>
}
</select>
<p>Amount test: @TestAmount.ToString("C", Culture)</p>

<p>Current UI culture: @CultureInfo.CurrentUICulture.DisplayName</p>
<p>Amount test: @TestAmount.ToString("C", CultureInfo.CurrentUICulture)</p>

@code {
private string? authMessage;
private IEnumerable<Claim> claims = Enumerable.Empty<Claim>();

private decimal TestAmount = 123.56M;
private CultureInfo[] _supportedCultures = Array.Empty<CultureInfo>();
private CultureInfo Culture { get; set; } = default!;

private string _version
{
get
Expand All @@ -59,5 +78,11 @@
{
authMessage = "The user is NOT authenticated.";
}

_supportedCultures = CultureInfo.GetCultures(CultureTypes.AllCultures & ~CultureTypes.NeutralCultures)
.Where(cul => !string.IsNullOrEmpty(cul.Name))
.ToArray();

Culture = CultureInfo.CurrentUICulture;
}
}
9 changes: 5 additions & 4 deletions Web/Pages/Transactions/TransactionForm.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@using Types
@using System.Globalization;
@using Types
@using Queries.Members.Handlers.AutocompleteMember

<div class="d-flex flex-column justify-start align-start mw-13">
Expand Down Expand Up @@ -145,7 +146,7 @@
{
<MudItem xs="6">
<MudNumericField Value="transactionType.Amount"
ValueChanged="value => OnAmountChanged(transactionType, value)" Label="Amount ()" Min="0"
ValueChanged="value => OnAmountChanged(transactionType, value)" Label="@($"Amount ({CultureInfo.CurrentUICulture.NumberFormat.CurrencySymbol})")" Min="0"
For="@(() => transactionType.Amount)" T="decimal?">
</MudNumericField>
</MudItem>
Expand All @@ -165,14 +166,14 @@
</MudGrid>
<MudDivider Class="my-2"></MudDivider>
<MudText>
Sum of all types: <strong>@Transaction.TransactionTypeAmounts.Sum(x => x.Amount)</strong>.
Sum of all types: <strong>@((Transaction.TransactionTypeAmounts.Sum(x => x.Amount) ?? 0).ToString("C", CultureInfo.CurrentUICulture))</strong>.
This value should match the total amount of the transaction
</MudText>
@if (CanExtendMembership && SelectedMember != null)
{
<MudCheckBox Color="Color.Secondary" @bind-Checked="Transaction.ApplyMembershipCalculation">
Extend
membership for @SelectedMember.FirstName: @SelectedMember.MembershipFee. This gives @AmountOfMonths
membership for @SelectedMember.FirstName: @SelectedMember.MembershipFee.ToString("C", CultureInfo.CurrentUICulture). This gives @AmountOfMonths
more month(s) of membership
</MudCheckBox>

Expand Down
5 changes: 3 additions & 2 deletions Web/Pages/Transactions/Transactions.razor
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
@using Types
@using TransactionTypeAmount = Queries.Transactions.ViewModels.TransactionTypeAmount
@using Web.Extensions
@using System.Globalization

@inject IMediator _mediator

Expand Down Expand Up @@ -58,7 +59,7 @@
@context.CounterPartyName
</MudTd>
<MudTd DataLabel="Amount">
@GetAmount(context).ToString("C")
@GetAmount(context).ToString("C", CultureInfo.CurrentUICulture)
</MudTd>
<MudTd DataLabel="ReceivedDateTime">
@context.ReceivedDateTime.ToString("dd-MM-yyyy")
Expand All @@ -69,7 +70,7 @@
<MudTd DataLabel="Transaction types">
@foreach (var type in context.TransactionTypeAmounts)
{
<MudChip>@type.TransactionType.GetDescription() for @type.Amount</MudChip>
<MudChip>@type.TransactionType.GetDescription() for @type.Amount.ToString("C", CultureInfo.CurrentUICulture)</MudChip>
}
</MudTd>
<MudTd>
Expand Down
4 changes: 2 additions & 2 deletions Web/Pages/_Host.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@

<script src="_framework/blazor.server.js"></script>
<script>
winow.triggerFileDownload = (fileName, url) => {
window.triggerFileDownload = (fileName, url) => {
const anchorElement = document.createElement('a');
anchorElement.href = url;
anchorElement.download = fileName ?? '';
anchorElement.click();
anchorElement.remove();
}
winow.downloadFileFromStream = async (fileName, contentStreamReference) => {
window.downloadFileFromStream = async (fileName, contentStreamReference) => {
const arrayBuffer = await contentStreamReference.arrayBuffer();
const blob = new Blob([arrayBuffer]);
const url = URL.createObjectURL(blob);
Expand Down
3 changes: 3 additions & 0 deletions Web/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ public void ConfigureServices(IServiceCollection services)
services.AddHttpContextAccessor();
services.AddScoped<IUserAccessor, UserAccessor>();
services.AddMailingService(Configuration);

services.AddLocalizationAndConfiguration();
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
Expand All @@ -107,6 +109,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
app.UseStaticFiles();

app.UseRouting();
app.UseRequestLocalizationWithSupportedCultures();
app.UseAuthentication();
app.UseAuthorization();

Expand Down
6 changes: 3 additions & 3 deletions Web/Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="7.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="7.0.11" />
<PackageReference Include="Microsoft.AspNetCore.Components.DataAnnotations.Validation" Version="3.2.0-rc1.20223.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.10">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.11">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="MudBlazor" Version="6.9.0" />
<PackageReference Include="MudBlazor" Version="6.10.0" />
</ItemGroup>

<PropertyGroup>
Expand Down

0 comments on commit e0bb5bf

Please sign in to comment.