This commit is contained in:
Zeeshaun
2026-03-17 09:53:09 -05:00
parent cdcba54aa4
commit 1a0702a79a
590 changed files with 62058 additions and 0 deletions
@@ -0,0 +1,8 @@
using LCU.Library.Internal.IncentiveApiModels.Requests;
namespace LCU.API.Internal.Operations.IncentiveApi.Services.Reporting;
public interface IReportingService
{
Task HandleMonthlyReporting(ReportingRequest request);
}
@@ -0,0 +1,46 @@
using LCU.API.Internal.Operations.IncentiveApiLib.Repositories;
using LCU.API.Internal.Operations.IncentiveApi.Services.Payout;
using LCU.Library.Internal.IncentiveApiModels.Common;
using LCU.Library.Internal.IncentiveApiModels.Requests;
using LCU.Library.Internal.IncentiveApiModels.Results;
using LCU.Library.Internal.ApiResponse.Services;
using LCU.Library.Internal.Exceptions;
namespace LCU.API.Internal.Operations.IncentiveApi.Services.Reporting;
public class ReportingService : IReportingService
{
private readonly IUserRepository _userRepository;
private readonly IPayoutService _payoutService;
private readonly ProcessResult _reportingProcessResult;
public ReportingService(IPayoutService payoutService, IUserRepository userRepository)
{
_payoutService = payoutService;
_userRepository = userRepository;
_reportingProcessResult = new ProcessResult();
}
public async Task HandleMonthlyReporting(ReportingRequest request)
{
try
{
var period = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1);
period = request.MonthsBack == 0 ? period.AddMonths(-1) : period.AddMonths(request.MonthsBack);
var range = new MonthRange(period);
_payoutService.CreateMonthlyAccountingPayouts(range).GetAwaiter().GetResult();
Log.Information($"Reporting Service processed");
_reportingProcessResult.MessageStack.Add($"Reporting Service Processed Month Starting {range.ToMonth}.");
await QueueReturnResponse.QueueResponse(request, _reportingProcessResult.Success, _reportingProcessResult.MessageStack);
}
catch (Exception exception)
{
var message = $"There was an issue with handling the Reporting Service Process Exception Message: {exception.Message}.";
_reportingProcessResult.MessageStack.Add(message);
_reportingProcessResult.Success = false;
await QueueReturnResponse.QueueResponse(request, _reportingProcessResult.Success, _reportingProcessResult.MessageStack);
throw new ServiceException(message);
}
}
}