18 package org.turro.financials.payroll;
20 import java.util.Collection;
21 import java.util.Date;
22 import org.turro.financials.contract.ContractListbox;
23 import org.turro.financials.document.DocumentTotal;
24 import org.turro.financials.document.logic.DocumentDefinitionWrapper;
25 import org.turro.financials.entity.Contract;
26 import org.turro.financials.entity.DocumentLine;
27 import org.turro.financials.model.contract.ContractUsualSet;
28 import org.turro.financials.model.contract.ContractWrapper;
29 import org.turro.financials.model.document.PayrollWrapper;
30 import org.turro.zkoss.grid.PagingGrid;
31 import org.turro.zkoss.input.ExpressionInput;
32 import org.turro.zkoss.label.LabelTypes;
33 import org.zkoss.zk.ui.Component;
34 import org.zkoss.zk.ui.event.Event;
35 import org.zkoss.zk.ui.event.EventListener;
36 import org.zkoss.zk.ui.event.Events;
37 import org.zkoss.zk.ui.ext.AfterCompose;
38 import org.zkoss.zul.*;
47 private boolean newPayrolls =
true;
48 private Date date =
new Date();
60 for(Component row :
getRows().getChildren()) {
72 this.newPayrolls = newPayrolls;
76 for(Component row :
getRows().getChildren()) {
92 private void addRows() {
96 rows.getChildren().clear();
100 pr.getPayroll().setDocumentDate(date);
101 pr.getPayroll().setReceiptDate(date);
102 pr.getPayroll().setDocumentNumber(
null);
104 date = pr.getPayroll().getDocumentDate();
108 row.setValign(
"top");
109 rows.appendChild(row);
110 pr.getPayroll().setDraft(
false);
111 if(pr.getPayroll().isDraft()) {
112 row.setSclass(
"draft");
115 Vbox vbox =
new Vbox();
116 row.appendChild(vbox);
118 final ContractListbox cl =
new ContractListbox(ContractWrapper.getContracts(26L));
119 cl.setMold(
"select");
120 cl.setObjectValue(pr.getPayroll().getContract());
121 cl.addEventListener(Events.ON_SELECT,
new EventListener() {
123 public void onEvent(Event event)
throws Exception {
124 pr.getPayroll().setContract(cl.getObjectValue());
127 vbox.appendChild(cl);
130 Grid grid =
new Grid();
131 row.appendChild(grid);
133 DocumentTotal total =
new DocumentTotal();
134 addLine(grid, pr.getPayrollLine(), total);
135 addLine(grid, pr.getInsuranceLine(), total);
136 addLine(grid, pr.getRetentionLine(), total);
137 addLine(grid, pr.getSeizureLine(), total);
138 addLine(grid, pr.getProtectionLine(), total);
139 addLine(grid, pr.getContingenciesLine(), total);
140 addLine(grid, total);
141 total.setDocument(pr.getPayroll());
143 PayrollExpiriesGrid expiries =
new PayrollExpiriesGrid();
144 expiries.setDocument(pr.getPayroll());
145 expiries.setAllowInsertions(
true);
146 expiries.setAllowDeletions(
true);
147 expiries.setDefaultBehavior(
false);
148 row.appendChild(expiries);
149 expiries.afterCompose();
155 private void addLine(Grid grid,
final DocumentLine line,
final DocumentTotal total) {
156 Rows rows = grid.getRows();
159 grid.appendChild(rows);
163 rows.appendChild(row);
165 row.appendChild(LabelTypes.getSoftLabel(line.getLineType().getName()));
166 final ExpressionInput ei =
new ExpressionInput();
168 ei.setValue(line.getPrice());
169 ei.addEventListener(Events.ON_CHANGE,
new EventListener() {
171 public void onEvent(Event event)
throws Exception {
172 line.setPrice(((Number) ei.getNumber(2)).doubleValue());
173 total.setDocument(line.getDocument());
178 Collection<Contract> stores =
new DocumentDefinitionWrapper(line.getDocument().getDocumentDefinition())
179 .getRelatedStores(line.getDocument().getContract());
180 if(stores.isEmpty()) {
181 stores =
new DocumentDefinitionWrapper(line.getDocument().getDocumentDefinition())
184 ContractWrapper.clearInactives(stores);
185 final ContractListbox slb =
new ContractListbox(
new ContractUsualSet(stores,
true, line.getDocument().getUsualPath() +
"st:"));
186 if(line.getStore() !=
null) slb.setObjectValue((Contract) line.getStore());
187 slb.setMold(
"select");
188 slb.addEventListener(Events.ON_SELECT,
new EventListener() {
190 public void onEvent(Event event)
throws Exception {
191 line.setStore(slb.getObjectValue());
195 row.appendChild(slb);
198 private void addLine(Grid grid, DocumentTotal total) {
199 Rows rows = grid.getRows();
202 grid.appendChild(rows);
206 rows.appendChild(row);
208 row.appendChild(LabelTypes.getEmptyLabel());
209 row.appendChild(total);
212 private void addColumns() {
213 Columns cols =
new Columns();
216 cols.appendChild(
new Column(
null,
null,
"20%"));
217 cols.appendChild(
new Column(
null,
null,
"40%"));
218 cols.appendChild(
new Column(
null,
null,
"40%"));
220 cols.setVisible(
false);
void setDocumentDate(Date documentDate)
void setReceiptDate(Date receiptDate)
Collection< Document > getPayrolls(Date date, boolean newPayrolls)
void setNewPayrolls(boolean newPayrolls)
PayrollFilter getFilter()
Rows getRows(boolean create)
void setRowCount(int rows)