public void UpdatePackagingInfoReplacesItems()
        {
            var notification = new NotificationApplication(Guid.NewGuid(), NotificationType.Recovery,
                UKCompetentAuthority.England, 0);

            var packagingInfos = new List<PackagingInfo>
            {
                PackagingInfo.CreateOtherPackagingInfo("package description"),
                PackagingInfo.CreatePackagingInfo(PackagingType.Bag)
            };

            var newPackagingInfos = new List<PackagingInfo>
            {
                PackagingInfo.CreatePackagingInfo(PackagingType.Box),
                PackagingInfo.CreatePackagingInfo(PackagingType.Bulk)
            };

            notification.SetPackagingInfo(packagingInfos);

            notification.SetPackagingInfo(newPackagingInfos);

            Assert.Collection(notification.PackagingInfos,
                item => Assert.Equal(notification.PackagingInfos.ElementAt(0).PackagingType, PackagingType.Box),
                item => Assert.Equal(notification.PackagingInfos.ElementAt(1).PackagingType, PackagingType.Bulk));
        }
        public WasteRecoveryBlock(IList<MergeField> mergeFields, NotificationApplication notification, WasteRecovery wasteRecovery, WasteDisposal wasteDisposal)
        {
            AnnexMergeFields = MergeFieldLocator.GetAnnexMergeFields(mergeFields, TypeName);

            CorrespondingMergeFields = MergeFieldLocator.GetCorrespondingFieldsForBlock(mergeFields, TypeName);
            data = new WasteRecoveryViewModel(notification, wasteRecovery, wasteDisposal, new WasteRecoveryFormatter());
            
            if (notification.NotificationType == NotificationType.Disposal)
            {
                HasAnnex = false;

                MergeMainDocumentBlock();
            }
            else
            {
                HasAnnex = true;

                if (notification.WasteRecoveryInformationProvidedByImporter.GetValueOrDefault())
                {
                    HasAnnex = false;

                    MergeMainDocumentBlock();
                }
            }
        }
Exemplo n.º 3
0
        public File CreateForNotification(IAnnexNameGenerator annexNameGenerator, NotificationApplication notification,
                                          byte[] annexBytes, string fileType)
        {
            var name = annexNameGenerator.GetValue(notification);

            return(new File(name, fileType, annexBytes));
        }
Exemplo n.º 4
0
        public OperationBlock(IList <MergeField> mergeFields, NotificationApplication notification, TechnologyEmployed technologyEmployed)
        {
            CorrespondingMergeFields = MergeFieldLocator.GetCorrespondingFieldsForBlock(mergeFields, TypeName);
            data = new OperationViewModel(notification, technologyEmployed, new OperationInfoFormatter());

            AnnexMergeFields = MergeFieldLocator.GetAnnexMergeFields(mergeFields, TypeName);
        }
Exemplo n.º 5
0
        private static NotificationApplication CreateNotificationApplication()
        {
            var notification = new NotificationApplication(Guid.NewGuid(), NotificationType.Recovery,
                                                           UKCompetentAuthority.England, 0);

            return(notification);
        }
Exemplo n.º 6
0
        public WasteCodesBlock(IList <MergeField> mergeFields, NotificationApplication notification)
        {
            CorrespondingMergeFields = MergeFieldLocator.GetCorrespondingFieldsForBlock(mergeFields, TypeName);
            data = new WasteCodesViewModel(notification, new WasteCodeInfoFormatter());

            AnnexMergeFields = MergeFieldLocator.GetAnnexMergeFields(mergeFields, TypeName);
        }
Exemplo n.º 7
0
        public string GetValueForMergeField(MergeField mergeField, NotificationApplication notification)
        {
            if (mergeField.FieldName.InnerTypeName.Equals("Number"))
            {
                return(notification.NotificationNumber);
            }

            if (notification.NotificationType == NotificationType.Disposal)
            {
                if (mergeField.FieldName.InnerTypeName.Equals("IsDisposal"))
                {
                    return("☑");
                }

                if (mergeField.FieldName.InnerTypeName.Equals("IsRecovery"))
                {
                    return("☐");
                }
            }

            if (notification.NotificationType == NotificationType.Recovery)
            {
                if (mergeField.FieldName.InnerTypeName.Equals("IsRecovery"))
                {
                    return("☑");
                }

                if (mergeField.FieldName.InnerTypeName.Equals("IsDisposal"))
                {
                    return("☐");
                }
            }

            return(String.Empty);
        }
Exemplo n.º 8
0
        public OperationBlock(IList<MergeField> mergeFields, NotificationApplication notification, TechnologyEmployed technologyEmployed)
        {
            CorrespondingMergeFields = MergeFieldLocator.GetCorrespondingFieldsForBlock(mergeFields, TypeName);
            data = new OperationViewModel(notification, technologyEmployed, new OperationInfoFormatter());

            AnnexMergeFields = MergeFieldLocator.GetAnnexMergeFields(mergeFields, TypeName);
        }
        public SetExitCustomsOfficeForNotificationByIdHandlerTests()
        {
            this.context = new TestIwsContext();
            var repository = A.Fake<ITransportRouteRepository>();

            anyNotification = NotificationApplicationFactory.Create(TestIwsContext.UserId, NotificationType.Recovery, UKCompetentAuthority.England, 0);
            EntityHelper.SetEntityId(anyNotification, notificationId);

            transport = new TransportRoute(notificationId);

            context.NotificationApplications.Add(anyNotification);
            context.TransportRoutes.Add(transport);

            country = CountryFactory.Create(AnyGuid);
            nonEuCountry = CountryFactory.Create(new Guid("606ECF5A-6571-4803-9CCA-7E1AF82D147A"), "test", false);

            context.Countries.AddRange(new[]
            {
                country,
                nonEuCountry
            });

            stateOfExport = new StateOfExport(country,
                CompetentAuthorityFactory.Create(AnyGuid, country),
                EntryOrExitPointFactory.Create(AnyGuid, country));

            stateOfImportNonEu = new StateOfImport(nonEuCountry,
                CompetentAuthorityFactory.Create(new Guid("5E4F1F22-5054-449B-9EC7-933A43BB5D6D"), nonEuCountry),
                EntryOrExitPointFactory.Create(new Guid("9781324F-17B8-4009-89B2-C18963E3E6E1"), nonEuCountry));

            A.CallTo(() => repository.GetByNotificationId(notificationId)).Returns(transport);

            this.handler = new SetExitCustomsOfficeForNotificationByIdHandler(context, repository);
        }
Exemplo n.º 10
0
        public File CreateForNotification(IAnnexNameGenerator annexNameGenerator, NotificationApplication notification,
            byte[] annexBytes, string fileType)
        {
            var name = annexNameGenerator.GetValue(notification);

            return new File(name, fileType, annexBytes);
        }
        public GetExitCustomsOfficeAddDataByNotificationIdTests()
        {
            context = new TestIwsContext();
            var repository = A.Fake<ITransportRouteRepository>();

            country = CountryFactory.Create(new Guid("05C21C57-2F39-4A15-A09A-5F38CF139C05"));
            exitCustomsOffice = new ExitCustomsOffice("any name", "any address", country);

            notification = NotificationApplicationFactory.Create(TestIwsContext.UserId, NotificationType.Recovery,
                UKCompetentAuthority.England, 500);

            transport = new TransportRoute(NotificationId);

            EntityHelper.SetEntityId(notification, NotificationId);

            context.Countries.Add(country);
            context.NotificationApplications.Add(notification);
            context.TransportRoutes.Add(transport);

            A.CallTo(() => repository.GetByNotificationId(NotificationId)).Returns(transport);

            handler = new GetExitCustomsOfficeAddDataByNotificationIdHandler(repository,
                new CustomsOfficeExitMap(context,
                                            new CountryMap(),
                                            new CustomsOfficeMap(new CountryMap())));
        }
        private static NotificationApplication CreateNotificationApplication()
        {
            var notification = new NotificationApplication(Guid.NewGuid(), NotificationType.Recovery,
                UKCompetentAuthority.England, 0);

            return notification;
        }
Exemplo n.º 13
0
        protected void SetUnNumbersAndShippingNames(NotificationApplication notification)
        {
            UnNumber = string.Empty;
            UnNumberAndShippingName = string.Empty;
            UnShippingName          = string.Empty;
            var separator = ", ";

            if (notification.UnNumbers == null)
            {
                return;
            }

            if (notification.UnNumbers.Any(c => c.IsNotApplicable))
            {
                UnNumber = NotApplicable;
                UnNumberAndShippingName = UnNumber;
                return;
            }

            var codes = notification.UnNumbers.OrderBy(c => c.WasteCode.Code);

            UnNumber                = string.Join(separator, codes.Select(c => c.WasteCode.Code));
            UnShippingName          = string.Join(separator, codes.Select(c => c.WasteCode.Description));
            UnNumberAndShippingName = string.Join(Environment.NewLine,
                                                  codes.Select(c => c.WasteCode.Code + " - " + c.WasteCode.Description));
        }
        public string GetValueForMergeField(MergeField mergeField, NotificationApplication notification)
        {
            if (mergeField.FieldName.InnerTypeName.Equals("Number"))
            {
                return notification.NotificationNumber;
            }

            if (notification.NotificationType == NotificationType.Disposal)
            {
                if (mergeField.FieldName.InnerTypeName.Equals("IsDisposal"))
                {
                    return "☑";
                }

                if (mergeField.FieldName.InnerTypeName.Equals("IsRecovery"))
                {
                    return "☐";
                }
            }

            if (notification.NotificationType == NotificationType.Recovery)
            {
                if (mergeField.FieldName.InnerTypeName.Equals("IsRecovery"))
                {
                    return "☑";
                }

                if (mergeField.FieldName.InnerTypeName.Equals("IsDisposal"))
                {
                    return "☐";
                }
            }

            return String.Empty;
        }
Exemplo n.º 15
0
        public WasteRecoveryBlock(IList <MergeField> mergeFields, NotificationApplication notification, WasteRecovery wasteRecovery, WasteDisposal wasteDisposal)
        {
            AnnexMergeFields = MergeFieldLocator.GetAnnexMergeFields(mergeFields, TypeName);

            CorrespondingMergeFields = MergeFieldLocator.GetCorrespondingFieldsForBlock(mergeFields, TypeName);
            data = new WasteRecoveryViewModel(notification, wasteRecovery, wasteDisposal, new WasteRecoveryFormatter());

            if (notification.NotificationType == NotificationType.Disposal)
            {
                HasAnnex = false;

                MergeMainDocumentBlock();
            }
            else
            {
                HasAnnex = true;

                if (notification.WasteRecoveryInformationProvidedByImporter.GetValueOrDefault())
                {
                    HasAnnex = false;

                    MergeMainDocumentBlock();
                }
            }
        }
Exemplo n.º 16
0
        public WasteCodesBlock(IList<MergeField> mergeFields, NotificationApplication notification)
        {
            CorrespondingMergeFields = MergeFieldLocator.GetCorrespondingFieldsForBlock(mergeFields, TypeName);
            data = new WasteCodesViewModel(notification, new WasteCodeInfoFormatter());

            AnnexMergeFields = MergeFieldLocator.GetAnnexMergeFields(mergeFields, TypeName);
        }
Exemplo n.º 17
0
        public void UpdatePackagingInfoReplacesItems()
        {
            var notification = new NotificationApplication(Guid.NewGuid(), NotificationType.Recovery,
                                                           UKCompetentAuthority.England, 0);

            var packagingInfos = new List <PackagingInfo>
            {
                PackagingInfo.CreateOtherPackagingInfo("package description"),
                PackagingInfo.CreatePackagingInfo(PackagingType.Bag)
            };

            var newPackagingInfos = new List <PackagingInfo>
            {
                PackagingInfo.CreatePackagingInfo(PackagingType.Box),
                PackagingInfo.CreatePackagingInfo(PackagingType.Bulk)
            };

            notification.SetPackagingInfo(packagingInfos);

            notification.SetPackagingInfo(newPackagingInfos);

            Assert.Collection(notification.PackagingInfos,
                              item => Assert.Equal(notification.PackagingInfos.ElementAt(0).PackagingType, PackagingType.Box),
                              item => Assert.Equal(notification.PackagingInfos.ElementAt(1).PackagingType, PackagingType.Bulk));
        }
Exemplo n.º 18
0
        public SharedUserRepositoryTests()
        {
            ownerUser = UserFactory.Create(Guid.NewGuid(), "Owner", "User", "12345",
                                           "*****@*****.**");
            sharedUser = UserFactory.Create(Guid.NewGuid(), "Shared", "User", "12345",
                                            "*****@*****.**");

            var userContext = A.Fake <IUserContext>();

            A.CallTo(() => userContext.UserId).Returns(Guid.Parse(ownerUser.Id));

            context       = new IwsContext(userContext, A.Fake <IEventDispatcher>());
            authorization = A.Fake <INotificationApplicationAuthorization>();
            repository    = new SharedUserRepository(context, authorization);

            preRunNotifications = context.NotificationApplications.Select(na => na.Id).ToArray();

            notification = NotificationApplicationFactory.Create(Guid.Parse(ownerUser.Id), NotificationType.Recovery,
                                                                 UKCompetentAuthority.England, 20191);

            context.Users.Add(ownerUser);
            context.Users.Add(sharedUser);
            context.NotificationApplications.Add(notification);
            context.SaveChanges();
        }
        public GetExitCustomsOfficeAddDataByNotificationIdTests()
        {
            context = new TestIwsContext();
            var repository = A.Fake <ITransportRouteRepository>();

            country           = CountryFactory.Create(new Guid("05C21C57-2F39-4A15-A09A-5F38CF139C05"));
            exitCustomsOffice = new ExitCustomsOffice("any name", "any address", country);

            notification = NotificationApplicationFactory.Create(TestIwsContext.UserId, NotificationType.Recovery,
                                                                 UKCompetentAuthority.England, 500);

            transport = new TransportRoute(NotificationId);

            EntityHelper.SetEntityId(notification, NotificationId);

            context.Countries.Add(country);
            context.NotificationApplications.Add(notification);
            context.TransportRoutes.Add(transport);

            A.CallTo(() => repository.GetByNotificationId(NotificationId)).Returns(transport);

            handler = new GetExitCustomsOfficeAddDataByNotificationIdHandler(repository,
                                                                             new CustomsOfficeExitMap(context,
                                                                                                      new CountryMap(),
                                                                                                      new CustomsOfficeMap(new CountryMap())));
        }
 public void NotificationNumberFormat(string expected, string country, int notificationNumber)
 {
     var userId = new Guid("{FCCC2E8A-2464-4C10-8521-09F16F2C550C}");
     var notificationApplication = new NotificationApplication(userId, NotificationType.Disposal,
         GetCompetentAuthority(country),
         notificationNumber);
     Assert.Equal(expected, notificationApplication.NotificationNumber);
 }
        public MovementOperationReceiptTests()
        {
            var notification = new NotificationApplication(Guid.NewGuid(), NotificationType.Recovery, UKCompetentAuthority.England, 0);

            movement = new Movement(1, notification.Id);
            ObjectInstantiator<Movement>.SetProperty(x => x.Date, MovementDate, movement);
            ObjectInstantiator<Movement>.SetProperty(x => x.Units, ShipmentQuantityUnits.Kilograms, movement);
        }
Exemplo n.º 22
0
        private static IEnumerable <PackagingInfo> GetPackagingInfoFromDraft(IEnumerable <DraftPackagingInfo> draftPackagingInfos,
                                                                             NotificationApplication notification)
        {
            var packagingTypes = draftPackagingInfos.Select(p => p.PackagingType);

            return(notification.PackagingInfos
                   .Where(p => packagingTypes.Contains(p.PackagingType)));
        }
 public SpecialHandlingViewModel(NotificationApplication notification)
 {
     if (notification.HasSpecialHandlingRequirements.GetValueOrDefault())
     {
         Requirements = "See Annex";
         details = notification.SpecialHandlingDetails;
     }
 }
Exemplo n.º 24
0
 public SpecialHandlingViewModel(NotificationApplication notification)
 {
     if (notification.HasSpecialHandlingRequirements.GetValueOrDefault())
     {
         Requirements = "See Annex";
         details      = notification.SpecialHandlingDetails;
     }
 }
Exemplo n.º 25
0
        public void CanAddPackagingInfo()
        {
            var notification = new NotificationApplication(Guid.NewGuid(), NotificationType.Recovery,
                                                           UKCompetentAuthority.England, 0);

            notification.SetPackagingInfo(new[] { PackagingInfo.CreateOtherPackagingInfo("package description") });

            Assert.Equal(1, notification.PackagingInfos.Count());
        }
        public void CanAddPackagingInfo()
        {
            var notification = new NotificationApplication(Guid.NewGuid(), NotificationType.Recovery,
                UKCompetentAuthority.England, 0);

            notification.SetPackagingInfo(new[] { PackagingInfo.CreateOtherPackagingInfo("package description") });

            Assert.Equal(1, notification.PackagingInfos.Count());
        }
Exemplo n.º 27
0
 public RelationshipDeletionIntegration()
 {
     userId      = new Guid("5BA5B2CE-A29C-4B94-A528-567F636CA456");
     userContext = A.Fake <IUserContext>();
     A.CallTo(() => userContext.UserId).Returns(userId);
     context      = new IwsContext(userContext, A.Fake <IEventDispatcher>());
     notification = NotificationApplicationFactory.Create(userId, NotificationType.Recovery,
                                                          UKCompetentAuthority.England, 0);
 }
        public void SetProvider_RaisesEvent()
        {
            var notification = new NotificationApplication(Guid.NewGuid(), NotificationType.Recovery,
                UKCompetentAuthority.England, 0);

            notification.SetWasteRecoveryInformationProvider(ProvidedBy.Importer);

            Assert.Equal(ProvidedBy.Importer, notification.Events.OfType<ProviderChangedEvent>().SingleOrDefault().NewProvider);
        }
 public RelationshipDeletionIntegration()
 {
     userId = new Guid("5BA5B2CE-A29C-4B94-A528-567F636CA456");
     userContext = A.Fake<IUserContext>();
     A.CallTo(() => userContext.UserId).Returns(userId);
     context = new IwsContext(userContext, A.Fake<IEventDispatcher>());
     notification = NotificationApplicationFactory.Create(userId, NotificationType.Recovery,
         UKCompetentAuthority.England, 0);
 }
        public async Task ReturnsCorrectFormat(string expected, UKCompetentAuthority competentAuthority, int notificationNumber, NotificationType notificationType, int movementNumber)
        {
            var notification = new NotificationApplication(Guid.NewGuid(), notificationType, competentAuthority, notificationNumber);
            A.CallTo(() => notificationRepository.GetById(notificationId)).Returns(notification);

            var result = await certificateOfRecoveryName.GetValue(new Movement(movementNumber, notificationId, AnyDate, userId));

            Assert.Equal(expected, result);
        }
Exemplo n.º 31
0
        public void NotificationNumberFormat(string expected, string country, int notificationNumber)
        {
            var userId = new Guid("{FCCC2E8A-2464-4C10-8521-09F16F2C550C}");
            var notificationApplication = new NotificationApplication(userId, NotificationType.Disposal,
                                                                      GetCompetentAuthority(country),
                                                                      notificationNumber);

            Assert.Equal(expected, notificationApplication.NotificationNumber);
        }
Exemplo n.º 32
0
        public GeneralViewModel(NotificationApplication notification,
            ShipmentInfo shipmentInfo,
            FacilityCollection facilityCollection,
            DateTimeFormatter dateTimeFormatter,
            QuantityFormatter quantityFormatter,
            PhysicalCharacteristicsFormatter physicalCharacteristicsFormatter)
        {
            Number = notification.NotificationNumber;
            IsDisposal = notification.NotificationType.Equals(NotificationType.Disposal);
            IsRecovery = notification.NotificationType.Equals(NotificationType.Recovery);

            var isPreconsented = facilityCollection.AllFacilitiesPreconsented;
            if (!isPreconsented.HasValue)
            {
                IsPreconsented = false;
                IsNotPreconsented = false;
            }
            else
            {
                IsPreconsented = isPreconsented.GetValueOrDefault();
                IsNotPreconsented = !isPreconsented.GetValueOrDefault();
            }

            if (shipmentInfo.NumberOfShipments > 1)
            {
                IsIndividualShipment = false;
                IsNotIndividualShipment = true;
            }
            else
            {
                IsIndividualShipment = true;
                IsNotIndividualShipment = false;
            }

            IntendedNumberOfShipments = shipmentInfo.NumberOfShipments.ToString();
            FirstDeparture = dateTimeFormatter.DateTimeToDocumentFormatString(shipmentInfo.ShipmentPeriod.FirstDate);
            LastDeparture = dateTimeFormatter.DateTimeToDocumentFormatString(shipmentInfo.ShipmentPeriod.LastDate);
            SetIntendedQuantityFields(shipmentInfo, quantityFormatter);

            var hasSpecialHandlingRequirements = notification.HasSpecialHandlingRequirements;
            if (!hasSpecialHandlingRequirements.HasValue)
            {
                IsSpecialHandling = false;
                IsNotSpecialHandling = false;
            }
            else
            {
                IsSpecialHandling = hasSpecialHandlingRequirements.GetValueOrDefault();
                IsNotSpecialHandling = !hasSpecialHandlingRequirements.GetValueOrDefault();
            }

            PackagingTypes = GetPackagingInfo(notification);

            PhysicalCharacteristics =
                physicalCharacteristicsFormatter.PhysicalCharacteristicsToCommaDelimitedString(
                    notification.PhysicalCharacteristics);
        }
Exemplo n.º 33
0
        public MovementOperationReceiptTests()
        {
            var notification = new NotificationApplication(Guid.NewGuid(), NotificationType.Recovery, UKCompetentAuthority.England, 0);

            movement = new Movement(1, notification.Id);
            ObjectInstantiator <Movement> .SetProperty(x => x.Date, MovementDate, movement);

            ObjectInstantiator <Movement> .SetProperty(x => x.Units, ShipmentQuantityUnits.Kilograms, movement);
        }
        public void SetProvider_RaisesEvent()
        {
            var notification = new NotificationApplication(Guid.NewGuid(), NotificationType.Recovery,
                                                           UKCompetentAuthority.England, 0);

            notification.SetWasteRecoveryInformationProvider(ProvidedBy.Importer);

            Assert.Equal(ProvidedBy.Importer, notification.Events.OfType <ProviderChangedEvent>().SingleOrDefault().NewProvider);
        }
Exemplo n.º 35
0
        public void CreateNotificationRaisesDomainEvent()
        {
            var notification = new NotificationApplication(Guid.Empty, NotificationType.Recovery,
                                                           UKCompetentAuthority.England, 0);

            EntityHelper.SetEntityId(notification, notificationId);

            Assert.Equal(notification,
                         notification.Events.OfType <NotificationCreatedEvent>().SingleOrDefault().Notification);
        }
        public void CreateNotificationRaisesDomainEvent()
        {
            var notification = new NotificationApplication(Guid.Empty, NotificationType.Recovery,
                UKCompetentAuthority.England, 0);

            EntityHelper.SetEntityId(notification, notificationId);

            Assert.Equal(notification,
                notification.Events.OfType<NotificationCreatedEvent>().SingleOrDefault().Notification);
        }
        public async Task ReturnsCorrectFormat(string expected, UKCompetentAuthority competentAuthority, int notificationNumber, NotificationType notificationType, int movementNumber)
        {
            var notification = new NotificationApplication(Guid.NewGuid(), notificationType, competentAuthority, notificationNumber);

            A.CallTo(() => notificationRepository.GetById(notificationId)).Returns(notification);

            var result = await certificateOfRecoveryName.GetValue(new Movement(movementNumber, notificationId, AnyDate, userId));

            Assert.Equal(expected, result);
        }
        private async Task CheckCompetentAuthority(NotificationApplication notification)
        {
            var userCompetentAuthority = await context.GetUsersCompetentAuthority(userContext);

            if (notification.CompetentAuthority != userCompetentAuthority)
            {
                throw new SecurityException(string.Format("Access denied to this notification {0} for user {1} for competent authority {2}",
                    notification.Id, userContext.UserId, userCompetentAuthority));
            }
        }
        public WasteCompositionBlock(IList<MergeField> mergeFields, NotificationApplication notification)
        {
            CorrespondingMergeFields = MergeFieldLocator.GetCorrespondingFieldsForBlock(mergeFields, TypeName);
            data = new WasteCompositionViewModel(notification.WasteType, new WasteCompositionFormatter());

            //Set annex merge fields
            AnnexMergeFields = MergeFieldLocator.GetAnnexMergeFields(mergeFields, TypeName);
            ((List<MergeField>)AnnexMergeFields).AddRange(MergeFieldLocator.GetAnnexMergeFields(mergeFields, Parameters));
            ((List<MergeField>)AnnexMergeFields).AddRange(MergeFieldLocator.GetAnnexMergeFields(mergeFields, Constituents));
        }
Exemplo n.º 40
0
        private async Task CheckCompetentAuthority(NotificationApplication notification)
        {
            var userCompetentAuthority = await context.GetUsersCompetentAuthority(userContext);

            if (notification.CompetentAuthority != userCompetentAuthority)
            {
                throw new SecurityException(string.Format("Access denied to this notification {0} for user {1} for competent authority {2}",
                                                          notification.Id, userContext.UserId, userCompetentAuthority));
            }
        }
Exemplo n.º 41
0
        public WasteCompositionBlock(IList <MergeField> mergeFields, NotificationApplication notification)
        {
            CorrespondingMergeFields = MergeFieldLocator.GetCorrespondingFieldsForBlock(mergeFields, TypeName);
            data = new WasteCompositionViewModel(notification.WasteType, new WasteCompositionFormatter());

            //Set annex merge fields
            AnnexMergeFields = MergeFieldLocator.GetAnnexMergeFields(mergeFields, TypeName);
            ((List <MergeField>)AnnexMergeFields).AddRange(MergeFieldLocator.GetAnnexMergeFields(mergeFields, Parameters));
            ((List <MergeField>)AnnexMergeFields).AddRange(MergeFieldLocator.GetAnnexMergeFields(mergeFields, Constituents));
        }
        public async Task ReturnsCorrectFormat(UKCompetentAuthority competentAuthority, int notificationNumber, int movementNumber, string expected)
        {
            var notification = new NotificationApplication(notificationId, NotificationType.Recovery, competentAuthority, notificationNumber);
            A.CallTo(() => notificationApplicationRepository.GetById(notificationId)).Returns(notification);

            var movement = new Movement(movementNumber, notificationId, AnyDate, userId);
            var name = await certificateOfReceiptName.GetValue(movement);

            Assert.Equal(expected, name);
        }
        private async Task<WasteRecovery> CreateWasteRecovery(NotificationApplication notification)
        {
            var estimatedValue = new EstimatedValue(ValuePerWeightUnits.Kilogram, 10);
            var recoveryCost = new RecoveryCost(ValuePerWeightUnits.Tonne, 50);

            var wasteRecovery = new WasteRecovery(notification.Id, new Percentage(50), estimatedValue, recoveryCost);

            context.WasteRecoveries.Add(wasteRecovery);
            await context.SaveChangesAsync();
            return wasteRecovery;
        }
Exemplo n.º 44
0
        public async Task ReturnsCorrectFormat(UKCompetentAuthority competentAuthority, int notificationNumber, int movementNumber, string expected)
        {
            var notification = new NotificationApplication(notificationId, NotificationType.Recovery, competentAuthority, notificationNumber);

            A.CallTo(() => notificationApplicationRepository.GetById(notificationId)).Returns(notification);

            var movement = new Movement(movementNumber, notificationId, AnyDate, userId);
            var name     = await certificateOfReceiptName.GetValue(movement);

            Assert.Equal(expected, name);
        }
Exemplo n.º 45
0
 private void ClearOldCodes(SetBaselOecdCodeForNotification message, NotificationApplication notification)
 {
     if (message.CodeType == CodeType.Basel)
     {
         notification.RemoveCodeOfType(CodeType.Oecd);
     }
     else if (message.CodeType == CodeType.Oecd)
     {
         notification.RemoveCodeOfType(CodeType.Basel);
     }
 }
Exemplo n.º 46
0
        internal void MergeDataIntoDocument(IList<MergeField> mergeFields, NotificationApplication notification)
        {
            foreach (var mergeField in mergeFields)
            {
                mergeField.RemoveCurrentContents();

                string value = notificationMergeMapper.GetValueForMergeField(mergeField, notification);

                mergeField.SetText(value);
            }
        }
Exemplo n.º 47
0
        public GeneralBlock(IList <MergeField> mergeFields, NotificationApplication notification, ShipmentInfo shipmentInfo, FacilityCollection facilityCollection)
        {
            CorrespondingMergeFields = MergeFieldLocator.GetCorrespondingFieldsForBlock(mergeFields, "General");

            data = new GeneralViewModel(notification,
                                        shipmentInfo,
                                        facilityCollection,
                                        new DateTimeFormatter(),
                                        new QuantityFormatter(),
                                        new PhysicalCharacteristicsFormatter());
        }
Exemplo n.º 48
0
        public GeneralBlock(IList<MergeField> mergeFields, NotificationApplication notification, ShipmentInfo shipmentInfo, FacilityCollection facilityCollection)
        {
            CorrespondingMergeFields = MergeFieldLocator.GetCorrespondingFieldsForBlock(mergeFields, "General");

            data = new GeneralViewModel(notification, 
                shipmentInfo,
                facilityCollection,
                new DateTimeFormatter(), 
                new QuantityFormatter(),
                new PhysicalCharacteristicsFormatter());
        }
Exemplo n.º 49
0
        public NotificationFacilityTests()
        {
            notification = new NotificationApplication(Guid.NewGuid(), NotificationType.Recovery,
                                                       UKCompetentAuthority.England, 0);

            facilityCollection = new FacilityCollection(notification.Id);

            facility1 = facilityCollection.AddFacility(ObjectFactory.CreateEmptyBusiness(),
                                                       ObjectFactory.CreateDefaultAddress(), ObjectFactory.CreateEmptyContact());
            facility2 = facilityCollection.AddFacility(ObjectFactory.CreateEmptyBusiness(),
                                                       ObjectFactory.CreateDefaultAddress(), ObjectFactory.CreateEmptyContact());
        }
        public NotificationFacilityTests()
        {
            notification = new NotificationApplication(Guid.NewGuid(), NotificationType.Recovery,
                           UKCompetentAuthority.England, 0);

            facilityCollection = new FacilityCollection(notification.Id);

            facility1 = facilityCollection.AddFacility(ObjectFactory.CreateEmptyBusiness(),
                        ObjectFactory.CreateDefaultAddress(), ObjectFactory.CreateEmptyContact());
            facility2 = facilityCollection.AddFacility(ObjectFactory.CreateEmptyBusiness(),
                        ObjectFactory.CreateDefaultAddress(), ObjectFactory.CreateEmptyContact());
        }
Exemplo n.º 51
0
        public MovementTests()
        {
            var notification = new NotificationApplication(
                Guid.NewGuid(),
                NotificationType.Recovery,
                UKCompetentAuthority.England,
                0);

            movement = new Movement(1, notification.Id, AnyDate, userId);

            SystemTime.Freeze(FrozenTime);
        }
Exemplo n.º 52
0
        public MovementTests()
        {
            var notification = new NotificationApplication(
                Guid.NewGuid(),
                NotificationType.Recovery,
                UKCompetentAuthority.England,
                0);

            movement = new Movement(1, notification.Id, AnyDate, userId);

            SystemTime.Freeze(FrozenTime);
        }
Exemplo n.º 53
0
        private async Task <WasteRecovery> CreateWasteRecovery(NotificationApplication notification)
        {
            var estimatedValue = new EstimatedValue(ValuePerWeightUnits.Kilogram, 10);
            var recoveryCost   = new RecoveryCost(ValuePerWeightUnits.Tonne, 50);

            var wasteRecovery = new WasteRecovery(notification.Id, new Percentage(50), estimatedValue, recoveryCost);

            context.WasteRecoveries.Add(wasteRecovery);
            await context.SaveChangesAsync();

            return(wasteRecovery);
        }
        public virtual void CopyNotificationProperties(NotificationApplication source,
            NotificationApplication destination)
        {
            // We want to set all properties except a few decided by business logic.
            typeof(NotificationApplication).GetProperty("NotificationNumber")
                .SetValue(source, destination.NotificationNumber, null);
            typeof(NotificationApplication).GetProperty("CompetentAuthority")
                .SetValue(source, destination.CompetentAuthority, null);
            typeof(NotificationApplication).GetProperty("NotificationType")
                .SetValue(source, destination.NotificationType, null);

            // This should not be needed however is a precaution to prevent overwriting the source data.
            typeof(Entity).GetProperty("Id").SetValue(source, Guid.Empty, null);
        }
        public virtual void CopyNotificationProperties(NotificationApplication source,
                                                       NotificationApplication destination)
        {
            // We want to set all properties except a few decided by business logic.
            typeof(NotificationApplication).GetProperty("NotificationNumber")
            .SetValue(source, destination.NotificationNumber, null);
            typeof(NotificationApplication).GetProperty("CompetentAuthority")
            .SetValue(source, destination.CompetentAuthority, null);
            typeof(NotificationApplication).GetProperty("NotificationType")
            .SetValue(source, destination.NotificationType, null);

            // This should not be needed however is a precaution to prevent overwriting the source data.
            typeof(Entity).GetProperty("Id").SetValue(source, Guid.Empty, null);
        }
        public void CantAddRecoveryCodesToDisposalNotification()
        {
            var notification = new NotificationApplication(Guid.NewGuid(), NotificationType.Disposal,
                                                           UKCompetentAuthority.England, 0);

            var codes = new List <OperationCode>
            {
                OperationCode.R1,
                OperationCode.R2
            };

            Action updateCodes = () => notification.SetOperationCodes(codes);

            Assert.Throws <InvalidOperationException>(updateCodes);
        }
Exemplo n.º 57
0
        public ProducerBlock(IList<MergeField> mergeFields, NotificationApplication notification, ProducerCollection producerCollection)
        {
            CorrespondingMergeFields = MergeFieldLocator.GetCorrespondingFieldsForBlock(mergeFields, TypeName);

            var numberOfProducers = producerCollection.Producers.Count();
            var processText = notification.WasteGenerationProcess;
            var isProcessAnnexAttached = notification.IsWasteGenerationProcessAttached;

            data = producerCollection.Producers.Select(p => new ProducerViewModel(p, numberOfProducers, processText, isProcessAnnexAttached)).ToList();

            // The producers annex contains a set of different merge fields for producer marked as Site of Export.
            AnnexMergeFields = MergeFieldLocator.GetAnnexMergeFields(mergeFields, TypeName);
            ((List<MergeField>)AnnexMergeFields).AddRange(MergeFieldLocator.GetAnnexMergeFields(mergeFields, SiteOfExport));
            ((List<MergeField>)AnnexMergeFields).AddRange(MergeFieldLocator.GetAnnexMergeFields(mergeFields, PoGtext));
        }
        public void CantAddRecoveryCodesToDisposalNotification()
        {
            var notification = new NotificationApplication(Guid.NewGuid(), NotificationType.Disposal,
                UKCompetentAuthority.England, 0);

            var codes = new List<OperationCode>
            {
                OperationCode.R1,
                OperationCode.R2
            };

            Action updateCodes = () => notification.SetOperationCodes(codes);

            Assert.Throws<InvalidOperationException>(updateCodes);
        }
Exemplo n.º 59
0
        public void CopyWasteCodes(NotificationApplication source, NotificationApplication destination)
        {
            var clone = new NotificationApplicationClone(source, destination);

            CopyBaselOecdCode(clone);
            CopyCustomsCode(clone);
            CopyExportCode(clone);
            CopyImportCode(clone);
            CopyOtherCode(clone);

            CopyEwcCodes(clone);
            CopyUnClasses(clone);
            CopyUnNumbers(clone);
            CopyYCodes(clone);
            CopyHCodes(clone);
        }