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 @@ -10,6 +10,7 @@
<ProjectReference Include="..\..\..\..\buildingblocks\Integrations\BuildingBlocks.Integrations.Wolverine\BuildingBlocks.Integrations.Wolverine.csproj" />
<ProjectReference Include="..\..\..\..\buildingblocks\src\application\BuildingBlocks.Application.csproj" />
<ProjectReference Include="..\FinancialReporting.Core.Contracts\FinancialReporting.Core.Contracts.csproj" />
<ProjectReference Include="..\FinancialReporting.Core.RequestResponse\FinancialReporting.Core.RequestResponse.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using BuildingBlocks.Application.Common;
using BuildingBlocks.Application.CQRS.Commands;
using BuildingBlocks.Common;
using FinancialReporting.Core.RequestResponse.Journals.Commands;
using Microsoft.Extensions.Logging;

namespace FinancialReporting.Core.Application.Journals.Commands.CreateGeneralLedger;

public class CreateGeneralLedgerCommandHandler(
ILogger<CreateGeneralLedgerCommandHandler> logger
) :
BaseCommandHandler<CreateGeneralLedgerCommand, Unit>(logger)
{
protected override async Task<Result<Unit>> HandleAsync(
CreateGeneralLedgerCommand command,
CancellationToken cancellationToken)
{


return Result<Unit>.Success(Unit.Value);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using BuildingBlocks.Application.CQRS.Events;
using BuildingBlocks.Application.Common;
using BuildingBlocks.Application.CQRS.Events;
using BuildingBlocks.Integrations.Wolverine;
using FinancialReporting.Core.Application.Mappings;
using FinancialReporting.Core.Contracts.Journals.IntegrationEvents;
using FinancialReporting.Core.RequestResponse.Journals.Commands;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Text;
using Wolverine;

namespace FinancialReporting.Core.Application.Journals.EventHandlers;
Expand All @@ -13,9 +14,10 @@ public class JournalPostedIntegrationHandler(
: BaseIntegrationEventHandler<JournalEntryPostedIntegrationEvent>(logger)
{
protected override async Task HandleAsync(
JournalEntryPostedIntegrationEvent domainEvent,
JournalEntryPostedIntegrationEvent integrationEvent,
CancellationToken cancellationToken)
{

await _bus.SendCommandAsync<Unit>(integrationEvent.MapToCreateCommand());
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using FinancialReporting.Core.Contracts.Journals.IntegrationEvents;
using FinancialReporting.Core.RequestResponse.Journals.Commands;
using System;
using System.Collections.Generic;
using System.Text;

namespace FinancialReporting.Core.Application.Mappings;

internal static class JournalMappingExtensions
{
public static CreateGeneralLedgerCommand MapToCreateCommand(this JournalEntryPostedIntegrationEvent @event)
{
if (@event == null)
return null;

var mappedLines = @event.Lines?.Select(line => new JournalLineCommand(
line.LineId,
line.AccountId,
line.Debit,
line.Credit
)).ToList() ?? new();

return new CreateGeneralLedgerCommand(
@event.JournalEntryId,
@event.Date,
@event.Description,
@event.JournalTypeId,
@event.JournalTypeName,
mappedLines
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\..\buildingblocks\src\application\BuildingBlocks.Application.csproj" />
<ProjectReference Include="..\..\..\..\buildingblocks\src\contracts\BuildingBlocks.Contracts\BuildingBlocks.Contracts.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using BuildingBlocks.Application.Common;
using BuildingBlocks.Contracts.Application.CQRS.Commands;

namespace FinancialReporting.Core.RequestResponse.Journals.Commands;

public class CreateGeneralLedgerCommand
(
Guid JournalEntryId,

Check warning on line 8 in src/services/financialreporting/1.core/FinancialReporting.Core.RequestResponse/Journals/Commands/CreateGeneralLedgerCommand.cs

View workflow job for this annotation

GitHub Actions / build

Parameter 'JournalEntryId' is unread.
DateOnly Date,

Check warning on line 9 in src/services/financialreporting/1.core/FinancialReporting.Core.RequestResponse/Journals/Commands/CreateGeneralLedgerCommand.cs

View workflow job for this annotation

GitHub Actions / build

Parameter 'Date' is unread.
string Description,
int JournalTypeId,
string JournalTypeName,
List<JournalLineCommand> Lines) : ICommand<Unit>
{
public Guid Id { get; } = Guid.NewGuid();
public DateTime HappenedAt { get; } = DateTime.Now;
}

public record JournalLineCommand(
Guid LineId,
Guid AccountId,
decimal Debit,
decimal Credit);
Loading