/// <summary> /// Converts a line from a CSV file into a <see cref="TaxRateItem"/>. /// </summary> /// <param name="line"></param> /// <returns></returns> private static TaxRateItem ToTaxRateItem(string line) { var parts = line.Split(new char[] { ',', '\t' }, StringSplitOptions.None); var taxRateItem = new TaxRateItem { Name = parts[0], LocationCode = parts[1], State = float.Parse(parts[2]), Local = float.Parse(parts[3]), Rta = float.Parse(parts[4]), Rate = float.Parse(parts[5]), EffectiveDate = DateTime.ParseExact(parts[6], _date_format, DateTimeFormatInfo.CurrentInfo), ExpirationDate = DateTime.ParseExact(parts[7], _date_format, DateTimeFormatInfo.CurrentInfo), }; // Add leading zero to location code if necessary. if (taxRateItem.LocationCode.Length < 4) { var zeroCount = 4 - taxRateItem.LocationCode.Length; var sb = new StringBuilder(taxRateItem.LocationCode); for (int i = 0; i < zeroCount; i++) { sb.Insert(0, '0'); } taxRateItem.LocationCode = sb.ToString(); } return(taxRateItem); }
public Revenue(CurrencyValue gross, DateTimeWithTimeZone accepted = null, CurrencyValue notTaxable = null, TaxRateItem lowerTaxRate = null, TaxRateItem reducedTaxRate = null, TaxRateItem standardTaxRate = null, CurrencyValue travelServices = null, CurrencyValue deposit = null, CurrencyValue usedDeposit = null) { Accepted = accepted ?? DateTimeProvider.Now; Gross = gross; NotTaxable = notTaxable; LowerTaxRate = lowerTaxRate; ReducedTaxRate = reducedTaxRate; StandardTaxRate = standardTaxRate; TravelServices = travelServices; Deposit = deposit; UsedDeposit = usedDeposit; }
public static bool IsDefined(this TaxRateItem item) { return(item != null); }
public static decimal GetOrDefault(this TaxRateItem item, Func <TaxRateItem, CurrencyValue> valueSelector) { return(IsValueDefined(item, valueSelector) ? valueSelector(item).GetOrDefault() : default(decimal)); }
public static bool IsValueDefined(this TaxRateItem item, Func <TaxRateItem, CurrencyValue> valueSelector) { return(item.IsDefined() && valueSelector(item).IsDefined()); }