2 package com
.interrupt
.bookkeeping
.journal
;
5 import java
.text
.ParseException
;
6 import java
.text
.SimpleDateFormat
;
7 import java
.util
.ArrayList
;
10 import java
.util
.Iterator
;
12 import org
.apache
.log4j
.Logger
;
14 import com
.interrupt
.bookkeeping
.account
.GCredit
;
15 import com
.interrupt
.bookkeeping
.account
.GDebit
;
16 import com
.interrupt
.bookkeeping
.cc
.bkell
.Bkell
;
17 import com
.interrupt
.bookkeeping
.exception
.EntryException
;
18 import com
.interrupt
.bookkeeping
.util
.Util
;
20 import com
.interrupt
.bob
.base
.IBob
;
21 import com
.interrupt
.bob
.base
.IVisitor
;
22 import com
.interrupt
.util
.DateUtil
;
24 public class Entries
extends GEntries
{
27 private Logger logger
= Logger
.getLogger(Entries
.class);
33 public Entries(String id
) {
39 public void addEntry(Entry entry
) {
40 this.addEntry((IEntry
)entry
);
42 public void addEntry(IEntry entry
) {
44 if( !((Entry
)entry
).balances() ) {
46 logger
.debug("Entries.addEntry: " + entry
.toXML());
47 throw new EntryException("Debits must equal Credits");
50 super.addEntry(entry
);
53 public boolean balances() {
55 List entryList
= this.allEntry();
56 Iterator iter
= entryList
.iterator();
58 while(iter
.hasNext()) {
60 next
= (Entry
)iter
.next();
61 if(!next
.balances()) {
72 * "MM/dd/yyyy HH:mm:ss z"
75 public com
.interrupt
.bookkeeping
.journal
.IEntry
findEntryByDate(String value
) {
78 java
.util
.Iterator iter
= _children
.iterator();
79 com
.interrupt
.bookkeeping
.journal
.IEntry each
= null;
80 while(iter
.hasNext()) {
82 Object next
= iter
.next();
83 if(next
instanceof com
.interrupt
.bookkeeping
.journal
.IEntry
) {
85 each
= (com
.interrupt
.bookkeeping
.journal
.IEntry
)next
;
87 String comparator
= each
.getDate();
90 if(DateUtil
.equals(comparator
, value
)) {
101 public List
listEntryBeforeDate(String value
) {
104 List dateList
= new ArrayList();
105 java
.util
.Iterator iter
= _children
.iterator();
106 com
.interrupt
.bookkeeping
.journal
.IEntry each
= null;
107 while(iter
.hasNext()) {
109 Object next
= iter
.next();
110 if(next
instanceof com
.interrupt
.bookkeeping
.journal
.IEntry
) {
112 each
= (com
.interrupt
.bookkeeping
.journal
.IEntry
)next
;
113 String comparator
= each
.getDate();
114 if(DateUtil
.before(comparator
, value
)) {
123 public List
listEntryAfterDate(String value
) {
126 List dateList
= new ArrayList();
127 java
.util
.Iterator iter
= _children
.iterator();
128 com
.interrupt
.bookkeeping
.journal
.IEntry each
= null;
129 while(iter
.hasNext()) {
131 Object next
= iter
.next();
132 if(next
instanceof com
.interrupt
.bookkeeping
.journal
.IEntry
) {
134 each
= (com
.interrupt
.bookkeeping
.journal
.IEntry
)next
;
136 String comparator
= each
.getDate();
139 if(DateUtil
.after(comparator
, value
)) {
149 public static void main( String srgs
[] ) {
152 String format_s
= "MM/dd/yyyy HH:mm:ss z";
153 SimpleDateFormat dformat
= new SimpleDateFormat( format_s
);
159 date1
= dformat
.parse("08/15/2005 00:00:00 EST");
160 date2
= dformat
.parse("09/15/2005 00:00:00 EST");
162 Logger
.getLogger(Entries
.class).debug( date1
.before(date2
) );
165 catch( ParseException e
) {