Example #1
0
        internal void MakePayment(double amount, Account toBeDebited, Account toBeCredited, Transaction transaction, string remarks)
        {
            // Check if the transaction is possible

            // What is total transaction done till now
            double netAmount= amount;
            // add pervious entries
            foreach(DebitsCredits entry in transaction.DebitsCredits )
            {
                netAmount += (entry.Type)? entry.Amount: 0;
            }

            // net amount should not be more than amount
            if(netAmount > transaction.Amount)
            {
                throw new RuleViolation(string.Format("Amount {0} exceeds the transaction amount {1} by {2}", amount, transaction.Amount, amount - transaction.Amount));
            }

            // TODO start transaction
            DebitsCredits debit = new DebitsCredits(transaction, toBeDebited, amount, DebitsCreditsType.Debit);
            DebitsCredits credit = new DebitsCredits(transaction, toBeCredited, amount, DebitsCreditsType.Credit);

            transaction.Remarks += remarks;
            transaction.Status = (netAmount == transaction.Amount) ? TransactionStatus.Posted.ToString() : TransactionStatus.PartialPost.ToString();

            // TODO commit transaction
        }
Example #2
0
 public DebitsCredits( Transaction transaction, Account account, double amount, DebitsCreditsType type)
 {
     this.Transaction = transaction;
     this.Account = account;
     this.Amount = amount;
     this.Type = (type == DebitsCreditsType.Credit);
 }
Example #3
0
 /// <summary>
 /// Create a new Account object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="accountType">Initial value of the AccountType property.</param>
 /// <param name="accountNo">Initial value of the AccountNo property.</param>
 public static Account CreateAccount(global::System.Int32 id, global::System.String name, global::System.String accountType, global::System.String accountNo)
 {
     Account account = new Account();
     account.Id = id;
     account.Name = name;
     account.AccountType = accountType;
     account.AccountNo = accountNo;
     return account;
 }
Example #4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Accounts EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToAccounts(Account account)
 {
     base.AddObject("Accounts", account);
 }