BrightSide Workbench Full Report + Source Code
StatementEntry.java
Go to the documentation of this file.
1
/*
2
* TurrĂ³ i Cutiller Foundation. License notice.
3
* Copyright (C) 2011 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4
*
5
* This program is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU Affero General Public License as published by
7
* the Free Software Foundation, either version 3 of the License, or
8
* (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU Affero General Public License for more details.
14
*
15
* You should have received a copy of the GNU Affero General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
*/
18
package
org.turro.financials.account.logic;
19
20
import
java.util.Date;
21
import
org.turro.financials.db.FinancialsPU;
22
import
org.turro.financials.entity.Document;
23
import
org.turro.financials.entity.MajorAccount;
24
import
org.turro.financials.entity.Register;
25
import
org.turro.financials.entity.RegisterEntry;
26
import
org.turro.financials.entity.RegisterView;
27
import
org.turro.util.CompareUtil;
28
import
org.turro.util.PhraseBuilder;
29
34
public
class
StatementEntry
implements
Comparable<StatementEntry> {
35
36
protected
double
balance
, inheritedBalance;
37
protected
RegisterEntry
entry
;
38
39
public
StatementEntry
(
RegisterEntry
entry
) {
40
this.entry =
entry
;
41
}
42
43
public
String
getId
() {
44
if
(
entry
!=
null
) {
45
return
"99"
+
entry
.
getId
();
46
}
47
return
null
;
48
}
49
50
public
double
getBalance
() {
51
return
inheritedBalance +
getDebit
() -
getCredit
();
52
}
53
54
public
double
getCredit
() {
55
if
(
entry
!=
null
) {
56
return
entry
.
getCredit
();
57
}
58
return
0.0;
59
}
60
61
public
double
getDebit
() {
62
if
(
entry
!=
null
) {
63
return
entry
.
getDebit
();
64
}
65
return
0.0;
66
}
67
68
public
Date
getDate
() {
69
if
(
entry
!=
null
) {
70
return
entry
.
getRegister
().
getRegisterDate
();
71
}
72
return
null
;
73
}
74
75
public
long
getOrder
() {
76
return
0;
77
}
78
79
public
String
getAccount
() {
80
if
(
entry
!=
null
) {
81
return
entry
.
getAccount
().
getId
();
82
}
83
return
null
;
84
}
85
86
public
String
getDescription
() {
87
if
(
entry
!=
null
&&
entry
.
getAccount
() !=
null
) {
88
MajorAccount
ma =
entry
.
getAccount
().
getParent
();
89
return
entry
.
getAccount
().
getDescription
() +
" "
+
90
getConcept
() +
91
(ma !=
null
?
" - "
+ ma.
getDescription
() :
""
);
92
}
93
return
null
;
94
}
95
96
// TODO: Canviar per DocumentString
97
public
String
getConcept
() {
98
if
(
entry
!=
null
) {
99
PhraseBuilder sb =
new
PhraseBuilder(
entry
.
getConcept
());
100
Document
document =
entry
.
getRegister
().
getDocument
();
101
if
(document !=
null
) {
102
sb.addWord(
"("
);
103
sb.addWord(document.
getDocumentDefinition
().
getName
());
104
sb.addWord(document.
getDocumentNumber
());
105
sb.addWord(
")"
,
false
);
106
}
107
return
sb.toString();
108
}
109
return
null
;
110
}
111
112
public
RegisterView
getView
() {
113
if
(
entry
!=
null
) {
114
return
entry
.
getRegister
().
getView
();
115
}
116
return
null
;
117
}
118
119
public
RegisterEntry
getEntry
() {
120
return
entry
;
121
}
122
123
public
Register
getRegister
() {
124
if
(
entry
!=
null
) {
125
return
entry
.
getRegister
();
126
}
127
return
null
;
128
}
129
130
public
Document
getDocument
() {
131
if
(
getRegister
() !=
null
) {
132
return
getRegister
().
getDocument
();
133
}
134
return
null
;
135
}
136
137
public
void
setInheritedBalance
(
double
inheritedBalance) {
138
this.inheritedBalance = inheritedBalance;
139
}
140
141
public
boolean
isConciliated
() {
142
if
(
entry
!=
null
) {
143
return
entry
.
isConciliated
();
144
}
145
return
false
;
146
}
147
148
public
void
setConciliated
(
boolean
value) {
149
if
(
entry
!=
null
) {
150
entry
.
setConciliated
(value);
151
new
FinancialsPU
().saveObject(
entry
);
152
}
153
}
154
155
public
boolean
isBank
() {
156
return
false
;
157
}
158
159
@Override
160
public
int
compareTo
(
StatementEntry
o) {
161
if
(
this
instanceof
StatementFirst
) {
162
return
-1;
163
}
else
if
(o instanceof
StatementFirst
) {
164
return
1;
165
}
166
int
r =
getDate
().compareTo(o.
getDate
());
167
if
(r == 0) {
168
r = CompareUtil.compare(
getOrder
(), o.
getOrder
());
169
}
170
if
(r == 0) {
171
r =
getAccount
().compareTo(o.
getAccount
());
172
}
173
if
(
entry
!=
null
) {
174
if
(r == 0) {
175
r = Long.valueOf(
entry
.
getRegister
().
getIdRegister
()).compareTo(
176
o.
entry
.
getRegister
().
getIdRegister
());
177
}
178
}
179
if
(r == 0) {
180
r =
getId
().compareTo(o.
getId
());
181
}
182
return
r;
183
}
184
185
}
org.turro.financials.account.logic.StatementEntry
Definition:
StatementEntry.java:34
org.turro.financials.account.logic.StatementEntry.setInheritedBalance
void setInheritedBalance(double inheritedBalance)
Definition:
StatementEntry.java:137
org.turro.financials.account.logic.StatementEntry.entry
RegisterEntry entry
Definition:
StatementEntry.java:37
org.turro.financials.account.logic.StatementEntry.getDate
Date getDate()
Definition:
StatementEntry.java:68
org.turro.financials.account.logic.StatementEntry.getView
RegisterView getView()
Definition:
StatementEntry.java:112
org.turro.financials.account.logic.StatementEntry.setConciliated
void setConciliated(boolean value)
Definition:
StatementEntry.java:148
org.turro.financials.account.logic.StatementEntry.balance
double balance
Definition:
StatementEntry.java:36
org.turro.financials.account.logic.StatementEntry.getBalance
double getBalance()
Definition:
StatementEntry.java:50
org.turro.financials.account.logic.StatementEntry.getRegister
Register getRegister()
Definition:
StatementEntry.java:123
org.turro.financials.account.logic.StatementEntry.getConcept
String getConcept()
Definition:
StatementEntry.java:97
org.turro.financials.account.logic.StatementEntry.getDescription
String getDescription()
Definition:
StatementEntry.java:86
org.turro.financials.account.logic.StatementEntry.compareTo
int compareTo(StatementEntry o)
Definition:
StatementEntry.java:160
org.turro.financials.account.logic.StatementEntry.StatementEntry
StatementEntry(RegisterEntry entry)
Definition:
StatementEntry.java:39
org.turro.financials.account.logic.StatementEntry.getEntry
RegisterEntry getEntry()
Definition:
StatementEntry.java:119
org.turro.financials.account.logic.StatementEntry.isConciliated
boolean isConciliated()
Definition:
StatementEntry.java:141
org.turro.financials.account.logic.StatementEntry.getDebit
double getDebit()
Definition:
StatementEntry.java:61
org.turro.financials.account.logic.StatementEntry.getId
String getId()
Definition:
StatementEntry.java:43
org.turro.financials.account.logic.StatementEntry.isBank
boolean isBank()
Definition:
StatementEntry.java:155
org.turro.financials.account.logic.StatementEntry.getDocument
Document getDocument()
Definition:
StatementEntry.java:130
org.turro.financials.account.logic.StatementEntry.getOrder
long getOrder()
Definition:
StatementEntry.java:75
org.turro.financials.account.logic.StatementEntry.getAccount
String getAccount()
Definition:
StatementEntry.java:79
org.turro.financials.account.logic.StatementEntry.getCredit
double getCredit()
Definition:
StatementEntry.java:54
org.turro.financials.account.logic.StatementFirst
Definition:
StatementFirst.java:30
org.turro.financials.db.FinancialsPU
Definition:
FinancialsPU.java:32
org.turro.financials.entity.Account.getParent
MajorAccount getParent()
Definition:
Account.java:75
org.turro.financials.entity.Account.getId
String getId()
Definition:
Account.java:49
org.turro.financials.entity.Account.getDescription
String getDescription()
Definition:
Account.java:41
org.turro.financials.entity.DocumentDefinition.getName
String getName()
Definition:
bsfinancials-core/src/main/java/org/turro/financials/entity/DocumentDefinition.java:91
org.turro.financials.entity.Document
Definition:
Document.java:56
org.turro.financials.entity.Document.getDocumentNumber
String getDocumentNumber()
Definition:
Document.java:188
org.turro.financials.entity.Document.getDocumentDefinition
DocumentDefinition getDocumentDefinition()
Definition:
Document.java:167
org.turro.financials.entity.MajorAccount
Definition:
MajorAccount.java:30
org.turro.financials.entity.MajorAccount.getDescription
String getDescription()
Definition:
MajorAccount.java:77
org.turro.financials.entity.RegisterEntry
Definition:
RegisterEntry.java:32
org.turro.financials.entity.RegisterEntry.isConciliated
boolean isConciliated()
Definition:
RegisterEntry.java:80
org.turro.financials.entity.RegisterEntry.getRegister
Register getRegister()
Definition:
RegisterEntry.java:128
org.turro.financials.entity.RegisterEntry.setConciliated
void setConciliated(boolean conciliated)
Definition:
RegisterEntry.java:84
org.turro.financials.entity.RegisterEntry.getCredit
double getCredit()
Definition:
RegisterEntry.java:88
org.turro.financials.entity.RegisterEntry.getConcept
String getConcept()
Definition:
RegisterEntry.java:72
org.turro.financials.entity.RegisterEntry.getId
long getId()
Definition:
RegisterEntry.java:112
org.turro.financials.entity.RegisterEntry.getAccount
Account getAccount()
Definition:
RegisterEntry.java:56
org.turro.financials.entity.RegisterEntry.getDebit
double getDebit()
Definition:
RegisterEntry.java:96
org.turro.financials.entity.RegisterView
Definition:
RegisterView.java:32
org.turro.financials.entity.Register
Definition:
Register.java:40
org.turro.financials.entity.Register.getRegisterDate
Date getRegisterDate()
Definition:
Register.java:123
org.turro.financials.entity.Register.getView
RegisterView getView()
Definition:
Register.java:159
org.turro.financials.entity.Register.getDocument
Document getDocument()
Definition:
Register.java:91
org.turro.financials.entity.Register.getIdRegister
long getIdRegister()
Definition:
Register.java:115
TurroProjects
Public
BrightSide
bsfinancials-www
src
main
java
org
turro
financials
account
logic
StatementEntry.java
Generated on Tue Mar 12 2024 07:01:21 for BrightSide by
1.9.1