BrightSide Workbench Full Report + Source Code
org.turro.financials.model.document.contract.DocumentByContractList Class Reference
Inheritance diagram for org.turro.financials.model.document.contract.DocumentByContractList:
Collaboration diagram for org.turro.financials.model.document.contract.DocumentByContractList:

Public Member Functions

 DocumentByContractList ()
 
void fillList (RegisterView view, Contract contract, Date from, Date to)
 
double getInitialBalance (RegisterView view, Contract contract, Date from, Date to)
 
Date getInitialDate (Dao dao, Date fromDate)
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 34 of file DocumentByContractList.java.

Constructor & Destructor Documentation

◆ DocumentByContractList()

org.turro.financials.model.document.contract.DocumentByContractList.DocumentByContractList ( )

Definition at line 36 of file DocumentByContractList.java.

36  {
37  super(new DocumentByContractComparator());
38  }

Member Function Documentation

◆ fillList()

void org.turro.financials.model.document.contract.DocumentByContractList.fillList ( RegisterView  view,
Contract  contract,
Date  from,
Date  to 
)

Definition at line 40 of file DocumentByContractList.java.

40  {
41  Dao dao = new FinancialsPU();
42  if(view != null) {
43  addAll(dao.getResultList(
44  "select doc from Document doc " +
45  "where doc.contract = ? " +
46  "and doc.forcedView = ? " +
47  "and doc.documentDate >= ? " +
48  "and doc.documentDate <= ?",
49  new Object[] { contract, view, from, to }));
50  } else {
51  addAll(dao.getResultList(
52  "select doc from Document doc " +
53  "where doc.contract = ? " +
54  "and doc.forcedView is null " +
55  "and doc.documentDate >= ? " +
56  "and doc.documentDate <= ?",
57  new Object[] { contract, from, to }));
58  }
59  }

◆ getInitialBalance()

double org.turro.financials.model.document.contract.DocumentByContractList.getInitialBalance ( RegisterView  view,
Contract  contract,
Date  from,
Date  to 
)

Definition at line 61 of file DocumentByContractList.java.

61  {
62  Dao dao = new FinancialsPU();
63  Date init = getInitialDate(dao, from);
64  Object o = null;
65  if(view != null) {
66  o = dao.getSingleResult(
67  "select sum(re.debit - re.credit) " +
68  "from RegisterEntry re " +
69  "join re.register r " +
70  "where r.view = ? " +
71  "and r.registerDate < ? " +
72  (init != null ? "and r.registerDate >= ? " : "and ? is null ") +
73  "and (re.account.id like '" + AccountFormat.expand("400." + contract.getId()) + "' " +
74  "or re.account.id like '" + AccountFormat.expand("401." + contract.getId()) + "' " +
75  "or re.account.id like '" + AccountFormat.expand("410." + contract.getId()) + "' " +
76  "or re.account.id like '" + AccountFormat.expand("411." + contract.getId()) + "' " +
77  "or re.account.id like '" + AccountFormat.expand("430." + contract.getId()) + "' " +
78  "or re.account.id like '" + AccountFormat.expand("431." + contract.getId()) + "' " +
79  "or re.account.id like '" + AccountFormat.expand("440." + contract.getId()) + "' " +
80  "or re.account.id like '" + AccountFormat.expand("441." + contract.getId()) + "')",
81  new Object[] { view, from, init });
82  } else {
83  o = dao.getSingleResult(
84  "select sum(re.debit - re.credit) " +
85  "from RegisterEntry re " +
86  "join re.register r " +
87  "where r.view.id = 1 " +
88  "and r.registerDate < ? " +
89  (init != null ? "and r.registerDate >= ? " : "and ? is null ") +
90  "and (re.account.id like '" + AccountFormat.expand("400." + contract.getId()) + "' " +
91  "or re.account.id like '" + AccountFormat.expand("401." + contract.getId()) + "' " +
92  "or re.account.id like '" + AccountFormat.expand("410." + contract.getId()) + "' " +
93  "or re.account.id like '" + AccountFormat.expand("411." + contract.getId()) + "' " +
94  "or re.account.id like '" + AccountFormat.expand("430." + contract.getId()) + "' " +
95  "or re.account.id like '" + AccountFormat.expand("431." + contract.getId()) + "' " +
96  "or re.account.id like '" + AccountFormat.expand("440." + contract.getId()) + "' " +
97  "or re.account.id like '" + AccountFormat.expand("441." + contract.getId()) + "')",
98  new Object[] { from, init });
99  }
100  if(o instanceof Double) {
101  if(contract.getContractDefinition().getId() == 55) {
102  return -((Double) o);
103  }
104  return (Double) o;
105  }
106  return 0.0;
107  }
Here is the call graph for this function:

◆ getInitialDate()

Date org.turro.financials.model.document.contract.DocumentByContractList.getInitialDate ( Dao  dao,
Date  fromDate 
)

Definition at line 109 of file DocumentByContractList.java.

109  {
110  try {
111  return (Date) dao.getSingleResult(
112  "select max(r.registerDate) from Register r " +
113  "where r.registerDate < ? " +
114  "and r.closing = TRUE " +
115  "and day(r.registerDate) = 1 " +
116  "and month(r.registerDate) = 1",
117  new Object[] { fromDate });
118  } catch(NoResultException ex) {
119  return null;
120  }
121  }
Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: