Esempio n. 1
0
 /// <summary>
 /// Create a new DebitsCredits object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="amount">Initial value of the Amount property.</param>
 /// <param name="type">Initial value of the Type property.</param>
 public static DebitsCredits CreateDebitsCredits(global::System.Int32 id, global::System.Double amount, global::System.Boolean type)
 {
     DebitsCredits debitsCredits = new DebitsCredits();
     debitsCredits.Id = id;
     debitsCredits.Amount = amount;
     debitsCredits.Type = type;
     return debitsCredits;
 }
Esempio n. 2
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
        }
Esempio n. 3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the DebitsCredits EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToDebitsCredits(DebitsCredits debitsCredits)
 {
     base.AddObject("DebitsCredits", debitsCredits);
 }