private bool ExecuteTaxCalculation(bool hasChanged, TaxIndicatorViewModel item) { TaxFormula taxFormula = null; try { if (string.IsNullOrEmpty(item.IndicatorFormula)) { item.SetError("formula goala"); } taxFormula = new TaxFormula(item.IndicatorFormula); } catch (Exception ex) { item.SetError("eroare la interpretarea formulei"); } try { var newValue = taxFormula.Execute(TaxIndicators.ToList()).ToString(); if (item.ValueField != newValue) { hasChanged = true; } item.ValueField = newValue; } catch (Exception ex) { item.SetError("formula invalida"); } return hasChanged; }
private TaxIndicatorViewModel GetEmptyRow(int? id) { TaxIndicatorViewModel newItem = new TaxIndicatorViewModel(); newItem.NrCrt = id; newItem.Type = TaxIndicatorType.Numeric; newItem.TypeDescription = newItem.Type.ToString(); newItem.Description = ""; newItem.IndicatorFormula = ""; newItem.ValueFieldNumeric = 0; newItem.Style = VmUtils.GetStyleInfo(newItem.Type); return newItem; }
private bool ExecuteTaxCalculation(bool hasChanged, TaxIndicatorViewModel item) { hasChanged = false; TaxFormula taxFormula = null; item.IsIndicatorValid(); taxFormula = new TaxFormula(item.IndicatorFormula); var newValueString = DecimalConvertor.Instance.DecimalToString(taxFormula.Execute(TaxIndicators.ToList()), 0); if (item.ValueField != newValueString) { hasChanged = true; } item.ValueField = newValueString; return hasChanged; }
private bool ExecuteTaxCalculation(bool hasChanged, TaxIndicatorViewModel item) { TaxFormula taxFormula = null; try { if (string.IsNullOrEmpty(item.IndicatorFormula)) { item.SetError("formula goala"); } taxFormula = new TaxFormula(item.IndicatorFormula); } catch (Exception ex) { //item.SetError(Constants.RulesText); item.SetError("eroare la interpretarea formulei"); } try { var newValueString = DecimalConvertor.Instance.DecimalToString(taxFormula.Execute(TaxIndicators.ToList()), nrDecimals); //var newValue = taxFormula.Execute(TaxIndicators.ToList()).ToString(); if (item.ValueField != newValueString) { hasChanged = true; } newValueString = newValueString.Replace(".", string.Empty); item.ValueField = newValueString; } catch (Exception ex) { item.SetError("formula invalida"); } return hasChanged; }
public static TaxIndicatorViewModel ToVm(this CompletedIndicatorVm item) { if (item.Value != null) item.Value = item.Value.Replace(".", string.Empty); var result = new TaxIndicatorViewModel() { NrCrt = string.IsNullOrEmpty(item.NrCrt) ? new Nullable<int>() : Convert.ToInt32(item.NrCrt), Description = item.Description, ValueField = item.Value, Type = item.Type, InnerId = item.InnerId, Style = VmUtils.GetStyleInfo(item.Type), IndicatorFormula = item.IndicatorFormula }; //result.ValueField= return result; }
public static TaxIndicatorViewModel ToVm(this TaxIndicator item) { var result = new TaxIndicatorViewModel() { NrCrt = item.NrCrt, Description = item.Description, TypeDescription = item.TypeDescription, IndicatorFormula = item.IndicatorFormula, Type = VmUtils.GetIndicatorType(item.TypeDescription), Style = VmUtils.GetStyleInfo(VmUtils.GetIndicatorType(item.TypeDescription)), InnerId = item.InnerId, InitialNrCrt = item.InitialNrCrt, InitialType = item.InitialType }; result.UpdateEnabledState(); return result; }