public async Task <string> GetValueFormula(string formula, string codeProduct, string codeRecipe)
        {
            string newFormula = "";

            List <string> variablesList = _helperService.GetListString(formula, "[", "]");

            newFormula = formula;
            foreach (string item in variablesList)
            {
                var recipe = await _unitOfWork.AppRecipesRepository.GetListRecipesByProductCodeVariableCode(codeProduct, item);

                if (recipe != null && recipe.Count > 0)
                {
                    var totalCost = recipe.Select(c => c.TotalCost).Sum();

                    newFormula = newFormula.Replace("[" + item + "]", totalCost.ToString());
                }
                else
                {
                    var configApp = await _unitOfWork.AppConfigAppRepository.GetByKey(item);

                    if (configApp != null)
                    {
                        newFormula = newFormula.Replace("[" + item + "]", configApp.Valor.ToString());
                    }
                }
            }


            return(newFormula);
        }
        public async Task <string> GetValueFormula(string formula, int appDetailQuotesId, string code)
        {
            string newFormula = "";

            List <string> variablesList = _helperService.GetListString(formula, "[", "]");

            newFormula = formula;
            foreach (string item in variablesList)
            {
                var detailQuotes = await _unitOfWork.AppDetailQuotesConversionUnitRepository.GetByAppDetailQuotesIdCode(appDetailQuotesId, item);

                if (detailQuotes != null)
                {
                    var variable = await _unitOfWork.AppVariablesRepository.GetByCode(item);

                    if (variable != null)
                    {
                        if (variable.Entero)
                        {
                            newFormula = newFormula.Replace("[" + item + "]", Math.Truncate((decimal)detailQuotes.Value).ToString());
                        }
                        else
                        {
                            newFormula = newFormula.Replace("[" + item + "]", detailQuotes.Value.ToString());
                        }
                    }
                }
                else
                {
                    var configApp = await _unitOfWork.AppConfigAppRepository.GetByKey(item);

                    if (configApp != null)
                    {
                        newFormula = newFormula.Replace("[" + item + "]", configApp.Valor.ToString());
                    }
                }
            }


            return(newFormula);
        }