示例#1
0
        public void GetReferencedDocuments_WriteOffTest()
        {
            var interactive = Substitute.For <IInteractiveQuestion>();

            interactive.Question(string.Empty).ReturnsForAnyArgs(true);
            var baseParameters = Substitute.For <BaseParameters>();

            using (var uow = UnitOfWorkFactory.CreateWithoutRoot()) {
                var warehouse = new Warehouse();
                uow.Save(warehouse);

                var nomenclatureType = new ItemsType {
                    Name = "Тестовый тип номенклатуры"
                };
                uow.Save(nomenclatureType);

                var nomenclature = new Nomenclature {
                    Type = nomenclatureType
                };
                uow.Save(nomenclature);

                var employee = new EmployeeCard();
                uow.Save(employee);

                var expense = new Expense {
                    Date      = new DateTime(2021, 9, 10),
                    Employee  = employee,
                    Operation = ExpenseOperations.Employee,
                    Warehouse = warehouse,
                };

                var size   = new Size();
                var height = new Size();
                uow.Save(size);
                uow.Save(height);

                var stockPosition = new StockPosition(nomenclature, 0, size, height);
                var item          = expense.AddItem(stockPosition, 10);

                expense.UpdateOperations(uow, baseParameters, interactive);
                uow.Save(expense);

                //Списываем 3 штуки
                var writeoff = new Writeoff()
                {
                    Date = new DateTime(2021, 9, 11),
                };

                var writeoffItem = writeoff.AddItem(item.EmployeeIssueOperation, 2);
                writeoff.UpdateOperations(uow);
                uow.Save(writeoff);
                uow.Commit();

                var repository = new EmployeeIssueRepository(uow);
                var result     = repository.GetReferencedDocuments(writeoffItem.EmployeeWriteoffOperation.Id);
                Assert.That(result.First().DocumentType, Is.EqualTo(StokDocumentType.WriteoffDoc));
                Assert.That(result.First().DocumentId, Is.EqualTo(writeoff.Id));
                Assert.That(result.First().ItemId, Is.EqualTo(writeoffItem.Id));
            }
        }
        public EmployeeMovementsViewModel(EmployeeViewModel employeeViewModel, OpenStockDocumentsModel openStockDocumentsModel, EmployeeIssueRepository employeeIssueRepository, FeaturesService featuresService, ITdiCompatibilityNavigation navigation)
        {
            this.employeeViewModel       = employeeViewModel ?? throw new ArgumentNullException(nameof(employeeViewModel));
            this.openStockDocumentsModel = openStockDocumentsModel ?? throw new ArgumentNullException(nameof(openStockDocumentsModel));
            this.employeeIssueRepository = employeeIssueRepository ?? throw new ArgumentNullException(nameof(employeeIssueRepository));
            this.featuresService         = featuresService ?? throw new ArgumentNullException(nameof(featuresService));
            this.navigation = navigation ?? throw new ArgumentNullException(nameof(navigation));

            this.employeeIssueRepository.RepoUow = UoW;
        }
示例#3
0
        public NormViewModel(
            IEntityUoWBuilder uowBuilder,
            IUnitOfWorkFactory unitOfWorkFactory,
            EmployeeIssueRepository employeeIssueRepository,
            INavigationManager navigation,
            IInteractiveQuestion interactive,
            IValidator validator = null) : base(uowBuilder, unitOfWorkFactory, navigation, validator)
        {
            this.employeeIssueRepository    = employeeIssueRepository ?? throw new ArgumentNullException(nameof(employeeIssueRepository));
            employeeIssueRepository.RepoUow = UoW;
            this.interactive = interactive;

            NormConditions = UoW.GetAll <NormCondition>().ToList();
            NormConditions.Insert(0, null);
        }
示例#4
0
        public EmployeeWearItemsViewModel(
            EmployeeViewModel employeeViewModel,
            EmployeeIssueRepository employeeIssueRepository,
            BaseParameters baseParameters,
            IInteractiveService interactive,
            ITdiCompatibilityNavigation navigation,
            OpenStockDocumentsModel stockDocumentsModel,
            FeaturesService featuresService)
        {
            this.employeeViewModel       = employeeViewModel ?? throw new ArgumentNullException(nameof(employeeViewModel));
            this.employeeIssueRepository = employeeIssueRepository ?? throw new ArgumentNullException(nameof(employeeIssueRepository));
            this.BaseParameters          = baseParameters ?? throw new ArgumentNullException(nameof(baseParameters));
            this.navigation          = navigation ?? throw new ArgumentNullException(nameof(navigation));
            this.stockDocumentsModel = stockDocumentsModel ?? throw new ArgumentNullException(nameof(stockDocumentsModel));
            FeaturesService          = featuresService ?? throw new ArgumentNullException(nameof(featuresService));
            this.interactive         = interactive ?? throw new ArgumentNullException(nameof(interactive));

            employeeIssueRepository.RepoUow = UoW;
            NotifyConfiguration.Instance.BatchSubscribeOnEntity <EmployeeCardItem>(HandleEntityChangeEvent);
        }
示例#5
0
        public void GetOperationsTouchDates_OneDateRangeTest()
        {
            using (var uow = UnitOfWorkFactory.CreateWithoutRoot()) {
                var nomenclatureType = new ItemsType();
                nomenclatureType.Name = "Тестовый тип номенклатуры";
                uow.Save(nomenclatureType);

                var nomenclature = new Nomenclature {
                    Type = nomenclatureType
                };
                uow.Save(nomenclature);

                var protectionTools = new ProtectionTools {
                    Name = "СИЗ для тестирования"
                };
                protectionTools.AddNomeclature(nomenclature);
                uow.Save(protectionTools);

                var employee = new EmployeeCard();
                uow.Save(employee);

                var opBefore = new EmployeeIssueOperation {
                    OperationTime    = new DateTime(2018, 12, 31, 14, 0, 0),
                    AutoWriteoffDate = new DateTime(2020, 1, 1),
                    Employee         = employee,
                    Nomenclature     = nomenclature,
                    ProtectionTools  = protectionTools,
                    Issued           = 1
                };
                uow.Save(opBefore);

                var opInRange = new EmployeeIssueOperation {
                    OperationTime    = new DateTime(2019, 1, 1, 0, 0, 0),
                    AutoWriteoffDate = new DateTime(2021, 1, 1),
                    Employee         = employee,
                    Nomenclature     = nomenclature,
                    ProtectionTools  = protectionTools,
                    Issued           = 1
                };
                uow.Save(opInRange);

                var opInRange2 = new EmployeeIssueOperation {
                    OperationTime    = new DateTime(2019, 1, 1, 13, 0, 0),
                    AutoWriteoffDate = new DateTime(2021, 2, 1),
                    Employee         = employee,
                    Nomenclature     = nomenclature,
                    ProtectionTools  = protectionTools,
                    Issued           = 2
                };
                uow.Save(opInRange2);

                var opAfter = new EmployeeIssueOperation {
                    OperationTime    = new DateTime(2019, 1, 2, 13, 0, 0),
                    AutoWriteoffDate = new DateTime(2021, 5, 1),
                    Employee         = employee,
                    Nomenclature     = nomenclature,
                    ProtectionTools  = protectionTools,
                    Issued           = 1
                };
                uow.Save(opAfter);

                uow.Commit();

                var repository = new EmployeeIssueRepository(uow);
                var result     =
                    repository.GetOperationsByDates(
                        new[] { employee }, new DateTime(2019, 1, 1), new DateTime(2019, 1, 1));
                Assert.That(result.Any(x => x.OperationTime == new DateTime(2019, 1, 1, 0, 0, 0)), Is.True);
                Assert.That(result.Any(x => x.OperationTime == new DateTime(2019, 1, 1, 13, 0, 0)), Is.True);
                Assert.That(result.Count, Is.EqualTo(2));
            }
        }
示例#6
0
        public void GetLastOperationsForEmployee_HappyPathTest()
        {
            using (var uow = UnitOfWorkFactory.CreateWithoutRoot()) {
                var nomenclatureType = new ItemsType {
                    Name = "Тестовый тип номенклатуры"
                };
                uow.Save(nomenclatureType);

                var nomenclature = new Nomenclature {
                    Type = nomenclatureType
                };
                uow.Save(nomenclature);

                var protectionTools = new ProtectionTools {
                    Name = "СИЗ для тестирования"
                };
                protectionTools.AddNomeclature(nomenclature);
                uow.Save(protectionTools);

                var protectionTools2 = new ProtectionTools {
                    Name = "СИЗ для тестирования 2"
                };
                protectionTools2.AddNomeclature(nomenclature);
                uow.Save(protectionTools2);

                var employee = new EmployeeCard();
                uow.Save(employee);

                var employee2 = new EmployeeCard();
                uow.Save(employee2);

                //Лишний
                var employee3 = new EmployeeCard();
                uow.Save(employee3);

                //Операция employee1 СИЗ 1
                var opE1P1 = new EmployeeIssueOperation {
                    OperationTime    = new DateTime(2018, 1, 1, 14, 0, 0),
                    AutoWriteoffDate = new DateTime(2020, 1, 1),
                    Employee         = employee,
                    Nomenclature     = nomenclature,
                    ProtectionTools  = protectionTools,
                    Issued           = 1
                };
                uow.Save(opE1P1);

                var op2E1P1 = new EmployeeIssueOperation {
                    OperationTime    = new DateTime(2019, 1, 1, 13, 0, 0),
                    AutoWriteoffDate = new DateTime(2021, 1, 1),
                    Employee         = employee,
                    Nomenclature     = nomenclature,
                    ProtectionTools  = protectionTools,
                    Issued           = 1
                };
                uow.Save(op2E1P1);

                var opE1P2 = new EmployeeIssueOperation {
                    OperationTime    = new DateTime(2021, 1, 1, 13, 0, 0),
                    AutoWriteoffDate = new DateTime(2021, 5, 1),
                    Employee         = employee,
                    Nomenclature     = nomenclature,
                    ProtectionTools  = protectionTools2,
                    Issued           = 1
                };
                uow.Save(opE1P2);

                var opE1P2Return = new EmployeeIssueOperation {
                    OperationTime    = new DateTime(2021, 2, 1, 13, 0, 0),
                    AutoWriteoffDate = new DateTime(2021, 5, 1),
                    Employee         = employee,
                    Nomenclature     = nomenclature,
                    ProtectionTools  = protectionTools2,
                    Issued           = 0,
                    Returned         = 1
                };
                uow.Save(opE1P2Return);

                var opE2P2 = new EmployeeIssueOperation {
                    OperationTime    = new DateTime(2021, 2, 1, 14, 0, 0),
                    AutoWriteoffDate = new DateTime(2021, 5, 1),
                    Employee         = employee2,
                    Nomenclature     = nomenclature,
                    ProtectionTools  = protectionTools2,
                    Issued           = 1
                };
                uow.Save(opE2P2);

                //Не хотим видеть в выборке от сотрудника 3
                var opE3P2 = new EmployeeIssueOperation {
                    OperationTime    = new DateTime(2021, 2, 1, 14, 0, 0),
                    AutoWriteoffDate = new DateTime(2021, 5, 1),
                    Employee         = employee3,
                    Nomenclature     = nomenclature,
                    ProtectionTools  = protectionTools2,
                    Issued           = 1
                };
                uow.Save(opE3P2);

                uow.Commit();

                var repository = new EmployeeIssueRepository(uow);
                var result     = repository.GetLastIssueOperationsForEmployee(new[] { employee, employee2 });

                Assert.That(result, Has.No.Member(opE1P1));
                Assert.That(result, Has.Member(op2E1P1));
                Assert.That(result, Has.Member(opE1P2));
                Assert.That(result, Has.No.Member(opE1P2Return));
                Assert.That(result, Has.Member(opE2P2));
                Assert.That(result, Has.No.Member(opE3P2));
            }
        }
示例#7
0
        public void GetReferencedDocuments_CollectiveExpenseTest()
        {
            var interactive = Substitute.For <IInteractiveQuestion>();

            interactive.Question(string.Empty).ReturnsForAnyArgs(true);
            var baseParameters = Substitute.For <BaseParameters>();

            using (var uow = UnitOfWorkFactory.CreateWithoutRoot()) {
                var warehouse = new Warehouse();
                uow.Save(warehouse);

                var protectionTools = new ProtectionTools {
                    Name = "Тестовая курточка"
                };
                uow.Save(protectionTools);

                var nomenclatureType = new ItemsType {
                    Name = "Тестовый тип номенклатуры"
                };
                uow.Save(nomenclatureType);

                var nomenclature = new Nomenclature {
                    Type = nomenclatureType
                };
                nomenclature.ProtectionTools.Add(protectionTools);
                uow.Save(nomenclature);

                var norm = new Norm();
                norm.AddItem(protectionTools);
                uow.Save(norm);

                var employee = new EmployeeCard();
                employee.AddUsedNorm(norm);
                uow.Save(employee);

                var employee2 = new EmployeeCard();
                employee2.AddUsedNorm(norm);
                uow.Save(employee2);

                var expense = new CollectiveExpense()
                {
                    Date      = new DateTime(2021, 9, 10),
                    Warehouse = warehouse,
                };

                var size   = new Size();
                var height = new Size();
                uow.Save(size);
                uow.Save(height);

                var stockPosition = new StockPosition(nomenclature, 0, size, height);
                var item          = expense.AddItem(employee.WorkwearItems.FirstOrDefault(), stockPosition, 1);
                var item2         = expense.AddItem(employee2.WorkwearItems.FirstOrDefault(), stockPosition, 10);

                expense.UpdateOperations(uow, baseParameters, interactive);
                uow.Save(expense);
                uow.Commit();

                var repository = new EmployeeIssueRepository(uow);
                var results    = repository
                                 .GetReferencedDocuments(item.EmployeeIssueOperation.Id, item2.EmployeeIssueOperation.Id);
                var result1 = results.First(x => x.OperationId == item.EmployeeIssueOperation.Id);
                Assert.That(result1.DocumentType, Is.EqualTo(StokDocumentType.CollectiveExpense));
                Assert.That(result1.DocumentId, Is.EqualTo(expense.Id));
                Assert.That(result1.ItemId, Is.EqualTo(item.Id));
                var result2 = results.First(x => x.OperationId == item2.EmployeeIssueOperation.Id);
                Assert.That(result2.DocumentType, Is.EqualTo(StokDocumentType.CollectiveExpense));
                Assert.That(result2.DocumentId, Is.EqualTo(expense.Id));
                Assert.That(result2.ItemId, Is.EqualTo(item2.Id));
            }
        }
 public virtual void UpdateRelatedOperations(IUnitOfWork uow, EmployeeIssueRepository employeeIssueRepository, BaseParameters baseParameters, IInteractiveQuestion askUser)
 {
     Employee.RecalculateDatesOfIssueOperations(uow, employeeIssueRepository, baseParameters, askUser, BeginDate, EndDate);
 }