Пример #1
0
        private void RemoveCOT(CustomerAccount customer, decimal amount)
        {
            var COT        = _configContext.GetCurrentConfig().COT;
            var cotValue   = CalculateCOT(COT, amount);
            var incomeGlId = _configContext.GetCurrentConfig().COTIncomeGlId;

            _customerAccountContext.DebitCustomer(customer, cotValue);
            CreditIncomeGl(incomeGlId, cotValue);

            //log transaction
            var COTPost = new COTPost
            {
                AccountToCreditId = incomeGlId,
                AccountToDebitId  = customer.Id,
                Amount            = cotValue,
                PostedAt          = DateTime.Now,
            };

            _COTPostContext.Add(COTPost);
            _COTPostContext.Save(COTPost);
        }
        public bool Withdrawal(decimal amount, int custId, int userId, TellerPosting tlPosting, DateTime date)
        {
            //Get teller till account
            var tillAccountId   = userId;
            var tillAccount     = _tillAccount.GetUserId(tillAccountId);
            var tillGlAccountId = tillAccount.AccountManagementId;
            var tellerGlAccount = _glContext.Get(tillGlAccountId);

            //Get Customer Account
            var CustomerAccount = _customer.Get(custId);
            var Amount          = amount;
            var CustomerId      = custId;
            var DatePosted      = date;



            if (CustomerAccount.AccountType == AccountType.Savings)
            {
                DebitCustomerAccount(Amount, custId, CustomerAccount);
                CreditGlAccount(Amount, tellerGlAccount);

                //Saving teller posting
                SavePost(tlPosting);

                return(true);
            }

            if (CustomerAccount.AccountType == AccountType.Current)
            {
                //Getting the Income COT Account
                var CurrentIncomeGl = _glContext.Get(_current.GetFirst().IncomeGlAccountId);


                //Getting Cot Values from the current account configuration
                var currentConfig = _current.GetFirst();
                var cot           = currentConfig.CommissionOnTurnover;

                var cotValue = calcCOT(cot, Amount);

                var isPossible = CheckWithdrawalPossible(cot, CustomerAccount.Balance, Amount);

                if (isPossible)
                {
                    DebitCustomerAccount(Amount + cotValue, CustomerId, CustomerAccount);
                    CreditGlAccount(Amount, tellerGlAccount);
                    CreditGlAccount(cotValue, CurrentIncomeGl);

                    //saving into database
                    SavePost(tlPosting);

                    //Loging values into database
                    var CotLog = new COTPost()
                    {
                        CustomerAccountId = CustomerId,
                        GlAccountId       = tillAccountId,
                        Amount            = Amount,
                        WhenPosted        = DatePosted
                    };


                    CustomerAccount.CotAccured += cotValue;

                    //Adding into customerAccount Entity
                    _context.Entry(CustomerAccount).State = EntityState.Modified;
                    _context.SaveChanges();


                    //Adding into COTPost Entity
                    _cotLogic.SavePost(CotLog);
                }
                else
                {
                    return(false);
                }
            }

            return(true);
        }
Пример #3
0
 public void SavePost(COTPost savePost)
 {
     //saving into the database
     _cot.Add(savePost);
     _cot.Save(savePost);
 }