PK R: META-INF/PK R:ƅMETA-INF/MANIFEST.MFManifest-Version: 1.0 Ant-Version: Apache Ant 1.7.1 Created-By: 11.0-b15 (Sun Microsystems Inc.) X-COMMENT: Main-Class will be added automatically by build PK R:com/PK R: com/rupiz/PK R:com/rupiz/model/PK R:com/rupiz/util/PK R:!com/rupiz/model/Account$1.class1C ( )* + , -. / 0 1234,(Ljava/lang/String;Lcom/rupiz/util/Amount;)VCodeLineNumberTableLocalVariableTablethis InnerClassesLcom/rupiz/model/Account$1;x0Ljava/lang/String;x1Lcom/rupiz/util/Amount; depositForOn[(Lcom/rupiz/util/Amount;Ljava/lang/String;Lorg/joda/time/LocalDate;)Lcom/rupiz/util/Amount;amtdescdateLorg/joda/time/LocalDate;transferToForOnt(Lcom/rupiz/util/Amount;Lcom/rupiz/model/Account;Ljava/lang/String;Lorg/joda/time/LocalDate;)Lcom/rupiz/util/Amount;destLcom/rupiz/model/Account;transLcom/rupiz/model/Transaction; SourceFile Account.javaEnclosingMethod 56com/rupiz/model/Transaction 7 89: ;< => ?@A ;Bcom/rupiz/model/Account$1com/rupiz/model/Accountbalance()Lcom/rupiz/util/Amount;w(Ljava/lang/String;Lcom/rupiz/util/Amount;Lcom/rupiz/model/Account;Lcom/rupiz/model/Account;Lorg/joda/time/LocalDate;)V access$0002(Lcom/rupiz/model/Account;)Lcom/rupiz/util/Amount;com/rupiz/util/Amountadd0(Lcom/rupiz/util/Amount;)Lcom/rupiz/util/Amount; access$002I(Lcom/rupiz/model/Account;Lcom/rupiz/util/Amount;)Lcom/rupiz/util/Amount; access$100*(Lcom/rupiz/model/Account;)Ljava/util/Set; java/util/Set(Ljava/lang/Object;)Z0  E*+, M** /Y-+*,:,,+W, W** >///!"// #$%&'   PK R:D &3 3 com/rupiz/model/Account.class1v O PQ R S T U VW UX U Y Z [\ ] ^_ ^` abcfgh i Tjk descriptionLjava/lang/String;amountLcom/rupiz/util/Amount; transactionsLjava/util/Set; Signature.Ljava/util/Set; globalSourceLcom/rupiz/model/Account;(Ljava/lang/String;)VCodeLineNumberTableLocalVariableTablethis,(Ljava/lang/String;Lcom/rupiz/util/Amount;)VgetDescription()Ljava/lang/String;setDescriptionbalance()Lcom/rupiz/util/Amount;getTransactions()Ljava/util/Set;0()Ljava/util/Set; depositForB(Lcom/rupiz/util/Amount;Ljava/lang/String;)Lcom/rupiz/util/Amount; depositForOn[(Lcom/rupiz/util/Amount;Ljava/lang/String;Lorg/joda/time/LocalDate;)Lcom/rupiz/util/Amount;dateLorg/joda/time/LocalDate; transferToFor[(Lcom/rupiz/util/Amount;Lcom/rupiz/model/Account;Ljava/lang/String;)Lcom/rupiz/util/Amount; destinationtransferToForOnt(Lcom/rupiz/util/Amount;Lcom/rupiz/model/Account;Ljava/lang/String;Lorg/joda/time/LocalDate;)Lcom/rupiz/util/Amount;transLcom/rupiz/model/Transaction; access$002I(Lcom/rupiz/model/Account;Lcom/rupiz/util/Amount;)Lcom/rupiz/util/Amount;x0x1 access$0002(Lcom/rupiz/model/Account;)Lcom/rupiz/util/Amount; access$100*(Lcom/rupiz/model/Account;)Ljava/util/Set;()V SourceFile Account.java !"  com/rupiz/util/DecimalAmount lm 'n '- 'L java/util/TreeSetorg/joda/time/LocalDate 89 %& ?@com/rupiz/model/Transaction 'op qr srt qucom/rupiz/model/Account$1 InnerClassesOpening Balancesjava/math/BigDecimal0.00 '(com/rupiz/model/Accountjava/lang/ObjectZEROLjava/math/BigDecimal;(Ljava/math/BigDecimal;)Vw(Ljava/lang/String;Lcom/rupiz/util/Amount;Lcom/rupiz/model/Account;Lcom/rupiz/model/Account;Lorg/joda/time/LocalDate;)Vcom/rupiz/util/Amountadd0(Lcom/rupiz/util/Amount;)Lcom/rupiz/util/Amount;subtract java/util/Set(Ljava/lang/Object;)Z! !"#$%&'()H*+Y* *++,&'-)h**+*,* Y *34 567+ ,& ./)/**?+ ,&0()>*+* HI+,&12)/**Q+ ,&34)/**[+ ,&#567)L*+, Y *f+ ,& 89)S +*,-*r+* ,&    :;<=)W*+,- Y *~+*,& >&?@)?Y-+*,:,,+++L*W,W+*%1=+>?,&? ?>&??:;0ABCD);*+Z*+E&F GH)/**+ E&IJ)/**+ E&KL)5YYY*MNe PK R:`Bcom/rupiz/model/Account.javapackage com.rupiz.model; import java.math.BigDecimal; import java.util.Set; import java.util.TreeSet; import com.rupiz.util.Amount; import com.rupiz.util.DecimalAmount; import org.joda.time.LocalDate; /** * * @author David */ public class Account { private String description; private Amount amount; private Set transactions; static Account globalSource = new Account("Opening Balances", new DecimalAmount(new BigDecimal("0.00"))) { @Override public Amount depositForOn(Amount amt, String desc, LocalDate date) { // Does nothing return balance(); } @Override public Amount transferToForOn(Amount amt, Account dest, String desc, LocalDate date) { Transaction trans = new Transaction(desc, amt, this, dest, date); dest.amount = dest.amount.add(amt); dest.transactions.add(trans); return balance(); } }; /** * Creates a new BasicAccount with a balance of 0.00 * * @param description the account description */ public Account(String description) { this(description, new DecimalAmount(BigDecimal.ZERO)); } /** * Creates a new BasicAccount with the given balance * * @param description the account description * @param amount the starting account balance */ public Account(String description, Amount amount) { this.description = description; this.amount = amount; transactions = new TreeSet(); } /** * Gets the account description * * @return the description */ public String getDescription() { return description; } /** * Sets the account description * * @param description the description to set */ public void setDescription(String description) { this.description = description; } /** * Gets the current account balance * * @return the amount */ public Amount balance() { return amount; } /** * Returns a Set<Transaction> containing all transactions that originate or terminate at * this account * * @return the Set of transactions */ public Set getTransactions() { return transactions; } /** * Deposits the given amount into this account * * @param amount * @param description * @return */ public Amount depositFor(Amount amount, String description) { return depositForOn(amount, description, new LocalDate()); } /** * Deposits the given amount into this account * * @param amount * @param description * @param date * @return */ public Amount depositForOn(Amount amount, String description, LocalDate date) { return globalSource.transferToForOn(amount, this, description, date); } /** * Transfers the given amount from this account into the destination account * * @param amount the amount to transfer * @param destination the destination account * @param description the transfer description * @return the current balance of this account after the transfer */ public Amount transferToFor(Amount amount, Account destination, String description) { return transferToForOn(amount, destination, description, new LocalDate()); } /** * Transfers the given amount from this account into the destination account * * @param amount the amount to transfer * @param destination the destination account * @param description the transfer description * @param date the date of the transfer * @return the current balance of this account after the transfer */ public Amount transferToForOn(Amount amount, Account destination, String description, LocalDate date) { Transaction trans = new Transaction(description, amount, this, destination, date); destination.amount = destination.amount.add(amount); amount = amount.subtract(amount); transactions.add(trans); destination.transactions.add(trans); return amount; } } PK R:2!com/rupiz/model/Transaction.class1S78 9 : 9 ; < = > ? @ AB CD EFG HIJamountLcom/rupiz/util/Amount;sourceLcom/rupiz/model/Account; destination descriptionLjava/lang/String; dateStampLorg/joda/time/LocalDate;L(Lcom/rupiz/util/Amount;Lcom/rupiz/model/Account;Lcom/rupiz/model/Account;)VCodeLineNumberTableLocalVariableTablethisLcom/rupiz/model/Transaction;amtsrcdeste(Lcom/rupiz/util/Amount;Lcom/rupiz/model/Account;Lcom/rupiz/model/Account;Lorg/joda/time/LocalDate;)Vdate^(Ljava/lang/String;Lcom/rupiz/util/Amount;Lcom/rupiz/model/Account;Lcom/rupiz/model/Account;)Vdescw(Ljava/lang/String;Lcom/rupiz/util/Amount;Lcom/rupiz/model/Account;Lcom/rupiz/model/Account;Lorg/joda/time/LocalDate;)V compareTo (Lcom/rupiz/model/Transaction;)ItransvalueI(Ljava/lang/Object;)Ix0Ljava/lang/Object; SignatureGLjava/lang/Object;Ljava/lang/Comparable; SourceFileTransaction.javaorg/joda/time/LocalDate K *      +0L MNO +PQ +Rcom/rupiz/model/Transaction +,java/lang/Objectjava/lang/Comparable()Vcom/rupiz/model/AccountgetDescription()Ljava/lang/String;java/lang/String(Ljava/lang/String;)Icom/rupiz/util/Amount(Lcom/rupiz/util/Amount;)I!]*+,-Y  *!"#$%&b *+,-   4 !" # $ % '(g*+,-Y  4!")#$%* **+*,*-* *   !"# > !" ) # $ % '+,b* + =* + =* + =*+=*+ 6 ' ()+$,(-*/<0@1B3P4T5V7 b!"b-" V./A+0= *+  !" 123456PK R:& y$$ com/rupiz/model/Transaction.javapackage com.rupiz.model; import org.joda.time.LocalDate; import com.rupiz.util.Amount; /** * * @author David */ public class Transaction implements Comparable{ public final Amount amount; public final Account source; public final Account destination; public final String description; public final LocalDate dateStamp; public Transaction(Amount amt, Account src, Account dest) { this("", amt, src, dest, new LocalDate()); } public Transaction(Amount amt, Account src,Account dest, LocalDate date){ this("", amt, src, dest, date); } public Transaction(String desc, Amount amt, Account src, Account dest) { this(desc, amt, src, dest, new LocalDate()); } public Transaction(String desc, Amount amt, Account src, Account dest, LocalDate date) { description = desc; amount = amt; source = src; destination = dest; dateStamp = date; } @Override public int compareTo(Transaction trans) { int value = dateStamp.compareTo(trans.dateStamp); if(value != 0) return value; value = source.getDescription().compareTo(trans.source.getDescription()); if(value != 0) return value; value = destination.getDescription().compareTo(trans.destination.getDescription()); if(value != 0) return value; value = amount.compareTo(trans.amount); if(value != 0) return value; return description.compareTo(trans.description); } } PK R:Bbeecom/rupiz/util/Amount.class1 add0(Lcom/rupiz/util/Amount;)Lcom/rupiz/util/Amount;subtract compareTo(Lcom/rupiz/util/Amount;)I SignatureALjava/lang/Object;Ljava/lang/Comparable; SourceFile Amount.javacom/rupiz/util/Amountjava/lang/Objectjava/lang/Comparable   PK R:pRcom/rupiz/util/Amount.javapackage com.rupiz.util; /** * * @author David */ public interface Amount extends Comparable{ public Amount add(Amount value); public Amount subtract(Amount value); @Override public int compareTo(Amount amount); } PK R:P P "com/rupiz/util/DecimalAmount.class1h B C DE F GH I J KL K M N OP Q RST B U VW X K F YZamountLjava/math/BigDecimal;scaleI ConstantValue(Ljava/math/BigDecimal;)VCodeLineNumberTableLocalVariableTablethisLcom/rupiz/util/DecimalAmount;amt(Ljava/lang/String;)VLjava/lang/String;(I)VtoString()Ljava/lang/String;add0(Lcom/rupiz/util/Amount;)Lcom/rupiz/util/Amount;valueLcom/rupiz/util/Amount;subtractequals(Ljava/lang/Object;)ZoLjava/lang/Object;hashCode()Ihash compareTo(Lcom/rupiz/util/Amount;)I(Ljava/lang/Object;)Ix0 SourceFileDecimalAmount.java #[  java/math/BigDecimal #+\ ]^ _` #- ./com/rupiz/util/DecimalAmount 0a #$ 4acom/rupiz/util/Amount <b 9:"java/lang/IllegalArgumentExceptionjava/lang/StringBuilder cd ef is not a subclass of Amount. eg <=java/lang/Object()Vjava/math/RoundingMode HALF_EVENLjava/math/RoundingMode;setScale1(ILjava/math/RoundingMode;)Ljava/math/BigDecimal;.(Ljava/math/BigDecimal;)Ljava/math/BigDecimal;(Ljava/math/BigDecimal;)IgetClass()Ljava/lang/Class;append-(Ljava/lang/Object;)Ljava/lang/StringBuilder;-(Ljava/lang/String;)Ljava/lang/StringBuilder;!  !" #$%O***+& '()*#+%]***Y+& '()*,#-%]***Y& '()* ./%2* &' ()01%U! Y*Y+  &"'!()!2341%U! Y*Y+  &''!()!2356%p&+Y+ M*,&,- /0' &()&78*9:%X<Oh* *`<&567'(); <=%t8+*Y+ YY+&<=>'8()873A<>%= *+& ' () ?8@APK R:"D~~!com/rupiz/util/DecimalAmount.javapackage com.rupiz.util; import java.math.BigDecimal; import static java.math.RoundingMode.HALF_EVEN; /** * An implementation of Amount backed by an instance of BigDecimal * @author David */ public class DecimalAmount implements Amount { public final BigDecimal amount; final int scale = 2; public DecimalAmount(BigDecimal amt) { amount = amt; } public DecimalAmount(String amt){ amount = new BigDecimal(amt).setScale(scale, HALF_EVEN); } public DecimalAmount(int amt){ amount = new BigDecimal(amt).setScale(scale, HALF_EVEN); } @Override public String toString() { return amount.toString(); } @Override public Amount add(Amount value) { return new DecimalAmount(amount.add(new BigDecimal(value.toString()).setScale(scale, HALF_EVEN))); } @Override public Amount subtract(Amount value) { return new DecimalAmount(amount.subtract(new BigDecimal(value.toString()).setScale(scale, HALF_EVEN))); } @Override public boolean equals(Object o){ if(!(o instanceof Amount)) return false; BigDecimal amt = new BigDecimal(o.toString()); return amount.compareTo(amt) == 0; } @Override public int hashCode() { int hash = 5; hash = 79 * hash + (this.amount != null ? this.amount.hashCode() : 0); return hash; } @Override public int compareTo(Amount o) { if(o instanceof Amount) return amount.compareTo(new BigDecimal(o.toString())); throw new IllegalArgumentException(o.getClass() + " is not a subclass of Amount."); } } PK R: AMETA-INF/PK R:ƅ+META-INF/MANIFEST.MFPK R:Acom/PK R: A!com/rupiz/PK R:AIcom/rupiz/model/PK R:Awcom/rupiz/util/PK R:!com/rupiz/model/Account$1.classPK R:D &3 3 com/rupiz/model/Account.classPK R:`Bcom/rupiz/model/Account.javaPK R:2!&com/rupiz/model/Transaction.classPK R:& y$$ /com/rupiz/model/Transaction.javaPK R:Bbee5com/rupiz/util/Amount.classPK R:pR7com/rupiz/util/Amount.javaPK R:P P "8com/rupiz/util/DecimalAmount.classPK R:"D~~!TBcom/rupiz/util/DecimalAmount.javaPKI