public static long CalculateFundingAccountId(this CalculatedRequiredLevyAmount levyTransaction, bool isReceiverTransferPayment)
        {
            if (isReceiverTransferPayment)
            {
                return(levyTransaction.AccountId.GetValueOrDefault());
            }

            return(levyTransaction.IsTransfer() ? levyTransaction.TransferSenderAccountId.GetValueOrDefault() : levyTransaction.AccountId.GetValueOrDefault());
        }
 public long GetDestinationAccountId(CalculatedRequiredLevyAmount message)
 {
     if (!message.AccountId.HasValue)
     {
         throw new InvalidOperationException($"The account id of the levy message is invalid.");
     }
     return(message.IsTransfer()
         ? message.TransferSenderAccountId.Value
         : message.AccountId.Value);
 }
        public async Task AddRequiredPayment(CalculatedRequiredLevyAmount paymentEvent)
        {
            if (paymentEvent.AmountDue < 0)
            {
                await AddRefundPaymentToCache(paymentEvent);

                return;
            }

            if (paymentEvent.IsTransfer())
            {
                await AddTransferPaymentToCache(paymentEvent);

                return;
            }

            await AddRequiredPaymentToCache(paymentEvent);
        }