///<inheritdoc/> public async Task <CalculateInssResult> CalculateInss(InssType type, decimal revenue, DateTime?date, CancellationToken cancellationToken = default) { CalculateInssResult result = null; InssTax inss = await _inssRepository.GetActive(type, date, cancellationToken); if (inss != null) { InssTaxRange range = inss .Range .OrderByDescending(o => o.EndValue) .FirstOrDefault(x => (revenue >= x.StartValue && revenue <= x.EndValue) || revenue >= x.EndValue); if (range != null) { result = new CalculateInssResult(); decimal value = (revenue * range.Rate / 100); value -= range.DeductedAmount; if (value > inss.Limit) { value = inss.Limit; result.IsLimit = true; } value = Math.Round(value, 2); result.Rate = range.Rate; result.Amount = value; } } return(result); }
public async Task <IActionResult> CalculateInss ( [FromServices] ILogger <LaborTaxesController> logger, [FromServices] ILaborTaxesService service, [FromBody] CalculateInssRequest request, [FromQuery] DateTime?date, CancellationToken cancellationToken = default ) { CalculateInssResult resp = await service.CalculateInss(request.Type.Value, request.Revenue, date, cancellationToken); if (resp == null) { return(NotFound(resp)); } return(Ok(resp)); }
/// <summary> /// Map CalculateInssResult to CalculateInssReply /// </summary> /// <param name="result">Object to map</param> public static CalculateInssReply MapResult(this CalculateInssResult result) => new()