18 package org.turro.financials.assets;
21 import org.turro.command.Command;
22 import org.turro.command.Context;
23 import org.turro.elephant.db.WhereClause;
24 import org.turro.financials.db.FinancialsPU;
25 import org.turro.financials.document.DocumentLinesListbox;
26 import org.turro.financials.entity.DocumentLine;
27 import org.turro.financials.entity.FixedAsset;
28 import org.turro.financials.entity.RegisterEntry;
29 import org.turro.financials.entity.RegisterView;
30 import org.turro.financials.menu.FinancialsMenu;
31 import static org.turro.financials.model.asset.FixedAssetWrapper.getAssets;
32 import org.turro.financials.model.document.DocumentWrapper;
33 import org.turro.financials.model.register.RegisterGenerator;
34 import org.turro.financials.model.register.ViewWrapper;
35 import org.turro.i18n.I_;
36 import org.turro.jpa.Dao;
37 import org.turro.math.Zero;
38 import org.turro.plugin.filter.IFilterValue;
39 import org.turro.zkoss.dialog.InputDialog;
40 import org.turro.zkoss.dialog.SelectionDialog;
41 import org.turro.zkoss.filter.FilterGrid;
42 import org.turro.zul.frame.Framework;
43 import org.zkoss.zk.ui.Component;
44 import org.zkoss.zk.ui.Page;
45 import org.zkoss.zul.Checkbox;
46 import org.zkoss.zul.Row;
59 if(
asset.isEmpty())
return null;
60 for(Component row : lines.
getRows().getChildren()) {
62 Checkbox cb = (Checkbox) row.getAttribute(
"cb");
63 if(cb !=
null && cb.isChecked()) {
65 Iterator<DocumentLine> it =
asset.getDocumentLines().iterator();
67 if(it.next().getId() == dl.
getId()) {
82 docLines.setMultiple(
true);
83 docLines.setCheckmark(
true);
90 docLines,
"80%",
"80%",
new Command() {
92 public Object execute(Context context) {
93 if(docLines !=
null) {
95 asset.getDocumentLines().add(dl);
97 if(command !=
null) command.execute(context);
104 private Collection<DocumentLine> getPossibleLines(
FilterGrid filterGrid) {
106 List<DocumentLine> relDocs =
new ArrayList<DocumentLine>();
109 relDocs.addAll(dao.getResultList(wc));
113 private WhereClause createCriteria(List<IFilterValue> values) {
114 WhereClause wc =
new WhereClause();
115 wc.addClause(
"select dl from DocumentLine as dl");
116 wc.addClause(
"where dl.lineType.id = :lineType");
117 wc.addNamedValue(
"lineType", 4L);
118 for(IFilterValue v : values) {
121 wc.addClause(
"order by dl.document.documentDate");
127 new Date(),
null, 0,
new Command() {
129 public Object execute(Context context) {
130 Date date = (Date) context.get(
"value");
135 if(
asset.getView().getId() == v.getId()) {
138 Set<RegisterEntry> sre = rg.
addAmount(v,
null,
asset.getStore(),
asset.getDepreciationLineType(),
139 asset.getId() +
"-" +
asset.getName(), toDepreciate);
FixedAssetWrapper(FixedAsset asset)
void loadLines(FilterGrid filterGrid, final Command command)
FixedAsset save(DocumentLinesGrid lines)
static void doDepreciations(Page page)
static String getObjectPath(Object object)
void setShowContract(boolean showContract)
void setContractPreference(ContractPreference contractPreference)
ContractPreference getDefaultContractPreference()
void setView(RegisterView view)
Set< RegisterEntry > getRegisterEntries()
void setRegisterDate(Date registerDate)
static Collection< FixedAsset > getAssets()
Set< RegisterEntry > addAmount(RegisterView view, Contract contract, Contract store, LineType lineType, String concept, double amount)
static List< RegisterView > getViews()
static String get(String msg)
static boolean near(double value, int digits)
List< IFilterValue > getValues()
Rows getRows(boolean create)
static Framework getCurrent()