Exemplo n.º 1
0
        public async Task <LevyDeclaration> Get(LevyDeclarationModel updateModel)
        {
            var model = await _dataSession.GetBySubmissionId(updateModel.SubmissionId) ??
                        updateModel;

            return(new LevyDeclaration(_payrollDateService, model));
        }
 public void Store(LevyDeclarationModel levyDeclaration)
 {
     //TODO: assumes all entities were originally retreived from the data context if Id > 0
     if (levyDeclaration.Id <= 0)
     {
         _dataContext.LevyDeclarations.Add(levyDeclaration);
     }
 }
        public async Task <LevySelectionOrchestratorResponse> SaveSelectionAsync(LevyDeclarationModel viewModel, ClaimsPrincipal user)
        {
            if (viewModel.ConfirmAsLevyPayer.Value)
            {
                await _client.SaveLevyDeclarationAsync(user.GetUserId(), viewModel.EmployerAccountId);
            }

            return(new LevySelectionOrchestratorResponse
            {
                RedirectRouteName = viewModel.ConfirmAsLevyPayer.Value ? RouteNames.Dashboard_Index_Get : RouteNames.NonLevyInfo_Get,
                CreateLevyCookie = viewModel.ConfirmAsLevyPayer.Value
            });
        }
 public void SetUp()
 {
     _moqer = new AutoMoqer();
     _moqer.GetMock <IPayrollDateService>()
     .Setup(svc => svc.GetPayrollDate(It.IsAny <string>(), It.IsAny <short>()))
     .Returns(DateTime.Today);
     _model = new LevyDeclarationModel
     {
         EmployerAccountId = 12345,
         Id           = 99,
         Scheme       = "ABC/123",
         PayrollMonth = 1,
         PayrollYear  = "18-19",
     };
     _moqer.SetInstance(_model);
 }
        private static LevyDeclarationModel MapLevySchemeDeclarationUpdatedMessageToLevyDeclarationModel(
            LevySchemeDeclarationUpdatedMessage levySchemeDeclaration)
        {
            var declaration = new LevyDeclarationModel
            {
                EmployerAccountId  = levySchemeDeclaration.AccountId,
                TransactionDate    = levySchemeDeclaration.CreatedDate,
                LevyAmountDeclared = levySchemeDeclaration.LevyDeclaredInMonth,
                SubmissionId       = levySchemeDeclaration.SubmissionId,
                PayrollMonth       = (byte)levySchemeDeclaration.PayrollMonth,
                PayrollYear        = levySchemeDeclaration.PayrollYear,
                Scheme             = levySchemeDeclaration.EmpRef
            };

            return(declaration);
        }
Exemplo n.º 6
0
        public async Task <IActionResult> Options(string employerAccountId, LevyDeclarationModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }

            var response = await _orchestrator.SaveSelectionAsync(viewModel, User);

            if (response.CreateLevyCookie)
            {
                SetLevyDeclarationCookie(User, employerAccountId);
            }

            return(RedirectToRoute(response.RedirectRouteName));
        }
Exemplo n.º 7
0
        public void ThereWillRecordInTheStorageWithNoSensitiveData(long substitutionId)
        {
            LevyDeclarationModel declaration = null;

            WaitForIt(() =>
            {
                var parameters = new DynamicParameters();
                parameters.Add("@employerAccountId", substitutionId, DbType.Int64);

                var declarations = Connection.Query <LevyDeclarationModel>("select * from LevyDeclaration where EmployerAccountId = @employerAccountId"
                                                                           , param: parameters, commandType: CommandType.Text);

                declaration = declarations.FirstOrDefault();

                return(declaration != null);
            });

            declaration.Should().NotBeNull();
        }
Exemplo n.º 8
0
        public void ThereWillBeThreeRecordsInTheStorage(long employerId)
        {
            LevyDeclarationModel declaration = null;

            WaitForIt(() =>
            {
                var parameters = new DynamicParameters();
                parameters.Add("@employerAccountId", employerId, DbType.Int64);

                var declarations = Connection.Query <LevyDeclarationModel>("select * from LevyDeclaration where EmployerAccountId = @employerAccountId"
                                                                           , param: parameters, commandType: CommandType.Text);

                declaration = declarations.FirstOrDefault();

                return(declaration != null);
            });

            declaration.Should().NotBeNull();

            declaration.PayrollYear.Should().EndWith("17-18");
            declaration.LevyAmountDeclared.Should().Be(8811M);
            declaration.TransactionDate.Should().BeCloseTo(DateTime.Now, precision: 60 * 1000);
        }
 public LevyDeclaration(IPayrollDateService payrollDateService, LevyDeclarationModel model)
 {
     Model = model ?? throw new ArgumentNullException(nameof(model));
     _payrollDateService = payrollDateService ?? throw new ArgumentNullException(nameof(payrollDateService));
     _levyDeclarationTransactionDateValidator = new LevyDeclarationTransactionDateValidator();
 }