예제 #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
        }
예제 #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);
 }
예제 #3
0
        internal Transaction CreatePaymentSlip(TransactionType transactionType, double amount, string remarks, User user, DateTime? dueDate)
        {
            // Start transaction
            var retVal = new Transaction();
            retVal.TransactionType = transactionType;
            retVal.Amount = amount;
            retVal.CreationDate = DateTime.Now;
            retVal.Remarks = remarks;
            retVal.DueDate = dueDate;
            retVal.Status = TransactionStatus.Pending.ToString();

            retVal.TransactionNo = Context.Instance.Group.NewTransactionNo();

            //TODO save transaction

            return retVal;
        }
예제 #4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Transactions EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToTransactions(Transaction transaction)
 {
     base.AddObject("Transactions", transaction);
 }
예제 #5
0
 /// <summary>
 /// Create a new Transaction object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="creationDate">Initial value of the CreationDate property.</param>
 /// <param name="transactionDate">Initial value of the TransactionDate property.</param>
 /// <param name="transactionNo">Initial value of the TransactionNo property.</param>
 /// <param name="amount">Initial value of the Amount property.</param>
 /// <param name="status">Initial value of the Status property.</param>
 public static Transaction CreateTransaction(global::System.Int32 id, global::System.DateTime creationDate, global::System.DateTime transactionDate, global::System.String transactionNo, global::System.Double amount, global::System.String status)
 {
     Transaction transaction = new Transaction();
     transaction.Id = id;
     transaction.CreationDate = creationDate;
     transaction.TransactionDate = transactionDate;
     transaction.TransactionNo = transactionNo;
     transaction.Amount = amount;
     transaction.Status = status;
     return transaction;
 }