18 package org.turro.financials.account.logic;
21 import org.amic.util.date.CheckDate;
22 import org.turro.financials.db.FinancialsPU;
23 import org.turro.financials.entity.RegisterEntry;
24 import org.turro.financials.entity.RegisterView;
25 import org.turro.jpa.Dao;
26 import org.turro.validate.ValidatedStatus;
34 private Date fromDate, toDate;
35 private String accountSearch;
43 public StatementSet(
double initialDebit,
double initialCredit, Collection<? extends StatementEntry> c) {
54 this.accountSearch = accountSearch;
62 this.fromDate = fromDate;
78 this.validated = validated;
90 long millis = toDate.getTime() - fromDate.getTime();
91 toDate.setTime(fromDate.getTime());
92 fromDate.setTime(toDate.getTime() - millis);
96 long millis = toDate.getTime() - fromDate.getTime();
97 fromDate.setTime(toDate.getTime());
98 toDate.setTime(fromDate.getTime() + millis);
103 if(accountSearch ==
null)
return;
121 private boolean hasBank() {
130 private void checkBalance() {
131 Iterator<StatementEntry> it = iterator();
133 while(it.hasNext()) {
134 StatementEntry se = it.next();
135 if(!(se instanceof BankEntry)) {
137 balance = se.getBalance();
142 private void addEntries(Dao dao) {
143 Object[] pars = view !=
null ?
145 accountSearch.replaceAll(
"\\*",
"%").replaceAll(
"\\.",
"%"),
151 accountSearch.replaceAll(
"\\*",
"%").replaceAll(
"\\.",
"%"),
155 List<RegisterEntry> l = (List<RegisterEntry>) dao.getResultList(
156 "select distinct entry " +
157 "from RegisterEntry as entry " +
158 "where entry.account.id like ? " +
159 "and entry.register.registerDate >= ? " +
160 "and entry.register.registerDate <= ? " +
161 (ValidatedStatus.VALIDATED_NOT.equals(validated) ?
162 "and entry.conciliated = FALSE " :
"") +
163 (ValidatedStatus.VALIDATED_YES.equals(validated) ?
164 "and entry.conciliated = TRUE " :
"") +
165 (view !=
null ?
"and entry.register.view = ?" :
""),
167 for(RegisterEntry re : l) {
168 add(
new StatementEntry(re));
172 private void initiateValues() {
174 fromDate =
new CheckDate(toDate).addMonths(-1).getDate();
static Collection< StatementEntry > getMovements(String account, Date start, Date end)
void setInheritedBalance(double inheritedBalance)
void setView(RegisterView view)
void setFromDate(Date fromDate)
void setAccountSearch(String accountSearch)
void refreshData(Dao dao)
void setAccountSearch(String accountSearch)
StatementSet(double initialDebit, double initialCredit, Collection<? extends StatementEntry > c)
void setView(RegisterView view)
void setValidated(ValidatedStatus validated)
String getAccountSearch()
void setFromDate(Date fromDate)
ValidatedStatus getValidated()
void setToDate(Date toDate)