18 package org.turro.financials.menu;
20 import java.util.Date;
21 import java.util.HashMap;
22 import javax.activation.MimetypesFileTypeMap;
23 import org.amic.util.date.CheckDate;
24 import org.turro.annotation.ExternalMenu;
25 import org.turro.command.Command;
26 import org.turro.command.Context;
27 import org.turro.elephant.context.ElephantContext;
28 import org.turro.financials.account.DiaryReport;
29 import org.turro.financials.account.PrintBook;
30 import org.turro.financials.assets.FixedAssetWrapper;
31 import org.turro.financials.book.ExpensesBook;
32 import org.turro.financials.book.IncomeBook;
33 import org.turro.financials.document.QuickDocument;
34 import org.turro.financials.entity.Document;
35 import org.turro.financials.entity.Register;
36 import org.turro.financials.model.document.AnnualTransactionsSet;
37 import org.turro.financials.product.ProductImport;
38 import org.turro.financials.report.ReportBody;
39 import org.turro.financials.usual.UsualUpdate;
40 import org.turro.i18n.I_;
41 import org.turro.jpa.export.ExportQuery;
42 import org.turro.menu.ElephantMenu;
43 import org.turro.menu.ElephantMenuBar;
44 import org.turro.reflection.Reflections;
45 import org.turro.security.Permission;
46 import org.turro.zkoss.dialog.InputDialog;
47 import org.turro.zkoss.dialog.InputField;
48 import org.turro.zul.frame.Framework;
49 import org.zkoss.zk.ui.Executions;
50 import org.zkoss.zk.ui.event.Event;
51 import org.zkoss.zk.ui.event.EventListener;
52 import org.zkoss.zul.Filedownload;
63 Integer.valueOf(0),
null, 0,
new Command() {
65 public Object execute(Context context) {
66 Integer year = (Integer) context.get(
"value");
70 public String getLabel(String key) {
77 Filedownload.save(eq.
getExcel(name),
new MimetypesFileTypeMap().getContentType(name), name);
87 new InputField(
"Year", Integer.valueOf(new CheckDate().getYear()), null, 0),
88 new InputField(
"Month", Integer.valueOf(new CheckDate().getMonth()), null, 0),
89 new InputField(
"Carry on initial balance", Boolean.valueOf(false), null, 0),
90 new InputField(
"Breakdown", Boolean.valueOf(false), null, 0)
93 public Object execute(Context context) {
95 if(fields.length > 0) {
110 Integer.valueOf(0),
null, 0,
new Command() {
112 public Object execute(Context context) {
113 Integer year = (Integer) context.get(
"value");
124 Integer.valueOf(0),
null, 0,
new Command() {
126 public Object execute(Context context) {
127 Integer year = (Integer) context.get(
"value");
138 bar.
addMenu(
"Financials",
Permission.
from(
"finan-contract",
"finan-document",
"finan-product",
"finan-account"))
140 .
addMenu(
"Management",
Permission.
from(
"finan-contract:list",
"finan-document:list",
"finan-product:list"))
142 .
addMenuitem(
"Contracts",
"contract",
"/financials/contract/contracts.zul",
true,
Permission.
from(
"finan-contract:list"))
143 .
addMenuitem(
"Documents",
"document",
"/financials/document/documents.zul",
true,
Permission.
from(
"finan-document:list"))
149 .
addMenuitem(
"New contract",
"contract_new", (EventListener) (Event event) -> {
152 .addMenuitem(
"New document",
"document_new", (EventListener) (Event event) -> {
155 .addMenuitem(
"New quick document", (EventListener) (Event event) -> {
156 Date now =
new Date();
158 w.setPage(bar.getPage());
162 .addMenuitem(
"New batch of",
"batchof_new", (EventListener) (Event event) -> {
165 .addMenuitem(
"New product",
"product_new", (EventListener) (Event event) -> {
168 .addMenuitem(
"Import CSV", (EventListener) (Event event) -> {
171 .addToolbarSeparator(
true)
174 .addToolbarSeparator(
true)
178 .
addMenuitem(
"Portfolio",
"portfolio",
"/financials/document/portfolio.zul",
true)
179 .
addMenuitem(
"Documents statement",
"/financials/contract/documentsStatement.zul")
180 .
addMenuitem(
"Portfolio status",
"/financials/document/portfolioStatus.zul")
182 .
addMenuitem(
"Portfolio disagreements",
"/financials/document/portfolioDisagreements.zul")
183 .
addMenuitem(
"Portfolio errors",
"/financials/document/portfolioErrors.zul")
185 .
addMenuitem(
"Portfolio by entity",
"/financials/entities/portfolio.zul")
189 .
addMenuitem(
"Export", (EventListener) (Event event) -> {
190 Reflections.of(
"org.turro.pos.financials.ExportProducts").invoke(
"execute");
193 .
addMenu(
"Accounting",
Permission.
from(
"finan-account:statement",
"finan-account:balance",
"finan-register:new"))
195 .
addMenuitem(
"Account statement",
"statement",
"/financials/account/statement.zul",
true,
Permission.
from(
"finan-account:statement"))
196 .addMenuitem(
"Account balance",
"/financials/account/balance.zul",
Permission.
from(
"finan-account:balance"))
201 esm.addMenuitem(rb.getName(), (EventListener) (Event event) -> {
202 HashMap<String, Object> map =
new HashMap<String, Object>();
204 showZulFile(rb.getName(),
"/financials/reports/report.zul", map);
209 dr.setLabel(
I_.
get(
"Diary book"));
213 .addObject(
new PrintBook(), (esm, pb) -> {
214 pb.setLabel(
I_.
get(
"Print book"));
218 .addMenuitem(
"Export diary", (EventListener) (Event event) -> {
221 .addMenuitem(
"Export account balance", (EventListener) (Event event) -> {
222 exportAccountBalance(bar);
224 .addMenuitem(
"Annual statement transactions", (EventListener) (Event event) -> {
225 exportAnnualTransactions(bar);
227 .addMenuitem(
"Report sheets", (EventListener) (Event event) -> {
230 .addMenuitem(
"Operating",
"linechart",
"/financials/business/operating.zul",
Permission.
from(
"finan-account:balance"))
233 .addMenuitem(
"Books",
"/financials/book/books.zul",
Permission.
from(
"finan-model:list"))
234 .addMenuitem(
"Major accounts",
"/financials/account/majors.zul",
Permission.
from(
"finan-model:list"))
235 .addMenuitem(
"Accounts",
"/financials/account/accounts.zul",
Permission.
from(
"finan-model:list"))
238 .addMenuitem(
"New fixed asset",
"asset_new", (EventListener) (Event event) -> {
241 .addMenuitem(
"Depreciations", (EventListener) (Event event) -> {
245 .
addMenuitem(
"New register",
"register_new", (EventListener) (Event event) -> {
251 .
addMenuitem(
"Model 111, 115, 123",
"/financials/treasury/model111.zul")
252 .
addMenuitem(
"Model 303 Quarter",
"/financials/treasury/model303.zul")
253 .
addMenuitem(
"Model 303 Month",
"/financials/treasury/model303m.zul")
254 .
addMenuitem(
"Settlement",
"/financials/treasury/settlement.zul")
255 .
addMenuitem(
"Expenses book", (EventListener) (Event event) -> {
258 .addMenuitem(
"Income book", (EventListener) (Event event) -> {
264 .
addMenuitem(
"Disagreements in contacts",
"/financials/contract/contactDisagreements.zul",
Permission.
from(
"finan-contract:list"))
265 .addMenuitem(
"Update Usuals", (EventListener) (Event event) -> {
268 .addMenuitem(
"Non balanced registers",
"/financials/register/nonBalanced.zul",
Permission.
from(
"finan-register:list"))
273 .
addMenuitem(
"Viewer",
"/financials/ctcdef/viewer.zul")
275 .
addMenuitem(
"Companies",
"/financials/business/companies.zul")
277 .
addMenuitem(
"Contract models",
"/financials/ctcdef/contracts.zul")
278 .
addMenuitem(
"Document models",
"/financials/docdef/documents.zul")
279 .
addMenuitem(
"Line types",
"/financials/linetype/lineTypes.zul")
281 .
addMenuitem(
"Notes",
"/financials/ctcdef/notes.zul");
285 showEntity(
id,
"docdefId",
"Document model",
"/financials/docdef/document.zul");
289 showEntity(
id,
"ctcdefId",
"Contract model",
"/financials/ctcdef/contract.zul");
293 showEntity(
id,
"contractId",
"Contract",
"/financials/contract/contract.zul");
297 showEntity(
id,
"documentId",
"Document",
"/financials/document/document.zul");
301 showEntity(
id,
"batchOfId",
"Batch of",
"/financials/batchof/batchof.zul");
305 HashMap<String, Object> map =
new HashMap<String, Object>();
306 map.put(
"documentGenerated", doc);
307 showEntity(doc.
getId(),
"documentId",
"Document",
"/financials/document/document.zul", map);
311 showEntity(
id,
"registerId",
"Register",
"/financials/register/register.zul");
315 HashMap<String, Object> map =
new HashMap<String, Object>();
316 map.put(
"registerGenerated", reg);
317 showEntity(reg.
getId(),
"registerId",
"Register",
"/financials/register/register.zul", map);
321 showEntity(
id,
"productId",
"Product",
"/financials/product/product.zul");
325 Executions.getCurrent().getDesktop().setAttribute(
"statementId", account);
326 showEntity(0L,
"none",
"Account statement",
"/financials/account/statement.zul");
330 showEntity(
id,
"fixedAssetId",
"Fixed asset",
"/financials/asset/fixedAsset.zul");
334 showZulFile(
"Companies",
"/financials/business/companies.zul");
static String getSiteName()
static void exportDiary()
static void exportAccountBalance(int year, int month, boolean carry, boolean breakdown)
static void doDepreciations(Page page)
static ExpensesBook from(int year)
static IncomeBook from(int year)
Collection< Object[]> getRows()
Collection< String > getColumns()
static List< ReportBody > reports()
static String get(String msg)
InputStream getExcel(String sheetName)
static Permission from(String... roles)
static Framework getCurrent()
void showModal(String label, String src, Map arg, Command command)