Ejemplo n.º 1
0
        public void AddManufacturer(Producer producer, Manufacturer manufacturer, User user)
        {
            CheckPossibilityToAddManufacturer(producer, manufacturer, user);

            producer.AddManufacturer(manufacturer);
            producerRepository.Save(producer);
        }
        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;
        }