public void CommitTransaction(ORMLibrary.Account debitAccount, ORMLibrary.Account creditAccount, decimal amount)
        {
            if (debitAccount.PlanOfAccount.AccountType == "P")
            {
                debitAccount.DebitValue += amount;
                debitAccount.Balance     = debitAccount.CreditValue - debitAccount.DebitValue;
            }
            else
            {
                debitAccount.CreditValue += amount;
                debitAccount.Balance      = debitAccount.DebitValue - debitAccount.CreditValue;
            }

            if (creditAccount.PlanOfAccount.AccountType == "P")
            {
                creditAccount.CreditValue += amount;
                creditAccount.Balance      = creditAccount.CreditValue - creditAccount.DebitValue;
            }
            else
            {
                creditAccount.DebitValue += amount;
                creditAccount.Balance     = creditAccount.DebitValue - creditAccount.CreditValue;
            }

            ORMLibrary.Transaction trs = new ORMLibrary.Transaction()
            {
                DebetAccountId  = debitAccount.Id,
                CreditAccountId = creditAccount.Id,
                Amount          = amount,
                TransactionDay  = CommonService.CurrentBankDay
            };

            Context.Transactions.Add(trs);
        }
 private ORMLibrary.Account CreateBaseAccounts(string accountPlanNumber, decimal debit, decimal credit)
 {
     ORMLibrary.Account account = new ORMLibrary.Account()
     {
         Balance       = credit - debit,
         CreditValue   = credit,
         DebitValue    = debit,
         PlanOfAccount = Context.PlanOfAccounts.FirstOrDefault(e => e.AccountNumber == accountPlanNumber),
         AccountNumber = GenerateAccountNumber(accountPlanNumber, 0)
     };
     return(account);
 }
        public AccountModel Create(AccountModel account, ClientModel client)
        {
            var plan = Context.PlanOfAccounts.FirstOrDefault(e => e.Id == account.PlanId);

            ORMLibrary.Account dbAccount = new ORMLibrary.Account()
            {
                AccountNumber = GenerateAccountNumber(plan.AccountNumber, client.Id),
                DebitValue    = account.DebitValue,
                CreditValue   = account.CreditValue,
                Balance       = account.DebitValue - account.CreditValue,
                PlanOfAccount = plan,
            };
            dbAccount = Context.Accounts.Add(dbAccount);
            Context.SaveChanges();
            return(Mapper.Map <ORMLibrary.Account, AccountModel>(dbAccount));
        }