BrightSide Workbench Full Report + Source Code
RelatedAccountGrid.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.model;
19 
20 import org.turro.auth.Authentication;
21 import org.turro.financials.entity.Account;
22 import org.turro.financials.entity.Contract;
23 import org.turro.financials.entity.ContractDefinition;
24 import org.turro.financials.entity.Document;
25 import org.turro.financials.entity.RelatedDocument;
26 import org.turro.financials.entity.RelatedLineType;
27 import org.turro.financials.entity.RelatedStoreDefinition;
28 import org.turro.zkoss.grid.PagingGrid;
29 import org.zkoss.zul.Hbox;
30 import org.zkoss.zul.Label;
31 import org.zkoss.zul.Row;
32 import org.zkoss.zul.Rows;
33 
38 public class RelatedAccountGrid extends PagingGrid {
39 
40  private ContractDefinition contractDefinition;
41 
42  public RelatedAccountGrid(ContractDefinition contractDefinition) {
43  this.contractDefinition = contractDefinition;
44  setSizedByContent(true);
45  setDefaultBehavior(false);
46  addRows();
47  }
48 
49  private void addRows() {
50  Rows rows = new Rows();
51  appendChild(rows);
52 
53  AccountSet accs = new AccountSet();
54 
55  Contract contract = new Contract();
56  contract.setContractDefinition(contractDefinition);
58  contract.setGlobalId("1");
59 
60  for(final RelatedDocument rd : contractDefinition.getRelatedDocuments()) {
62 
63  Contract store = new Contract();
64  store.setContractDefinition(rsd.getRelatedStore());
66  store.setGlobalId("2");
67 
68  Document document = new Document();
69  document.setDocumentDefinition(rd.getDocumentDefinition());
70  document.setContract(contract);
71 
73  accs.addAll(new AccountCreator(document, rlt.getLineType(), store).getAccounts());
74  }
75  }
76  }
77 
78  for(Account acc : accs) {
79  Row row = new Row();
80  rows.appendChild(row);
81 
82  Hbox hbox = new Hbox();
83  hbox.setSpacing("20px");
84  hbox.appendChild(new Label(acc.getId()));
85  hbox.appendChild(new Label(acc.getDescription()));
86  row.appendChild(hbox);
87  }
88 
89  setRowCount(accs.size());
90  }
91 
92 }
void setContractor(String contractor)
Definition: Contract.java:157
void setGlobalId(String globalId)
Definition: Contract.java:200
void setContractDefinition(ContractDefinition contractDefinition)
Definition: Contract.java:133
void setContract(Contract contract)
Definition: Document.java:123
void setDocumentDefinition(DocumentDefinition documentDefinition)
Definition: Document.java:175
RelatedAccountGrid(ContractDefinition contractDefinition)
void setDefaultBehavior(boolean defaultBehavior)