private CreditAccountStateDto CloseAccount(CreditAccountDto account, CreditAccountStateDto latestCreditAccountState) { var accountCurrency = account.Currency; account.IsClosed = true; var updateCreditAccountCommand = new UpdateModelCommand <CreditAccountDto>() { ModelDto = account }; _creditAccountCommandRepository.Execute(updateCreditAccountCommand); var zeroPrice = new PriceDto() { Currency = accountCurrency, Value = 0m }; var closingCreditAccountState = new CreditAccountStateDto() { CreditAccount = account, FinesForOverdue = zeroPrice, InterestCounted = zeroPrice, MainDebtRemain = zeroPrice, RemainDebt = zeroPrice, Month = latestCreditAccountState.Month + 1, TotalInterestSumNotPaid = zeroPrice }; var newCreditAccountStateCommand = new CreateModelCommand <CreditAccountStateDto>() { ModelDto = closingCreditAccountState }; _creditAccountStateCommandRepository.Execute(newCreditAccountStateCommand); return(closingCreditAccountState); }
private static bool ShouldAccountUpdate(CreditAccountDto account, DateTime today) { return(account.AgreementDate.Date != today.Date && account.AgreementDate.Day == today.Day); }