예제 #1
0
        //public void CurrentAccountCotRate()
        //{
        //    var month = financialDate.Month;
        //    var currentAccounts = _customerAccount.GetByAccountType(AccountType.Current);
        //    var currentConfig = _current.GetFirst();

        //    var COTGl = _glAccount.Get(currentConfig.IncomeGlAccountId);
        //    if (currentAccounts != null)
        //    {
        //        if (financialDate.Day == daysInMonth[month - 1])
        //        {
        //            foreach (var account in currentAccounts)
        //            {
        //                _post.DebitCustomerAccount(account.CotAccured, account.Id, account);
        //                _post.CreditGlAccount(account.CotAccured, COTGl);

        //                account.CotAccured = 0;
        //                _customerAccount.Save(account);
        //            }
        //        }
        //    }
        //}

        public void LoanAccountInterestRate()
        {
            var loanConfig = _loan.GetFirst();
            var loanAcct   = _loanAccount.GetAll();

            if (loanAcct != null)
            {
                var interestIncomeGlAccount = _glAccount.Get(loanConfig.IncomeGlAccountId);


                foreach (var account in loanAcct)
                {
                    var loanAccountId   = _customerAccount.GetByAccountNumber(account.AccountNumber);
                    var customerAccount = _customerAccount.Get(account.CustomerAccountId);

                    if (account.DurationInMonths * 30 != account.DaysCount)
                    {
                        //payment of interest
                        _post.CreditGlAccount(account.InterestDeduction, interestIncomeGlAccount);
                        _post.DebitCustomerAccount(account.InterestDeduction, account.CustomerAccountId, customerAccount);

                        account.InterestRemaining -= account.InterestDeduction;


                        //paying daily loan back
                        _post.DebitCustomerAccount(account.DailyLoanDeduction, account.CustomerAccountId, customerAccount);
                        _post.CreditCustomerAccount(account.DailyLoanDeduction, loanAccountId.Id, loanAccountId);

                        account.LoanBalance -= account.DailyLoanDeduction;

                        _loanAccount.Save(account);
                    }

                    if (account.DurationInMonths * 30 == account.DaysCount)
                    {
                        account.Status    = false;
                        account.DaysCount = 0;
                    }

                    //increases days if loan payment not reached
                    if (account.DurationInMonths * 30 != account.DaysCount)
                    {
                        account.DaysCount++;
                    }

                    _loanAccount.Update(account);
                }
            }
        }