18 package org.turro.financials.payroll;
20 import java.util.ArrayList;
21 import java.util.Collection;
22 import java.util.Date;
23 import java.util.logging.Level;
24 import java.util.logging.Logger;
25 import org.turro.string.Strings;
26 import org.turro.collections.CollectionUtil;
27 import org.turro.elephant.context.ElephantContext;
28 import org.turro.financials.contract.ContractListbox;
29 import org.turro.financials.contract.logic.ContractWrapper;
30 import org.turro.financials.db.FinancialsPU;
31 import org.turro.financials.document.logic.DocumentDefinitionWrapper;
32 import org.turro.financials.entity.Contract;
33 import org.turro.financials.entity.Document;
34 import org.turro.financials.entity.DocumentDefinition;
35 import org.turro.financials.entity.DocumentRelation;
36 import org.turro.financials.entity.LineType;
37 import org.turro.financials.model.contract.ContractUsualSet;
38 import org.turro.financials.model.document.SingleLineDocumentWrapper;
39 import org.turro.i18n.I_;
40 import org.turro.jpa.Dao;
41 import org.turro.zkoss.grid.CollectionGrid;
42 import org.turro.zkoss.grid.EditableCell;
43 import org.turro.zkoss.grid.EditableColumn;
44 import org.zkoss.zk.ui.HtmlBasedComponent;
45 import org.zkoss.zk.ui.event.Event;
46 import org.zkoss.zk.ui.event.Events;
47 import org.zkoss.zul.Row;
58 private Collection<Contract> stores;
66 ArrayList<DocumentRelation> list =
new ArrayList<DocumentRelation>();
68 list.add(sldw.getRelation());
78 this.document = document;
81 lineType = dao.find(
LineType.class, 7L);
84 if(stores.isEmpty()) {
89 lastStore = CollectionUtil.from(stores).first();
94 Events.postEvent(
new Event(Events.ON_CHANGE,
this));
107 super.afterCompose();
133 return v !=
null && v.
isValid();
141 }
catch (ClassNotFoundException ex) {
144 super.afterCompose();
153 }
else if(value instanceof
LineType) {
156 }
else if(value instanceof
Contract) {
160 return super.formatCell(editableCell, value);
176 slb.setMold(
"select");
181 sldw.
setPrice(getCurrentDifference());
183 return super.createEditor(editableCell);
186 return super.createEditor(editableCell);
191 super.cellChanged(editableCell, value);
198 private void addColumns() throws ClassNotFoundException {
199 int fractionDigits = document.
getCurrency().getDefaultFractionDigits();
201 "documentDate",
null, 0,
true,
false).setWidth(
"80px");
203 "price",
null, fractionDigits,
false,
false).setWidth(
"70px");
205 "store",
null, 0,
false,
false).setWidth(
"80px");
209 private Double getCurrentDifference() {
211 for(SingleLineDocumentWrapper sldw :
getValues()) {
212 total += sldw.getTotal();
static String logMsg(String msg)
String getPartialDescription()
Set< DocumentRelation > getDescendants()
String getDocumentNumber()
ContractPreference getDefaultContractPreference()
void setContractPreference(ContractPreference contractPreference)
static void clearInactives(Collection< Contract > contracts)
Collection< Contract > getRelatedStores(Contract contract)
static Collection< SingleLineDocumentWrapper > adapt(Document source, Collection< DocumentRelation > relations)
void setLineType(LineType lineType)
void setPrice(double price)
void setDocumentNumber(String documentNumber)
void setDocument(Document document)
void initiateRow(Row row, SingleLineDocumentWrapper value)
void cellChanged(EditableCell editableCell, Object value)
String formatCell(EditableCell editableCell, Object value)
Collection< DocumentRelation > getRelations()
boolean deleteRow(Row row)
boolean isValid(SingleLineDocumentWrapper v)
HtmlBasedComponent createEditor(EditableCell editableCell)
static String get(String msg)
void setCollection(Collection< V > collection)
EditableColumn addColumn(String label, Class javaClass, String property, String format, int scale, boolean onlyDate, boolean readOnly)
Object getCellValue(EditableCell editableCell)
void setReadOnly(boolean readOnly)
Columns getColumns(boolean create)