Пример #1
0
        public void PermissionDistributions_With_Direct_Relation_And_Less_Child_Value_Must_Be_Ok()
        {
            role.AddPermissionDistribution(new PermissionDistribution(Permission.Storage_List_Details, PermissionDistributionType.All));
            role.AddPermissionDistribution(new PermissionDistribution(Permission.ReceiptWaybill_List_Details, PermissionDistributionType.Teams));
            role.AddPermissionDistribution(new PermissionDistribution(Permission.ReceiptWaybill_Create_Edit, PermissionDistributionType.Personal));

            service.CheckPermissionDistributionValues(role);

            Assert.AreEqual(3, role.PermissionDistributions.Count());
        }
Пример #2
0
        public void Init()
        {
            IoCInitializer.Init();

            var taskRepository = IoCContainer.Resolve <ITaskRepository>();
            var taskExecutionItemRepository = IoCContainer.Resolve <ITaskExecutionItemRepository>();

            taskService = new TaskService(taskRepository, taskExecutionItemRepository);

            topic           = "123";
            deal            = new Mock <Deal>();
            contractor      = new Mock <Contractor>();
            productionOrder = new Mock <ProductionOrder>();
            taskType        = new TaskType("Type_1");
            state           = new TaskExecutionState("State_1", TaskExecutionStateType.New, 1);
            taskType.AddState(state);
            taskPriority = new TaskPriority("Priority_1", 1);
            currentDate  = DateTime.Now;

            user = new User(new Employee("Иван", "Иванов", "Иванович", new EmployeePost("Менеджер"), null), "Иванов Иван", "ivanov", "pa$$w0rd", new Team("Тестовая команда", null), null);
            var role = new Role("Администратор");

            role.AddPermissionDistribution(new PermissionDistribution(Permission.Task_Create, PermissionDistributionType.All));
            user.AddRole(role);
        }
        public void Init()
        {
            // инициализация IoC
            IoCInitializer.Init();

            storageRepository              = Mock.Get(IoCContainer.Resolve <IStorageRepository>());
            accountingPriceListRepository  = Mock.Get(IoCContainer.Resolve <IAccountingPriceListRepository>());
            articleAvailabilityService     = Mock.Get(IoCContainer.Resolve <IArticleAvailabilityService>());
            articlePriceService            = Mock.Get(IoCContainer.Resolve <IArticlePriceService>());
            accountingPriceCalcRuleService = Mock.Get(IoCContainer.Resolve <IAccountingPriceCalcRuleService>());
            accountingPriceCalcRule        = new Mock <AccountingPriceCalcRule>();
            lastDigitCalcRule              = new Mock <LastDigitCalcRule>();

            accountingPriceCalcService = new AccountingPriceCalcService();

            articleGroup = new ArticleGroup("Бытовая техника", "Бытовая техника");
            articleGroup.MarkupPercent = 25;
            measureUnit = new MeasureUnit("шт.", "Штука", "123", 0)
            {
                Id = 1
            };

            article = new Article("Пылесос", articleGroup, measureUnit, false)
            {
                Id = 101
            };

            priceLists = new List <ArticleAccountingPrice>()
            {
                new ArticleAccountingPrice(article, 100)
            };

            storageA = new Storage("А", StorageType.TradePoint)
            {
                Id = 1
            };
            storageB = new Storage("Б", StorageType.DistributionCenter)
            {
                Id = 2
            };
            storageC = new Storage("В", StorageType.DistributionCenter)
            {
                Id = 3
            };
            storageA1 = new Storage("А1", StorageType.TradePoint)
            {
                Id = 4
            };
            storageB1 = new Storage("Б1", StorageType.DistributionCenter)
            {
                Id = 5
            };
            storageC1 = new Storage("В1", StorageType.DistributionCenter)
            {
                Id = 6
            };

            storageList = new List <Storage> {
                storageA, storageB, storageC, storageA1, storageB1, storageC1
            };

            storageRepository.Setup(x => x.GetAll()).Returns(storageList);
            storageRepository.Setup(x => x.GetStoragesByType(It.IsAny <StorageType>())).Returns <StorageType>(x => storageList.Where(s => s.Type == x).ToList());

            valueAddedTax = new ValueAddedTax("10%", 10);

            user = new User(new Employee("Иван", "Иванов", "Иванович", new EmployeePost("Менеджер"), null), "Иванов Иван", "ivanov", "pa$$w0rd", new Team("Тестовая команда", null), null);
            var role = new Role("Администратор");

            role.AddPermissionDistribution(new PermissionDistribution(Permission.PurchaseCost_View_ForEverywhere, PermissionDistributionType.All));
            role.AddPermissionDistribution(new PermissionDistribution(Permission.AccountingPrice_NotCommandStorage_View, PermissionDistributionType.All));
            user.AddRole(role);
        }
Пример #4
0
        public void Init()
        {
            // инициализация IoC
            IoCInitializer.Init();

            receiptWaybillRepository = Mock.Get(IoCContainer.Resolve <IReceiptWaybillRepository>());

            receiptWaybillService = new ReceiptWaybillService(IoCContainer.Resolve <IArticleRepository>(),
                                                              receiptWaybillRepository.Object,
                                                              IoCContainer.Resolve <IMovementWaybillRepository>(), IoCContainer.Resolve <IExpenditureWaybillRepository>(),
                                                              IoCContainer.Resolve <IStorageRepository>(), IoCContainer.Resolve <IUserRepository>(),
                                                              IoCContainer.Resolve <IChangeOwnerWaybillRepository>(), IoCContainer.Resolve <IWriteoffWaybillRepository>(),
                                                              IoCContainer.Resolve <IStorageService>(),
                                                              IoCContainer.Resolve <IAccountOrganizationService>(),
                                                              IoCContainer.Resolve <IProviderService>(),
                                                              IoCContainer.Resolve <IProviderContractService>(),
                                                              IoCContainer.Resolve <IValueAddedTaxService>(),
                                                              IoCContainer.Resolve <IArticleMovementService>(),
                                                              IoCContainer.Resolve <IArticlePriceService>(),
                                                              IoCContainer.Resolve <IExactArticleAvailabilityIndicatorService>(),
                                                              IoCContainer.Resolve <IIncomingAcceptedArticleAvailabilityIndicatorService>(),
                                                              IoCContainer.Resolve <IArticleAccountingPriceIndicatorService>(),
                                                              IoCContainer.Resolve <IArticleMovementOperationCountService>(),
                                                              IoCContainer.Resolve <IOutgoingAcceptedFromExactArticleAvailabilityIndicatorService>(),
                                                              IoCContainer.Resolve <IOutgoingAcceptedFromIncomingAcceptedArticleAvailabilityIndicatorService>(),
                                                              IoCContainer.Resolve <IArticleMovementFactualFinancialIndicatorService>(),
                                                              IoCContainer.Resolve <IFactualFinancialArticleMovementService>(),
                                                              IoCContainer.Resolve <IAcceptedSaleIndicatorService>(),
                                                              IoCContainer.Resolve <IShippedSaleIndicatorService>(),
                                                              IoCContainer.Resolve <IReceiptedReturnFromClientIndicatorService>(),
                                                              IoCContainer.Resolve <IAcceptedReturnFromClientIndicatorService>(),
                                                              IoCContainer.Resolve <IReturnFromClientBySaleAcceptanceDateIndicatorService>(),
                                                              IoCContainer.Resolve <IReturnFromClientBySaleShippingDateIndicatorService>(),
                                                              IoCContainer.Resolve <IArticleRevaluationService>(),
                                                              IoCContainer.Resolve <IArticlePurchaseService>(),
                                                              IoCContainer.Resolve <IAcceptedPurchaseIndicatorService>(),
                                                              IoCContainer.Resolve <IApprovedPurchaseIndicatorService>(),
                                                              IoCContainer.Resolve <IArticleAvailabilityService>()
                                                              );

            var juridicalLegalForm = new LegalForm("ООО", EconomicAgentType.JuridicalPerson);
            var providerType       = new ProviderType("Тестовый тип поставщика");
            var articleGroup       = new ArticleGroup("Бытовая техника", "Бытовая техника");
            var measureUnit        = new MeasureUnit("шт", "штука", "123", 0);
            var article            = new Article("Пылесос", articleGroup, measureUnit, true)
            {
                Id = 1
            };

            priceLists = new List <ArticleAccountingPrice>()
            {
                new ArticleAccountingPrice(article, 100M)
            };

            var provider = new Provider("Нейтральная организация", providerType, ProviderReliability.Medium, 5);

            var providerOrganization = new ProviderOrganization("Тестовое физическое лицо", "Тестовое физическое лицо", new JuridicalPerson(juridicalLegalForm))
            {
                Id = 1
            };
            var accountOrganization = new AccountOrganization(@"ООО ""Юридическое лицо""", @"ООО ""Юридическое лицо""", new JuridicalPerson(juridicalLegalForm))
            {
                Id = 2
            };

            provider.AddContractorOrganization(providerOrganization);

            var providerContract = new ProviderContract(accountOrganization, providerOrganization, "ABC", "123", DateTime.Now, DateTime.Today);

            provider.AddProviderContract(providerContract);

            role = new Role("Администратор");
            role.AddPermissionDistribution(new PermissionDistribution(Permission.ReceiptWaybill_Delete_Row_Delete, PermissionDistributionType.All));
            user = new User(new Employee("Иван", "Иванов", "Иванович", new EmployeePost("Менеджер"), null), "Иванов Иван", "ivanov", "pa$$w0rd", new Team("Тестовая команда", null), null);
            user.AddRole(role);
            createdBy = new User(new Employee("Олег", "Олегов", "Олегович", new EmployeePost("Менеджер"), null), "Олегов Олег", "olegov", "pa$$w0rd", new Team("Тестовая команда", null), null);
            createdBy.AddRole(role);
            acceptedBy = new User(new Employee("Петр", "Петров", "Петрович", new EmployeePost("Менеджер"), null), "Петров Петр", "petrov", "pa$$w0rd", new Team("Тестовая команда", null), null);
            acceptedBy.AddRole(role);
            receiptedBy = new User(new Employee("Николай", "Николаев", "Николаевия", new EmployeePost("Менеджер"), null), "Николаев Николай", "nikolaev", "pa$$w0rd", new Team("Тестовая команда", null), null);
            receiptedBy.AddRole(role);

            var customDeclarationNumber = new String('0', 25);

            receiptWaybill    = new ReceiptWaybill("999999", DateTime.Today, new Storage("Третий склад", StorageType.DistributionCenter), accountOrganization, provider, 50, 0M, new ValueAddedTax("10%", 10), providerContract, customDeclarationNumber, user, createdBy, DateTime.Now);
            receiptWaybillRow = new ReceiptWaybillRow(article, 5, 50M, receiptWaybill.PendingValueAddedTax);

            receiptWaybill.AddRow(receiptWaybillRow);

            receiptWaybillList = new List <ReceiptWaybill> {
                receiptWaybill
            };

            receiptWaybillRepository.Setup(x => x.Delete(It.IsAny <ReceiptWaybill>())).Callback <ReceiptWaybill>(waybill => receiptWaybillList.Remove(waybill));
        }
        public void Init()
        {
            receiptWaybillRepository              = Mock.Get(IoCContainer.Resolve <IReceiptWaybillRepository>());
            productionOrderRepository             = Mock.Get(IoCContainer.Resolve <IProductionOrderRepository>());
            productionOrderBatchRepository        = Mock.Get(IoCContainer.Resolve <IProductionOrderBatchRepository>());
            defaultProductionOrderStageRepository = Mock.Get(IoCContainer.Resolve <IDefaultProductionOrderStageRepository>());
            taskRepository = Mock.Get(IoCContainer.Resolve <ITaskRepository>());

            articleAccountingPriceIndicatorService = Mock.Get(IoCContainer.Resolve <IArticleAccountingPriceIndicatorService>());

            productionOrderService_accessor = new Mock <ProductionOrderService_Accessor>(productionOrderRepository.Object, productionOrderBatchRepository.Object,
                                                                                         receiptWaybillRepository.Object, taskRepository.Object, defaultProductionOrderStageRepository.Object);
            productionOrderService = new Mock <ProductionOrderService>(productionOrderRepository.Object, productionOrderBatchRepository.Object,
                                                                       receiptWaybillRepository.Object, taskRepository.Object, defaultProductionOrderStageRepository.Object);

            var juridicalLegalForm = new LegalForm("ООО", EconomicAgentType.JuridicalPerson);
            var providerType       = new ProviderType("Тестовый тип поставщика");
            var articleGroup       = new ArticleGroup("Бытовая техника", "Бытовая техника");
            var measureUnit        = new MeasureUnit("шт", "штука", "123", 0);

            article1 = new Article("Пылесос", articleGroup, measureUnit, true)
            {
                Id = 1
            };
            article2 = new Article("Пылесос2", articleGroup, measureUnit, true)
            {
                Id = 2
            };
            article3 = new Article("Пылесос3", articleGroup, measureUnit, true)
            {
                Id = 3
            };

            priceLists = new List <ArticleAccountingPrice>()
            {
                new ArticleAccountingPrice(article1, 100M),
                new ArticleAccountingPrice(article2, 150M),
                new ArticleAccountingPrice(article3, 200M)
            };

            var provider = new Provider("Нейтральная организация", providerType, ProviderReliability.Medium, 5);

            var providerOrganization = new ProviderOrganization("Тестовое физическое лицо", "Тестовое физическое лицо", new JuridicalPerson(juridicalLegalForm))
            {
                Id = 1
            };
            var accountOrganization = new AccountOrganization(@"ООО ""Юридическое лицо""", @"ООО ""Юридическое лицо""", new JuridicalPerson(juridicalLegalForm))
            {
                Id = 2
            };

            provider.AddContractorOrganization(providerOrganization);

            var providerContract = new ProviderContract(accountOrganization, providerOrganization, "ABC", "123", DateTime.Now, DateTime.Today);

            provider.AddProviderContract(providerContract);

            role = new Role("Администратор");
            role.AddPermissionDistribution(new PermissionDistribution(Permission.ReceiptWaybill_Delete_Row_Delete, PermissionDistributionType.All));
            user = new User(new Employee("Иван", "Иванов", "Иванович", new EmployeePost("Менеджер"), null), "Иванов Иван", "ivanov", "pa$$w0rd", new Team("Тестовая команда", null), null);
            user.AddRole(role);

            storage = new Storage("МХ", StorageType.TradePoint);
            storage.AddAccountOrganization(accountOrganization);

            producer = new Producer("producer", "organization", 5, user, false);
            var producerContract = new ProducerContract(accountOrganization, producer.Organization, "ABC", "123", DateTime.Now, DateTime.Today);

            currency = new Currency("755", "EUR", "Евро");

            var stage1 = new ProductionOrderBatchStage_Accessor("1", ProductionOrderBatchStageType.Calculation, 1, false)
            {
                IsDefault = true
            };
            var stage2 = new ProductionOrderBatchStage_Accessor("2", ProductionOrderBatchStageType.Closed, 0, false)
            {
                IsDefault = true
            };
            var stage3 = new ProductionOrderBatchStage_Accessor("3", ProductionOrderBatchStageType.Closed, 0, false)
            {
                IsDefault = true
            };
            var currentDateTime = DateTimeUtils.GetCurrentDateTime();

            productionOrder = new ProductionOrder("ЗАКАЗ", producer, currency,
                                                  (ProductionOrderBatchStage)stage1.Target,
                                                  (ProductionOrderBatchStage)stage2.Target,
                                                  (ProductionOrderBatchStage)stage3.Target,
                                                  ProductionOrderArticleTransportingPrimeCostCalculationType.Weight,
                                                  true, true, true, true, true, false, false,
                                                  user, currentDateTime)
            {
                Storage = storage
            };

            productionOrder.AddContract(producerContract);
            productionOrderBatch = productionOrder.Batches.FirstOrDefault();
            manufacturer         = new Manufacturer("Изготовитель");
            producer.AddManufacturer(manufacturer);
            productionOrderBatchRow1 = new ProductionOrderBatchRow(article1, currency, 5M, 10M, 1.0M, new Country("Страна1", "686"), manufacturer)
            {
                Id = Guid.NewGuid()
            };
            productionOrderBatchRow2 = new ProductionOrderBatchRow(article2, currency, 25M, 5M, 2.0M, new Country("Страна2", "686"), manufacturer)
            {
                Id = Guid.NewGuid()
            };
            productionOrderBatchRow3 = new ProductionOrderBatchRow(article3, currency, 100M, 2M, 1.5M, new Country("Страна3", "686"), manufacturer)
            {
                Id = Guid.NewGuid()
            };
            productionOrderBatch.AddRow(productionOrderBatchRow1);
            productionOrderBatch.AddRow(productionOrderBatchRow2);
            productionOrderBatch.AddRow(productionOrderBatchRow3);

            var customDeclarationNumber = new String('0', 25);

            receiptWaybill_accessor = new ReceiptWaybill_Accessor(productionOrderBatch, "999999", DateTime.Today, new ValueAddedTax("10%", 10), customDeclarationNumber, user, user, DateTime.Now);
            receiptWaybill          = (ReceiptWaybill)receiptWaybill_accessor.Target;

            receiptWaybillRow1 = new ReceiptWaybillRow(article1, 10M, 0M, receiptWaybill.PendingValueAddedTax)
            {
                Id = Guid.NewGuid()
            };
            receiptWaybill.AddRow(receiptWaybillRow1);
            productionOrderBatch.Rows.Where(x => x.Article == article1).FirstOrDefault().ReceiptWaybillRow = receiptWaybillRow1;

            receiptWaybillRow2 = new ReceiptWaybillRow(article2, 5M, 0M, receiptWaybill.PendingValueAddedTax)
            {
                Id = Guid.NewGuid()
            };
            receiptWaybill.AddRow(receiptWaybillRow2);
            productionOrderBatch.Rows.Where(x => x.Article == article2).FirstOrDefault().ReceiptWaybillRow = receiptWaybillRow2;

            receiptWaybillRow3 = new ReceiptWaybillRow(article3, 2M, 0M, receiptWaybill.PendingValueAddedTax)
            {
                Id = Guid.NewGuid()
            };
            receiptWaybill.AddRow(receiptWaybillRow3);
            productionOrderBatch.Rows.Where(x => x.Article == article3).FirstOrDefault().ReceiptWaybillRow = receiptWaybillRow3;

            receiptWaybillList = new List <ReceiptWaybill> {
                receiptWaybill
            };

            receiptWaybillRepository.Setup(x => x.Delete(It.IsAny <ReceiptWaybill>())).Callback <ReceiptWaybill>(waybill => receiptWaybillList.Remove(waybill));

            receiptWaybill.Accept(priceLists, user, DateTime.Now);

            receiptWaybillRow1.ReceiptedCount = receiptWaybillRow1.PendingCount;
            receiptWaybillRow1.ProviderCount  = receiptWaybillRow1.PendingCount;
            receiptWaybillRow1.ProviderSum    = 0M;

            receiptWaybillRow2.ReceiptedCount = receiptWaybillRow2.PendingCount;
            receiptWaybillRow2.ProviderCount  = receiptWaybillRow2.PendingCount;
            receiptWaybillRow2.ProviderSum    = 0M;

            receiptWaybillRow3.ReceiptedCount = receiptWaybillRow3.PendingCount;
            receiptWaybillRow3.ProviderCount  = receiptWaybillRow3.PendingCount;
            receiptWaybillRow3.ProviderSum    = 0M;
        }