diff --git a/src/services/financialreporting/1.core/FinancialReporting.Core.Application/FinancialReporting.Core.Application.csproj b/src/services/financialreporting/1.core/FinancialReporting.Core.Application/FinancialReporting.Core.Application.csproj index b84b5c7..54312a4 100644 --- a/src/services/financialreporting/1.core/FinancialReporting.Core.Application/FinancialReporting.Core.Application.csproj +++ b/src/services/financialreporting/1.core/FinancialReporting.Core.Application/FinancialReporting.Core.Application.csproj @@ -10,6 +10,7 @@ + diff --git a/src/services/financialreporting/1.core/FinancialReporting.Core.Application/Journals/Commands/CreateGeneralLedger/CreateGeneralLedgerCommandHandler.cs b/src/services/financialreporting/1.core/FinancialReporting.Core.Application/Journals/Commands/CreateGeneralLedger/CreateGeneralLedgerCommandHandler.cs new file mode 100644 index 0000000..762970a --- /dev/null +++ b/src/services/financialreporting/1.core/FinancialReporting.Core.Application/Journals/Commands/CreateGeneralLedger/CreateGeneralLedgerCommandHandler.cs @@ -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 logger + ) : + BaseCommandHandler(logger) +{ + protected override async Task> HandleAsync( + CreateGeneralLedgerCommand command, + CancellationToken cancellationToken) + { + + + return Result.Success(Unit.Value); + } +} diff --git a/src/services/financialreporting/1.core/FinancialReporting.Core.Application/Journals/EventHandlers/JournalPostedIntegrationHandler.cs b/src/services/financialreporting/1.core/FinancialReporting.Core.Application/Journals/EventHandlers/JournalPostedIntegrationHandler.cs index 60cf1a9..982f682 100644 --- a/src/services/financialreporting/1.core/FinancialReporting.Core.Application/Journals/EventHandlers/JournalPostedIntegrationHandler.cs +++ b/src/services/financialreporting/1.core/FinancialReporting.Core.Application/Journals/EventHandlers/JournalPostedIntegrationHandler.cs @@ -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; @@ -13,9 +14,10 @@ public class JournalPostedIntegrationHandler( : BaseIntegrationEventHandler(logger) { protected override async Task HandleAsync( - JournalEntryPostedIntegrationEvent domainEvent, + JournalEntryPostedIntegrationEvent integrationEvent, CancellationToken cancellationToken) { - + await _bus.SendCommandAsync(integrationEvent.MapToCreateCommand()); } -} \ No newline at end of file +} + diff --git a/src/services/financialreporting/1.core/FinancialReporting.Core.Application/Mappings/JournalMappingExtensions.cs b/src/services/financialreporting/1.core/FinancialReporting.Core.Application/Mappings/JournalMappingExtensions.cs new file mode 100644 index 0000000..eac9664 --- /dev/null +++ b/src/services/financialreporting/1.core/FinancialReporting.Core.Application/Mappings/JournalMappingExtensions.cs @@ -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 + ); + } +} diff --git a/src/services/financialreporting/1.core/FinancialReporting.Core.RequestResponse/FinancialReporting.Core.RequestResponse.csproj b/src/services/financialreporting/1.core/FinancialReporting.Core.RequestResponse/FinancialReporting.Core.RequestResponse.csproj index b760144..8fcc104 100644 --- a/src/services/financialreporting/1.core/FinancialReporting.Core.RequestResponse/FinancialReporting.Core.RequestResponse.csproj +++ b/src/services/financialreporting/1.core/FinancialReporting.Core.RequestResponse/FinancialReporting.Core.RequestResponse.csproj @@ -6,4 +6,9 @@ enable + + + + + diff --git a/src/services/financialreporting/1.core/FinancialReporting.Core.RequestResponse/Journals/Commands/CreateGeneralLedgerCommand.cs b/src/services/financialreporting/1.core/FinancialReporting.Core.RequestResponse/Journals/Commands/CreateGeneralLedgerCommand.cs new file mode 100644 index 0000000..75c6f01 --- /dev/null +++ b/src/services/financialreporting/1.core/FinancialReporting.Core.RequestResponse/Journals/Commands/CreateGeneralLedgerCommand.cs @@ -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, + DateOnly Date, + string Description, + int JournalTypeId, + string JournalTypeName, + List Lines) : ICommand +{ + public Guid Id { get; } = Guid.NewGuid(); + public DateTime HappenedAt { get; } = DateTime.Now; +} + +public record JournalLineCommand( + Guid LineId, + Guid AccountId, + decimal Debit, + decimal Credit); \ No newline at end of file