18 package org.turro.financials.document.contract;
20 import java.util.Date;
21 import org.amic.util.date.CheckDate;
22 import org.turro.elephant.util.DateFormats;
23 import org.turro.elephant.util.DecimalFormats;
24 import org.turro.financials.command.DocumentLabel;
25 import org.turro.financials.entity.Contract;
26 import org.turro.financials.entity.Document;
27 import org.turro.financials.entity.DocumentRelation;
28 import org.turro.financials.entity.RegisterView;
29 import org.turro.financials.model.document.contract.DocumentByContractList;
30 import org.turro.i18n.I_;
31 import org.turro.zkoss.grid.PagingGrid;
32 import org.turro.zkoss.label.LabelTypes;
33 import org.turro.zkoss.label.StyledLabel;
34 import org.turro.zkoss.layout.GridLayout;
35 import org.zkoss.zk.ui.event.Event;
36 import org.zkoss.zk.ui.event.EventListener;
37 import org.zkoss.zk.ui.event.Events;
38 import org.zkoss.zul.*;
48 private Date from, to;
51 from =
new CheckDate(-1, 1, 1, 0, 0, 0).getDate();
68 this.contract = contract;
84 private void addCols() {
86 cols.getChildren().clear();
90 Column col =
new Column(
I_.
get(
"Date"));
92 cols.appendChild(col);
94 col =
new Column(
I_.
get(
"Concept"));
95 cols.appendChild(col);
97 col =
new Column(
I_.
get(
"Invoice"));
98 col.setWidth(
"120px");
99 col.setAlign(
"right");
100 cols.appendChild(col);
102 col =
new Column(
I_.
get(
"Portfolio"));
103 col.setWidth(
"120px");
104 col.setAlign(
"right");
105 cols.appendChild(col);
107 col =
new Column(
I_.
get(
"Balance"));
108 col.setWidth(
"120px");
109 col.setAlign(
"right");
110 cols.appendChild(col);
112 col =
new Column(
I_.
get(
"Settlement"));
113 col.setWidth(
"120px");
114 col.setAlign(
"right");
115 cols.appendChild(col);
117 col =
new Column(
I_.
get(
"Balance"));
118 col.setWidth(
"120px");
119 col.setAlign(
"right");
120 cols.appendChild(col);
123 private void addRows() {
125 rows.getChildren().clear();
127 DocumentByContractList dbcl =
new DocumentByContractList();
128 dbcl.fillList(view, contract, from, to);
130 double portfolio_balance = 0.0, final_balance = dbcl.getInitialBalance(view, contract, from, to);
133 if(final_balance != 0.0) {
137 rows.appendChild(row);
139 final Detail d =
new Detail();
141 row.appendChild(
new Space());
142 row.appendChild(
new Label(
I_.
get(
"Accumulated")));
143 row.appendChild(
new Space());
144 row.appendChild(
new Space());
145 row.appendChild(
new Space());
146 row.appendChild(
new Space());
151 for(
final Document doc : dbcl) {
153 if(doc.getDocumentDefinition().getId() != 1 &&
154 doc.getDocumentDefinition().getId() != 67 &&
155 doc.getDocumentDefinition().getId() != 2 &&
156 doc.getDocumentDefinition().getId() != 43 &&
157 doc.getDocumentDefinition().getId() != 44 &&
158 doc.getDocumentDefinition().getId() != 6 &&
159 doc.getDocumentDefinition().getId() != 7) {
166 rows.appendChild(row);
168 final Detail d =
new Detail();
170 d.addEventListener(Events.ON_OPEN,
new EventListener() {
172 public void onEvent(Event event)
throws Exception {
173 if(d.getChildren().isEmpty() && !doc.getDescendants().isEmpty()) {
174 Vbox vbox =
new Vbox();
175 vbox.setClass(
"softLabel");
176 vbox.setStyle(
"margin:3px;margin-left:150px;");
178 GridLayout gl =
new GridLayout(
"min,right-120px");
179 vbox.appendChild(gl);
181 for(DocumentRelation dr : doc.getDescendants()) {
182 Document dd = dr.getDescendant();
183 A b =
new DocumentLabel(dd);
186 double tdd = dd.getTotalAmount();
187 gl.addComponent(
new Label(DecimalFormats.format(tdd,
188 DecimalFormats.getStringFormat(2))));
193 gl.addComponent(
new StyledLabel(DecimalFormats.format(total,
194 DecimalFormats.getStringFormat(2)),
"font-weight:bold"));
199 row.appendChild(
new Label(DateFormats.format(doc.getDocumentDate(),
true)));
201 Vlayout vbox =
new Vlayout();
202 vbox.setStyle(
"padding:2px;padding-left:20px");
203 row.appendChild(vbox);
204 A b =
new DocumentLabel(doc);
206 vbox.appendChild(LabelTypes.getSoftLabel(doc.getConcept()));
207 vbox.appendChild(LabelTypes.getSoftLabel(doc.getNotes()));
209 double amount = doc.getTotalAmount();
211 if(doc.getDocumentDefinition().getId() == 1 ||
212 doc.getDocumentDefinition().getId() == 67 ||
213 doc.getDocumentDefinition().getId() == 2) {
214 row.appendChild(
new Label(DecimalFormats.format(amount,
215 DecimalFormats.getStringFormat(2))));
216 row.appendChild(
new Cell());
217 portfolio_balance += amount;
218 row.appendChild(
new Label(DecimalFormats.format(portfolio_balance,
219 DecimalFormats.getStringFormat(2))));
220 row.appendChild(
new Cell());
221 final_balance += amount;
222 row.appendChild(
new Label(DecimalFormats.format(final_balance,
223 DecimalFormats.getStringFormat(2))));
224 }
else if(doc.getDocumentDefinition().getId() == 44 ||
225 doc.getDocumentDefinition().getId() == 43) {
226 row.appendChild(
new Cell());
227 row.appendChild(
new Label(DecimalFormats.format(amount,
228 DecimalFormats.getStringFormat(2))));
229 portfolio_balance -= amount;
230 row.appendChild(
new Label(DecimalFormats.format(portfolio_balance,
231 DecimalFormats.getStringFormat(2))));
232 row.appendChild(
new Cell());
233 row.appendChild(
new Label(DecimalFormats.format(final_balance,
234 DecimalFormats.getStringFormat(2))));
235 }
else if(doc.getDocumentDefinition().getId() == 6 ||
236 doc.getDocumentDefinition().getId() == 7) {
237 row.appendChild(
new Cell());
238 row.appendChild(
new Cell());
239 row.appendChild(
new Label(DecimalFormats.format(portfolio_balance,
240 DecimalFormats.getStringFormat(2))));
241 row.appendChild(
new Label(DecimalFormats.format(amount,
242 DecimalFormats.getStringFormat(2))));
243 final_balance -= amount;
244 row.appendChild(
new Label(DecimalFormats.format(final_balance,
245 DecimalFormats.getStringFormat(2))));
void setView(RegisterView view)
void setContract(Contract contract)
static String get(String msg)
Columns getColumns(boolean create)
Rows getRows(boolean create)
void setRowCount(int rows)