Skip to content

Commit

Permalink
additional logging on null transfer payment error
Browse files Browse the repository at this point in the history
  • Loading branch information
cofaulco committed Jan 22, 2021
1 parent 33c5e20 commit 145a64f
Showing 1 changed file with 20 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,32 @@ protected override async Task HandleCore(RefreshAccountTransfersCommand message)

foreach (var transfer in transfers)
{
transfer.PeriodEnd = message.PeriodEnd;
try
{
transfer.PeriodEnd = message.PeriodEnd;

_logger.Info($"Getting payment details for transfer AccountId = {message.ReceiverAccountId}' and PeriodEnd = '{message.PeriodEnd}' CorrelationId: {message.CorrelationId}");
_logger.Info($"Getting payment details for transfer AccountId = {message.ReceiverAccountId}' and PeriodEnd = '{message.PeriodEnd}' CorrelationId: {message.CorrelationId}");

var paymentDetails = await _transferRepository.GetTransferPaymentDetails(transfer);
var paymentDetails = await _transferRepository.GetTransferPaymentDetails(transfer);

_logger.Info($"Got payment details for transfer: {(paymentDetails == null ? "null payment details" : paymentDetails.CourseName)} AccountId = {message.ReceiverAccountId}' and PeriodEnd = '{message.PeriodEnd}' CorrelationId: {message.CorrelationId}");
_logger.Info($"Got payment details for transfer: {(paymentDetails == null ? "null payment details" : paymentDetails.CourseName)} AccountId = {message.ReceiverAccountId}' and PeriodEnd = '{message.PeriodEnd}' CorrelationId: {message.CorrelationId}");

transfer.CourseName = paymentDetails.CourseName ?? "Unknown Course";
transfer.CourseLevel = paymentDetails.CourseLevel;
transfer.ApprenticeCount = paymentDetails.ApprenticeCount;
transfer.CourseName = paymentDetails.CourseName ?? "Unknown Course";
transfer.CourseLevel = paymentDetails.CourseLevel;
transfer.ApprenticeCount = paymentDetails.ApprenticeCount;

transfer.SenderAccountName = transferSenderAccountNames[transfer.SenderAccountId];
transfer.ReceiverAccountName = transferReceiverAccountName;
transfer.SenderAccountName = transferSenderAccountNames[transfer.SenderAccountId];
transfer.ReceiverAccountName = transferReceiverAccountName;

if (transfer.Amount != paymentDetails.PaymentTotal)
_logger.Warn("Transfer total does not match transfer payments total");
if (transfer.Amount != paymentDetails.PaymentTotal)
_logger.Warn("Transfer total does not match transfer payments total");
}
catch(Exception ex)
{
_logger.Error(ex, $"Failed to process transfer: ReceiverAccountId = {transfer.ReceiverAccountId}, PeriodEnd = {message.PeriodEnd}, ApprenticeshipId = {transfer.ApprenticeshipId}, CorrelationId = {message.CorrelationId}");
throw;
}

}

_logger.Info($"Creating account transfers AccountId = {message.ReceiverAccountId}' and PeriodEnd = '{message.PeriodEnd}' CorrelationId: {message.CorrelationId}");
Expand Down

0 comments on commit 145a64f

Please sign in to comment.