public Tax ValidateItem(Tax tax)
        {
            decimal amount;
            var invalid = new InvalidTax(tax);
            var valid = new ValidTax(tax);

            if (tax == null)
                return invalid;

            if (string.IsNullOrEmpty(tax.Account))
            {
                invalid.AccountMessage = "Account field is empty";
                return invalid;
            }

            if (string.IsNullOrEmpty(tax.Description))
            {
                invalid.DescriptionMessage = "Description field is empty";
                return invalid;
            }

            if (string.IsNullOrEmpty(tax.CurrencyCode))
            {
                invalid.CurrencyCodeMessage = "Currency Code field is empty";
                return invalid;
            }

            if (string.IsNullOrEmpty(tax.Amount))
            {
                invalid.AmountMessage = "Amount field is empty";
                return invalid;
            }

            var currency = Iso4217Lookup.LookupByCode(tax.CurrencyCode);
            if (!currency.Found)
            {
                invalid.CurrencyCodeMessage = "Currency Code value is invalid:" +
                                               "must be a valid ISO 4217 currency code ";
                return invalid;
            }

            if (!decimal.TryParse(tax.Amount, out amount))
            {
                invalid.CurrencyCodeMessage = "Amount value is invalid:" +
                                                "must be a valid number";
                return invalid;
            }

            return valid;
        }
        public IEnumerable<Tax> Parse(string path)
        {
            string line;
            var taxes = new List<Tax>();

            using (var file = new StreamReader(path))
            {
                file.ReadLine();
                while ((line = file.ReadLine()) != null)
                {
                    var tax = new Tax();
                    var values = line.Split(',');

                    if (values.Length > 0)
                        tax.Account = values[0].Trim();

                    if (values.Length > 1)
                        tax.Description = values[1].Trim();

                    if (values.Length > 2)
                        tax.CurrencyCode = values[2].Trim();

                    if (values.Length > 3)
                    {
                        decimal amount;
                        decimal.TryParse(values[3], out amount);
                        tax.Amount = values[3];
                    }

                    taxes.Add(tax);
                }

                file.Close();
            }

            return taxes;
        }
        public IEnumerable<Tax> Parse(string path)
        {
            var taxes = new List<Tax>();
            using (var stream = File.Open(path, FileMode.Open, FileAccess.Read))
            {
                IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
                excelReader.Read();

                while (excelReader.Read())
                {
                    var tax = new Tax();

                    tax.Account = excelReader.GetString(0);
                    tax.Description = excelReader.GetString(1);
                    tax.CurrencyCode = excelReader.GetString(2);
                    tax.Amount = excelReader.GetString(3);

                    if (!string.IsNullOrEmpty(tax.Account))
                        tax.Account.Trim();

                    if (!string.IsNullOrEmpty(tax.Description))
                        tax.Description.Trim();

                    if (!string.IsNullOrEmpty(tax.CurrencyCode))
                        tax.CurrencyCode.Trim();

                    if (!string.IsNullOrEmpty(tax.Amount))
                        tax.Amount.Trim();

                    taxes.Add(tax);
                }

                excelReader.Close();
            }

            return taxes;
        }
 public bool Update(Tax tax)
 {
     return _repository.Update(tax);
 }