public Billing GetBiller(String strategy) { TaxCalculatorFactory factory = new TaxCalculatorFactory(); ITaxCalculation taxCal = factory.GetTaxCalculator(strategy); return(new Billing(taxCal)); }
public HomeController(ISqlRepository sqlRepository, ITaxCalculation taxCalculation, IPublisher publisher) { _sqlRepository = sqlRepository; _taxCalculation = taxCalculation; _publisher = publisher; }
public AreaBase(AreaDefinition definition) { Definition = definition; if (Definition != null) { Calculation = TaxCalculationFactory.Instance.Create(Definition.CalKey); } if (null == Calculation) { throw new Exception("Calculation class error."); } }
public ITaxCalculation Create(string calKey) { ITaxCalculation calculation = null; Definition definition = Definitions.ContainsKey(calKey) ? Definitions[calKey] : null; try { calculation = ClassFactory.Create <ITaxCalculation>(definition, null); } catch { } return(calculation); }
public (ITaxCalculation calculator, ITaxSettings settings) GetCalculator(string postalCode) { var map = _context.CalculatorMappings.FirstOrDefault(m => m.PostalCode == postalCode); if (map == null) { throw new CalculationException("Unknown postal code, please first add that postal code"); } var objectType = Type.GetType(map.ClassName); ITaxCalculation obj = (ITaxCalculation)Activator.CreateInstance(objectType); var settings = new DictionaryTaxSettings(map.Settings); return(calculator : obj, settings : settings); }
protected void StatTax(ITaxCalculation taxCalculation) { Interlocked.Increment(ref m_stat_TaxCount); if (taxCalculation.RetailerTax != null) { m_stat_RetailerTaxAmounts.AddOrUpdate(taxCalculation.RetailerTax.CurrencyISO, taxCalculation.RetailerTax.Total, (k, v) => v + taxCalculation.RetailerTax.Total); } if (taxCalculation.WholesellerTax != null) { m_stat_WholesellerTaxAmounts.AddOrUpdate(taxCalculation.WholesellerTax.CurrencyISO, taxCalculation.RetailerTax.Total, (k, v) => v + taxCalculation.WholesellerTax.Total); } }
private ITaxCalculation GetCalculatorInternal(string postalCode) { if (_calculators.ContainsKey(postalCode)) { return(_calculators[postalCode]); } ITaxCalculation calculator; switch (postalCode) { case "7441": calculator = new ProgressiveTaxCalculation(); break; case "A100": calculator = new FlatValueCalculation(); break; case "7000": calculator = new FlatRateTaxCalculation(); break; case "1000": calculator = new ProgressiveTaxCalculation(); break; default: throw new CalculationException("Unknown postal code"); } _calculators[postalCode] = calculator; return(_calculators[postalCode]); }
public ITaxCalculation GetTaxCalculator(String strategy) { ITaxCalculation taxCalc = (ITaxCalculation)taxCalculators[strategy]; return(taxCalc); }
public void RegisterInFactory(string strategy, ITaxCalculation taxCalc) { taxCalculators.Add(strategy, taxCalc); }
public EmployeeModel() { objTaxCalculation = new TaxCalculation(); }
public Billing(ITaxCalculation taxCalc) { taxCalculator = taxCalc; }