public RetailCalculatorService(
     PriceCalculationService calculator,
     DiscountCalculationService discountCalculator,
     TaxCalculationService taxCalculator)
 {
     Calculator         = calculator;
     DiscountCalculator = discountCalculator;
     TaxCalculator      = taxCalculator;
 }
Example #2
0
        public void ShouldCalculateTaxAndPerist()
        {
            var calculatedTaxEntity = new CalculatedTaxEntity("PostalCode", 5m);
            var calculatedTax       = fixture.Create <decimal>();

            mocktaxTypeCalculatorStrategy.Setup(x => x.Invoke(It.IsAny <string>())).Returns(mockTaxTypeCalculator.Object);
            mockTaxTypeCalculator.Setup(x => x.CalulateTax(It.IsAny <decimal>())).Returns(calculatedTax);
            mockCalculatedTaxRepostiory.Setup(x => x.Add(It.IsAny <CalculatedTaxEntity>())).Returns(calculatedTaxEntity);

            taxCalculationService = new TaxCalculationService(mocktaxTypeCalculatorStrategy.Object, mockCalculatedTaxRepostiory.Object);
            taxCalculationService.CalculateTax(calculatedTaxEntity);

            mockCalculatedTaxRepostiory.Verify(x => x.Add(It.Is <CalculatedTaxEntity>(y => y.CalculatedTaxAmount == calculatedTax)), Times.Once);
        }
        public TaxCalculationServiceTests()
        {
            var config           = InitConfiguration();
            var taxConfig        = config.GetSection("Tax").Get <Tax>();
            var taxConfigOptions = Options.Create(taxConfig);

            var insuranceConfig        = config.GetSection("Insurance").Get <Insurance>();
            var insuranceConfigOptions = Options.Create(insuranceConfig);

            var reductionConfig        = config.GetSection("Reduction").Get <Reduction>();
            var reductionConfigOptions = Options.Create(reductionConfig);

            taxCalculationService = new TaxCalculationService(taxConfigOptions, insuranceConfigOptions, reductionConfigOptions);
        }
        public void Calculatetax()
        {
            var price    = 2f;
            var state    = "AA";
            var expected = 2.2f;
            var options  = new TaxOptions
            {
                Taxes = new Dictionary <string, float> {
                    [state] = 0.1f
                }
            };
            var sut = new TaxCalculationService(options);

            Assert.Equal(expected, sut.CalculateTaxes(price, state));
        }
Example #5
0
        private static void SeedPayments()
        {
            var random     = new Random();
            var taxService = new TaxCalculationService();

            using (var db = new AppDbContext())
            {
                var employees = db.Employees.ToList();
                foreach (var employee in employees)
                {
                    for (var i = 59; i > 1; i = i - 2)
                    {
                        var grosspay   = (decimal)Math.Round(random.NextDouble() * 1000, 2);
                        var deductions = taxService.GetDeductions(employee, grosspay);
                        var payment    = new Payment
                        {
                            EmpId             = employee.Id,
                            GrossPay          = grosspay,
                            PaymentPeriodFrom = DateTime.Now.AddDays(-i * 7 + 1),
                            PaymentPeriodTo   = DateTime.Now.AddDays(-(i - 2) * 7),
                            FedTax            = deductions.FedTax,
                            StateTax          = deductions.StateTax,
                            Insurance         = deductions.Insurance,
                            SocialSecurityTax = deductions.SocialSecurityTax,
                            MedicareTax       = deductions.MedicareTax,
                            Retirement401K    = deductions.Retirement401K,
                            NetPay            = deductions.NetPay,
                            CreateDateTime    = DateTime.Now.AddDays((-(i - 2) * 7) + 1)
                        };
                        // add only if valid payment
                        if (payment.NetPay > 0)
                        {
                            db.Payments.Add(payment);
                        }
                    }
                }
                db.SaveChanges();
            }
        }
Example #6
0
        public float CalculateTaxes(PDVCalculation data)
        {
            TaxCalculationService service = new TaxCalculationService();

            return(service.CalculateTaxes(data.Cijena, data.Drzava, data.PDV));
        }
Example #7
0
 public TaxCalculatorController(IConfiguration configuration,
                                TaxCalculationService <TaxCalculationViewModel, TaxCalculation> taxCalculationService)
 {
     Configuration          = configuration;
     _taxCalculationService = taxCalculationService;
 }
Example #8
0
 public TaxController(TaxCalculationService taxCalculationService)
 {
     _taxCalculationService = taxCalculationService;
 }