Пример #1
0
        public async Task <OperationResult <TaxCalculationResponse> > CalculateTax(TaxCalculationRequest request)
        {
            OperationResult <TaxCalculationResponse> validatorResult = _validationRuleEngine.Validate(request);

            if (validatorResult.HasErrors)
            {
                return(validatorResult);
            }

            var calculationTypeMapping = await _calculationMappingRepository.GetByPostalCodeAsync(request.PostalCode).ConfigureAwait(false);

            var taxCalculator = _taxCalculatorFactory.GetCalculator(calculationTypeMapping.CalculationType);
            var taxYear       = await _taxYearRepository.GetTaxYearAsync(_clock.GetCurrentDateTime()).ConfigureAwait(false);

            var taxAmountResult = await taxCalculator.CalculateTaxAsync(taxYear, request.AnnualIncome).ConfigureAwait(false);

            if (taxAmountResult.HasErrors)
            {
                return(taxAmountResult.MapErrors <TaxCalculationResponse>());
            }

            var response = new TaxCalculationResponse
            {
                TaxYear         = taxYear.ToString(),
                CalculationType = calculationTypeMapping.CalculationType,
                TaxAmount       = taxAmountResult.Response
            };

            await SaveCalculation(request, response, taxYear);

            return(new OperationResult <TaxCalculationResponse>(response));
        }
Пример #2
0
        public OperationResult <TaxCalculationResponse> Validate(TaxCalculationRequest request)
        {
            var operationResult = new OperationResult <TaxCalculationResponse>();
            var taxYear         = _taxYear.GetTaxYearAsync(_clock.GetCurrentDateTime()).Result;

            if (taxYear == null)
            {
                operationResult.AddErrorMessage(string.Empty, "Tax year was not found for today's date.");
                return(operationResult);
            }

            return(operationResult);
        }
        public void SaveEvents(
            IMutualFundDomainEvent[] mutualFundDomainEvent)
        {
            var mutualFundEvenDtos = new List <MutualFundEvenDto>();

            foreach (var fundDomainEvent in mutualFundDomainEvent)
            {
                var mutualFundEvenDto = new MutualFundEvenDto()
                {
                    EventType     = fundDomainEvent.EventType,
                    EffectiveDate = fundDomainEvent.EffectiveDate,
                    Priority      = fundDomainEvent.Priority,
                    TickerSymbol  = fundDomainEvent.TickerSymbol,
                    JsonPayload   = fundDomainEvent.GetJsonPayload(),
                    DateCreated   = _clock.GetCurrentDateTime()
                };

                mutualFundEvenDtos.Add(mutualFundEvenDto);
            }

            _mutualFundEvenDataTableGateway.Insert(
                mutualFundEvenDtos.ToArray());
        }
Пример #4
0
 public string Format(string message)
 {
     return(_clock.GetCurrentDateTime() + " > " + message);
 }