Example #1
0
 /// <summary>
 /// Конструктор для создания приходной накладной, связанной с партией заказа
 /// </summary>
 /// <param name="productionOrderBatch">Партия заказа</param>
 /// <param name="number">Номер</param>
 /// <param name="date">Дата</param>
 /// <param name="pendingValueAddedTax">Ожидаемая НДС</param>
 /// <param name="curator">Куратор</param>
 public ReceiptWaybill(ProductionOrderBatch productionOrderBatch, string number, DateTime date, ValueAddedTax pendingValueAddedTax, string customsDeclarationNumber,
                       User curator, User createdBy, DateTime creationDate)
     : this(number, date, productionOrderBatch.ProductionOrder.Storage, productionOrderBatch.ProductionOrder.Contract.AccountOrganization, 0, 0, pendingValueAddedTax,
            customsDeclarationNumber, curator, createdBy, creationDate)
 {
     ValidationUtils.NotNull(productionOrderBatch, "Необходимо указать партию заказа.");
     ValidationUtils.Assert(productionOrderBatch.ReceiptWaybill == null, "Указанная партия заказа уже связана с приходной накладной.");
     ProductionOrderBatch = productionOrderBatch;
     ProductionOrderBatch.ReceiptWaybill = this;
 }
Example #2
0
        public ProductionOrder(string name, Producer producer, Currency currency, ProductionOrderBatchStage calculationStage, ProductionOrderBatchStage successfullClosingStage,
                               ProductionOrderBatchStage unsuccessfulClosingStage, ProductionOrderArticleTransportingPrimeCostCalculationType articleTransportingPrimeCostCalculationType,
                               bool mondayIsWorkDay, bool tuesdayIsWorkDay, bool wednesdayIsWorkDay, bool thursdayIsWorkDay, bool fridayIsWorkDay, bool saturdayIsWorkDay, bool sundayIsWorkDay,
                               User createdBy, DateTime currentDateTime)
        {
            ValidationUtils.Assert(!String.IsNullOrEmpty(name), "Название заказа не указано.");
            Name = name;

            ValidationUtils.NotNull(currency, "Валюта не указана.");
            this.currency     = currency;
            this.currencyRate = null;

            ValidationUtils.NotNull(producer, "Производитель не указан.");
            Producer = producer;

            CreationDate = currentDateTime;
            Date         = currentDateTime.Date;
            CreatedBy    = createdBy;
            Curator      = createdBy;
            ArticleTransportingPrimeCostCalculationType = articleTransportingPrimeCostCalculationType;
            Comment = "";

            batches             = new HashedSet <ProductionOrderBatch>();
            payments            = new HashedSet <ProductionOrderPayment>();
            plannedPayments     = new HashedSet <ProductionOrderPlannedPayment>();
            transportSheets     = new HashedSet <ProductionOrderTransportSheet>();
            extraExpensesSheets = new HashedSet <ProductionOrderExtraExpensesSheet>();
            customsDeclarations = new HashedSet <ProductionOrderCustomsDeclaration>();
            materialsPackages   = new HashedSet <ProductionOrderMaterialsPackage>();

            var batch = new ProductionOrderBatch(calculationStage, successfullClosingStage, unsuccessfulClosingStage, createdBy, currentDateTime);

            AddBatch(batch);

            IsClosed = false;

            MondayIsWorkDay    = mondayIsWorkDay;
            TuesdayIsWorkDay   = tuesdayIsWorkDay;
            WednesdayIsWorkDay = wednesdayIsWorkDay;
            ThursdayIsWorkDay  = thursdayIsWorkDay;
            FridayIsWorkDay    = fridayIsWorkDay;
            SaturdayIsWorkDay  = saturdayIsWorkDay;
            SundayIsWorkDay    = sundayIsWorkDay;
            CheckWorkDaysPlan();
        }
        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;
        }
 public void Delete(ProductionOrderBatch entity)
 {
     CurrentSession.Delete(entity);
 }
 public void Save(ProductionOrderBatch entity)
 {
     CurrentSession.SaveOrUpdate(entity);
 }
Example #6
0
 /// <summary>
 /// Удаление партии
 /// </summary>
 /// <param name="batch">Партия</param>
 /// <param name="currentDateTime">Текущее время</param>
 public virtual void DeleteBatch(ProductionOrderBatch batch, DateTime currentDateTime)
 {
     batch.DeletionDate = currentDateTime;
     batches.Remove(batch);
 }
Example #7
0
 /// <summary>
 /// Добавление партии
 /// </summary>
 /// <param name="batch">Партия</param>
 public virtual void AddBatch(ProductionOrderBatch batch)
 {
     batches.Add(batch);
     batch.ProductionOrder = this;
 }
Example #8
0
 public virtual void CheckPossibilityToDeleteBatch(ProductionOrderBatch batch)
 {
     ValidationUtils.Assert(!IsIncludingOneBatch, "Невозможно удалить последнюю партию в заказе.");
     ValidationUtils.IsNull(batch.ReceiptWaybill, "Невозможно удалить партию, по которой создана приходная накладная.");
 }