Ejemplo n.º 1
0
        public Billing GetBiller(String strategy)
        {
            TaxCalculatorFactory factory = new TaxCalculatorFactory();
            ITaxCalculation      taxCal  = factory.GetTaxCalculator(strategy);

            return(new Billing(taxCal));
        }
Ejemplo n.º 2
0
 public HomeController(ISqlRepository sqlRepository,
                       ITaxCalculation taxCalculation,
                       IPublisher publisher)
 {
     _sqlRepository  = sqlRepository;
     _taxCalculation = taxCalculation;
     _publisher      = publisher;
 }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 6
0
        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);
            }
        }
Ejemplo n.º 7
0
        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]);
        }
Ejemplo n.º 8
0
        public ITaxCalculation GetTaxCalculator(String strategy)
        {
            ITaxCalculation taxCalc = (ITaxCalculation)taxCalculators[strategy];

            return(taxCalc);
        }
Ejemplo n.º 9
0
 public void RegisterInFactory(string strategy, ITaxCalculation taxCalc)
 {
     taxCalculators.Add(strategy, taxCalc);
 }
 public EmployeeModel()
 {
     objTaxCalculation = new TaxCalculation();
 }
Ejemplo n.º 11
0
 public Billing(ITaxCalculation taxCalc)
 {
     taxCalculator = taxCalc;
 }