001 /*
002 * Created on Aug 29, 2007
003 */
004 package com.x8ing.mc.bp;
005
006 import java.text.SimpleDateFormat;
007 import java.util.Calendar;
008
009 /**
010 * Implements a money transaction.
011 *
012 * @author Patrick Heusser
013 */
014 public class MoneyTransaction {
015
016 private String bookingDescription = null;
017
018 private Calendar transactionDate = null;
019
020 private double amount = 0;
021
022 private BalanceAccount balanceAccount = null;
023
024 /**
025 * @param bookingDescription
026 * @param transactionDate
027 * @param amount
028 */
029 public MoneyTransaction(String bookingDescription, Calendar transactionDate, double amount, BalanceAccount balanceAccount) {
030 super();
031 this.bookingDescription = bookingDescription;
032 this.transactionDate = (Calendar) transactionDate.clone();
033 this.amount = amount;
034 this.balanceAccount = balanceAccount;
035 }
036
037 /**
038 * @return Returns the amount.
039 */
040 public double getAmount() {
041 return amount;
042 }
043
044 /**
045 * @param amount
046 * The amount to set.
047 */
048 public void setAmount(double amount) {
049 this.amount = amount;
050 }
051
052 /**
053 * @return Returns the bookingDescription.
054 */
055 public String getBookingDescription() {
056 return bookingDescription;
057 }
058
059 /**
060 * @param bookingDescription
061 * The bookingDescription to set.
062 */
063 public void setBookingDescription(String bookingDescription) {
064 this.bookingDescription = bookingDescription;
065 }
066
067 /**
068 * @return Returns the transactionDate.
069 */
070 public Calendar getTransactionDate() {
071 return transactionDate;
072 }
073
074 /**
075 * @param transactionDate
076 * The transactionDate to set.
077 */
078 public void setTransactionDate(Calendar transactionDate) {
079 this.transactionDate = transactionDate;
080 }
081
082 public void toString(StringBuffer sb) {
083 SimpleDateFormat sdf = new SimpleDateFormat(Constants.GLOBAL_DATE_FORMAT);
084 sb.append(sdf.format(transactionDate.getTime()));
085 sb.append("amount:");
086 sb.append(amount);
087 sb.append("\t desc");
088 sb.append(bookingDescription);
089 sb.append(" account:" + balanceAccount.getName());
090 }
091
092 public String toString() {
093 StringBuffer sb = new StringBuffer();
094 toString(sb);
095 return sb.toString();
096 }
097
098 public BalanceAccount getBalanceAccount() {
099 return balanceAccount;
100 }
101
102 public void setBalanceAccount(BalanceAccount balanceAccount) {
103 this.balanceAccount = balanceAccount;
104 }
105 }
|