Ejemplo n.º 1
0
 public void AddTaxToCity(string city, TaxScheduleEntry scheduleEntry)
 {
     if (scheduleDatabase.ContainsKey(city))
     {
         //existing city, add entry to existing schedule
         var schedule = scheduleDatabase[city];
         schedule.AddEntry(scheduleEntry);
     }
     else
     {
         //new city, new schedule, with one entry
         var schedule = new TaxSchedule(city);
         schedule.AddEntry(scheduleEntry);
         scheduleDatabase.Add(city, schedule);
     }
 }
Ejemplo n.º 2
0
        //here we make the tax calculation based on the narrowest range of dates from the list
        //tax could also be done by adding the rates of all the date ranges that match
        public double GetTax(DateTime queryDate)
        {
            DateRange        narrowestRange          = new DateRange(new DateTime(1, 1, 1), new DateTime(9999, 12, 31));
            TaxScheduleEntry entryWithNarrowestRange = null;

            foreach (var entry in scheduleEntryList)
            {
                if (TaxScheduleEntry.IsDateInRange(queryDate, entry.dateRange))
                {
                    if (entry.dateRange.TotalDays() < narrowestRange.TotalDays())
                    {
                        narrowestRange          = entry.dateRange;
                        entryWithNarrowestRange = entry;
                    }
                }
            }
            return(entryWithNarrowestRange == null? 0.0: entryWithNarrowestRange.GetTax(queryDate));
        }
Ejemplo n.º 3
0
 public void AddEntry(TaxScheduleEntry entry)
 {
     scheduleEntryList.Add(entry);
 }