예제 #1
0
        public void Deal_Quota_Deletion_Must_Be_Ok()
        {
            var deal = new Deal("Тестовая сделка", user)
            {
                Id = 1
            };
            var quota1 = new DealQuota("Тестовая квота 1", 10)
            {
                Id = 2
            };
            var quota2 = new DealQuota("Тестовая квота 2", 99)
            {
                Id = 3
            };

            deal.AddQuota(quota1);
            deal.AddQuota(quota2);

            Assert.AreEqual(2, deal.QuotaCount);

            deal.RemoveQuota(quota2, true);

            Assert.AreEqual(1, deal.QuotaCount);
            Assert.AreEqual(null, quota2.DeletionDate);
        }
예제 #2
0
        public void Init()
        {
            // инициализация IoC
            IoCInitializer.Init();

            dealRepository = Mock.Get(IoCContainer.Resolve <IDealRepository>());
            clientContractIndicatorService = Mock.Get(IoCContainer.Resolve <IClientContractIndicatorService>());
            dealIndicatorService           = Mock.Get(IoCContainer.Resolve <IDealIndicatorService>());

            blockingService = new BlockingService(dealRepository.Object, dealIndicatorService.Object, clientContractIndicatorService.Object);

            var employee = new Employee("Иван", "Рюрикович", "Васильевич", new EmployeePost("Царь"), null);

            user = new User(employee, "И.В. Грозный", "ivanvas", "ivanvas", new Team("Тестовая команда", null), null);

            var clientType           = new ClientType("Тестовый тип клиента");
            var region               = new ClientRegion("Дубовка");
            var clientServiceProgram = new ClientServiceProgram("Программа удовлетворения клиента");

            clientOk = new Client("Клиент без блокировки", clientType, ClientLoyalty.Follower, clientServiceProgram, region, 5);
            clientWithManualBlocking = new Client("Клиент с ручной блокировкой", clientType, ClientLoyalty.Follower, clientServiceProgram, region, 5);
            clientWithManualBlocking.Block(user);
            clientWithPaymentDelayBlocking = new Client("Клиент с блокировкой по просрочке платежа", clientType, ClientLoyalty.Follower, clientServiceProgram, region, 5);
            clientWithCreditLimitBlocking  = new Client("Клиент с блокировкой по кредитному лимиту", clientType, ClientLoyalty.Follower, clientServiceProgram, region, 5);

            dealWithPrePayment = new Deal("Сделка с предоплатой", user);
            dealWithPrePayment.AddQuota(new DealQuota("Quota 1 с предоплатой", 7));
            dealWithPostPayment14d20k = new Deal("Сделка с отсрочкой платежа 14 дн 20k", user);
            dealWithPostPayment14d20k.AddQuota(new DealQuota("Quota 2 с отсрочкой платежа 14 дн 20k", 8, 14, 20000.0M));
            dealWithPostPayment7d40k = new Deal("Сделка с отсрочкой платежа 7 дн 40k", user);
            dealWithPostPayment7d40k.AddQuota(new DealQuota("Quota 3 с отсрочкой платежа 7 дн 40k", 8, 7, 40000.0M));
            dealWithPostPayment10d30k = new Deal("Сделка с отсрочкой платежа 10 дн 30k", user);
            dealWithPostPayment10d30k.AddQuota(new DealQuota("Quota 4 с отсрочкой платежа 10 дн 30k", 8, 10, 30000.0M));
        }
        public void Init()
        {
            storage = new Storage("Тестовое место хранения", StorageType.DistributionCenter)
            {
                Id = 1
            };
            user                = new User(new Employee("Иван", "Иванов", "Иванович", new EmployeePost("Менеджер"), null), "Иванов Иван", "ivanov", "pa$$w0rd", new Team("Тестовая команда", null), null);
            economicAgent       = new PhysicalPerson(new LegalForm("Легал форм", EconomicAgentType.PhysicalPerson));
            accountOrganization = new AccountOrganization("Орг1 кор имя", "орг1 длин имя", economicAgent)
            {
                Id = 1
            };
            clientOrganization = new ClientOrganization("client org", "cllll", economicAgent)
            {
                Id = 3
            };
            storage.AddAccountOrganization(accountOrganization);
            deal = new Deal("Тестовая сделка", user)
            {
                Id = 2
            };
            client        = new Client("клиент1", new ClientType("основной тип клиента"), ClientLoyalty.Follower, new ClientServiceProgram("программа 1"), new ClientRegion("Регион 1"), 10);
            deal.Contract = new ClientContract(accountOrganization, clientOrganization, "Договор 1", "1", DateTime.Now, DateTime.Now);
            client.AddDeal(deal);
            quota = new DealQuota("Тестовая квота", 20, 14, 20000.0M)
            {
                Id = 3
            };
            deal.AddQuota(quota);
            team = new Mock <Team>();

            expenditureWaybill = new ExpenditureWaybill("123", DateTime.Today, storage, deal, team.Object, quota, false, user, DeliveryAddressType.ClientAddress, "", DateTime.Today, user);
        }
예제 #4
0
        public void AddQuotas(Deal deal, IEnumerable <DealQuota> dealQuotas, User user)
        {
            CheckPossibilityToAddQuota(deal, user);

            foreach (var quota in dealQuotas.Except(deal.Quotas))
            {
                deal.AddQuota(quota);
            }
        }
예제 #5
0
        public void Deal_Quota_Addition_Must_Be_Ok()
        {
            var deal = new Deal("Тестовая сделка", user)
            {
                Id = 1
            };
            var quota = new DealQuota("Тестовая квота", 10)
            {
                Id = 2
            };

            deal.AddQuota(quota);

            Assert.AreEqual(1, deal.QuotaCount);
            Assert.AreEqual(2, deal.Quotas.ElementAt(0).Id);
            Assert.AreEqual(1, deal.Id);
            Assert.AreEqual(DateTime.Today, quota.StartDate.Date);
        }
예제 #6
0
        public void AddQuota(Deal deal, DealQuota dealQuota, User user)
        {
            CheckPossibilityToAddQuota(deal, user);

            deal.AddQuota(dealQuota);
        }
        public void Init()
        {
            employee1           = new Employee("Работник 1 имя", "Работник 1 фамилия", "Работник 1 отчество", new EmployeePost("Работник 1 пост"), null);
            curator             = new User(employee1, "Куратор", "log", "pas", new Team("Тестовая команда", null), null);
            team                = new Team("123", curator);
            economicAgent       = new PhysicalPerson(new LegalForm("Легал форм", EconomicAgentType.PhysicalPerson));
            accountOrganization = new AccountOrganization("Орг1 кор имя", "орг1 длин имя", economicAgent)
            {
                Id = 1
            };
            accountOrganizationAnother = new AccountOrganization("Орг2 кор имя", "орг2 длин имя", economicAgent)
            {
                Id = 2
            };
            clientOrganization = new ClientOrganization("client org", "cllll", economicAgent)
            {
                Id = 3
            };
            client = new Client("клиент1", new ClientType("основной тип клиента"), ClientLoyalty.Follower, new ClientServiceProgram("программа 1"), new ClientRegion("Регион 1"), 10);
            deal   = new Deal("Тестовая сделка", curator);
            client.AddDeal(deal);
            storage = new Storage("Склад 1", StorageType.ExtraStorage);
            storage.AddAccountOrganization(accountOrganization);
            storage.AddAccountOrganization(accountOrganizationAnother);
            storage2 = new Storage("Склад 2", StorageType.ExtraStorage);
            returnFromClientReason  = new ReturnFromClientReason("Брак");
            returnFromClientWaybill = new ReturnFromClientWaybill("142", DateTime.Today, accountOrganization, deal, team, storage, returnFromClientReason, curator, curator, DateTime.Now);
            valueAddedTax           = new ValueAddedTax("18%", 18);
            ag     = new ArticleGroup("Группа товаров", "Группа товаров");
            art1   = new Article("Товар 1", ag, new MeasureUnit("шт.", "штуки", "123", 1), false);
            art2   = new Article("Товар 2", ag, new MeasureUnit("шт.", "штуки", "123", 1), false);
            art3   = new Article("Товар 3", ag, new MeasureUnit("шт.", "штуки", "123", 1), false);
            Prices = new List <ArticleAccountingPrice>();
            Prices.Add(new ArticleAccountingPrice(art1, 10M));
            Prices.Add(new ArticleAccountingPrice(art2, 13M));
            Prices.Add(new ArticleAccountingPrice(art3, 15M));

            deal1  = new Deal("Deal1", curator);
            deal2  = new Deal("Deal2", curator);
            quota1 = new DealQuota("qq", 1);
            quota2 = new DealQuota("qq", 2);

            deal1.AddQuota(quota1);
            deal2.AddQuota(quota2);
            deal1.Contract = new ClientContract(accountOrganization, clientOrganization, "Договор", "1", DateTime.Now, DateTime.Now);
            deal2.Contract = new ClientContract(accountOrganizationAnother, clientOrganization, "kk", "22", DateTime.Today, DateTime.Now);

            recRow1 = new ReceiptWaybillRow(art1, 5, 50, new ValueAddedTax("18%", 18))
            {
                Id = Guid.NewGuid()
            };
            recRow1_1 = new ReceiptWaybillRow(art1, 2, 30, new ValueAddedTax("18%", 18))
            {
                Id = Guid.NewGuid()
            };
            recRow2 = new ReceiptWaybillRow(art2, 7, 35, new ValueAddedTax("18%", 18))
            {
                Id = Guid.NewGuid()
            };
            recRow3 = new ReceiptWaybillRow(art3, 9, 90, new ValueAddedTax("18%", 18))
            {
                Id = Guid.NewGuid()
            };
            recRow1.PurchaseCost = 50 / 5;
            recRow1.PurchaseCost = 35 / 7;
            recRow1.PurchaseCost = 90 / 9;

            saleRow1 = new ExpenditureWaybillRow(recRow1, 3, valueAddedTax)
            {
                Id = Guid.NewGuid()
            };
            saleRow1_1 = new ExpenditureWaybillRow(recRow1_1, 1, valueAddedTax)
            {
                Id = Guid.NewGuid()
            };
            saleRow2 = new ExpenditureWaybillRow(recRow2, 4, valueAddedTax)
            {
                Id = Guid.NewGuid()
            };
            saleRow3 = new ExpenditureWaybillRow(recRow3, 5, valueAddedTax)
            {
                Id = Guid.NewGuid()
            };

            saleRowAnother1 = new ExpenditureWaybillRow(recRow1, 3, valueAddedTax)
            {
                Id = Guid.NewGuid()
            };
            saleRowAnother2 = new ExpenditureWaybillRow(recRow2, 4, valueAddedTax)
            {
                Id = Guid.NewGuid()
            };
            saleRowAnother3 = new ExpenditureWaybillRow(recRow3, 5, valueAddedTax)
            {
                Id = Guid.NewGuid()
            };

            sale = new ExpenditureWaybill("1", DateTime.Today, storage, deal1, team, quota1, true, curator, DeliveryAddressType.ClientAddress, "", DateTime.Now, curator)
            {
                Id = Guid.NewGuid()
            };
            saleAnother = new ExpenditureWaybill("1", DateTime.Today, storage, deal2, team, quota2, true, curator, DeliveryAddressType.ClientAddress, "", DateTime.Now, curator)
            {
                Id = Guid.NewGuid()
            };

            sale.As <ExpenditureWaybill>().AddRow((ExpenditureWaybillRow)saleRow1);
            sale.As <ExpenditureWaybill>().AddRow((ExpenditureWaybillRow)saleRow2);
            sale.As <ExpenditureWaybill>().AddRow((ExpenditureWaybillRow)saleRow3);
            saleAnother.As <ExpenditureWaybill>().AddRow((ExpenditureWaybillRow)saleRowAnother1);
            saleAnother.As <ExpenditureWaybill>().AddRow((ExpenditureWaybillRow)saleRowAnother2);
            saleAnother.As <ExpenditureWaybill>().AddRow((ExpenditureWaybillRow)saleRowAnother3);

            sale.As <ExpenditureWaybill>().Accept(Prices, false, curator, DateTime.Now);

            saleAnother.As <ExpenditureWaybill>().Accept(Prices, false, curator, DateTime.Now);
        }