Esempio n. 1
0
        public static CouncilTaxDetailsModel MapAccount(
            this CouncilTaxAccountResponse accountResponse,
            CouncilTaxDetailsModel model,
            int taxYear)
        {
            model.PersonName            = $"{accountResponse.PersonName.Forenames} {accountResponse.PersonName.Surname}";
            model.PaymentMethod         = accountResponse.AccountDetails.ActPayGrp.PaymentMethod.Contains("DD") ? "Direct Debit" : string.Empty;
            model.IsDirectDebitCustomer = accountResponse.AccountDetails.ActPayGrp.IsDirectDebit();
            model.AmountOwing           = accountResponse.CouncilTaxAccountBalance;
            model.YearTotals            = accountResponse.FinancialDetails.YearTotals;
            model.Reference             = accountResponse.CouncilTaxAccountReference;
            model.PaymentSummary        = accountResponse.FinancialDetails
                                          .YearTotals?
                                          .FirstOrDefault()?
                                          .YearSummaries?
                                          .FirstOrDefault()?
                                          .NextPayment ?? new PaymentSummaryResponse();
            model.AccountName   = accountResponse.AccountDetails.BankDetails?.AccountName;
            model.AccountNumber = accountResponse.AccountDetails.BankDetails?.AccountNumber;
            model.IsFinalNotice = accountResponse.FinancialDetails.YearTotals?.FirstOrDefault()?.YearSummaries.Any(x => !ValidAccountStages.Contains(x.Stage.StageCode));
            model.IsClosed      = accountResponse.CtxActClosed == "TRUE";
            model.HasSpar       = accountResponse.FinancialDetails.YearTotals?.FirstOrDefault(_ => _.TaxYear == taxYear)?.SparNo != 0;

            return(model);
        }
Esempio n. 2
0
        public static CouncilTaxDetailsModel MapAccounts(
            this List <CtaxActDetails> accountsResponse,
            CouncilTaxDetailsModel model)
        {
            model.Accounts = accountsResponse.Select(_ => new CouncilTaxAccountDetails
            {
                Reference = _.CtaxActRef,
                Address   = _.CtaxActAddress,
                Balance   = _.CtaxBalance,
                Status    = _.AccountStatus
            }).ToList();

            return(model);
        }
Esempio n. 3
0
        public static CouncilTaxDetailsModel DocumentsMapper(
            this List <CouncilTaxDocumentReference> documentResponse,
            CouncilTaxDetailsModel model,
            int taxYear)
        {
            model.Documents = documentResponse
                              .Where(_ => _.AccountReference == model.Reference)
                              .Select(_ => new CouncilTaxDocument
            {
                AccountReference = _.AccountReference,
                DateCreated      = _.DateCreated,
                DocumentId       = _.DocumentId,
                DocumentName     = _.DocumentName,
                DocumentType     = _.DocumentType,
                Downloaded       = _.Downloaded
            }).ToList();

            if (model.Documents != null)
            {
                var documentsForCurrentTaxYear = model.Documents.Where(_ =>
                {
                    DateTime.TryParse(_.DateCreated, new CultureInfo("en-GB"), DateTimeStyles.AssumeLocal, out var dateCreated);

                    var year = dateCreated.Month < 3 ? dateCreated.Year - 1 : dateCreated.Year;

                    return(year == taxYear);
                });

                var latestDocument = documentsForCurrentTaxYear.OrderByDescending(_ => _.DateCreated).FirstOrDefault();

                model.LatestBillId = latestDocument?.DocumentId ?? string.Empty;
            }
            else
            {
                model.LatestBillId = string.Empty;
            }

            return(model);
        }