private async Task <HolidayPaymentConfiguration> GetPeriodTypesHolidayConfiguration(Guid companyID, Guid instanceID) { var _clientPeriodType = new MiddlewareManager <PeriodType>(new BaseRecordManager <PeriodType>(), new PeriodTypeValidator()); var periodTypes = await _clientPeriodType.GetAllAsync(companyID, instanceID); return(periodTypes.FirstOrDefault().HolidayPremiumPaymentType); }
public async Task Should_Get_All_In_Memory_Should_Be_Equal_To_Get_All_DB( ) { using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled); //Arrange var middlewareManager = new MiddlewareManager <UMI>(new BaseRecordManager <UMI>(), new UMIValidator()); var memoryMgr = new MemoryStorageContext(); //Asserts //Get var result = await middlewareManager.GetAllAsync(); Assert.True(result.Any()); var resultMemory = memoryMgr.GetdDefaultUMI(); Assert.True(resultMemory.Any()); Assert.Equal(result.Count(), resultMemory.Count()); resultMemory.ForEach(memory => { var db = result.FirstOrDefault(x => x.ID == memory.ID); Assert.NotNull(db); }); }
public async Task <List <T> > GetAllAsync(Guid identityWorkId, Guid instanceId, string[] objectsToInclude = null) { var middlewareManager = new MiddlewareManager <T>(new BaseRecordManager <T>(), Validator); var lstReturn = await middlewareManager.GetAllAsync(identityWorkId, instanceId, objectsToInclude); return(lstReturn); }
public async Task <List <ConceptPayment> > CreateDefaultSalaryPaymentConceptsAsync(Guid identityWorkId, Guid instanceID) { var memoryStorageContext = new MemoryStorageContext(); var middlewareAccumulates = new MiddlewareManager <AccumulatedType>(new BaseRecordManager <AccumulatedType>(), new AccumulatedTypeValidator()); var accumulatesTypes = await middlewareAccumulates.GetAllAsync(identityWorkId, instanceID); if (!accumulatesTypes.Any()) { accumulatesTypes = memoryStorageContext.GetDefaultAccumulatedType(identityWorkId, instanceID, Guid.NewGuid()); await middlewareAccumulates.CreateAsync(accumulatesTypes, identityWorkId); } var resultTuple = memoryStorageContext.GetDefaultConcept <ConceptPayment>(identityWorkId, instanceID, Guid.NewGuid(), accumulatesTypes); var concepts = resultTuple.Item1 .Cast <ConceptPayment>().ToList(); var middlewareManagerConceptPaymentRelationship = new MiddlewareManager <ConceptPaymentRelationship>(new BaseRecordManager <ConceptPaymentRelationship>(), new ConceptPaymentRelationshipValidator()); var middlewareConcept = new MiddlewareManager <ConceptPayment>(new BaseRecordManager <ConceptPayment>(), new ConceptPaymentValidator()); await middlewareConcept.CreateAsync(concepts, identityWorkId); var relationships = resultTuple.Item2.Cast <ConceptPaymentRelationship>().ToList(); await middlewareManagerConceptPaymentRelationship.CreateAsync(relationships, identityWorkId); return(concepts); }
public async Task Authorization_Should_Authorize() { using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled); var identityWorkId = Guid.NewGuid(); var instanceID = Guid.NewGuid(); var employee = await new EmployeeManagerUT().CreateDefaultAsync <Employee>(identityWorkId, instanceID); var middlewareManager = new MiddlewareManager <OverdraftDetail>(new BaseRecordManager <OverdraftDetail>(), new OverdraftDetailValidator()); var overdraftDetails = await middlewareManager.FindByExpressionAsync(p => p.InstanceID == instanceID && p.ConceptPayment.Name == "Sueldo", identityWorkId, new string[] { "Overdraft" }); var randomValue = new Random(15000); for (int i = 0; i < overdraftDetails.Count; i++) { overdraftDetails[i].Amount = Convert.ToDecimal(randomValue.NextDouble()); overdraftDetails[i].Taxed = Convert.ToDecimal(randomValue.NextDouble()); overdraftDetails[i].Exempt = Convert.ToDecimal(randomValue.NextDouble()); overdraftDetails[i].IMSSTaxed = Convert.ToDecimal(randomValue.NextDouble()); overdraftDetails[i].IMSSExempt = Convert.ToDecimal(randomValue.NextDouble()); } var middlewareDetailManager = new MiddlewareManager <OverdraftDetail>(new BaseRecordManager <OverdraftDetail>(), new OverdraftDetailValidator()); await middlewareDetailManager.UpdateAsync(overdraftDetails, identityWorkId); var authManager = new AuthorizationManager(); var authParams = new AuthorizationParams() { IdentityWorkID = identityWorkId, InstanceID = instanceID, PeriodDetailIDToAuthorize = overdraftDetails.FirstOrDefault().Overdraft.PeriodDetailID }; await authManager.AuthorizationAsync(authParams); var middlewareHistoricAccumulatedEmployeeManager = new MiddlewareManager <HistoricAccumulatedEmployee>(new BaseRecordManager <HistoricAccumulatedEmployee>(), new HistoricAccumulatedEmployeeValidator()); //Total de acumulados por empleado var resultHistoric = await middlewareHistoricAccumulatedEmployeeManager.GetAllAsync(identityWorkId, instanceID, new string[] { "AccumulatedType" }); Assert.True(resultHistoric.Count == 33); //Overdraft after authorization var overdraftDetailsAfter = await middlewareManager.FindByExpressionAsync(p => p.Overdraft.EmployeeID == employee.FirstOrDefault().ID, identityWorkId, new string[] { "Overdraft" }); Assert.True(overdraftDetailsAfter.FirstOrDefault().Overdraft.PeriodDetailID != overdraftDetails.FirstOrDefault().Overdraft.PeriodDetailID); }
public async Task Should_Get_All(string date, decimal value) { var ValidityDate = DateTime.Parse(date); using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled); //Arrange var middlewareManager = new MiddlewareManager <UMI>(new BaseRecordManager <UMI>(), new UMIValidator()); //Asserts //Get var result = await middlewareManager.GetAllAsync(); Assert.True(result.Any()); Assert.NotNull(result.FirstOrDefault(x => x.ValidityDate == ValidityDate)); Assert.Equal(value, result.FirstOrDefault(x => x.ValidityDate == ValidityDate).Value); }
public async Task <IEnumerable <EmployeeDTO> > GetEmployees(string instanceID, string companyID) { List <EmployeeDTO> result = new List <EmployeeDTO>(); var config = new MapperConfiguration(cfg => { cfg.CreateMap <Employee, EmployeeDTO>(); }); var _mapper = config.CreateMapper(); var middlewareManager = new MiddlewareManager <Employee>(new BaseRecordManager <Employee>(), new EmployeeValidator()); var employees = await middlewareManager.GetAllAsync(Guid.Parse(companyID), Guid.Parse(instanceID), new string[] { "JobPosition", "Department" }); employees.ForEach(employee => { var employeeDTO = _mapper.Map <Employee, EmployeeDTO>(employee); employeeDTO.DepartmentDTO.Name = employee.Department.Name; employeeDTO.JobPositionDTO.Name = employee.JobPosition.Name; result.Add(employeeDTO); }); return(result); }
public async Task <List <T> > CreateDefaultAsync <T>(Guid identityWorkId, Guid instanceID, string rfc = "RAQÑ7701212M3", string nss = "833531862", string curp = "KAHO641101HDFLKS06", string name = "Jaime", string firstLastName = "Duende", string secondLastName = "Gongora y Gongora", string code = "1", bool randomValues = false) where T : BaseEntity { //Act Dependencies var deparments = await new DepartmentManagerUT().CreateDefaultAsync <Department>(identityWorkId, instanceID); var jobPositions = await new JobPositionManagerUT().CreateDefaultAsync <JobPosition>(identityWorkId, instanceID); var periodManager = new MiddlewareManager <Period>(new BaseRecordManager <Period>(), new PeriodValidator()); var period = await periodManager.GetAllAsync(identityWorkId, instanceID); var periodType = new List <PeriodType>(); if (!period.Any()) { var fiscalYear = DateTime.Now.Year; var initialDate = new DateTime(fiscalYear, 1, 1); var finalDate = new DateTime(fiscalYear, 12, 31); var periodTypeManager = new MiddlewareManager <PeriodType>(new BaseRecordManager <PeriodType>(), new PeriodTypeValidator()); periodType = new MemoryStorageContext().GetDefaultPeriodType(identityWorkId, instanceID, Guid.NewGuid(), PaymentPeriodicity.Biweekly, 15M, AdjustmentPay_16Days_Febrary.PayCalendarDays, forceUpdate: true); await periodTypeManager.CreateAsync(periodType, identityWorkId); period = new MemoryStorageContext().GetDefaultPeriod(identityWorkId, instanceID, Guid.NewGuid(), initialDate, finalDate, fiscalYear, periodType.FirstOrDefault(p => p.PaymentPeriodicity == PaymentPeriodicity.Biweekly)); await periodManager.CreateAsync(period, identityWorkId); } var workshifts = await new WorkshiftManagerUT().CreateDefaultAsync <Workshift>(identityWorkId, instanceID); var emploRegID = await new EmployerRegistrationUT().CreateDefaultAsync <EmployerRegistration>(identityWorkId, instanceID); //Arrange var employees = new List <Employee>(); if (randomValues) { Random _random = new Random(); var num = _random.Next(0, 26); // Zero to 25 char let = (char)('a' + num); rfc = rfc.Replace("A", let.ToString()); num = _random.Next(0, 26); // Zero to 25 let = (char)('a' + num); curp = curp.Replace("A", let.ToString()); num = _random.Next(0, 9); // Zero to 25 nss = nss.Replace("3", num.ToString()); num = _random.Next(10, 100); // Zero to 25 code = num.ToString(); firstLastName = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 5); } employees.Add(new Employee() { ID = Guid.NewGuid(), Active = true, company = identityWorkId, RFC = rfc, Timestamp = DateTime.UtcNow, InstanceID = instanceID, user = Guid.NewGuid(), BirthDate = DateTime.Now, NSS = nss, BornPlace = "Guadalajara", CivilStatus = CivilStatus.Viudo, Code = code, CURP = curp, DeleteDate = null, Name = name, FirstLastName = firstLastName, SecondLastName = secondLastName, Gender = Gender.Male, EntryDate = new DateTime(DateTime.UtcNow.Year - 1, 1, 1), JobPositionID = jobPositions.FirstOrDefault().ID, DepartmentID = deparments.FirstOrDefault().ID, PeriodTypeID = period.FirstOrDefault().PeriodTypeID, WorkshiftID = workshifts.FirstOrDefault().ID, EmployerRegistrationID = emploRegID.FirstOrDefault().ID, BankAccount = "123456789145214587", EmployeeTrustLevel = EmployeeTrustLevel.Trusted, StatusID = 1, Description = "desc", RegimeType = EmployeeRegimeType.Salaries, ContractType = ContractType.IndefiniteTermEmploymentContract, DailySalary = 2150.45m, ContributionBase = BaseQuotation.Fixed, SalaryZone = SalaryZone.ZoneA, PaymentBase = PaymentBase.SalaryComission, SBCFixedPart = 2150.45m, SBCMax25UMA = 2112.25m, SBCVariablePart = 1.54m, LocalStatus = CotorriaStatus.Active, LastStatusChange = DateTime.Now }); //needed to create overdraft var conceptPayments = await(new ConceptManagerUT().CreateDefaultSalaryPaymentConceptsAsync(identityWorkId, instanceID)); //Act var middlewareManager = new MiddlewareManager <Employee>(new BaseRecordManager <Employee>(), new EmployeeValidator()); await middlewareManager.CreateAsync(employees, identityWorkId); return(employees as List <T>); }
public async Task <List <T> > GetAllAsync(string[] objectsToInclude = null) { var middlewareManager = new MiddlewareManager <T>(new BaseRecordManager <T>(), Validator); return(await middlewareManager.GetAllAsync(objectsToInclude)); }
public async Task <List <T> > CreateDefaultAsyncList <T>(Guid identityWorkId, Guid instanceID, string rfc = "RAQÑ7701212M3", string nss = "833531862", string curp = "KAHO641101HDFLKS06", string name = "Jaime", string firstLastName = "Duende", string secondLastName = "Gongora y Gongora", string code = "1", bool randomValues = false, int laps = 1) where T : BaseEntity { //Act Dependencies var deparments = Guid.Parse("1AB7ADFE-9E51-47A2-BF6E-38381415BFD1"); var jobPositions = Guid.Parse("DC6FA1A7-59DD-4E29-BE13-1C97404EFBF8"); var periodManager = new MiddlewareManager <Period>(new BaseRecordManager <Period>(), new PeriodValidator()); var period = await periodManager.GetAllAsync(identityWorkId, instanceID); var periodType = new List <PeriodType>(); if (!period.Any()) { var fiscalYear = DateTime.Now.Year; var initialDate = new DateTime(fiscalYear, 1, 1); var finalDate = new DateTime(fiscalYear, 12, 31); var periodTypeManager = new MiddlewareManager <PeriodType>(new BaseRecordManager <PeriodType>(), new PeriodTypeValidator()); periodType = new MemoryStorageContext().GetDefaultPeriodType(identityWorkId, instanceID, Guid.NewGuid(), PaymentPeriodicity.Biweekly, 15M, AdjustmentPay_16Days_Febrary.PayCalendarDays, forceUpdate: true); await periodTypeManager.CreateAsync(periodType, identityWorkId); period = new MemoryStorageContext().GetDefaultPeriod(identityWorkId, instanceID, Guid.NewGuid(), initialDate, finalDate, fiscalYear, periodType.FirstOrDefault(p => p.PaymentPeriodicity == PaymentPeriodicity.Biweekly)); await periodManager.CreateAsync(period, identityWorkId); } var workshifts = await new WorkshiftManagerUT().CreateDefaultAsync <Workshift>(identityWorkId, instanceID); var emploRegID = Guid.Parse("AFBBA215-7B9F-4EE6-AE4E-12721485F7B1"); //Arrange var employees = new List <Employee>(); var rfcs = FiscalStringsUtils.GenerateRFCs(laps); var curps = FiscalStringsUtils.GenerateCURPs(laps); var NSSs = FiscalStringsUtils.GenerateNSS(laps); var actualCode = 101; for (int i = 0; i < laps; i++) { if (randomValues) { Random _random = new Random(); var num = _random.Next(0, 90); rfc = rfcs[i]; curp = curps[i]; nss = NSSs[i]; code = (actualCode++).ToString(); firstLastName = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 5); } employees.Add(new Employee() { ID = Guid.NewGuid(), Active = true, company = identityWorkId, RFC = rfc, Timestamp = DateTime.UtcNow, InstanceID = instanceID, user = Guid.NewGuid(), BirthDate = DateTime.Now, NSS = nss, BornPlace = "Guadalajara", CivilStatus = CivilStatus.Viudo, Code = code, CURP = curp, DeleteDate = null, Name = name, FirstLastName = firstLastName, SecondLastName = secondLastName, Gender = Gender.Male, EntryDate = new DateTime(DateTime.UtcNow.Year - 1, 1, 1), JobPositionID = jobPositions, DepartmentID = deparments, PeriodTypeID = period.FirstOrDefault().PeriodTypeID, WorkshiftID = workshifts.FirstOrDefault().ID, EmployerRegistrationID = emploRegID, BankAccount = "123456789145214587", EmployeeTrustLevel = EmployeeTrustLevel.Trusted, StatusID = 1, Description = "desc", RegimeType = EmployeeRegimeType.Salaries, ContractType = ContractType.IndefiniteTermEmploymentContract, DailySalary = 2150.45m, ContributionBase = BaseQuotation.Fixed, SalaryZone = SalaryZone.ZoneA, PaymentBase = PaymentBase.SalaryComission, SBCFixedPart = 2150.45m, SBCMax25UMA = 2112.25m, SBCVariablePart = 1.54m, LocalStatus = CotorriaStatus.Active, LastStatusChange = DateTime.Now }); } //Act var middlewareManager = new MiddlewareManager <Employee>(new BaseRecordManager <Employee>(), new EmployeeValidator()); await middlewareManager.CreateAsync(employees, new LicenseParams() { IdentityWorkID = identityWorkId }); return(employees as List <T>); }