public async Task Delete_PaymentNotFullyReceived_ReceivedDateNull()
        {
            var transactionId           = new Guid("F7DF1DD7-E356-47E2-8C9C-281C4A824F94");
            var notificationTransaction = CreateNotificationTransaction(600, new DateTime(2018, 1, 1));

            A.CallTo(() => importNotificationTransactionRepository.GetById(transactionId))
            .Returns(notificationTransaction);

            // Set payment to fully received
            A.CallTo(() => importNotificationTransactionCalculator.Balance(notificationId))
            .Returns(0);

            assessment.Dates.PaymentReceivedDate = new DateTime(2017, 2, 2);

            // Delete payment, balance now £600
            await transaction.Delete(notificationId, transactionId);

            Assert.Null(assessment.Dates.PaymentReceivedDate);
        }
예제 #2
0
        public async Task <TransactionRecordData> HandleAsync(GetTransactionById message)
        {
            var transaction = await repository.GetById(message.TransactionId);

            return(new TransactionRecordData
            {
                Transaction = transaction.Credit.HasValue ? TransactionType.Payment : TransactionType.Refund,
                Date = transaction.Date,
                Amount = transaction.Credit.HasValue ? transaction.Credit.Value : transaction.Debit.GetValueOrDefault(0),
                Type = transaction.PaymentMethod,
                ReceiptNumber = transaction.ReceiptNumber,
                Comments = transaction.Comments,
                TransactionId = transaction.Id
            });
        }
예제 #3
0
        public async Task Delete(Guid notificationId, Guid transactionId)
        {
            var transaction = await transactionRepository.GetById(transactionId);

            var balance = await transactionCalculator.Balance(transaction.NotificationId)
                          + transaction.Credit.GetValueOrDefault()
                          - transaction.Debit.GetValueOrDefault();

            var transactions = (await transactionRepository.GetTransactions(transaction.NotificationId)).ToList();

            transactions.RemoveAll(t => t.Id == transactionId);

            var paymentDate = CalculatePaymentReceivedDate(transactions, balance);

            await UpdatePaymentReceivedDate(paymentDate, transaction.NotificationId);

            await transactionRepository.DeleteById(transactionId);
        }