Пример #1
0
        public async Task ShipmentInfoNull_ReturnsZero()
        {
            A.CallTo(() => shipmentInfoRepository.GetByNotificationId(notificationId)).Returns <ShipmentInfo>(null);

            var result = await chargeCalculator.GetValue(notificationId);

            Assert.Equal(0m, result);
        }
Пример #2
0
        public async Task <decimal> Balance(Guid notificationId)
        {
            var totalBillable = await chargeCalculator.GetValue(notificationId);

            var totalPaid = await TotalPaid(notificationId);

            return(totalBillable - totalPaid);
        }
        public async Task <NotificationApplicationOverview> GetById(Guid notificationId)
        {
            await authorization.EnsureAccessAsync(notificationId);

            var query =
                from notification in db.NotificationApplications
                where notification.Id == notificationId
                from wasteRecovery
                //left join waste recovery, if it exists
                in db.WasteRecoveries
                .Where(wr => wr.NotificationId == notification.Id)
                .DefaultIfEmpty()
                from assessment
                //left join assessment, if it exists
                in db.NotificationAssessments
                .Where(na => na.NotificationApplicationId == notification.Id)
                .DefaultIfEmpty()
                from wasteDiposal
                in db.WasteDisposals
                .Where(wd => wd.NotificationId == notification.Id)
                .DefaultIfEmpty()
                from exporter
                in db.Exporters
                .Where(e => e.NotificationId == notification.Id)
                .DefaultIfEmpty()
                from importer
                in db.Importers
                .Where(i => i.NotificationId == notification.Id)
                .DefaultIfEmpty()
                from shipmentInfo
                in db.ShipmentInfos
                .Where(si => si.NotificationId == notification.Id)
                .DefaultIfEmpty()
                select new
            {
                Notification           = notification,
                WasteRecovery          = wasteRecovery,
                WasteDisposal          = wasteDiposal,
                NotificationAssessment = assessment,
                ShipmentInfo           = shipmentInfo,
                Exporter = exporter,
                Importer = importer
            };

            var data = await query.SingleAsync();

            return(NotificationApplicationOverview.Load(
                       data.Notification,
                       data.NotificationAssessment,
                       data.WasteRecovery,
                       data.WasteDisposal,
                       data.Exporter,
                       data.Importer,
                       decimal.ToInt32(await chargeCalculator.GetValue(notificationId)),
                       progressService.GetNotificationProgressInfo(notificationId)));
        }
Пример #4
0
 public async Task <ConfirmNumberOfShipmentsChangeData> HandleAsync(GetChangeNumberOfShipmentConfrimationData message)
 {
     return(new ConfirmNumberOfShipmentsChangeData
     {
         NotificationId = message.NotificationId,
         CurrentNumberOfShipments = await shipmentHistotyRepository.GetCurrentNumberOfShipments(message.NotificationId),
         CurrentCharge = await notificationChargeCalculator.GetValue(message.NotificationId),
         NewCharge = await notificationChargeCalculator.GetValueForNumberOfShipments(message.NotificationId, message.NumberOfShipments)
     });
 }
        public async Task <AccountManagementData> HandleAsync(GetAccountManagementData message)
        {
            var transactions = await repository.GetTransactions(message.NotificationId);

            var accountManagementData = accountManagementMap.Map(transactions);

            var totalBillable = await chargeCalculator.GetValue(message.NotificationId);

            accountManagementData.TotalBillable = totalBillable;
            accountManagementData.Balance       = await transactionCalculator.TotalPaid(message.NotificationId);

            return(accountManagementData);
        }
Пример #6
0
        public async Task <WhatToDoNextPaymentData> HandleAsync(GetWhatToDoNextPaymentDataForNotification message)
        {
            var notification = await context.GetNotificationApplication(message.Id);

            var competentAuthority = await context.UnitedKingdomCompetentAuthorities.SingleAsync(
                n => n.Id == (int)notification.CompetentAuthority);

            var result = map.Map(notification, competentAuthority);

            result.Status = await assessmentRepository.GetStatusByNotificationId(message.Id);

            result.Charge = await chargeCalculator.GetValue(message.Id);

            result.AmountPaid = await transactionCalculator.TotalPaid(message.Id);

            return(result);
        }
Пример #7
0
 public async Task <decimal> HandleAsync(GetNotificationCharge message)
 {
     return(await chargeCalculator.GetValue(message.NotificationId));
 }