private List <DasDeclaration> CreateDasDeclarations(GetHMRCLevyDeclarationResponse levyDeclarationQueryResult) { var declarations = new List <DasDeclaration>(); foreach (var declaration in levyDeclarationQueryResult.LevyDeclarations.Declarations) { _logger.Debug($"Creating Levy Declaration with submission Id {declaration.SubmissionId} from HMRC query results"); var dasDeclaration = new DasDeclaration { SubmissionDate = declaration.SubmissionTime, Id = declaration.Id, PayrollMonth = declaration.PayrollPeriod?.Month, PayrollYear = declaration.PayrollPeriod?.Year, LevyAllowanceForFullYear = declaration.LevyAllowanceForFullYear, LevyDueYtd = declaration.LevyDueYearToDate, NoPaymentForPeriod = declaration.NoPaymentForPeriod, DateCeased = declaration.DateCeased, InactiveFrom = declaration.InactiveFrom, InactiveTo = declaration.InactiveTo, SubmissionId = declaration.SubmissionId }; declarations.Add(dasDeclaration); } return(declarations); }
public static GetHMRCLevyDeclarationResponse Create(string empref = "123avc") { var declarationResponse = new GetHMRCLevyDeclarationResponse { Empref = empref, LevyDeclarations = DeclarationsObjectMother.Create(empref) }; return(declarationResponse); }
public void WhenIGetTheFollowingDeclarationsFromHMRC(Table table) { var groups = table.Rows.GroupBy(row => row["PAYEScheme"]).ToList(); var hmrcResponses = new List <GetHMRCLevyDeclarationResponse>(); foreach (var levyGroup in groups) { var response = new GetHMRCLevyDeclarationResponse { Empref = levyGroup.Key, LevyDeclarations = new LevyDeclarations { EmpRef = levyGroup.Key, Declarations = levyGroup.Select(row => new Declaration { Id = row["Id"], SubmissionId = string.IsNullOrEmpty(row["SubmissionId"]) ? 0 : Convert.ToInt64(row["SubmissionId"]), DateCeased = string.IsNullOrEmpty(row["DateCeased"]) ? default(DateTime) : Convert.ToDateTime(row["DateCeased"]), LevyDueYearToDate = string.IsNullOrEmpty(row["LevyDueYTD"]) ? 0 : Convert.ToDecimal(row["LevyDueYTD"]), NoPaymentForPeriod = !string.IsNullOrEmpty(row["NoPaymentForPeriod"]) && Convert.ToBoolean(row["NoPaymentForPeriod"]), SubmissionTime = row["SubmissionTime"], LevyAllowanceForFullYear = string.IsNullOrEmpty(row["LevyAllowanceForFullYear"]) ? 0 : Convert.ToDecimal(row["LevyAllowanceForFullYear"]), PayrollPeriod = new PayrollPeriod { Month = Convert.ToInt16(row["PayrollMonth"]), Year = row["PayrollPeriod"] } }).ToList() } }; hmrcResponses.Add(response); _levyWorkerSteps.RunWorker(hmrcResponses); } }