public void OnShow() { if (isConfigured) { return; } isConfigured = true; Entity.FillWearInStockInfo(UoW, BaseParameters, Entity.Subdivision?.Warehouse, DateTime.Now); Entity.FillWearRecivedInfo(employeeIssueRepository); OnPropertyChanged(nameof(ObservableWorkwearItems)); }
public void FillWearRecivedInfo_NotMergeAnalogTest() { using (var uow = UnitOfWorkFactory.CreateWithoutRoot()) { var nomenclatureType = new ItemsType(); nomenclatureType.Name = "Тестовый тип номенклатуры"; nomenclatureType.Category = ItemTypeCategory.wear; uow.Save(nomenclatureType); var nomenclature = new Nomenclature(); nomenclature.Type = nomenclatureType; nomenclature.Sex = ClothesSex.Men; uow.Save(nomenclature); var protectionToolsAnalog = new ProtectionTools(); protectionToolsAnalog.Name = "Номенклатура нормы Аналог"; protectionToolsAnalog.AddNomeclature(nomenclature); var protectionTools = new ProtectionTools(); protectionTools.Name = "Номенклатура нормы"; protectionTools.AddAnalog(protectionToolsAnalog); protectionTools.AddNomeclature(nomenclature); protectionToolsAnalog.AddAnalog(protectionTools); uow.Save(protectionToolsAnalog); uow.Save(protectionTools); var norm = new Norm(); var normItem = norm.AddItem(protectionTools); normItem.Amount = 1; normItem.NormPeriod = NormPeriodType.Year; normItem.PeriodCount = 1; var normItem2 = norm.AddItem(protectionToolsAnalog); normItem2.Amount = 2; normItem2.NormPeriod = NormPeriodType.Year; normItem2.PeriodCount = 1; uow.Save(norm); var employee = new EmployeeCard(); employee.AddUsedNorm(norm); employee.Sex = Sex.M; Assert.That(employee.WorkwearItems.Count, Is.GreaterThan(0)); uow.Save(employee); uow.Commit(); var warehouseOperation = new WarehouseOperation { Nomenclature = nomenclature, Amount = 1, OperationTime = new DateTime(2018, 1, 20), }; uow.Save(warehouseOperation); var operation = new EmployeeIssueOperation { Employee = employee, ExpiryByNorm = new DateTime(2019, 1, 20), Issued = 1, Nomenclature = nomenclature, NormItem = normItem, ProtectionTools = protectionTools, OperationTime = new DateTime(2018, 1, 20), WarehouseOperation = warehouseOperation, }; uow.Save(operation); var warehouseOperation2 = new WarehouseOperation { Nomenclature = nomenclature, Amount = 2, OperationTime = new DateTime(2018, 1, 20), }; uow.Save(warehouseOperation2); var operation2 = new EmployeeIssueOperation { Employee = employee, ExpiryByNorm = new DateTime(2019, 1, 20), Issued = 2, Nomenclature = nomenclature, NormItem = normItem2, ProtectionTools = protectionToolsAnalog, OperationTime = new DateTime(2018, 1, 20), WarehouseOperation = warehouseOperation, }; uow.Save(operation2); uow.Commit(); employee.FillWearRecivedInfo(new EmployeeIssueRepository(uow)); var item1 = employee.WorkwearItems.FirstOrDefault(x => x.ActiveNormItem == normItem); Assert.That(item1.Amount, Is.EqualTo(1)); var item2 = employee.WorkwearItems.FirstOrDefault(x => x.ActiveNormItem == normItem2); Assert.That(item2.Amount, Is.EqualTo(2)); } }
public void FillWearRecivedInfo_LastIssueDateExistAfterAutoWriteoffDateTest() { using (var uow = UnitOfWorkFactory.CreateWithoutRoot()) { var nomenclatureType = new ItemsType(); nomenclatureType.Name = "Тестовый тип номенклатуры"; nomenclatureType.Category = ItemTypeCategory.wear; uow.Save(nomenclatureType); var nomenclature = new Nomenclature(); nomenclature.Type = nomenclatureType; nomenclature.Sex = ClothesSex.Men; uow.Save(nomenclature); var protectionTools = new ProtectionTools(); protectionTools.Name = "Номенклатура нормы"; protectionTools.AddNomeclature(nomenclature); uow.Save(protectionTools); var norm = new Norm(); var normItem = norm.AddItem(protectionTools); normItem.Amount = 1; normItem.NormPeriod = NormPeriodType.Year; normItem.PeriodCount = 1; uow.Save(norm); var employee = new EmployeeCard(); employee.AddUsedNorm(norm); employee.Sex = Sex.M; Assert.That(employee.WorkwearItems.Count, Is.GreaterThan(0)); uow.Save(employee); uow.Commit(); var warehouseOperation = new WarehouseOperation { Nomenclature = nomenclature, Amount = 1, OperationTime = new DateTime(2018, 1, 20), }; uow.Save(warehouseOperation); var operationIssue = new EmployeeIssueOperation { Employee = employee, ExpiryByNorm = new DateTime(2019, 1, 20), AutoWriteoffDate = new DateTime(2019, 1, 20), UseAutoWriteoff = true, Issued = 1, Nomenclature = nomenclature, NormItem = normItem, ProtectionTools = protectionTools, OperationTime = new DateTime(2018, 1, 20), StartOfUse = new DateTime(2018, 1, 20), WarehouseOperation = warehouseOperation, }; uow.Save(operationIssue); uow.Commit(); employee.FillWearRecivedInfo(new EmployeeIssueRepository(uow)); var item = employee.WorkwearItems.First(); Assert.That(item.Amount, Is.EqualTo(1)); Assert.That(item.LastIssue, Is.EqualTo(new DateTime(2018, 1, 20))); } }