public async Task ShouldInsert_ExternalAgentAndEmployee() { Guid id = Guid.NewGuid(); Employee employee = new Employee ( new ExternalAgent(id, AgentType.Employee), SupervisorId.Create(id), PersonName.Create("George", "Orwell", "J"), SSN.Create("623789999"), PhoneNumber.Create("817-987-1234"), MaritalStatus.Create("M"), TaxExemption.Create(5), PayRate.Create(40.00M), StartDate.Create(new DateTime(1998, 12, 2)), IsActive.Create(true) ); await _employeeRepo.AddAsync(employee); await _unitOfWork.Commit(); var employeeResult = await _employeeRepo.Exists(employee.Id); Assert.True(employeeResult); }
/// <summary> /// Update the details of a tax exemption. /// </summary> /// <param name="id">The id of the tax exemption to update.</param> /// <param name="item">The tax exemption details to update the selected tax exemption with.</param> /// <returns>The tax exemption details after they have passed through the Zoho service.</returns> public async Task <TaxExemption> UpdateTaxExemptionAsync(string id, TaxExemption item) { var response = await PostDataAsync <TaxExemption, ZohoBooksResponse <TaxExemption> > (string.Format("settings/taxexemptions/{0}", id), item, OrganizationIdFilter); return(response.Resource); }
public void Configure(EntityTypeBuilder <Employee> entity) { entity.ToTable("Employees", schema: "HumanResources"); entity.HasKey(e => e.Id); entity.Property(p => p.Id).HasColumnType("UNIQUEIDENTIFIER").HasColumnName("EmployeeId"); entity.Property(p => p.SupervisorId) .HasConversion(p => p.Value, p => SupervisorId.Create(p)) .HasColumnType("UNIQUEIDENTIFIER") .HasColumnName("SupervisorId") .IsRequired(); entity.OwnsOne(p => p.EmployeeName, p => { p.Property(pp => pp.LastName).HasColumnType("NVARCHAR(25)").HasColumnName("LastName").IsRequired(); p.Property(pp => pp.FirstName).HasColumnType("NVARCHAR(25)").HasColumnName("FirstName").IsRequired(); p.Property(pp => pp.MiddleInitial).HasColumnType("NCHAR(1)").HasColumnName("MiddleInitial"); }); entity.Property(p => p.SSN) .HasConversion(p => p.Value, p => SSN.Create(p)) .HasColumnType("NVARCHAR(9)") .HasColumnName("SSN") .IsRequired(); entity.Property(p => p.Telephone) .HasConversion(p => p.Value, p => PhoneNumber.Create(p)) .HasColumnType("NVARCHAR(14)") .HasColumnName("Telephone") .IsRequired(); entity.Property(p => p.MaritalStatus) .HasConversion(p => p.Value, p => MaritalStatus.Create(p)) .HasColumnType("NCHAR(1)") .HasColumnName("MaritalStatus") .IsRequired(); entity.Property(p => p.TaxExemption) .HasConversion(p => p.Value, p => TaxExemption.Create(p)) .HasColumnType("int") .HasColumnName("Exemptions") .IsRequired(); entity.Property(p => p.PayRate) .HasConversion(p => p.Value, p => PayRate.Create(p)) .HasColumnType("DECIMAL(18,2)") .HasColumnName("PayRate") .IsRequired(); entity.Property(p => p.StartDate) .HasConversion(p => p.Value, p => StartDate.Create(p)) .HasColumnType("datetime2(0)") .HasColumnName("StartDate") .IsRequired(); entity.Property(p => p.IsActive) .HasConversion(p => p.Value, p => IsActive.Create(p)) .HasColumnType("BIT") .HasColumnName("IsActive") .IsRequired(); entity.Property(e => e.CreatedDate) .HasColumnType("datetime2(7)") .ValueGeneratedOnAdd() .HasDefaultValueSql("sysdatetime()"); entity.Property(e => e.LastModifiedDate).HasColumnType("datetime2(7)"); }
public void ShouldReturn_Valid_TaxExemption() { int exemption = 0; var result = TaxExemption.Create(exemption); Assert.IsType <TaxExemption>(result); Assert.Equal(exemption, result); }
private string CheckTaxExemptionStatus(TaxExemption taxExemption, RationalyType rationalyType) { if (taxExemption.Rationaly.Contains(rationalyType)) { return("1"); } return("0"); }
public void ShouldUpdate_Employee_TaxExemptions() { var employee = GetEmployee(); Assert.Equal(5, employee.TaxExemption); employee.UpdateTaxExemptions(TaxExemption.Create(6)); Assert.Equal(6, employee.TaxExemption); }
public void ShouldRaiseError_Invalid_NegativeTaxExemption() { int exemption = -1; Action action = () => TaxExemption.Create(exemption); var caughtException = Assert.Throws <ArgumentException>(action); Assert.Contains("Number of exemptions must be greater than or equal to zero.", caughtException.Message); }
/// <summary> /// Updates the tax exemption. /// </summary> /// <param name="tax_exemption_id">The tax_exemption_id.</param> /// <param name="update_info">The update_info.</param> /// <returns>TaxExemption.</returns> public TaxExemption UpdateTaxExemption(string tax_exemption_id, TaxExemption update_info) { var url = baseAddress + "/taxexemptions/" + tax_exemption_id; var json = JsonConvert.SerializeObject(update_info); var jsonParams = new Dictionary <object, object>(); jsonParams.Add("JSONString", json); var response = ZohoHttpClient.put(url, getQueryParameters(jsonParams)); return(SettingsParser.getTaxExemption(response)); }
internal static TaxExemption getTaxExemption(HttpResponseMessage response) { var taxExemption = new TaxExemption(); var jsonObj = JsonConvert.DeserializeObject <Dictionary <string, object> >(response.Content.ReadAsStringAsync().Result); if (jsonObj.ContainsKey("tax_exemption")) { taxExemption = JsonConvert.DeserializeObject <TaxExemption>(jsonObj["tax_exemption"].ToString()); } return(taxExemption); }
internal bool IsISK(TaxExemption entity) { var result = false; bool isISK = false; DateTime startDate = new DateTime(entity.Year, 1, 1); DateTime endDate = new DateTime(entity.Year, 12, 31); var shares = dbContext.ProjectCompanyShares.Where(c => c.DependentProjectCompanyId == entity.DependentProjectCompanyId) .Where(x => x.ShareStartDate <= endDate) .Where(x => x.ShareFinishDate >= startDate || x.ShareFinishDate == null).ToList(); if (shares != null && shares.Any()) { var parentCompanyIds = shares.Select(share => share.OwnerProjectCompanyId).Distinct(); foreach (var parentCompany in parentCompanyIds) { // Проверяю что Owner=КЛ var parentOwner = entity.OwnerProjectCompanyId; bool isIHK = IsIHK(entity.Year, parentCompany, parentOwner); if (isIHK) { // проверяю доли прямого участия этого ИХК в кик var shareICHK = shares.Where(share => share.OwnerProjectCompanyId == parentCompany); if (shareICHK != null && shareICHK.Any()) { // Проверяю долю ИХК в КИК var factShares = GetFactShares(parentCompany, entity.Year, shareICHK); var calcShare = CalculateShare(factShares); isISK = calcShare.All(val => val >= 75); // Проверяю что ИХК является КИКом var kikShares = dbContext.ProjectCompanyShares.Where(c => c.DependentProjectCompanyId == parentCompany) .Where(y => y.OwnerProjectCompanyId == parentOwner) .Where(x => x.ShareStartDate <= endDate) .Where(x => x.ShareFinishDate >= startDate || x.ShareFinishDate == null) .Include(x => x.OwnerProjectCompany).Include(c => c.DependentProjectCompany) .Include(x => x.OwnerProjectCompany.DomesticCompany).ToList(); var factKikShares = GetFactShares(parentOwner, entity.Year, kikShares); bool isKik = IsKIK(factKikShares); //isISK = shareICHK.Select(val => val.SharePart).All(val => val >= 75); isISK = calcShare.All(val => val >= 75); if (isISK && isKik) { result = true; return(result); } } } } } return(result); }
internal bool IsAskShareMoreThan75(TaxExemption entity) { var result = false; DateTime startDate = new DateTime(entity.Year, 1, 1); DateTime endDate = new DateTime(entity.Year, 12, 31); var shares = dbContext.ProjectCompanyShares.Where(c => c.OwnerProjectCompany.Id == entity.DependentProjectCompanyId) .Where(x => x.ShareStartDate <= endDate) .Where(x => x.ShareFinishDate >= startDate || x.ShareFinishDate == null).ToList(); if (shares != null && shares.Any()) { var dependentCompanyIds = shares.Select(share => share.DependentProjectCompanyId).Distinct(); foreach (var dependentCompany in dependentCompanyIds) { bool checkIncomeKIKTotalAmount = false; bool passivePartWithoutDividendsIncomeValue = false; // Прямое участие в АК >= 50 % за 365 дней bool isAskDirectShare = false; var askShares = shares.Where(share => share.DependentProjectCompanyId == dependentCompany); var factShares = GetFactShares(entity.DependentProjectCompanyId, entity.Year, askShares); var calcShare = CalculateShare(factShares); isAskDirectShare = calcShare.All(val => val >= 75); //isAkDirectShare = askShares.Select(val => val.SharePart).All(val => val >= 50); if (isAskDirectShare) { checkIncomeKIKTotalAmount = CheckIncomeKIKTotalAmount(entity.Year, dependentCompany); passivePartWithoutDividendsIncomeValue = CheckPassivePartWithoutDividendsIncomeValue(entity.Year, dependentCompany); // проверяю регистр if (checkIncomeKIKTotalAmount || passivePartWithoutDividendsIncomeValue) { // Проверяю прямое участие в АК bool isAK = false; isAK = IsAkShareMoreThan50(entity.Year, dependentCompany); if (isAK) { result = true; return(result); } } } } } return(result); }
internal static TaxExemptionList getTaxExemptionList(HttpResponseMessage response) { var taxExemptionList = new TaxExemptionList(); var jsonObj = JsonConvert.DeserializeObject <Dictionary <string, object> >(response.Content.ReadAsStringAsync().Result); if (jsonObj.ContainsKey("tax_exemptions")) { var taxExemptionArray = JsonConvert.DeserializeObject <List <object> >(jsonObj["tax_exemptions"].ToString()); foreach (var taxExemptionObj in taxExemptionArray) { var taxExemption = new TaxExemption(); taxExemption = JsonConvert.DeserializeObject <TaxExemption>(taxExemptionObj.ToString()); taxExemptionList.Add(taxExemption); } } return(taxExemptionList); }
/** Helper methods **/ private Employee GetEmployee() { var employeeAgent = new ExternalAgent(Guid.NewGuid(), AgentType.Employee); return(new Employee ( employeeAgent, SupervisorId.Create(Guid.NewGuid()), PersonName.Create("George", "Orwell", "Z"), SSN.Create("123789999"), PhoneNumber.Create("817-987-1234"), MaritalStatus.Create("M"), TaxExemption.Create(5), PayRate.Create(40.00M), StartDate.Create(new DateTime(1998, 12, 2)), IsActive.Create(true) )); }
public void ShouldRaiseError_CreateEmployeeWithNullExternalAgent() { Action action = () => new Employee ( null, SupervisorId.Create(Guid.NewGuid()), PersonName.Create("Ken", "Sanchez", "J"), SSN.Create("123789999"), PhoneNumber.Create("817-987-1234"), MaritalStatus.Create("M"), TaxExemption.Create(5), PayRate.Create(40.00M), StartDate.Create(new DateTime(1998, 12, 2)), IsActive.Create(true) ); var caughtException = Assert.Throws <ArgumentNullException>(action); Assert.Contains("The external agent is required.", caughtException.Message); }
public void ShouldReturn_NewEmployee() { var employeeAgent = new ExternalAgent(Guid.NewGuid(), AgentType.Employee); Employee employee = new Employee ( employeeAgent, SupervisorId.Create(employeeAgent.Id), PersonName.Create("Ken", "Sanchez", "J"), SSN.Create("123789999"), PhoneNumber.Create("817-987-1234"), MaritalStatus.Create("M"), TaxExemption.Create(5), PayRate.Create(40.00M), StartDate.Create(new DateTime(1998, 12, 2)), IsActive.Create(true) ); Assert.IsType <Employee>(employee); }
private DomainUser GetUser() { var agent = new ExternalAgent(Guid.NewGuid(), AgentType.Employee); Employee employee = new Employee ( agent, SupervisorId.Create(agent.Id), PersonName.Create("Ken", "Sanchez", "J"), SSN.Create("123789999"), PhoneNumber.Create("817-987-1234"), MaritalStatus.Create("M"), TaxExemption.Create(5), PayRate.Create(40.00M), StartDate.Create(new DateTime(1998, 12, 2)), IsActive.Create(true) ); return(new DomainUser(agent.Id, "Jon", "Doe", "")); }
private Employee GetEmployeeWithContactPeople() { var employeeAgent = new ExternalAgent(Guid.NewGuid(), AgentType.Employee); var employee = new Employee ( employeeAgent, SupervisorId.Create(Guid.NewGuid()), PersonName.Create("George", "Orwell", "Z"), SSN.Create("123789999"), PhoneNumber.Create("817-987-1234"), MaritalStatus.Create("M"), TaxExemption.Create(5), PayRate.Create(40.00M), StartDate.Create(new DateTime(1998, 12, 2)), IsActive.Create(true) ); employee.AddContactPerson(1, PersonName.Create("Fidel", "Castro", "C"), PhoneNumber.Create("555-555-1234"), "You are being tested."); employee.AddContactPerson(2, PersonName.Create("Fidel", "Raul", "Z"), PhoneNumber.Create("555-555-5678"), "You are not being tested."); return(employee); }
private Employee GetEmployeeWithAddresses() { var employeeAgent = new ExternalAgent(Guid.NewGuid(), AgentType.Employee); var employee = new Employee ( employeeAgent, SupervisorId.Create(Guid.NewGuid()), PersonName.Create("George", "Orwell", "Z"), SSN.Create("123789999"), PhoneNumber.Create("817-987-1234"), MaritalStatus.Create("M"), TaxExemption.Create(5), PayRate.Create(40.00M), StartDate.Create(new DateTime(1998, 12, 2)), IsActive.Create(true) ); employee.AddAddress(1, AddressVO.Create("123 Main Terrace", "#4", "Somewhere", "TX", "78885")); employee.AddAddress(2, AddressVO.Create("123 Main Plaza", "Apt 13", "nowhere", "TX", "78981")); return(employee); }
internal static TaxExemptionList getTaxExemptionList(HttpResponseMessage response) { var taxExemptionList = new TaxExemptionList(); var jsonObj = JsonConvert.DeserializeObject<Dictionary<string, object>>(response.Content.ReadAsStringAsync().Result); if (jsonObj.ContainsKey("tax_exemptions")) { var taxExemptionArray = JsonConvert.DeserializeObject<List<object>>(jsonObj["tax_exemptions"].ToString()); foreach(var taxExemptionObj in taxExemptionArray) { var taxExemption = new TaxExemption(); taxExemption = JsonConvert.DeserializeObject<TaxExemption>(taxExemptionObj.ToString()); taxExemptionList.Add(taxExemption); } } return taxExemptionList; }
/// <summary> /// Create a tax exemption. /// </summary> /// <param name="newItem">The new tax exemption details.</param> /// <returns>The tax exemption details after they have passed through the Zoho service.</returns> public async Task <TaxExemption> CreateTaxExemptionAsync(TaxExemption newItem) { var response = await PostDataAsync <TaxExemption, ZohoBooksResponse <TaxExemption> >("settings/taxexemptions", newItem, OrganizationIdFilter); return(response.Resource); }
internal static TaxExemption getTaxExemption(HttpResponseMessage response) { var taxExemption = new TaxExemption(); var jsonObj = JsonConvert.DeserializeObject<Dictionary<string, object>>(response.Content.ReadAsStringAsync().Result); if (jsonObj.ContainsKey("tax_exemption")) { taxExemption = JsonConvert.DeserializeObject<TaxExemption>(jsonObj["tax_exemption"].ToString()); } return taxExemption; }
/// <summary> /// Updates the tax exemption. /// </summary> /// <param name="tax_exemption_id">The tax_exemption_id.</param> /// <param name="update_info">The update_info.</param> /// <returns>TaxExemption.</returns> public TaxExemption UpdateTaxExemption(string tax_exemption_id,TaxExemption update_info) { string url = baseAddress + "/taxexemptions/" + tax_exemption_id; var json = JsonConvert.SerializeObject(update_info); var jsonParams = new Dictionary<object, object>(); jsonParams.Add("JSONString", json); var response = ZohoHttpClient.put(url, getQueryParameters(jsonParams)); return SettingsParser.getTaxExemption(response); }
public async Task <EmpTaxDto> UploadTax(EmpTaxDto tax, IFormFileCollection files) { if (Context.TaxExemptions.Any(x => x.Username == tax.Username)) { return(null); } int iterator = 0; var folderName = Path.Combine("Resources"); var pathToSave = Path.Combine(Directory.GetCurrentDirectory(), folderName); if (files.Count > 0) { foreach (var file in files) { var fileName = ContentDispositionHeaderValue.Parse(file.ContentDisposition).FileName.Trim('"'); var fullPath = Path.Combine(pathToSave, fileName); using (var stream = new FileStream(fullPath, FileMode.Create)) { file.CopyTo(stream); } if (iterator == 0) { tax.FoodPath = fileName; } else if (iterator == 1) { tax.FuelPath = fileName; } else if (iterator == 2) { tax.HraPath = fileName; } else if (iterator == 3) { tax.TravelPath = fileName; } ++iterator; } } else { return(null); } var exemption = new TaxExemption { Username = tax.Username, Name = tax.Name, FoodAmount = tax.FoodAmount, FuelAmount = tax.FuelAmount, HraAmount = tax.HraAmount, TravelAmount = tax.TravelAmount, FoodPath = tax.FoodPath, FuelPath = tax.FuelPath, HraPath = tax.HraPath, TravelPath = tax.TravelPath }; await Context.TaxExemptions.AddAsync(exemption); await Context.SaveChangesAsync(); return(tax); }
public static async Task Execute(CreateEmployeeInfo model, IEmployeeAggregateRepository repo, IUnitOfWork unitOfWork) { if (await repo.Exists(model.Id)) { throw new InvalidOperationException($"This employee ({model.FirstName} {model.MiddleInitial ?? ""} {model.LastName}) already exists!"); } ExternalAgent agent = new(model.Id, AgentType.Employee); Employee employee = new Employee ( agent, SupervisorId.Create(model.SupervisorId), PersonName.Create(model.FirstName, model.LastName, model.MiddleInitial), SSN.Create(model.SSN), PhoneNumber.Create(model.Telephone), MaritalStatus.Create(model.MaritalStatus), TaxExemption.Create(model.Exemptions), PayRate.Create(model.PayRate), StartDate.Create(model.StartDate), IsActive.Create(model.IsActive) ); if (model.Addresses != null && model.Addresses.Count > 0) { foreach (var address in model.Addresses) { employee.AddAddress( 0, AddressVO.Create ( address.AddressLine1, address.AddressLine2, address.City, address.StateCode, address.Zipcode ) ); } } if (model.Contacts != null && model.Contacts.Count > 0) { foreach (var contact in model.Contacts) { employee.AddContactPerson ( 0, PersonName.Create(contact.FirstName, contact.LastName, contact.MiddleInitial), PhoneNumber.Create(contact.Telephone), contact.Notes ); } } await repo.AddAsync(employee); await unitOfWork.Commit(); model.Id = employee.Id; }
public static async Task Execute(EditEmployeeInfo model, IEmployeeAggregateRepository repo, IUnitOfWork unitOfWork) { var employee = await repo.GetByIdAsync(model.Id) ?? throw new InvalidOperationException($"An employee with id '{model.Id}' could not be found!"); if (model.Status == RecordStatus.Modified) { employee.UpdateSupervisorId(SupervisorId.Create(model.SupervisorId)); employee.UpdateEmployeeName(PersonName.Create(model.FirstName, model.LastName, model.MiddleInitial)); employee.UpdateSSN(SSN.Create(model.SSN)); employee.UpdateTelephone(PhoneNumber.Create(model.Telephone)); employee.UpdateMaritalStatus(MaritalStatus.Create(model.MaritalStatus)); employee.UpdateTaxExemptions(TaxExemption.Create(model.Exemptions)); employee.UpdatePayRate(PayRate.Create(model.PayRate)); employee.UpdateLastModifiedDate(); if (model.IsActive) { employee.Activate(); } else if (!model.IsActive) { employee.Deactivate(); } } if (model.Addresses != null && model.Addresses.Count > 0) { foreach (var address in model.Addresses) { if (address.Status == RecordStatus.New) { employee.AddAddress(0, AddressVO.Create(address.AddressLine1, address.AddressLine2, address.City, address.StateCode, address.Zipcode)); } else if (address.Status == RecordStatus.Modified) { employee.UpdateAddress(address.AddressId, AddressVO.Create(address.AddressLine1, address.AddressLine2, address.City, address.StateCode, address.Zipcode)); } else if (address.Status == RecordStatus.Deleted) { employee.DeleteAddress(address.AddressId); } } } if (model.Contacts != null && model.Contacts.Count > 0) { foreach (var contact in model.Contacts) { if (contact.Status == RecordStatus.New) { employee.AddContactPerson(0, PersonName.Create(contact.FirstName, contact.LastName, contact.MiddleInitial), PhoneNumber.Create(contact.Telephone), contact.Notes); } else if (contact.Status == RecordStatus.Modified) { employee.UpdateContactPerson(contact.PersonId, PersonName.Create(contact.FirstName, contact.LastName, contact.MiddleInitial), PhoneNumber.Create(contact.Telephone), contact.Notes); } if (contact.Status == RecordStatus.Deleted) { employee.DeleteContactPerson(contact.PersonId); } } } await unitOfWork.Commit(); }