diff --git a/pom.xml b/pom.xml
index 4610f40..564fa1b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
seicentobilling
war
SeicentoBilling
- 20.4.0
+ 21.1.0
Einfache Leistungserfassungs und Rechnungssstellungs
Web-Applikation.
diff --git a/src/META-INF/persistence.xml b/src/META-INF/persistence.xml
index 8324a6f..afb583d 100644
--- a/src/META-INF/persistence.xml
+++ b/src/META-INF/persistence.xml
@@ -1,83 +1,84 @@
-
-
-
-
- org.hibernate.jpa.HibernatePersistenceProvider
-
- ch.xwr.seicentobilling.entities.Language
- ch.xwr.seicentobilling.entities.RowParameter
- ch.xwr.seicentobilling.entities.Company
- ch.xwr.seicentobilling.entities.RowImage
- ch.xwr.seicentobilling.entities.Customer
- ch.xwr.seicentobilling.entities.Project
- ch.xwr.seicentobilling.entities.ItemGroup
- ch.xwr.seicentobilling.entities.RowText
- ch.xwr.seicentobilling.entities.RowObject
- ch.xwr.seicentobilling.entities.Communication
- ch.xwr.seicentobilling.entities.Expense
- ch.xwr.seicentobilling.entities.RowLabel
- ch.xwr.seicentobilling.entities.Vat
- ch.xwr.seicentobilling.entities.VatLine
- ch.xwr.seicentobilling.entities.Item
- ch.xwr.seicentobilling.entities.OrderLine
- ch.xwr.seicentobilling.entities.Entity
- ch.xwr.seicentobilling.entities.RowRelation
- ch.xwr.seicentobilling.entities.ResPlanning
- ch.xwr.seicentobilling.entities.Periode
- ch.xwr.seicentobilling.entities.CostAccount
- ch.xwr.seicentobilling.entities.Order
- ch.xwr.seicentobilling.entities.StateCode
- ch.xwr.seicentobilling.entities.City
- ch.xwr.seicentobilling.entities.PaymentCondition
- ch.xwr.seicentobilling.entities.Bank
- ch.xwr.seicentobilling.entities.ProjectLine
- ch.xwr.seicentobilling.entities.ProjectLineTemplate
- ch.xwr.seicentobilling.entities.ExpenseTemplate
- ch.xwr.seicentobilling.entities.Activity
- ch.xwr.seicentobilling.entities.LabelDefinition
- ch.xwr.seicentobilling.entities.LabelAssignment
- ch.xwr.seicentobilling.entities.Address
- ch.xwr.seicentobilling.entities.CustomerLink
- ch.xwr.seicentobilling.entities.ContactRelation
- ch.xwr.seicentobilling.entities.Conversion
- ch.xwr.seicentobilling.entities.AppUser
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+ org.hibernate.jpa.HibernatePersistenceProvider
+
+ ch.xwr.seicentobilling.entities.Language
+ ch.xwr.seicentobilling.entities.RowParameter
+ ch.xwr.seicentobilling.entities.Company
+ ch.xwr.seicentobilling.entities.RowImage
+ ch.xwr.seicentobilling.entities.Customer
+ ch.xwr.seicentobilling.entities.Project
+ ch.xwr.seicentobilling.entities.ItemGroup
+ ch.xwr.seicentobilling.entities.RowText
+ ch.xwr.seicentobilling.entities.RowObject
+ ch.xwr.seicentobilling.entities.Communication
+ ch.xwr.seicentobilling.entities.Expense
+ ch.xwr.seicentobilling.entities.RowLabel
+ ch.xwr.seicentobilling.entities.Vat
+ ch.xwr.seicentobilling.entities.VatLine
+ ch.xwr.seicentobilling.entities.Item
+ ch.xwr.seicentobilling.entities.OrderLine
+ ch.xwr.seicentobilling.entities.Entity
+ ch.xwr.seicentobilling.entities.RowRelation
+ ch.xwr.seicentobilling.entities.ResPlanning
+ ch.xwr.seicentobilling.entities.Periode
+ ch.xwr.seicentobilling.entities.CostAccount
+ ch.xwr.seicentobilling.entities.Order
+ ch.xwr.seicentobilling.entities.StateCode
+ ch.xwr.seicentobilling.entities.City
+ ch.xwr.seicentobilling.entities.PaymentCondition
+ ch.xwr.seicentobilling.entities.Bank
+ ch.xwr.seicentobilling.entities.ProjectLine
+ ch.xwr.seicentobilling.entities.ProjectLineTemplate
+ ch.xwr.seicentobilling.entities.ExpenseTemplate
+ ch.xwr.seicentobilling.entities.Activity
+ ch.xwr.seicentobilling.entities.LabelDefinition
+ ch.xwr.seicentobilling.entities.LabelAssignment
+ ch.xwr.seicentobilling.entities.Address
+ ch.xwr.seicentobilling.entities.CustomerLink
+ ch.xwr.seicentobilling.entities.ContactRelation
+ ch.xwr.seicentobilling.entities.Conversion
+ ch.xwr.seicentobilling.entities.AppUser
+ ch.xwr.seicentobilling.entities.ProjectAllocation
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/ch/xwr/seicentobilling/business/JasperManager.java b/src/ch/xwr/seicentobilling/business/JasperManager.java
index fc86416..829829b 100644
--- a/src/ch/xwr/seicentobilling/business/JasperManager.java
+++ b/src/ch/xwr/seicentobilling/business/JasperManager.java
@@ -1,559 +1,622 @@
-package ch.xwr.seicentobilling.business;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.HttpURLConnection;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.nio.file.Paths;
-import java.text.MessageFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Set;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
-
-import org.apache.pdfbox.io.MemoryUsageSetting;
-import org.apache.pdfbox.multipdf.PDFMergerUtility;
-import org.apache.pdfbox.pdmodel.PDDocument;
-import org.jfree.util.Log;
-
-import ch.xwr.seicentobilling.dal.CompanyDAO;
-import ch.xwr.seicentobilling.dal.EntityDAO;
-import ch.xwr.seicentobilling.dal.PeriodeDAO;
-import ch.xwr.seicentobilling.dal.RowObjectDAO;
-import ch.xwr.seicentobilling.dal.RowParameterDAO;
-import ch.xwr.seicentobilling.entities.Company;
-import ch.xwr.seicentobilling.entities.Customer;
-import ch.xwr.seicentobilling.entities.Expense;
-import ch.xwr.seicentobilling.entities.Order;
-import ch.xwr.seicentobilling.entities.Periode;
-import ch.xwr.seicentobilling.entities.RowImage;
-import ch.xwr.seicentobilling.entities.RowObject;
-import ch.xwr.seicentobilling.entities.RowParameter;
-
-public class JasperManager {
- /** Logger initialized */
- private static final org.apache.log4j.Logger _logger = org.apache.log4j.Logger.getLogger(JasperManager.class);
-
- private Periode selectedPeriod = null;
- private final List keys = new ArrayList<>();
- private final List values = new ArrayList<>();
- private List fileList = new ArrayList<>();
-
- public static String CustomerReport1 = "Seicento_Kunden_Journal";
- public static String ProjectSummary1 = "Seicento_ProjectSummary";
- public static String ProjectReport1 = "Seicento_ProjectReport";
- public static String ExpenseReport1 = "Seicento_Spesen";
- public static String BillReport1 = "Rechnung_Seicento";
- public static String ProjectLineReport1 = "Seicento_ProjectReport";
- public static String ContactDetails1 = "Nested/Seicento_Contacts_Details";
-
- public void addParameter(final String name, final String value) {
- this.keys.add(name);
- this.values.add(value);
- }
-
- /**
- *
- * @param report
- * static report name
- * @return the uri to start the report on the jasper Server
- */
- public String getUri(final String report) {
- final CompanyDAO dao = new CompanyDAO();
- final Company cmp = dao.getActiveConfig();
-
- String uri = cmp.getCmpJasperUri().trim();
- if (cmp.getCmpReportUsr() != null) {
- uri = uri.replace("{user}", cmp.getCmpReportUsr().trim());
- }
- if (cmp.getCmpReportPwd() != null) {
- uri = uri.replace("{password}", cmp.getCmpReportPwd().trim());
- }
- uri = MessageFormat.format(uri, report);
-
- addDefaultParams(cmp);
- uri = getParamsToUri(uri);
-
- return uri;
- }
-
- private String getParamsToUri(String uriIn) {
- if (this.keys.size() > 0) {
- for (int i = 0; i < this.keys.size(); i++) {
- final String s1 = this.keys.get(i);
- final String s2 = this.values.get(i);
-
- uriIn = uriIn + "&" + s1 + "=" + s2;
- }
- }
-
- return uriIn;
- }
-
- public String getRestPdfUri(final String report) {
- try {
- final String ur = getRestUri(report);
- return ur;
- } catch (final Exception e) {
- e.printStackTrace();
- }
- return "";
- }
-
- public String getExpenseZip(final Periode per) {
- String zipFile = "";
- String fileExp = "";
- final String expname = "Spesen_" + per.getPerName();
- int httpcode = 0;
- this.fileList = new ArrayList<>();
-
- // compute URL for Expense
- resetParams();
- addParameter("Param_Periode", "" + per.getPerId());
- final String resturl = getRestPdfUri(ExpenseReport1);
-
- try {
- //Spesen
- fileExp = getTempFileName4Zip(expname, ".pdf");
- httpcode = streamToFile(resturl, fileExp);
- if (httpcode == 200) {
- this.fileList.add(new File(fileExp));
- }
- _logger.debug("PDF erstellt..." + httpcode);
-
- loopAttachments(per);
-
- zipFile = getTempFileName4Zip(expname, ".zip");
- zip(this.fileList, zipFile);
- return zipFile;
-
- } catch (final Exception e) {
- _logger.error("Fehler beim Erstellen von PDF Reports");
- e.printStackTrace();
- }
-
- return "Es ist ein Fehler aufgetreten!";
- }
-
- private void loopAttachments(final Periode per) {
- //get all Attachments of a specific expense Periode and write it to local file system
- final Periode bean = new PeriodeDAO().find(per.getPerId());
-
- final Set lst = bean.getExpenses();
- for (final Expense expense : lst) {
- lookupAttachments(expense);
- }
- }
-
- private void lookupAttachments(final Expense expense) {
- final RowObjectDAO row = new RowObjectDAO();
- final RowObject bean = row.getObjectBase(Expense.class.getSimpleName(), expense.getExpId());
- if (bean != null) {
- final Set flst = bean.getRowImages();
- for (final RowImage rowImage : flst) {
- writeAttachment(rowImage);
- }
- }
- }
-
- private void writeAttachment(final RowImage rowImage) {
- final String tempDir = System.getProperty("java.io.tmpdir");
- final String fname = tempDir + "/Att" + rowImage.getRimId() + "-" + rowImage.getRimName();
- final File fn = Paths.get(fname).toFile();
-
- FileOutputStream fos = null;
- try {
- fos = new FileOutputStream(fn);
- fos.write(rowImage.getRimImage());
- fos.close();
-
- this.fileList.add(fn);
- Log.debug("Attachment added to list " + fn.getName());
-
- } catch(final IOException ioe) {
- _logger.error("Can not write attachment", ioe);
- }
- }
-
-
- public String getBillingZip(final Order oBean) {
- String fileBill = "";
- String fileProject = "";
- String fileReport = "";
- String zipFile = "";
- final List lst = new ArrayList<>();
- int httpcode = 0;
-
- final boolean generateSummary = getBillReportOutputOptions(oBean, "reportSummary");
- final boolean generateWorkReport = getBillReportOutputOptions(oBean, "reportWork");
-
- // compute URL for Bill
- resetParams();
- addParameter("OrderNummer", "" + oBean.getOrdNumber());
- final String urlBill = getRestPdfUri(BillReport1);
-
- // compute URL for Project Summary
- resetParams();
- if (oBean.getProject() != null && generateSummary) {
- addParameter("Param_Project", "" + oBean.getProject().getProId());
- addParameter("BILL_Print", "true");
- }
- final String urlProject = getRestPdfUri(ProjectSummary1);
-
- // compute URL for Project Report
- resetParams();
- final long perId = getPeriode(oBean);
- if (oBean.getProject() != null && generateWorkReport) {
- addParameter("Param_Periode", "" + perId); // Periode
- addParameter("Param_ProjectId", "" + oBean.getProject().getProId());
- addParameter("REKAP_Print", "false");
- }
- final String urlReport = getRestPdfUri(ProjectReport1);
-
- try {
- //Rechnung
- fileBill = getTempFileName4Zip(oBean, 0);
- lst.add(new File(fileBill));
- httpcode = streamToFile(urlBill, fileBill); // Rechnung
- _logger.debug("PDF Rechnung erstellt..." + httpcode);
- //Workreport
- if (oBean.getProject() != null && perId > 0 && generateWorkReport) {
- fileReport = getTempFileName4Zip(oBean, 3);
- httpcode = streamToFile(urlReport, fileReport);
- _logger.debug("PDF Arbeitsrapport erstellt... Code: " + httpcode);
-
- if (httpcode == 200) { //ok
- lst.add(new File(fileReport));
- }
- }
- //ProjectSummary
- if (oBean.getProject() != null && generateSummary) {
- fileProject = getTempFileName4Zip(oBean, 1);
- httpcode = streamToFile(urlProject, fileProject); // ProjectSummary
- _logger.debug("PDF Projektsummary erstellt... Code: " + httpcode);
-
- if (httpcode == 200) {
- lst.add(new File(fileProject));
- }
- }
-
- final String mergePdf = mergeOnePdf(lst, oBean);
- if (!mergePdf.isEmpty()) {
- lst.clear();
- lst.add(new File(mergePdf));
- }
-
- zipFile = getTempFileName4Zip(oBean, 2);
- zip(lst, zipFile);
-
- } catch (final Exception e) {
- _logger.error("Fehler beim Erstellen von PDF Reports");
- e.printStackTrace();
- }
-
- return zipFile;
- }
-
- private String mergeOnePdf(final List lst, final Order oBean) {
- final Customer cus = oBean.getCustomer();
- String filename = "";
- if (cus.getCusSinglepdf() == null || !cus.getCusSinglepdf().booleanValue()) {
- return "";
- } else {
- filename = getTempFileName4Zip(oBean, 4);
- try {
- final PDFMergerUtility pdfmerger = new PDFMergerUtility();
- for (final File file : lst) {
- final PDDocument document = PDDocument.load(file);
- pdfmerger.setDestinationFileName(filename);
- pdfmerger.addSource(file);
- pdfmerger.mergeDocuments(MemoryUsageSetting.setupTempFileOnly());
- document.close();
- }
- } catch (final IOException e) {
- _logger.error("Error to merge PDF files. Error: " + e.getMessage());
- }
- }
-
- return filename;
- }
-
- private long getPeriode(final Order oBean) {
- return getSelectedPeriod().getPerId();
- }
-
- private void resetParams() {
- this.keys.clear();
- this.values.clear();
- }
-
- /**
- *
- * @param report
- * static report name
- * @return the uri to start the report on the jasper Server
- */
- private String getRestUri(final String report) {
- final String path = "/jasperserver/rest_v2/reports/reports/XWare_GmbH/";
-
- // http://xwrprod-srv1.cloudapp.net:80
- // /jasperserver/rest_v2/reports/reports/XWare_GmbH/Lohn/Salary_Slip.pdf
- // ?j_username=userxware&j_password=userxware&userLocale=de_CH&EmployeeId=2&Param_DateFrom=2016-01-20&Param_DateTo=2016-12-31
-
- final CompanyDAO dao = new CompanyDAO();
- final Company cmp = dao.getActiveConfig();
-
- addDefaultParams(cmp);
-
- URI cb;
- String cbs = "";
- try {
- String jasper = cmp.getCmpJasperUri().trim();
- jasper = jasper.substring(0, 100); // ged rid of {0}
-
- cb = new URI(jasper);
- cbs = cb.getScheme() + "://" + cb.getHost();
- if (cb.getPort() > 0) {
- cbs = cbs + ":" + cb.getPort();
- }
-
- cbs = cbs + path + report + ".pdf?";
- cbs = getParamsToUri(cbs);
-
- } catch (final URISyntaxException e) {
- _logger.error("URI ist fehlerhaft: " + cmp.getCmpJasperUri());
- e.printStackTrace();
- }
-
- return cbs;
- }
-
- private void addDefaultParams(final Company cmp) {
- if (cmp.getCmpReportUsr() != null) {
- addParameter("j_username", cmp.getCmpReportUsr().trim());
- }
- if (cmp.getCmpReportPwd() != null) {
- addParameter("j_password", cmp.getCmpReportPwd().trim());
- }
-
- addParameter("userLocale", "de_CH");
- }
-
- private int streamToFile(final String urlToRead, final String fileName) throws Exception {
- try {
- final URL url = new URL(urlToRead);
- final HttpURLConnection conn = (HttpURLConnection) url.openConnection();
- conn.setRequestMethod("GET");
- conn.setDoOutput(true);
-
- copyInputStreamToFile(conn.getInputStream(), new File(fileName));
-
- return conn.getResponseCode();
-
- } catch (final Exception e) {
- System.out.println(e.getLocalizedMessage());
- e.printStackTrace();
- }
-
- return 500;
- }
-
- private void copyInputStreamToFile(final InputStream in, final File file) {
- try {
- final OutputStream out = new FileOutputStream(file);
- final byte[] buf = new byte[1024];
- int len;
- while ((len = in.read(buf)) > 0) {
- out.write(buf, 0, len);
- }
- out.close();
- in.close();
- } catch (final Exception e) {
- _logger.error(e.getMessage());
- e.printStackTrace();
- }
- }
-
- private File zip(final List files, final String filename) {
- final File zipfile = new File(filename);
- // Create a buffer for reading the files
- final byte[] buf = new byte[1024];
- try {
- // create the ZIP file
- final ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipfile));
- // compress the files
- for (int i = 0; i < files.size(); i++) {
- final FileInputStream in = new FileInputStream(files.get(i).getCanonicalFile());
- // add ZIP entry to output stream
- out.putNextEntry(new ZipEntry(files.get(i).getName()));
- // transfer bytes from the file to the ZIP file
- int len;
- while ((len = in.read(buf)) > 0) {
- out.write(buf, 0, len);
- }
- // complete the entry
- out.closeEntry();
- in.close();
- }
- // complete the ZIP file
- out.close();
-
- // delete origin files
- for (int i = 0; i < files.size(); i++) {
- files.get(i).delete();
- }
-
- return zipfile;
- } catch (final IOException ex) {
- _logger.error(ex.getMessage());
- }
- return null;
- }
-
- private String getTempFileName4Zip(final Order bean, final int iflag) {
- //Default
- String fileExt = ".pdf";
- String prefix = "Rechnung_" + bean.getOrdNumber();
-
- if (iflag == 1) {
- prefix = "ProjectSummary_#" + bean.getProject().getProId();
- }
- if (iflag == 2) {
- fileExt = ".zip";
- prefix = "XWare_R" + bean.getOrdNumber() + "_" + getTimeStamp();
- }
- if (iflag == 3) {
- prefix = "WorkReport_" + getSelectedPeriod().getPerName();
- }
- if (iflag == 4) {
- prefix = "RechnungLang_" + bean.getOrdNumber();
- }
-
- return getTempFileName4Zip(prefix, fileExt);
- }
-
- private String getTempFileName4Zip(final String prefix, final String fileExt) {
- final String tempDir = System.getProperty("java.io.tmpdir");
-
- final String fname = tempDir + "/" + prefix + fileExt;
- return Paths.get(fname).toFile().toString();
- }
-
- private String getTimeStamp() {
- final String timeStamp = new SimpleDateFormat("yyMMddHHmmss").format(new Date());
- return timeStamp;
- }
-
- private boolean getBillReportOutputOptions(final Order obean, final String key)
- {
- final Customer cus = obean.getCustomer();
- final Long cusId = cus.getCusId();
-
- if (cus.getCusBillingReport() != null) {
- if (key.equalsIgnoreCase("reportWork")) {
- if (hasNoReports()) {
- return false;
- }
- if (cus.getCusBillingReport() == LovCrm.BillReport.working) {
- return true;
- }
- if (cus.getCusBillingReport() == LovCrm.BillReport.project) {
- return true;
- }
- }
- if (key.equalsIgnoreCase("reportSummary")) {
- if (cus.getCusBillingReport() == LovCrm.BillReport.project) {
- return true;
- }
- }
-
- return false;
- }
-
- //fallback
- //final var cus = this.Orders.SelectedItem.Customer.cusId;
- RowObject objRoot = getObjRoot(cusId, "Customer");
- if (objRoot == null) {
- objRoot = new RowObject();
- }
- RowObject cmpRoot = getObjRoot((long) 1, "Company");
- if (cmpRoot == null) {
- cmpRoot = new RowObject();
- }
-
- final String outputOptions = getRowParameter(objRoot, "pdfmail", "pdfmail", key);
- if (outputOptions == null || outputOptions.isEmpty()) {
- return true;
- }
-
- if ("true".equalsIgnoreCase(outputOptions)) {
- return true;
- }
- return false;
- }
-
- private boolean hasNoReports() {
- final PeriodeDAO dao = new PeriodeDAO();
- final Periode per = dao.find(getSelectedPeriod().getPerId());
-
- if (per.getProjectLines().size() > 0) {
- return false; //has data
- }
- // No data to print
- return true;
- }
-
- private String getRowParameter(final RowObject objRoot, final String group, final String subgroup, final String key)
- {
- final RowParameterDAO dao = new RowParameterDAO();
- final RowParameter bean = dao.getParameter(objRoot, group, subgroup, key);
- if (bean == null) {
- return "";
- }
- return bean.getPrmValue();
- }
-
- private RowObject getObjRoot(final Long id, final String entName) {
- final EntityDAO entDao = new EntityDAO();
- final RowObjectDAO rooDao = new RowObjectDAO();
-
- final ch.xwr.seicentobilling.entities.Entity entBean = entDao.findEntity(entName);
- final RowObject rooBean = rooDao.findObjectBase(entBean, id).get(0);
-
- return rooBean;
- }
-
- public Periode getSelectedPeriod() {
- return this.selectedPeriod;
- }
-
- public void setSelectedPeriod(final Periode selectedPeriod) {
- this.selectedPeriod = selectedPeriod;
- }
-
-// private void downloadToWS(final String name) {
-// final File inp = new File(name);
-//
-// final String home = System.getProperty("user.home");
-// final File outf = new File(home+"/Downloads/" + inp.getName());
-//
-// try (ReadableByteChannel in = Channels
-// .newChannel(new FileInputStream(inp));
-// FileChannel out = new FileOutputStream(outf).getChannel()) {
-//
-// out.transferFrom(in, 0, Long.MAX_VALUE);
-// } catch (final Exception e) {
-// e.printStackTrace();
-// }
-// }
-
-}
+package ch.xwr.seicentobilling.business;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.file.Paths;
+import java.text.MessageFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+import org.apache.pdfbox.io.MemoryUsageSetting;
+import org.apache.pdfbox.multipdf.PDFMergerUtility;
+import org.apache.pdfbox.pdmodel.PDDocument;
+import org.jfree.util.Log;
+
+import ch.xwr.seicentobilling.dal.CompanyDAO;
+import ch.xwr.seicentobilling.dal.EntityDAO;
+import ch.xwr.seicentobilling.dal.PeriodeDAO;
+import ch.xwr.seicentobilling.dal.ProjectDAO;
+import ch.xwr.seicentobilling.dal.RowObjectDAO;
+import ch.xwr.seicentobilling.dal.RowParameterDAO;
+import ch.xwr.seicentobilling.entities.Company;
+import ch.xwr.seicentobilling.entities.Customer;
+import ch.xwr.seicentobilling.entities.Expense;
+import ch.xwr.seicentobilling.entities.Order;
+import ch.xwr.seicentobilling.entities.Periode;
+import ch.xwr.seicentobilling.entities.Project;
+import ch.xwr.seicentobilling.entities.ProjectAllocation;
+import ch.xwr.seicentobilling.entities.RowImage;
+import ch.xwr.seicentobilling.entities.RowObject;
+import ch.xwr.seicentobilling.entities.RowParameter;
+
+public class JasperManager {
+ /** Logger initialized */
+ private static final org.apache.log4j.Logger _logger = org.apache.log4j.Logger.getLogger(JasperManager.class);
+
+ private Periode selectedPeriod = null;
+ private final List keys = new ArrayList<>();
+ private final List values = new ArrayList<>();
+ private List fileList = new ArrayList<>();
+
+ public static String CustomerReport1 = "Seicento_Kunden_Journal";
+ public static String ProjectSummary1 = "Seicento_ProjectSummary";
+ public static String ProjectReport1 = "Seicento_ProjectReport";
+ public static String ExpenseReport1 = "Seicento_Spesen";
+ public static String BillReport1 = "Rechnung_Seicento";
+ public static String ProjectLineReport1 = "Seicento_ProjectReport";
+ public static String ContactDetails1 = "Nested/Seicento_Contacts_Details";
+
+ public void addParameter(final String name, final String value) {
+ this.keys.add(name);
+ this.values.add(value);
+ }
+
+ /**
+ *
+ * @param report
+ * static report name
+ * @return the uri to start the report on the jasper Server
+ */
+ public String getUri(final String report) {
+ final CompanyDAO dao = new CompanyDAO();
+ final Company cmp = dao.getActiveConfig();
+
+ String uri = cmp.getCmpJasperUri().trim();
+ if (cmp.getCmpReportUsr() != null) {
+ uri = uri.replace("{user}", cmp.getCmpReportUsr().trim());
+ }
+ if (cmp.getCmpReportPwd() != null) {
+ uri = uri.replace("{password}", cmp.getCmpReportPwd().trim());
+ }
+ uri = MessageFormat.format(uri, report);
+
+ addDefaultParams(cmp);
+ uri = getParamsToUri(uri);
+
+ return uri;
+ }
+
+ private String getParamsToUri(String uriIn) {
+ if (this.keys.size() > 0) {
+ for (int i = 0; i < this.keys.size(); i++) {
+ final String s1 = this.keys.get(i);
+ final String s2 = this.values.get(i);
+
+ uriIn = uriIn + "&" + s1 + "=" + s2;
+ }
+ }
+
+ return uriIn;
+ }
+
+ public String getRestPdfUri(final String report) {
+ try {
+ final String ur = getRestUri(report);
+ return ur;
+ } catch (final Exception e) {
+ e.printStackTrace();
+ }
+ return "";
+ }
+
+ public String getExpenseZip(final Periode per) {
+ String zipFile = "";
+ String fileExp = "";
+ final String expname = "Spesen_" + per.getPerName();
+ int httpcode = 0;
+ this.fileList = new ArrayList<>();
+
+ // compute URL for Expense
+ resetParams();
+ addParameter("Param_Periode", "" + per.getPerId());
+ final String resturl = getRestPdfUri(ExpenseReport1);
+
+ try {
+ //Spesen
+ fileExp = getTempFileName4Zip(expname, ".pdf");
+ httpcode = streamToFile(resturl, fileExp);
+ if (httpcode == 200) {
+ this.fileList.add(new File(fileExp));
+ }
+ _logger.debug("PDF erstellt..." + httpcode);
+
+ loopAttachments(per);
+
+ zipFile = getTempFileName4Zip(expname, ".zip");
+ zip(this.fileList, zipFile);
+ return zipFile;
+
+ } catch (final Exception e) {
+ _logger.error("Fehler beim Erstellen von PDF Reports");
+ e.printStackTrace();
+ }
+
+ return "Es ist ein Fehler aufgetreten!";
+ }
+
+ private void loopAttachments(final Periode per) {
+ //get all Attachments of a specific expense Periode and write it to local file system
+ final Periode bean = new PeriodeDAO().find(per.getPerId());
+
+ final Set lst = bean.getExpenses();
+ for (final Expense expense : lst) {
+ lookupAttachments(expense);
+ }
+ }
+
+ private void lookupAttachments(final Expense expense) {
+ final RowObjectDAO row = new RowObjectDAO();
+ final RowObject bean = row.getObjectBase(Expense.class.getSimpleName(), expense.getExpId());
+ if (bean != null) {
+ final Set flst = bean.getRowImages();
+ for (final RowImage rowImage : flst) {
+ writeAttachment(rowImage);
+ }
+ }
+ }
+
+ private void writeAttachment(final RowImage rowImage) {
+ final String tempDir = System.getProperty("java.io.tmpdir");
+ final String fname = tempDir + "/Att" + rowImage.getRimId() + "-" + rowImage.getRimName();
+ final File fn = Paths.get(fname).toFile();
+
+ FileOutputStream fos = null;
+ try {
+ fos = new FileOutputStream(fn);
+ fos.write(rowImage.getRimImage());
+ fos.close();
+
+ this.fileList.add(fn);
+ Log.debug("Attachment added to list " + fn.getName());
+
+ } catch(final IOException ioe) {
+ _logger.error("Can not write attachment", ioe);
+ }
+ }
+
+
+ public String getBillingZip(final Order oBean) {
+ String fileBill = "";
+ String fileProject = "";
+ String fileReport = "";
+ String zipFile = "";
+ final List lst = new ArrayList<>();
+ int httpcode = 0;
+
+ final boolean generateSummary = getBillReportOutputOptions(oBean, "reportSummary");
+ final boolean generateWorkReport = getBillReportOutputOptions(oBean, "reportWork");
+
+ // compute URL for Bill
+ resetParams();
+ addParameter("OrderNummer", "" + oBean.getOrdNumber());
+ final String urlBill = getRestPdfUri(BillReport1);
+
+ // compute URL for Project Summary
+ resetParams();
+ if (oBean.getProject() != null && generateSummary) {
+ addParameter("Param_Project", "" + oBean.getProject().getProId());
+ addParameter("BILL_Print", "true");
+ }
+ final String urlProject = getRestPdfUri(ProjectSummary1);
+
+ // compute URL for Project Report (ProjectReport1)
+ final HashMap wrepurls = getWorkReportUrl(oBean.getProject());
+ try {
+ //Rechnung
+ fileBill = getTempFileName4Zip(oBean, 0, "");
+ lst.add(new File(fileBill));
+ httpcode = streamToFile(urlBill, fileBill); // Rechnung
+ _logger.debug("PDF Rechnung erstellt..." + httpcode);
+ //Workreport
+ if (oBean.getProject() != null && generateWorkReport) {
+ if (wrepurls.size() > 0) {
+ final Iterator> it = wrepurls.entrySet().iterator();
+ while (it.hasNext()) {
+ final Map.Entry pair = it.next();
+ System.out.println(pair.getKey() + " = " + pair.getValue());
+
+ fileReport = getTempFileName4Zip(oBean, 3, pair.getKey());
+ httpcode = streamToFile(pair.getValue().toString(), fileReport);
+ _logger.debug("PDF Arbeitsrapport erstellt... Code: " + httpcode);
+
+ if (httpcode == 200) { //ok
+ lst.add(new File(fileReport));
+ }
+ }
+ }
+ }
+ //ProjectSummary
+ if (oBean.getProject() != null && generateSummary) {
+ fileProject = getTempFileName4Zip(oBean, 1, "");
+ httpcode = streamToFile(urlProject, fileProject); // ProjectSummary
+ _logger.debug("PDF Projektsummary erstellt... Code: " + httpcode);
+
+ if (httpcode == 200) {
+ lst.add(new File(fileProject));
+ }
+ }
+
+ final String mergePdf = mergeOnePdf(lst, oBean);
+ if (!mergePdf.isEmpty()) {
+ lst.clear();
+ lst.add(new File(mergePdf));
+ }
+
+ zipFile = getTempFileName4Zip(oBean, 2, "");
+ zip(lst, zipFile);
+
+ } catch (final Exception e) {
+ _logger.error("Fehler beim Erstellen von PDF Reports");
+ e.printStackTrace();
+ }
+
+ return zipFile;
+ }
+
+ private HashMap getWorkReportUrl(final Project project) {
+ final HashMap urls = new HashMap<>();
+
+ final ProjectDAO dao = new ProjectDAO();
+ final Project pro = dao.find(project.getProId());
+
+ if (getSelectedPeriod() != null) {
+ final long perId = getSelectedPeriod().getPerId();
+
+ urls.put(getSelectedPeriod().getPerName(), getSingleWorkReportUrl(perId, project.getProId()));
+
+ if (project.getProOrdergenerationStrategy() == LovState.ProOrderStrategy.zusammenziehen ) {
+ final Set lst = pro.getProjectAllocations();
+ for (final Iterator itr = lst.iterator(); itr.hasNext();) {
+ final ProjectAllocation pra = itr.next();
+ if (!pra.getCostAccount().getCsaId().equals(getSelectedPeriod().getCostAccount().getCsaId())) { //prevent own double
+ final Periode per = getValidPeriodForCst(getSelectedPeriod(), pra);
+ //now we have the periode and the project
+ if (per != null) {
+ urls.put(per.getPerName(), getSingleWorkReportUrl(per.getPerId(), project.getProId()));
+ }
+ }
+ }
+
+ }
+ }
+
+ return urls;
+ }
+
+ private String getSingleWorkReportUrl(final long perId, final Long proId) {
+ resetParams();
+ addParameter("Param_Periode", "" + perId); // Periode
+ addParameter("Param_ProjectId", "" + proId);
+ addParameter("REKAP_Print", "false");
+
+ final String urlReport = getRestPdfUri(ProjectReport1);
+ return urlReport;
+
+ }
+
+ private Periode getValidPeriodForCst(final Periode inp, final ProjectAllocation pra) {
+ final PeriodeDAO pd = new PeriodeDAO();
+ final List lsper = pd.findByCostAccountTop(pra.getCostAccount(), 5);
+ for (final Iterator itrP = lsper.iterator(); itrP.hasNext();) {
+ final Periode per = itrP.next();
+
+ if (per.getPerMonth().getValue() == inp.getPerMonth().getValue() && per.getPerYear().equals(inp.getPerYear())) {
+ return per;
+ }
+ }
+
+ return null; //no Periode found
+ }
+
+
+ private String mergeOnePdf(final List lst, final Order oBean) {
+ final Customer cus = oBean.getCustomer();
+ String filename = "";
+ if (cus.getCusSinglepdf() == null || !cus.getCusSinglepdf().booleanValue()) {
+ return "";
+ } else {
+ filename = getTempFileName4Zip(oBean, 4, "");
+ try {
+ final PDFMergerUtility pdfmerger = new PDFMergerUtility();
+ for (final File file : lst) {
+ final PDDocument document = PDDocument.load(file);
+ pdfmerger.setDestinationFileName(filename);
+ pdfmerger.addSource(file);
+ pdfmerger.mergeDocuments(MemoryUsageSetting.setupTempFileOnly());
+ document.close();
+ }
+ } catch (final IOException e) {
+ _logger.error("Error to merge PDF files. Error: " + e.getMessage());
+ }
+ }
+
+ return filename;
+ }
+
+// private long getPeriode(final Order oBean) {
+// return getSelectedPeriod().getPerId();
+// }
+
+ private void resetParams() {
+ this.keys.clear();
+ this.values.clear();
+ }
+
+ /**
+ *
+ * @param report
+ * static report name
+ * @return the uri to start the report on the jasper Server
+ */
+ private String getRestUri(final String report) {
+ final String path = "/jasperserver/rest_v2/reports/reports/XWare_GmbH/";
+
+ // http://xwrprod-srv1.cloudapp.net:80
+ // /jasperserver/rest_v2/reports/reports/XWare_GmbH/Lohn/Salary_Slip.pdf
+ // ?j_username=userxware&j_password=userxware&userLocale=de_CH&EmployeeId=2&Param_DateFrom=2016-01-20&Param_DateTo=2016-12-31
+
+ final CompanyDAO dao = new CompanyDAO();
+ final Company cmp = dao.getActiveConfig();
+
+ addDefaultParams(cmp);
+
+ URI cb;
+ String cbs = "";
+ try {
+ String jasper = cmp.getCmpJasperUri().trim();
+ jasper = jasper.substring(0, 100); // ged rid of {0}
+
+ cb = new URI(jasper);
+ cbs = cb.getScheme() + "://" + cb.getHost();
+ if (cb.getPort() > 0) {
+ cbs = cbs + ":" + cb.getPort();
+ }
+
+ cbs = cbs + path + report + ".pdf?";
+ cbs = getParamsToUri(cbs);
+
+ } catch (final URISyntaxException e) {
+ _logger.error("URI ist fehlerhaft: " + cmp.getCmpJasperUri());
+ e.printStackTrace();
+ }
+
+ return cbs;
+ }
+
+ private void addDefaultParams(final Company cmp) {
+ if (cmp.getCmpReportUsr() != null) {
+ addParameter("j_username", cmp.getCmpReportUsr().trim());
+ }
+ if (cmp.getCmpReportPwd() != null) {
+ addParameter("j_password", cmp.getCmpReportPwd().trim());
+ }
+
+ addParameter("userLocale", "de_CH");
+ }
+
+ private int streamToFile(final String urlToRead, final String fileName) throws Exception {
+ try {
+ final URL url = new URL(urlToRead);
+ final HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+ conn.setRequestMethod("GET");
+ conn.setDoOutput(true);
+
+ copyInputStreamToFile(conn.getInputStream(), new File(fileName));
+
+ return conn.getResponseCode();
+
+ } catch (final Exception e) {
+ System.out.println(e.getLocalizedMessage());
+ e.printStackTrace();
+ }
+
+ return 500;
+ }
+
+ private void copyInputStreamToFile(final InputStream in, final File file) {
+ try {
+ final OutputStream out = new FileOutputStream(file);
+ final byte[] buf = new byte[1024];
+ int len;
+ while ((len = in.read(buf)) > 0) {
+ out.write(buf, 0, len);
+ }
+ out.close();
+ in.close();
+ } catch (final Exception e) {
+ _logger.error(e.getMessage());
+ e.printStackTrace();
+ }
+ }
+
+ private File zip(final List files, final String filename) {
+ final File zipfile = new File(filename);
+ // Create a buffer for reading the files
+ final byte[] buf = new byte[1024];
+ try {
+ // create the ZIP file
+ final ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipfile));
+ // compress the files
+ for (int i = 0; i < files.size(); i++) {
+ final FileInputStream in = new FileInputStream(files.get(i).getCanonicalFile());
+ // add ZIP entry to output stream
+ out.putNextEntry(new ZipEntry(files.get(i).getName()));
+ // transfer bytes from the file to the ZIP file
+ int len;
+ while ((len = in.read(buf)) > 0) {
+ out.write(buf, 0, len);
+ }
+ // complete the entry
+ out.closeEntry();
+ in.close();
+ }
+ // complete the ZIP file
+ out.close();
+
+ // delete origin files
+ for (int i = 0; i < files.size(); i++) {
+ files.get(i).delete();
+ }
+
+ return zipfile;
+ } catch (final IOException ex) {
+ _logger.error(ex.getMessage());
+ }
+ return null;
+ }
+
+ private String getTempFileName4Zip(final Order bean, final int iflag, final String name) {
+ //Default
+ String fileExt = ".pdf";
+ String prefix = "Rechnung_" + bean.getOrdNumber();
+
+ if (iflag == 1) {
+ prefix = "ProjectSummary_#" + bean.getProject().getProId();
+ }
+ if (iflag == 2) {
+ fileExt = ".zip";
+ prefix = "XWare_R" + bean.getOrdNumber() + "_" + getTimeStamp();
+ }
+ if (iflag == 3) {
+ prefix = "WorkReport_" + name;
+ }
+ if (iflag == 4) {
+ prefix = "RechnungLang_" + bean.getOrdNumber();
+ }
+
+ return getTempFileName4Zip(prefix, fileExt);
+ }
+
+ private String getTempFileName4Zip(final String prefix, final String fileExt) {
+ final String tempDir = System.getProperty("java.io.tmpdir");
+
+ final String fname = tempDir + "/" + prefix + fileExt;
+ return Paths.get(fname).toFile().toString();
+ }
+
+ private String getTimeStamp() {
+ final String timeStamp = new SimpleDateFormat("yyMMddHHmmss").format(new Date());
+ return timeStamp;
+ }
+
+ private boolean getBillReportOutputOptions(final Order obean, final String key)
+ {
+ final Customer cus = obean.getCustomer();
+ final Long cusId = cus.getCusId();
+
+ if (cus.getCusBillingReport() != null) {
+ if (key.equalsIgnoreCase("reportWork")) {
+ if (hasNoReports()) {
+ return false;
+ }
+ if (cus.getCusBillingReport() == LovCrm.BillReport.working) {
+ return true;
+ }
+ if (cus.getCusBillingReport() == LovCrm.BillReport.project) {
+ return true;
+ }
+ }
+ if (key.equalsIgnoreCase("reportSummary")) {
+ if (cus.getCusBillingReport() == LovCrm.BillReport.project) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ //fallback
+ //final var cus = this.Orders.SelectedItem.Customer.cusId;
+ RowObject objRoot = getObjRoot(cusId, "Customer");
+ if (objRoot == null) {
+ objRoot = new RowObject();
+ }
+ RowObject cmpRoot = getObjRoot((long) 1, "Company");
+ if (cmpRoot == null) {
+ cmpRoot = new RowObject();
+ }
+
+ final String outputOptions = getRowParameter(objRoot, "pdfmail", "pdfmail", key);
+ if (outputOptions == null || outputOptions.isEmpty()) {
+ return true;
+ }
+
+ if ("true".equalsIgnoreCase(outputOptions)) {
+ return true;
+ }
+ return false;
+ }
+
+ private boolean hasNoReports() {
+ final PeriodeDAO dao = new PeriodeDAO();
+ final Periode per = dao.find(getSelectedPeriod().getPerId());
+
+ if (per.getProjectLines().size() > 0) {
+ return false; //has data
+ }
+ // No data to print
+ return true;
+ }
+
+ private String getRowParameter(final RowObject objRoot, final String group, final String subgroup, final String key)
+ {
+ final RowParameterDAO dao = new RowParameterDAO();
+ final RowParameter bean = dao.getParameter(objRoot, group, subgroup, key);
+ if (bean == null) {
+ return "";
+ }
+ return bean.getPrmValue();
+ }
+
+ private RowObject getObjRoot(final Long id, final String entName) {
+ final EntityDAO entDao = new EntityDAO();
+ final RowObjectDAO rooDao = new RowObjectDAO();
+
+ final ch.xwr.seicentobilling.entities.Entity entBean = entDao.findEntity(entName);
+ final RowObject rooBean = rooDao.findObjectBase(entBean, id).get(0);
+
+ return rooBean;
+ }
+
+ public Periode getSelectedPeriod() {
+ return this.selectedPeriod;
+ }
+
+ public void setSelectedPeriod(final Periode selectedPeriod) {
+ this.selectedPeriod = selectedPeriod;
+ }
+
+// private void downloadToWS(final String name) {
+// final File inp = new File(name);
+//
+// final String home = System.getProperty("user.home");
+// final File outf = new File(home+"/Downloads/" + inp.getName());
+//
+// try (ReadableByteChannel in = Channels
+// .newChannel(new FileInputStream(inp));
+// FileChannel out = new FileOutputStream(outf).getChannel()) {
+//
+// out.transferFrom(in, 0, Long.MAX_VALUE);
+// } catch (final Exception e) {
+// e.printStackTrace();
+// }
+// }
+
+}
diff --git a/src/ch/xwr/seicentobilling/business/LovState.java b/src/ch/xwr/seicentobilling/business/LovState.java
index 137c1b7..0ca5867 100644
--- a/src/ch/xwr/seicentobilling/business/LovState.java
+++ b/src/ch/xwr/seicentobilling/business/LovState.java
@@ -1,102 +1,111 @@
-package ch.xwr.seicentobilling.business;
-
-public class LovState {
- public static enum State {
- inactive, active, locked
- }
-
- public static enum Unit {
- piece, hour, unit, kg, meter, litre
- }
-
- public static enum ProState {
- grün, gelb, rot
- }
-
- public static enum ProModel {
- undefined, fix, variable
- }
-
- public static enum ExpUnit {
- kilometer, währung, stück
- }
-
- public static enum ExpType {
- standard, essen, reise
- }
-
- public static enum WorkType {
- analysis, consulting, development, project, journey, expense
- }
-
- public static enum ValueType {
- string, integer, decimal, bool, date
- }
-
- public static enum BookingType {
- offen, gebucht
- }
-
- public static enum Theme {
- dark, facebook, light
- }
-
- /**
- * Monate (sollte eigentlich bei 1 starten)
- **/
- public static enum Month {
- empty(0), januar(1), februar(2), märz(3), april(4), mai(5), juni(6), juli(7), august(8), september(9), oktober(
- 10), november(11), dezember(12);
-
- private final int value;
-
- private Month(final int value) {
- this.value = value;
- }
-
- public int getValue() {
- return this.value;
- }
-
- public static Month fromId(final int id) {
- for (final Month type : Month.values()) {
- if (type.getValue() == id) {
- return type;
- }
- }
- return null;
- }
- }
-
- public static enum AccountType {
- natürlich, juristisch
- }
-
-
- /**
- * Spesenkonti (Text) not used anymore - own DAO
- **/
-// public static enum Accounts {
-// spesen("a.Spesen"), weiterbildung("Test"), büroaufwand("x"), reisespesen("y"), divers("d"),
-// repräsentation("r"), werbung("w"), miete("m"), itunterhalt("itc");
-//
-// private final String text;
-//
-// Accounts(final String text) {
-// this.text = text;
-// }
-//
-// public String getText() {
-// return this.text;
-// }
-//
-// public static Accounts fromString(final String text) {
-// for (final Accounts b : Accounts.values()) {
-// if (b.text.equalsIgnoreCase(text)) {
-// return b;
-// }
-// }
-// return null;
-// }
-// }
-}
+package ch.xwr.seicentobilling.business;
+
+public class LovState {
+ public static enum State {
+ inactive, active, locked
+ }
+
+ public static enum Unit {
+ piece, hour, unit, kg, meter, litre
+ }
+
+ public static enum ProState {
+ grün, gelb, rot
+ }
+
+ public static enum ProModel {
+ undefined, fix, variable
+ }
+
+ public static enum ProOrderStrategy {
+ exklusiv, zusammenziehen
+ }
+
+ public static enum ExpUnit {
+ kilometer, währung, stück
+ }
+
+ public static enum ExpType {
+ standard, essen, reise
+ }
+
+ public static enum WorkType {
+ analysis, consulting, development, project, journey, expense
+ }
+
+ public static enum ValueType {
+ string, integer, decimal, bool, date
+ }
+
+ public static enum BookingType {
+ offen, gebucht
+ }
+
+ public static enum Theme {
+ dark, facebook, light
+ }
+
+ /**
+ * Monate (sollte eigentlich bei 1 starten)
+ **/
+ public static enum Month {
+ empty(0), januar(1), februar(2), märz(3), april(4), mai(5), juni(6), juli(7), august(8), september(9), oktober(
+ 10), november(11), dezember(12);
+
+ private final int value;
+
+ private Month(final int value) {
+ this.value = value;
+ }
+
+ public int getValue() {
+ return this.value;
+ }
+
+ public static Month fromId(final int id) {
+ for (final Month type : Month.values()) {
+ if (type.getValue() == id) {
+ return type;
+ }
+ }
+ return null;
+ }
+ }
+
+ public static enum AccountType {
+ natürlich, juristisch
+ }
+
+
+ /**
+ * Spesenkonti (Text) not used anymore - own DAO
+ **/
+// public static enum Accounts {
+// spesen("a.Spesen"), weiterbildung("Test"), büroaufwand("x"), reisespesen("y"), divers("d"),
+// repräsentation("r"), werbung("w"), miete("m"), itunterhalt("itc");
+//
+// private final String text;
+//
+// Accounts(final String text) {
+// this.text = text;
+// }
+//
+// public String getText() {
+// return this.text;
+// }
+//
+// public static Accounts fromString(final String text) {
+// for (final Accounts b : Accounts.values()) {
+// if (b.text.equalsIgnoreCase(text)) {
+// return b;
+// }
+// }
+// return null;
+// }
+// }
+
+ public static enum itmPriceLevel {
+ item, project
+ }
+
+}
diff --git a/src/ch/xwr/seicentobilling/business/OrderGenerator.java b/src/ch/xwr/seicentobilling/business/OrderGenerator.java
index f1ca08d..017bc8b 100644
--- a/src/ch/xwr/seicentobilling/business/OrderGenerator.java
+++ b/src/ch/xwr/seicentobilling/business/OrderGenerator.java
@@ -1,290 +1,391 @@
-package ch.xwr.seicentobilling.business;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-import ch.xwr.seicentobilling.business.model.billing.BillDto;
-import ch.xwr.seicentobilling.business.model.billing.BillLine;
-import ch.xwr.seicentobilling.business.model.billing.GuiGeneratorFields;
-import ch.xwr.seicentobilling.dal.OrderDAO;
-import ch.xwr.seicentobilling.dal.OrderLineDAO;
-import ch.xwr.seicentobilling.dal.ProjectLineDAO;
-import ch.xwr.seicentobilling.entities.Order;
-import ch.xwr.seicentobilling.entities.OrderLine;
-import ch.xwr.seicentobilling.entities.Periode;
-import ch.xwr.seicentobilling.entities.ProjectLine;
-
-public class OrderGenerator {
- private final HashMap _billMap = new HashMap<>();
- private OrderCalculator _calc = null;
- private GuiGeneratorFields _guifld = null;
- /** Logger initialized */
- private static final org.apache.log4j.Logger _logger = org.apache.log4j.Logger.getLogger(OrderGenerator.class);
-
-
- public List proposeDraft(final Periode inp) {
- final ProjectLineDAO dao = new ProjectLineDAO();
- final List list = dao.findByPeriode(inp);
-
- for (final Iterator iterator = list.iterator(); iterator.hasNext();) {
- final ProjectLine pln = iterator.next();
- final int cusnbr = pln.getProject().getCustomer().getCusNumber();
- final long proId = pln.getProject().getProId();
- BillDto bill = null;
- if (! this._billMap.containsKey(proId)) {
- bill = new BillDto();
- bill.setCustomerNbr(cusnbr);
- bill.setCustomer(pln.getProject().getCustomer());
- bill.setProject(pln.getProject());
- bill.setCostaccount(pln.getPeriode().getCostAccount());
- bill.setPeriode(inp);
- this._billMap.put(proId, bill);
- } else {
- bill = this._billMap.get(proId);
- }
-
- cumulateLine(bill, pln);
- }
-
- final List rlist = calculateTotalHeader2List();
- return rlist;
- }
-
- private List calculateTotalHeader2List() {
- final List rlist = new ArrayList<>(this._billMap.values());
-
- for (final BillDto billDto : rlist) {
- final Double amt1 = getAmountFromLine(billDto.getExpenseHours());
- final Double amt2 = getAmountFromLine(billDto.getJourneyHours());
- final Double amt3 = getAmountFromLine(billDto.getProjectHours());
-
- billDto.setTotalAmount(amt1 + amt2 + amt3);
- }
-
- return rlist;
-
- }
-
- private Double getAmountFromLine(final List list) {
- Double retVal = new Double(0);
-
- if (list!= null && ! list.isEmpty()) {
- for (int i = 0; i < list.size(); i++) {
- final BillLine tmp = list.get(i);
- retVal = retVal + tmp.getAmount();
- }
- }
-
- return retVal;
- }
-
- private void cumulateLine(final BillDto bill, final ProjectLine pln) {
- if (pln.getPrlWorkType().equals(LovState.WorkType.journey)) { //Reisezeit
- checkListEntry(bill.getJourneyHours(), pln);
- } else if (pln.getPrlWorkType().equals(LovState.WorkType.expense)) { //Spesen
- checkListEntry(bill.getExpenseHours(), pln);
- } else {
- checkListEntry(bill.getProjectHours(), pln);
- }
- }
-
- private void checkListEntry(final List list, final ProjectLine pln) {
- BillLine line = null;
- if (! list.isEmpty()) {
- for (int i = 0; i < list.size(); i++) {
- final BillLine tmp = list.get(i);
- if (tmp.getRate().equals(pln.getPrlRate()) &&
- tmp.getCostaccount().getCsaId().equals(pln.getPeriode().getCostAccount().getCsaId())) {
- line = list.get(i);
- line.setHours(line.getHours() + pln.getPrlHours());
- }
- }
- }
-
- if (line == null) {
- list.add(getEmptyLine(pln)); //either empty or missing criteria
- }
-
- }
-
- private BillLine getEmptyLine(final ProjectLine pln) {
- final BillLine line = new BillLine();
- line.setRate(pln.getPrlRate());
- line.setWorkType(pln.getPrlWorkType());
- line.setCostaccount(pln.getPeriode().getCostAccount());
- line.setHours(pln.getPrlHours());
-
- return line;
- }
-
- public Order createBill(final BillDto billDto, final GuiGeneratorFields guifld) {
- this._calc = new OrderCalculator();
- this._guifld = guifld;
- final Integer ordNbr = this._calc.getNewOrderNumber(false, 0);
-
- final OrderDAO dao = new OrderDAO();
- final Order hdr = getNewOrderWithDefaults(guifld, billDto);
- hdr.setOrdNumber(ordNbr);
- dao.save(hdr);
-
- //commit ordnbr
- this._calc.getNewOrderNumber(true, ordNbr); //commit ordnbr
-
- createPositions(hdr, billDto);
- this._calc.calculateHeader(hdr);
-
- //create objRoot
- final RowObjectManager man = new RowObjectManager();
- man.updateObject(hdr.getOrdId(), hdr.getClass().getSimpleName());
-
- _logger.debug("New Order Created " + hdr.getOrdId());
-
- return hdr;
- }
-
- private void createPositions(final Order hdr, final BillDto billDto) {
- createPosition(hdr, billDto, billDto.getProjectHours(), 0);
- createPosition(hdr, billDto, billDto.getJourneyHours(), 2);
- createPosition(hdr, billDto, billDto.getExpenseHours(), 1);
- }
-
- private void createPosition(final Order hdr, final BillDto billDto, final List list, final int flag) {
- final OrderLineDAO dao = new OrderLineDAO();
-
- if (list!= null && ! list.isEmpty()) {
- for (int i = 0; i < list.size(); i++) {
- final BillLine tmp = list.get(i);
-
- final OrderLine pos = new OrderLine();
- pos.setOrderhdr(hdr);
- pos.setCostAccount(tmp.getCostaccount());
- pos.setOdlPrice(tmp.getRate());
- pos.setOdlQuantity(tmp.getHours());
- pos.setOdlState(LovState.State.active);
-
- switch (flag) {
- case 0:
- pos.setItem(this._guifld.getItemProject());
- pos.setOdlText(disolveLineText(billDto, tmp, this._guifld.getLineTextProject()));
- break;
- case 1:
- pos.setItem(this._guifld.getItemExpense());
- pos.setOdlText(disolveLineText(billDto, tmp, this._guifld.getLineTextExpense()));
- break;
- case 2:
- pos.setItem(this._guifld.getItemJourney());
- pos.setOdlText(disolveLineText(billDto, tmp, this._guifld.getLineTextJourney()));
- break;
- }
-
- pos.setVat(hdr.getProject().getVat());
- pos.setOdlNumber(this._calc.getNextLineNumber(hdr));
-
- final OrderLine newodl = this._calc.calculateLine(pos);
- dao.save(newodl);
-
- //create objRoot
- final RowObjectManager man = new RowObjectManager();
- man.updateObject(newodl.getOdlId(), newodl.getClass().getSimpleName());
-
- }
-
- }
-
- }
-
-
- private Order getNewOrderWithDefaults(final GuiGeneratorFields guifld, final BillDto billDto) {
- final Order dao = new Order();
-
- dao.setOrdState(LovState.State.active);
- dao.setOrdOrderDate(new Date());
- dao.setOrdAmountBrut(new Double(0.));
- dao.setOrdAmountNet(new Double(0.));
-
- dao.setOrdCreated(new Date());
- dao.setOrdCreatedBy(Seicento.getUserName());
- //guifld
- dao.setOrdBillDate(guifld.getBillDate());
- dao.setOrdText(disolveHeaderText(billDto, guifld.getBillText()));
-
- if (guifld.getCopyTextFromLastBill().booleanValue()) {
- final String lastText = lookupLastBill(billDto);
- if (!lastText.isEmpty()) {
- dao.setOrdText(lastText);
- }
- }
- //billDto
- dao.setCustomer(billDto.getCustomer());
- dao.setPaymentCondition(billDto.getCustomer().getPaymentCondition());
- dao.setProject(billDto.getProject());
-
- return dao;
- }
-
- private String lookupLastBill(final BillDto billDto) {
- final OrderDAO dao = new OrderDAO();
- final List list = dao.findByCustomer(billDto.getCustomer());
-
- int icount=0;
- for (final Iterator iterator = list.iterator(); iterator.hasNext();) {
- final Order order = iterator.next();
- if (order.getProject().getProId().equals(billDto.getProject().getProId())) {
- return order.getOrdText();
- }
- icount++;
- if (icount > 20) {
- return "";
- }
- }
-
- return "";
- }
-
- private String disolveHeaderText(final BillDto billDto, String text) {
- String contact = "";
- if (billDto.getProject().getProContact() != null) {
- contact = billDto.getProject().getProContact();
- }
-
- String monthText = LovState.Month.fromId(billDto.getPeriode().getPerMonth().getValue()).name();
- monthText = monthText.substring(0, 1).toUpperCase() + monthText.substring(1);
-
- text = text.replace("{proExtReference}", getText(billDto.getProject().getProExtReference()));
- text = text.replace("{proName}", billDto.getProject().getProName().trim());
- text = text.replace("{proContact}", contact.trim());
- //subject = subject.replace("#", "%23");
- text = text.replace("{csaName}", billDto.getCostaccount().getCsaName().trim());
- text = text.replace("{perYear}", billDto.getPeriode().getPerYear().toString());
- text = text.replace("{perMonth}", "" + billDto.getPeriode().getPerMonth().getValue());
- text = text.replace("{perMonthText}", monthText);
-
- return text;
- }
-
- private String getText(final String input) {
- if (input == null || input.isEmpty()) {
- return "";
- }
-
- return input.trim();
- }
-
- private String disolveLineText(final BillDto billDto, final BillLine tmp, String text) {
- String monthText = LovState.Month.fromId(billDto.getPeriode().getPerMonth().getValue()).name();
- monthText = monthText.substring(0, 1).toUpperCase() + monthText.substring(1);
-
- text = text.replace("{csaName}", tmp.getCostaccount().getCsaName().trim());
- text = text.replace("{csaCode}", tmp.getCostaccount().getCsaCode().trim());
- text = text.replace("{perYear}", billDto.getPeriode().getPerYear().toString());
- text = text.replace("{perMonth}", "" + billDto.getPeriode().getPerMonth().getValue());
- text = text.replace("{perMonthText}", monthText);
-
-
- return text;
- }
-
-}
+package ch.xwr.seicentobilling.business;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import ch.xwr.seicentobilling.business.model.billing.BillDto;
+import ch.xwr.seicentobilling.business.model.billing.BillLine;
+import ch.xwr.seicentobilling.business.model.billing.GuiGeneratorFields;
+import ch.xwr.seicentobilling.dal.OrderDAO;
+import ch.xwr.seicentobilling.dal.OrderLineDAO;
+import ch.xwr.seicentobilling.dal.PeriodeDAO;
+import ch.xwr.seicentobilling.dal.ProjectDAO;
+import ch.xwr.seicentobilling.dal.ProjectLineDAO;
+import ch.xwr.seicentobilling.entities.CostAccount;
+import ch.xwr.seicentobilling.entities.Item;
+import ch.xwr.seicentobilling.entities.Order;
+import ch.xwr.seicentobilling.entities.OrderLine;
+import ch.xwr.seicentobilling.entities.Periode;
+import ch.xwr.seicentobilling.entities.Project;
+import ch.xwr.seicentobilling.entities.ProjectAllocation;
+import ch.xwr.seicentobilling.entities.ProjectLine;
+
+public class OrderGenerator {
+ private final HashMap _billMap = new HashMap<>();
+ private OrderCalculator _calc = null;
+ private GuiGeneratorFields _guifld = null;
+ /** Logger initialized */
+ private static final org.apache.log4j.Logger _logger = org.apache.log4j.Logger.getLogger(OrderGenerator.class);
+
+
+ public List proposeDraft(final Periode inp, final GuiGeneratorFields guifld) {
+ this._guifld = guifld;
+ final ProjectLineDAO dao = new ProjectLineDAO();
+ final List list = dao.findByPeriode(inp);
+ BillDto bill = null;
+
+ //Loop 1 collect ProjectLines of current Periode
+ for (final Iterator iterator = list.iterator(); iterator.hasNext();) {
+ final ProjectLine pln = iterator.next();
+
+ bill = getBillDto(pln, inp);
+ cumulateLine(bill, pln);
+ }
+
+ //Loop 2 check additonal Ressources
+ lookupProjectForStrategy(inp);
+
+ final List rlist = calculateTotalHeader2List();
+ return rlist;
+ }
+
+ private void lookupProjectForStrategy(final Periode inp) {
+ final ProjectDAO proDao = new ProjectDAO();
+ final List list = proDao.findByCostAccountActive(inp.getCostAccount());
+ for (final Iterator iterator = list.iterator(); iterator.hasNext();) {
+ final Project pro = iterator.next();
+
+ if (pro.getProOrdergenerationStrategy() == LovState.ProOrderStrategy.zusammenziehen) {
+ //this project should have more costaccounts for billing lookup
+ final Set lst = pro.getProjectAllocations();
+ for (final Iterator itr = lst.iterator(); itr.hasNext();) {
+ final ProjectAllocation pra = itr.next();
+ if (!pra.getCostAccount().getCsaId().equals(inp.getCostAccount().getCsaId())) { //prevent own double
+ final Periode per = getValidPeriodForCst(inp, pra);
+ //now we have the periode and the project
+ if (per != null) {
+ lookupProjectLinesForProject(per, pro);
+ }
+ }
+ }
+
+ }
+
+ }
+
+ }
+
+ private Periode getValidPeriodForCst(final Periode inp, final ProjectAllocation pra) {
+ final PeriodeDAO pd = new PeriodeDAO();
+ final List lsper = pd.findByCostAccountTop(pra.getCostAccount(), 5);
+ for (final Iterator itrP = lsper.iterator(); itrP.hasNext();) {
+ final Periode per = itrP.next();
+
+ if (per.getPerMonth().getValue() == inp.getPerMonth().getValue() && per.getPerYear().equals(inp.getPerYear())) {
+ return per;
+ }
+ }
+
+ return null; //no Periode found
+ }
+
+ private void lookupProjectLinesForProject(final Periode per, final Project pro) {
+ final ProjectLineDAO dao = new ProjectLineDAO();
+ BillDto bill = null;
+
+ final List lstPl = dao.findByPeriode(per);
+ for (final Iterator itrPl = lstPl.iterator(); itrPl.hasNext();) {
+ //here we have the project line of the periode from the ProjectAllocation
+ final ProjectLine pln = itrPl.next();
+
+ if (pln.getProject().getProId().equals(pro.getProId())) {
+ //only take same projects
+ bill = getBillDto(pln, per);
+ cumulateLine(bill, pln);
+ }
+ }
+
+ }
+
+ private BillDto getBillDto(final ProjectLine pln, final Periode per) {
+ final int cusnbr = pln.getProject().getCustomer().getCusNumber();
+ final long proId = pln.getProject().getProId();
+ //final long perId = per.getPerId();
+ BillDto bill = null;
+
+ if (! this._billMap.containsKey(proId)) {
+ bill = new BillDto();
+ bill.setCustomerNbr(cusnbr);
+ bill.setCustomer(pln.getProject().getCustomer());
+ bill.setProject(pln.getProject());
+ bill.setCostaccount(per.getCostAccount());
+ bill.setPeriode(per);
+ this._billMap.put(proId, bill);
+ } else {
+ bill = this._billMap.get(proId);
+ }
+ return bill;
+ }
+
+ private List calculateTotalHeader2List() {
+ final List rlist = new ArrayList<>(this._billMap.values());
+
+ for (final BillDto billDto : rlist) {
+ final Double amt = getAmountFromLine(billDto.getLines());
+ billDto.setTotalAmount(amt);
+ }
+
+ return rlist;
+
+ }
+
+ private Double getAmountFromLine(final List list) {
+ Double retVal = new Double(0);
+
+ if (list!= null && ! list.isEmpty()) {
+ for (int i = 0; i < list.size(); i++) {
+ final BillLine tmp = list.get(i);
+ retVal = retVal + tmp.getAmount();
+ }
+ }
+
+ return retVal;
+ }
+
+ private void cumulateLine(final BillDto bill, final ProjectLine pln) {
+ final Item itm = getItem(pln);
+ final List list = bill.getLines();
+
+ BillLine line = null;
+ if (! list.isEmpty()) {
+ for (int i = 0; i < list.size(); i++) {
+ final BillLine tmp = list.get(i);
+ if (tmp.getRate().equals(pln.getPrlRate()) &&
+ tmp.getCostaccount().getCsaId().equals(pln.getPeriode().getCostAccount().getCsaId()) &&
+ tmp.getItem().getItmId().equals(itm.getItmId())) {
+ line = list.get(i);
+ line.setHours(line.getHours() + pln.getPrlHours());
+ }
+ }
+ }
+
+ if (line == null) {
+ final String text = getLineText(bill, pln);
+ list.add(getEmptyLine(pln, itm, text)); //either empty or missing criteria
+ }
+
+ }
+
+ private String getLineText(final BillDto billDto, final ProjectLine pln) {
+ String text = null;
+
+ if (pln.getPrlWorkType().equals(LovState.WorkType.journey)) { //Reisezeit
+ text = this._guifld.getLineTextJourney();
+ } else if (pln.getPrlWorkType().equals(LovState.WorkType.expense)) { //Spesen
+ text = this._guifld.getLineTextExpense();
+ } else {
+ text = this._guifld.getLineTextProject();
+ }
+
+ if (text == null) {
+ text = "no text!";
+ }
+
+ final String text2 = disolveLineText(billDto, pln.getPeriode().getCostAccount(), text);
+ return text2;
+ }
+
+ private Item getItem(final ProjectLine pln) {
+ Item itm = null;
+
+ if (pln.getPrlWorkType().equals(LovState.WorkType.journey)) { //Reisezeit
+ itm = this._guifld.getItemJourney();
+ } else if (pln.getPrlWorkType().equals(LovState.WorkType.expense)) { //Spesen
+ itm = this._guifld.getItemExpense();
+ } else {
+ itm = this._guifld.getItemProject();
+ }
+
+ return itm;
+ }
+
+
+ private BillLine getEmptyLine(final ProjectLine pln, final Item itm, final String text) {
+ final BillLine line = new BillLine();
+ line.setRate(pln.getPrlRate());
+ line.setWorkType(pln.getPrlWorkType());
+ line.setCostaccount(pln.getPeriode().getCostAccount());
+ line.setHours(pln.getPrlHours());
+ line.setItem(itm);
+ line.setText(text);
+
+ return line;
+ }
+
+ public Order createBill(final BillDto billDto, final GuiGeneratorFields guifld) {
+ this._calc = new OrderCalculator();
+ this._guifld = guifld;
+ final Integer ordNbr = this._calc.getNewOrderNumber(false, 0);
+
+ final OrderDAO dao = new OrderDAO();
+ final Order hdr = getNewOrderWithDefaults(guifld, billDto);
+ hdr.setOrdNumber(ordNbr);
+ dao.save(hdr);
+
+ //commit ordnbr
+ this._calc.getNewOrderNumber(true, ordNbr); //commit ordnbr
+
+ createPositions(hdr, billDto);
+ this._calc.calculateHeader(hdr);
+
+ //create objRoot
+ final RowObjectManager man = new RowObjectManager();
+ man.updateObject(hdr.getOrdId(), hdr.getClass().getSimpleName());
+
+ _logger.debug("New Order Created " + hdr.getOrdId());
+
+ return hdr;
+ }
+
+ private void createPositions(final Order hdr, final BillDto billDto) {
+ createPosition(hdr, billDto, billDto.getLines());
+ }
+
+ private void createPosition(final Order hdr, final BillDto billDto, final List list) {
+ final OrderLineDAO dao = new OrderLineDAO();
+
+ if (list!= null && ! list.isEmpty()) {
+ for (int i = 0; i < list.size(); i++) {
+ final BillLine tmp = list.get(i);
+
+ final OrderLine pos = new OrderLine();
+ pos.setOrderhdr(hdr);
+ pos.setCostAccount(tmp.getCostaccount());
+ pos.setOdlPrice(tmp.getRate());
+ pos.setOdlQuantity(tmp.getHours());
+ pos.setOdlState(LovState.State.active);
+ pos.setItem(tmp.getItem());
+ pos.setOdlText(tmp.getText());
+
+ pos.setVat(hdr.getProject().getVat());
+ pos.setOdlNumber(this._calc.getNextLineNumber(hdr));
+
+ final OrderLine newodl = this._calc.calculateLine(pos);
+ dao.save(newodl);
+
+ //create objRoot
+ final RowObjectManager man = new RowObjectManager();
+ man.updateObject(newodl.getOdlId(), newodl.getClass().getSimpleName());
+
+ }
+
+ }
+
+ }
+
+
+ private Order getNewOrderWithDefaults(final GuiGeneratorFields guifld, final BillDto billDto) {
+ final Order dao = new Order();
+
+ dao.setOrdState(LovState.State.active);
+ dao.setOrdOrderDate(new Date());
+ dao.setOrdAmountBrut(new Double(0.));
+ dao.setOrdAmountNet(new Double(0.));
+
+ dao.setOrdCreated(new Date());
+ dao.setOrdCreatedBy(Seicento.getUserName());
+ //guifld
+ dao.setOrdBillDate(guifld.getBillDate());
+ dao.setOrdText(disolveHeaderText(billDto, guifld.getBillText()));
+
+ if (guifld.getCopyTextFromLastBill().booleanValue()) {
+ final String lastText = lookupLastBill(billDto);
+ if (!lastText.isEmpty()) {
+ dao.setOrdText(lastText);
+ }
+ }
+ //billDto
+ dao.setCustomer(billDto.getCustomer());
+ dao.setPaymentCondition(billDto.getCustomer().getPaymentCondition());
+ dao.setProject(billDto.getProject());
+
+ return dao;
+ }
+
+ private String lookupLastBill(final BillDto billDto) {
+ final OrderDAO dao = new OrderDAO();
+ final List list = dao.findByCustomer(billDto.getCustomer());
+
+ int icount=0;
+ for (final Iterator iterator = list.iterator(); iterator.hasNext();) {
+ final Order order = iterator.next();
+ if (order.getProject().getProId().equals(billDto.getProject().getProId())) {
+ return order.getOrdText();
+ }
+ icount++;
+ if (icount > 20) {
+ return "";
+ }
+ }
+
+ return "";
+ }
+
+ private String disolveHeaderText(final BillDto billDto, String text) {
+ String contact = "";
+ if (billDto.getProject().getProContact() != null) {
+ contact = billDto.getProject().getProContact();
+ }
+
+ String monthText = LovState.Month.fromId(billDto.getPeriode().getPerMonth().getValue()).name();
+ monthText = monthText.substring(0, 1).toUpperCase() + monthText.substring(1);
+
+ text = text.replace("{proExtReference}", getText(billDto.getProject().getProExtReference()));
+ text = text.replace("{proName}", billDto.getProject().getProName().trim());
+ text = text.replace("{proContact}", contact.trim());
+ //subject = subject.replace("#", "%23");
+ text = text.replace("{csaName}", billDto.getCostaccount().getCsaName().trim());
+ text = text.replace("{perYear}", billDto.getPeriode().getPerYear().toString());
+ text = text.replace("{perMonth}", "" + billDto.getPeriode().getPerMonth().getValue());
+ text = text.replace("{perMonthText}", monthText);
+
+ return text;
+ }
+
+ private String getText(final String input) {
+ if (input == null || input.isEmpty()) {
+ return "";
+ }
+
+ return input.trim();
+ }
+
+ private String disolveLineText(final BillDto billDto, final CostAccount cst, String text) {
+ String monthText = LovState.Month.fromId(billDto.getPeriode().getPerMonth().getValue()).name();
+ monthText = monthText.substring(0, 1).toUpperCase() + monthText.substring(1);
+
+ text = text.replace("{csaName}", cst.getCsaName().trim());
+ text = text.replace("{csaCode}", cst.getCsaCode().trim());
+ text = text.replace("{perYear}", billDto.getPeriode().getPerYear().toString());
+ text = text.replace("{perMonth}", "" + billDto.getPeriode().getPerMonth().getValue());
+ text = text.replace("{perMonthText}", monthText);
+
+
+ return text;
+ }
+
+}
+
+//final class _HashDto {
+// public long proId;
+// public long perId;
+//
+// public _HashDto(final long proId, final long perId) {
+// this.proId = proId;
+// this.perId = 1; //perId;
+// }
+//}
\ No newline at end of file
diff --git a/src/ch/xwr/seicentobilling/business/model/billing/BillDto.java b/src/ch/xwr/seicentobilling/business/model/billing/BillDto.java
index 59209d1..3a6414c 100644
--- a/src/ch/xwr/seicentobilling/business/model/billing/BillDto.java
+++ b/src/ch/xwr/seicentobilling/business/model/billing/BillDto.java
@@ -1,77 +1,63 @@
-package ch.xwr.seicentobilling.business.model.billing;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import ch.xwr.seicentobilling.entities.CostAccount;
-import ch.xwr.seicentobilling.entities.Customer;
-import ch.xwr.seicentobilling.entities.Periode;
-import ch.xwr.seicentobilling.entities.Project;
-
-public class BillDto {
- private int customerNbr = 0;
- private Project project;
- private Customer customer;
- private CostAccount costaccount;
- private Double totalAmount;
- private List expenseHours = new ArrayList<>();
- private List journeyHours = new ArrayList<>();
- private List projectHours = new ArrayList<>();
- private Periode periode;
-
-
- public Customer getCustomer() {
- return this.customer;
- }
- public void setCustomer(final Customer customer) {
- this.customer = customer;
- }
- public Double getTotalAmount() {
- return this.totalAmount;
- }
- public void setTotalAmount(final Double totalAmount) {
- this.totalAmount = totalAmount;
- }
- public int getCustomerNbr() {
- return this.customerNbr;
- }
- public void setCustomerNbr(final int customerNbr) {
- this.customerNbr = customerNbr;
- }
- public List getExpenseHours() {
- return this.expenseHours;
- }
- public void setExpenseHours(final List expenses) {
- this.expenseHours = expenses;
- }
- public List getJourneyHours() {
- return this.journeyHours;
- }
- public void setJourneyHours(final List journey) {
- this.journeyHours = journey;
- }
- public List getProjectHours() {
- return this.projectHours;
- }
- public void setProjectHours(final List project) {
- this.projectHours = project;
- }
- public Project getProject() {
- return this.project;
- }
- public void setProject(final Project project) {
- this.project = project;
- }
- public CostAccount getCostaccount() {
- return this.costaccount;
- }
- public void setCostaccount(final CostAccount costaccount) {
- this.costaccount = costaccount;
- }
- public Periode getPeriode() {
- return periode;
- }
- public void setPeriode(Periode periode) {
- this.periode = periode;
- }
-}
+package ch.xwr.seicentobilling.business.model.billing;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import ch.xwr.seicentobilling.entities.CostAccount;
+import ch.xwr.seicentobilling.entities.Customer;
+import ch.xwr.seicentobilling.entities.Periode;
+import ch.xwr.seicentobilling.entities.Project;
+
+public class BillDto {
+ private int customerNbr = 0;
+ private Project project;
+ private Customer customer;
+ private CostAccount costaccount;
+ private Double totalAmount;
+ private List lines = new ArrayList<>();
+ private Periode periode;
+
+
+ public Customer getCustomer() {
+ return this.customer;
+ }
+ public void setCustomer(final Customer customer) {
+ this.customer = customer;
+ }
+ public Double getTotalAmount() {
+ return this.totalAmount;
+ }
+ public void setTotalAmount(final Double totalAmount) {
+ this.totalAmount = totalAmount;
+ }
+ public int getCustomerNbr() {
+ return this.customerNbr;
+ }
+ public void setCustomerNbr(final int customerNbr) {
+ this.customerNbr = customerNbr;
+ }
+ public Project getProject() {
+ return this.project;
+ }
+ public void setProject(final Project project) {
+ this.project = project;
+ }
+ public CostAccount getCostaccount() {
+ return this.costaccount;
+ }
+ public void setCostaccount(final CostAccount costaccount) {
+ this.costaccount = costaccount;
+ }
+ public Periode getPeriode() {
+ return this.periode;
+ }
+ public void setPeriode(final Periode periode) {
+ this.periode = periode;
+ }
+ public List getLines() {
+ return this.lines;
+ }
+ public void setLines(final List lines) {
+ this.lines = lines;
+ }
+}
diff --git a/src/ch/xwr/seicentobilling/business/model/billing/BillLine.java b/src/ch/xwr/seicentobilling/business/model/billing/BillLine.java
index b50a65e..05df992 100644
--- a/src/ch/xwr/seicentobilling/business/model/billing/BillLine.java
+++ b/src/ch/xwr/seicentobilling/business/model/billing/BillLine.java
@@ -1,43 +1,57 @@
-package ch.xwr.seicentobilling.business.model.billing;
-
-import ch.xwr.seicentobilling.business.LovState;
-import ch.xwr.seicentobilling.entities.CostAccount;
-
-public class BillLine {
- private Double hours;
- private LovState.WorkType workType;
- private Double rate;
- @SuppressWarnings("unused")
- private Double amount;
- private CostAccount costaccount;
-
-
-
- public Double getHours() {
- return this.hours;
- }
- public void setHours(final Double hours) {
- this.hours = hours;
- }
- public LovState.WorkType getWorkType() {
- return this.workType;
- }
- public void setWorkType(final LovState.WorkType workType) {
- this.workType = workType;
- }
- public Double getRate() {
- return this.rate;
- }
- public void setRate(final Double rate) {
- this.rate = rate;
- }
- public Double getAmount() {
- return getHours() * getRate();
- }
- public CostAccount getCostaccount() {
- return costaccount;
- }
- public void setCostaccount(CostAccount costaccount) {
- this.costaccount = costaccount;
- }
-}
+package ch.xwr.seicentobilling.business.model.billing;
+
+import ch.xwr.seicentobilling.business.LovState;
+import ch.xwr.seicentobilling.entities.CostAccount;
+import ch.xwr.seicentobilling.entities.Item;
+
+public class BillLine {
+ private Double hours;
+ private LovState.WorkType workType;
+ private Double rate;
+ @SuppressWarnings("unused")
+ private Double amount;
+ private CostAccount costaccount;
+ private Item item;
+ private String text;
+
+
+ public Double getHours() {
+ return this.hours;
+ }
+ public void setHours(final Double hours) {
+ this.hours = hours;
+ }
+ public LovState.WorkType getWorkType() {
+ return this.workType;
+ }
+ public void setWorkType(final LovState.WorkType workType) {
+ this.workType = workType;
+ }
+ public Double getRate() {
+ return this.rate;
+ }
+ public void setRate(final Double rate) {
+ this.rate = rate;
+ }
+ public Double getAmount() {
+ return getHours() * getRate();
+ }
+ public CostAccount getCostaccount() {
+ return this.costaccount;
+ }
+ public void setCostaccount(final CostAccount costaccount) {
+ this.costaccount = costaccount;
+ }
+ public Item getItem() {
+ return this.item;
+ }
+ public void setItem(final Item item) {
+ this.item = item;
+ }
+ public String getText() {
+ return this.text;
+ }
+ public void setText(final String text) {
+ this.text = text;
+ }
+}
diff --git a/src/ch/xwr/seicentobilling/dal/CostAccountDAO.java b/src/ch/xwr/seicentobilling/dal/CostAccountDAO.java
index 5751a67..11657b1 100644
--- a/src/ch/xwr/seicentobilling/dal/CostAccountDAO.java
+++ b/src/ch/xwr/seicentobilling/dal/CostAccountDAO.java
@@ -1,68 +1,86 @@
-
-package ch.xwr.seicentobilling.dal;
-
-import java.util.List;
-
-import javax.persistence.EntityManager;
-import javax.persistence.TypedQuery;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaQuery;
-import javax.persistence.criteria.ParameterExpression;
-import javax.persistence.criteria.Root;
-
-import com.xdev.dal.JPADAO;
-
-import ch.xwr.seicentobilling.entities.CostAccount;
-import ch.xwr.seicentobilling.entities.CostAccount_;
-
-/**
- * Home object for domain model class CostAccount.
- *
- * @see CostAccount
- */
-public class CostAccountDAO extends JPADAO {
- public CostAccountDAO() {
- super(CostAccount.class);
- }
-
- /**
- * @queryMethod Do not edit, method is generated by editor!
- */
- public List findByName(final String name) {
- final EntityManager entityManager = em();
-
- final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
-
- final ParameterExpression nameParameter = criteriaBuilder.parameter(String.class, "name");
-
- final CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(CostAccount.class);
-
- final Root root = criteriaQuery.from(CostAccount.class);
-
- criteriaQuery.where(criteriaBuilder.equal(root.get(CostAccount_.csaName), nameParameter));
-
- final TypedQuery query = entityManager.createQuery(criteriaQuery);
- query.setParameter(nameParameter, name);
- return query.getResultList();
- }
-
- /**
- * @queryMethod Do not edit, method is generated by editor!
- */
- public List findAllActive() {
- final EntityManager entityManager = em();
-
- final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
-
- final CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(CostAccount.class);
-
- final Root root = criteriaQuery.from(CostAccount.class);
-
- criteriaQuery.where(criteriaBuilder.equal(root.get(CostAccount_.csaState), criteriaBuilder.literal(1)));
-
- criteriaQuery.orderBy(criteriaBuilder.asc(root.get(CostAccount_.csaName)));
-
- final TypedQuery query = entityManager.createQuery(criteriaQuery);
- return query.getResultList();
- }
+
+package ch.xwr.seicentobilling.dal;
+
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.TypedQuery;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.ParameterExpression;
+import javax.persistence.criteria.Root;
+
+import com.xdev.dal.JPADAO;
+
+import ch.xwr.seicentobilling.entities.CostAccount;
+import ch.xwr.seicentobilling.entities.CostAccount_;
+
+/**
+ * Home object for domain model class CostAccount.
+ *
+ * @see CostAccount
+ */
+public class CostAccountDAO extends JPADAO {
+ public CostAccountDAO() {
+ super(CostAccount.class);
+ }
+
+ /**
+ * @queryMethod Do not edit, method is generated by editor!
+ */
+ public List findByName(final String name) {
+ final EntityManager entityManager = em();
+
+ final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
+
+ final ParameterExpression nameParameter = criteriaBuilder.parameter(String.class, "name");
+
+ final CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(CostAccount.class);
+
+ final Root root = criteriaQuery.from(CostAccount.class);
+
+ criteriaQuery.where(criteriaBuilder.equal(root.get(CostAccount_.csaName), nameParameter));
+
+ final TypedQuery query = entityManager.createQuery(criteriaQuery);
+ query.setParameter(nameParameter, name);
+ return query.getResultList();
+ }
+
+ /**
+ * @queryMethod Do not edit, method is generated by editor!
+ */
+ public List findAllActive() {
+ final EntityManager entityManager = em();
+
+ final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
+
+ final CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(CostAccount.class);
+
+ final Root root = criteriaQuery.from(CostAccount.class);
+
+ criteriaQuery.where(criteriaBuilder.equal(root.get(CostAccount_.csaState), criteriaBuilder.literal(1)));
+
+ criteriaQuery.orderBy(criteriaBuilder.asc(root.get(CostAccount_.csaName)));
+
+ final TypedQuery query = entityManager.createQuery(criteriaQuery);
+ return query.getResultList();
+ }
+
+ /**
+ * @queryMethod Do not edit, method is generated by editor!
+ */
+ public List findAllOrderByName() {
+ final EntityManager entityManager = em();
+
+ final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
+
+ final CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(CostAccount.class);
+
+ final Root root = criteriaQuery.from(CostAccount.class);
+
+ criteriaQuery.orderBy(criteriaBuilder.asc(root.get(CostAccount_.csaName)));
+
+ final TypedQuery query = entityManager.createQuery(criteriaQuery);
+ return query.getResultList();
+ }
}
\ No newline at end of file
diff --git a/src/ch/xwr/seicentobilling/dal/CostAccountDAO.jpasql b/src/ch/xwr/seicentobilling/dal/CostAccountDAO.jpasql
index 0d4a8f0..51f8b2c 100644
--- a/src/ch/xwr/seicentobilling/dal/CostAccountDAO.jpasql
+++ b/src/ch/xwr/seicentobilling/dal/CostAccountDAO.jpasql
@@ -1,12 +1,17 @@
-import ch.xwr.seicentobilling.entities.CostAccount
-
-findByName(String name)
-{
- //select * from Company where cmpState = :state
- select * from CostAccount where csaName = :name
-}
-
-findAllActive()
-{
- select * from CostAccount where csaState = 1 order by csaName asc
+import ch.xwr.seicentobilling.entities.CostAccount
+
+findByName(String name)
+{
+ //select * from Company where cmpState = :state
+ select * from CostAccount where csaName = :name
+}
+
+findAllActive()
+{
+ select * from CostAccount where csaState = 1 order by csaName asc
+}
+
+findAllOrderByName()
+{
+ select * from CostAccount order by csaName asc
}
\ No newline at end of file
diff --git a/src/ch/xwr/seicentobilling/dal/ItemDAO.java b/src/ch/xwr/seicentobilling/dal/ItemDAO.java
index df18341..82805a0 100644
--- a/src/ch/xwr/seicentobilling/dal/ItemDAO.java
+++ b/src/ch/xwr/seicentobilling/dal/ItemDAO.java
@@ -1,48 +1,86 @@
-
-package ch.xwr.seicentobilling.dal;
-
-import java.util.List;
-
-import javax.persistence.EntityManager;
-import javax.persistence.TypedQuery;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaQuery;
-import javax.persistence.criteria.ParameterExpression;
-import javax.persistence.criteria.Root;
-
-import com.xdev.dal.JPADAO;
-
-import ch.xwr.seicentobilling.entities.Item;
-import ch.xwr.seicentobilling.entities.Item_;
-
-/**
- * Home object for domain model class Item.
- *
- * @see Item
- */
-public class ItemDAO extends JPADAO- {
- public ItemDAO() {
- super(Item.class);
- }
-
- /**
- * @queryMethod Do not edit, method is generated by editor!
- */
- public List
- findByIdent(final String ident) {
- final EntityManager entityManager = em();
-
- final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
-
- final ParameterExpression identParameter = criteriaBuilder.parameter(String.class, "ident");
-
- final CriteriaQuery
- criteriaQuery = criteriaBuilder.createQuery(Item.class);
-
- final Root
- root = criteriaQuery.from(Item.class);
-
- criteriaQuery.where(criteriaBuilder.equal(root.get(Item_.itmIdent), identParameter));
-
- final TypedQuery
- query = entityManager.createQuery(criteriaQuery);
- query.setParameter(identParameter, ident);
- return query.getResultList();
- }
+
+package ch.xwr.seicentobilling.dal;
+
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.TypedQuery;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.ParameterExpression;
+import javax.persistence.criteria.Root;
+
+import com.xdev.dal.JPADAO;
+
+import ch.xwr.seicentobilling.entities.Item;
+import ch.xwr.seicentobilling.entities.Item_;
+
+/**
+ * Home object for domain model class Item.
+ *
+ * @see Item
+ */
+public class ItemDAO extends JPADAO
- {
+ public ItemDAO() {
+ super(Item.class);
+ }
+
+ /**
+ * @queryMethod Do not edit, method is generated by editor!
+ */
+ public List
- findByIdent(final String ident) {
+ final EntityManager entityManager = em();
+
+ final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
+
+ final ParameterExpression identParameter = criteriaBuilder.parameter(String.class, "ident");
+
+ final CriteriaQuery
- criteriaQuery = criteriaBuilder.createQuery(Item.class);
+
+ final Root
- root = criteriaQuery.from(Item.class);
+
+ criteriaQuery.where(criteriaBuilder.equal(root.get(Item_.itmIdent), identParameter));
+
+ final TypedQuery
- query = entityManager.createQuery(criteriaQuery);
+ query.setParameter(identParameter, ident);
+ return query.getResultList();
+ }
+
+ /**
+ * @queryMethod Do not edit, method is generated by editor!
+ */
+ public List
- findAllSortedByName() {
+ final EntityManager entityManager = em();
+
+ final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
+
+ final CriteriaQuery
- criteriaQuery = criteriaBuilder.createQuery(Item.class);
+
+ final Root
- root = criteriaQuery.from(Item.class);
+
+ criteriaQuery.orderBy(criteriaBuilder.asc(root.get(Item_.itmName)));
+
+ final TypedQuery
- query = entityManager.createQuery(criteriaQuery);
+ return query.getResultList();
+ }
+
+ /**
+ * @queryMethod Do not edit, method is generated by editor!
+ */
+ public List
- findAllActiveSortedByName() {
+ final EntityManager entityManager = em();
+
+ final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
+
+ final CriteriaQuery
- criteriaQuery = criteriaBuilder.createQuery(Item.class);
+
+ final Root
- root = criteriaQuery.from(Item.class);
+
+ criteriaQuery.where(criteriaBuilder.equal(root.get(Item_.itmState), criteriaBuilder.literal(1)));
+
+ criteriaQuery.orderBy(criteriaBuilder.asc(root.get(Item_.itmName)));
+
+ final TypedQuery
- query = entityManager.createQuery(criteriaQuery);
+ return query.getResultList();
+ }
}
\ No newline at end of file
diff --git a/src/ch/xwr/seicentobilling/dal/ItemDAO.jpasql b/src/ch/xwr/seicentobilling/dal/ItemDAO.jpasql
index 2d34a71..7f348d2 100644
--- a/src/ch/xwr/seicentobilling/dal/ItemDAO.jpasql
+++ b/src/ch/xwr/seicentobilling/dal/ItemDAO.jpasql
@@ -1,7 +1,19 @@
-import ch.xwr.seicentobilling.entities.Item
-
-findByIdent(String ident)
-{
- select * from Item where itmIdent = :ident
- //select * from Company where cmpId = 1
-}
\ No newline at end of file
+import ch.xwr.seicentobilling.entities.Item
+
+findByIdent(String ident)
+{
+ select * from Item where itmIdent = :ident
+ //select * from Company where cmpId = 1
+}
+
+findAllSortedByName()
+{
+ select * from Item order by itmName asc
+ //select * from Company where cmpId = 1
+}
+
+findAllActiveSortedByName()
+{
+ select * from Item where itmState = 1 order by itmName asc
+ //select * from Company where cmpId = 1
+}
diff --git a/src/ch/xwr/seicentobilling/dal/LovAccountDAO.java b/src/ch/xwr/seicentobilling/dal/LovAccountDAO.java
index 19cf58e..d022c84 100644
--- a/src/ch/xwr/seicentobilling/dal/LovAccountDAO.java
+++ b/src/ch/xwr/seicentobilling/dal/LovAccountDAO.java
@@ -1,34 +1,35 @@
-
-package ch.xwr.seicentobilling.dal;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import com.xdev.dal.JPADAO;
-
-import ch.xwr.seicentobilling.entities.LovAccount;
-
-/**
- * Dummyklasse für combobox....
- *
- *
- */
-public class LovAccountDAO extends JPADAO {
- public LovAccountDAO() {
- super(LovAccount.class);
- }
-
- public List findAllMine() {
- final List lst = new ArrayList<>();
- lst.add(new LovAccount("a.Spesen", "Spesen"));
- lst.add(new LovAccount("a.Weiterbildung", "Weiterbildung"));
- lst.add(new LovAccount("a.Büroaufwand", "Büroaufwand"));
- lst.add(new LovAccount("a.Reisespesen", "Reisespesen"));
- lst.add(new LovAccount("a.Repräsentation", "Repräsentation"));
- lst.add(new LovAccount("a.Werbung / Marketing", "Werbung u. Marketing"));
- lst.add(new LovAccount("a.Mietaufwand", "Miete"));
- lst.add(new LovAccount("a.EDV Unterhalt", "IT Unterhalt"));
-
- return lst;
- }
+
+package ch.xwr.seicentobilling.dal;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.xdev.dal.JPADAO;
+
+import ch.xwr.seicentobilling.entities.LovAccount;
+
+/**
+ * Dummyklasse für combobox....
+ *
+ *
+ */
+public class LovAccountDAO extends JPADAO {
+ public LovAccountDAO() {
+ super(LovAccount.class);
+ }
+
+ public List findAllMine() {
+ final List lst = new ArrayList<>();
+ lst.add(new LovAccount("a.Spesen", "Spesen"));
+ lst.add(new LovAccount("a.Weiterbildung", "Weiterbildung"));
+ lst.add(new LovAccount("a.Büroaufwand", "Büroaufwand"));
+ lst.add(new LovAccount("a.Reisespesen", "Reisespesen"));
+ lst.add(new LovAccount("a.Repräsentation", "Repräsentation"));
+ lst.add(new LovAccount("a.Werbung / Marketing", "Werbung u. Marketing"));
+ lst.add(new LovAccount("a.Mietaufwand", "Miete"));
+ lst.add(new LovAccount("a.EDV Unterhalt", "IT Unterhalt"));
+ lst.add(new LovAccount("a.Drittleistungen", "Drittleistungen"));
+
+ return lst;
+ }
}
\ No newline at end of file
diff --git a/src/ch/xwr/seicentobilling/dal/ProjectAllocationDAO.java b/src/ch/xwr/seicentobilling/dal/ProjectAllocationDAO.java
new file mode 100644
index 0000000..ed027fb
--- /dev/null
+++ b/src/ch/xwr/seicentobilling/dal/ProjectAllocationDAO.java
@@ -0,0 +1,94 @@
+
+package ch.xwr.seicentobilling.dal;
+
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.TypedQuery;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.ParameterExpression;
+import javax.persistence.criteria.Root;
+
+import com.xdev.dal.JPADAO;
+
+import ch.xwr.seicentobilling.entities.CostAccount;
+import ch.xwr.seicentobilling.entities.Project;
+import ch.xwr.seicentobilling.entities.ProjectAllocation;
+import ch.xwr.seicentobilling.entities.ProjectAllocation_;
+import ch.xwr.seicentobilling.entities.Project_;
+
+/**
+ * Home object for domain model class Project.
+ *
+ * @see Project
+ */
+public class ProjectAllocationDAO extends JPADAO {
+ public ProjectAllocationDAO() {
+ super(ProjectAllocation.class);
+ }
+
+ /**
+ * @queryMethod Do not edit, method is generated by editor!
+ */
+ public List findByProject(final Project pro) {
+ final EntityManager entityManager = em();
+
+ final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
+
+ final ParameterExpression proParameter = criteriaBuilder.parameter(Project.class, "pro");
+
+ final CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(ProjectAllocation.class);
+
+ final Root root = criteriaQuery.from(ProjectAllocation.class);
+
+ criteriaQuery.where(criteriaBuilder.equal(root.get(ProjectAllocation_.project), proParameter));
+
+ final TypedQuery query = entityManager.createQuery(criteriaQuery);
+ query.setParameter(proParameter, pro);
+ return query.getResultList();
+ }
+
+ /**
+ * @queryMethod Do not edit, method is generated by editor!
+ */
+ public List findByCostAccount(final CostAccount csa) {
+ final EntityManager entityManager = em();
+
+ final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
+
+ final ParameterExpression csaParameter = criteriaBuilder.parameter(CostAccount.class, "csa");
+
+ final CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(ProjectAllocation.class);
+
+ final Root root = criteriaQuery.from(ProjectAllocation.class);
+
+ criteriaQuery.where(criteriaBuilder.equal(root.get(ProjectAllocation_.costAccount), csaParameter));
+
+ final TypedQuery query = entityManager.createQuery(criteriaQuery);
+ query.setParameter(csaParameter, csa);
+ return query.getResultList();
+ }
+
+ /**
+ * @queryMethod Do not edit, method is generated by editor!
+ */
+ public List findAllActiveProjects() {
+ final EntityManager entityManager = em();
+
+ final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
+
+ final CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(ProjectAllocation.class);
+
+ final Root root = criteriaQuery.from(ProjectAllocation.class);
+
+ criteriaQuery.where(criteriaBuilder.equal(root.get(ProjectAllocation_.project).get(Project_.proState),
+ criteriaBuilder.literal(1)));
+
+ criteriaQuery.orderBy(criteriaBuilder.desc(root.get(ProjectAllocation_.praStartDate)));
+
+ final TypedQuery query = entityManager.createQuery(criteriaQuery);
+ return query.getResultList();
+ }
+
+}
\ No newline at end of file
diff --git a/src/ch/xwr/seicentobilling/dal/ProjectAllocationDAO.jpasql b/src/ch/xwr/seicentobilling/dal/ProjectAllocationDAO.jpasql
new file mode 100644
index 0000000..ad1c8d6
--- /dev/null
+++ b/src/ch/xwr/seicentobilling/dal/ProjectAllocationDAO.jpasql
@@ -0,0 +1,19 @@
+import ch.xwr.seicentobilling.entities.ProjectAllocation
+import ch.xwr.seicentobilling.entities.Project
+import ch.xwr.seicentobilling.entities.CostAccount
+
+findByProject(Project pro)
+{
+ select * from ProjectAllocation where project=:pro
+}
+
+findByCostAccount(CostAccount csa)
+{
+ select * from ProjectAllocation where costAccount=:csa
+}
+
+findAllActiveProjects()
+{
+ select * from ProjectAllocation where project.proState = 1 order by praStartDate desc
+ //, Project where proState = 1 order by praStartDate desc
+}
diff --git a/src/ch/xwr/seicentobilling/dal/ProjectDAO.java b/src/ch/xwr/seicentobilling/dal/ProjectDAO.java
index 3af4acc..39a51fd 100644
--- a/src/ch/xwr/seicentobilling/dal/ProjectDAO.java
+++ b/src/ch/xwr/seicentobilling/dal/ProjectDAO.java
@@ -1,124 +1,147 @@
-
-package ch.xwr.seicentobilling.dal;
-
-import java.util.List;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-import javax.persistence.TypedQuery;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaQuery;
-import javax.persistence.criteria.ParameterExpression;
-import javax.persistence.criteria.Root;
-
-import com.xdev.dal.JPADAO;
-
-import ch.xwr.seicentobilling.entities.Project;
-import ch.xwr.seicentobilling.entities.Project_;
-
-/**
- * Home object for domain model class Project.
- *
- * @see Project
- */
-public class ProjectDAO extends JPADAO {
- public ProjectDAO() {
- super(Project.class);
- }
-
- /**
- * @queryMethod Do not edit, method is generated by editor!
- */
- public List findByName(final String name) {
- final EntityManager entityManager = em();
-
- final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
-
- final ParameterExpression nameParameter = criteriaBuilder.parameter(String.class, "name");
-
- final CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(Project.class);
-
- final Root root = criteriaQuery.from(Project.class);
-
- criteriaQuery.where(criteriaBuilder.like(root.get(Project_.proName), nameParameter));
-
- final TypedQuery query = entityManager.createQuery(criteriaQuery);
- query.setParameter(nameParameter, name);
- return query.getResultList();
- }
-
- /**
- * @queryMethod Do not edit, method is generated by editor!
- */
- public List findAllActive() {
- final EntityManager entityManager = em();
-
- final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
-
- final CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(Project.class);
-
- final Root root = criteriaQuery.from(Project.class);
-
- criteriaQuery.where(criteriaBuilder.equal(root.get(Project_.proState), criteriaBuilder.literal(1)));
-
- criteriaQuery.orderBy(criteriaBuilder.asc(root.get(Project_.proName)));
-
- final TypedQuery query = entityManager.createQuery(criteriaQuery);
- return query.getResultList();
- }
-
- /**
- * @queryMethod Do not edit, method is generated by editor!
- */
- public List findEqNameIgnoreCase(final String name) {
- final EntityManager entityManager = em();
-
- final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
-
- final ParameterExpression nameParameter = criteriaBuilder.parameter(String.class, "name");
-
- final CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(Project.class);
-
- final Root root = criteriaQuery.from(Project.class);
-
- criteriaQuery.where(criteriaBuilder.equal(criteriaBuilder.lower(root.get(Project_.proName)),
- criteriaBuilder.lower(nameParameter)));
-
- final TypedQuery query = entityManager.createQuery(criteriaQuery);
- query.setParameter(nameParameter, name);
- return query.getResultList();
- }
-
- public int calculateEffectiveHours(final Long proId) {
- final String sql = "EXECUTE seicento_Calculate_ProjectHours :ProjectId";
- final Query nativeQuery = em().createNativeQuery(sql).setParameter("ProjectId", proId);
- final int ires = nativeQuery.executeUpdate();
- return ires;
- }
-
- /**
- * @queryMethod Do not edit, method is generated by editor!
- */
- public List findAllChildren(final Long id) {
- final EntityManager entityManager = em();
-
- final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
-
- final ParameterExpression idParameter = criteriaBuilder.parameter(Long.class, "id");
-
- final CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(Project.class);
-
- final Root root = criteriaQuery.from(Project.class);
-
- criteriaQuery.where(
- criteriaBuilder.and(criteriaBuilder.equal(root.get(Project_.project).get(Project_.proId), idParameter),
- criteriaBuilder.equal(root.get(Project_.proState), criteriaBuilder.literal(1))));
-
- criteriaQuery.orderBy(criteriaBuilder.asc(root.get(Project_.proName)));
-
- final TypedQuery query = entityManager.createQuery(criteriaQuery);
- query.setParameter(idParameter, id);
- return query.getResultList();
- }
-
+
+package ch.xwr.seicentobilling.dal;
+
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import javax.persistence.TypedQuery;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.ParameterExpression;
+import javax.persistence.criteria.Root;
+
+import com.xdev.dal.JPADAO;
+
+import ch.xwr.seicentobilling.entities.CostAccount;
+import ch.xwr.seicentobilling.entities.Project;
+import ch.xwr.seicentobilling.entities.Project_;
+
+/**
+ * Home object for domain model class Project.
+ *
+ * @see Project
+ */
+public class ProjectDAO extends JPADAO {
+ public ProjectDAO() {
+ super(Project.class);
+ }
+
+ /**
+ * @queryMethod Do not edit, method is generated by editor!
+ */
+ public List findByName(final String name) {
+ final EntityManager entityManager = em();
+
+ final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
+
+ final ParameterExpression nameParameter = criteriaBuilder.parameter(String.class, "name");
+
+ final CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(Project.class);
+
+ final Root root = criteriaQuery.from(Project.class);
+
+ criteriaQuery.where(criteriaBuilder.like(root.get(Project_.proName), nameParameter));
+
+ final TypedQuery query = entityManager.createQuery(criteriaQuery);
+ query.setParameter(nameParameter, name);
+ return query.getResultList();
+ }
+
+ /**
+ * @queryMethod Do not edit, method is generated by editor!
+ */
+ public List findAllActive() {
+ final EntityManager entityManager = em();
+
+ final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
+
+ final CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(Project.class);
+
+ final Root root = criteriaQuery.from(Project.class);
+
+ criteriaQuery.where(criteriaBuilder.equal(root.get(Project_.proState), criteriaBuilder.literal(1)));
+
+ criteriaQuery.orderBy(criteriaBuilder.asc(root.get(Project_.proName)));
+
+ final TypedQuery query = entityManager.createQuery(criteriaQuery);
+ return query.getResultList();
+ }
+
+ /**
+ * @queryMethod Do not edit, method is generated by editor!
+ */
+ public List findEqNameIgnoreCase(final String name) {
+ final EntityManager entityManager = em();
+
+ final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
+
+ final ParameterExpression nameParameter = criteriaBuilder.parameter(String.class, "name");
+
+ final CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(Project.class);
+
+ final Root root = criteriaQuery.from(Project.class);
+
+ criteriaQuery.where(criteriaBuilder.equal(criteriaBuilder.lower(root.get(Project_.proName)),
+ criteriaBuilder.lower(nameParameter)));
+
+ final TypedQuery query = entityManager.createQuery(criteriaQuery);
+ query.setParameter(nameParameter, name);
+ return query.getResultList();
+ }
+
+ public int calculateEffectiveHours(final Long proId) {
+ final String sql = "EXECUTE seicento_Calculate_ProjectHours :ProjectId";
+ final Query nativeQuery = em().createNativeQuery(sql).setParameter("ProjectId", proId);
+ final int ires = nativeQuery.executeUpdate();
+ return ires;
+ }
+
+ /**
+ * @queryMethod Do not edit, method is generated by editor!
+ */
+ public List findAllChildren(final Long id) {
+ final EntityManager entityManager = em();
+
+ final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
+
+ final ParameterExpression idParameter = criteriaBuilder.parameter(Long.class, "id");
+
+ final CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(Project.class);
+
+ final Root root = criteriaQuery.from(Project.class);
+
+ criteriaQuery.where(
+ criteriaBuilder.and(criteriaBuilder.equal(root.get(Project_.project).get(Project_.proId), idParameter),
+ criteriaBuilder.equal(root.get(Project_.proState), criteriaBuilder.literal(1))));
+
+ criteriaQuery.orderBy(criteriaBuilder.asc(root.get(Project_.proName)));
+
+ final TypedQuery query = entityManager.createQuery(criteriaQuery);
+ query.setParameter(idParameter, id);
+ return query.getResultList();
+ }
+
+ /**
+ * @queryMethod Do not edit, method is generated by editor!
+ */
+ public List findByCostAccountActive(final CostAccount cst) {
+ final EntityManager entityManager = em();
+
+ final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
+
+ final ParameterExpression cstParameter = criteriaBuilder.parameter(CostAccount.class, "cst");
+
+ final CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(Project.class);
+
+ final Root root = criteriaQuery.from(Project.class);
+
+ criteriaQuery.where(criteriaBuilder.and(criteriaBuilder.equal(root.get(Project_.costAccount), cstParameter),
+ criteriaBuilder.equal(root.get(Project_.proState), criteriaBuilder.literal(1))));
+
+ final TypedQuery query = entityManager.createQuery(criteriaQuery);
+ query.setParameter(cstParameter, cst);
+ return query.getResultList();
+ }
+
}
\ No newline at end of file
diff --git a/src/ch/xwr/seicentobilling/dal/ProjectDAO.jpasql b/src/ch/xwr/seicentobilling/dal/ProjectDAO.jpasql
index bca2484..1b24d86 100644
--- a/src/ch/xwr/seicentobilling/dal/ProjectDAO.jpasql
+++ b/src/ch/xwr/seicentobilling/dal/ProjectDAO.jpasql
@@ -1,21 +1,27 @@
-import ch.xwr.seicentobilling.entities.Project
-
-findByName(String name)
-{
- select * from Project where proName like :name
-}
-
-findEqNameIgnoreCase(String name)
-{
- select * from Project where lower(proName) = lower(:name)
-}
-
-findAllActive()
-{
- select * from Project where proState = 1 order by proName asc
-}
-
-findAllChildren(Long id)
-{
- select * from Project where project.proId = :id and proState = 1 order by proName asc
-}
+import ch.xwr.seicentobilling.entities.Project
+import ch.xwr.seicentobilling.entities.CostAccount
+
+findByName(String name)
+{
+ select * from Project where proName like :name
+}
+
+findEqNameIgnoreCase(String name)
+{
+ select * from Project where lower(proName) = lower(:name)
+}
+
+findAllActive()
+{
+ select * from Project where proState = 1 order by proName asc
+}
+
+findAllChildren(Long id)
+{
+ select * from Project where project.proId = :id and proState = 1 order by proName asc
+}
+
+findByCostAccountActive(CostAccount cst)
+{
+ select * from Project where costAccount = :cst and proState = 1
+}
diff --git a/src/ch/xwr/seicentobilling/entities/Item.java b/src/ch/xwr/seicentobilling/entities/Item.java
index d4e358c..41e6e7a 100644
--- a/src/ch/xwr/seicentobilling/entities/Item.java
+++ b/src/ch/xwr/seicentobilling/entities/Item.java
@@ -1,179 +1,190 @@
-package ch.xwr.seicentobilling.entities;
-
-import static javax.persistence.GenerationType.IDENTITY;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.OneToMany;
-import javax.persistence.Table;
-import javax.persistence.Transient;
-import javax.persistence.UniqueConstraint;
-
-import com.xdev.dal.DAO;
-import com.xdev.util.Caption;
-
-import ch.xwr.seicentobilling.business.LovState;
-import ch.xwr.seicentobilling.dal.ItemDAO;
-
-/**
- * Item
- */
-@DAO(daoClass = ItemDAO.class)
-@Caption("{%itmIdent}")
-@Entity
-@Table(name = "Item", schema = "dbo", uniqueConstraints = @UniqueConstraint(columnNames = "itmIdent"))
-public class Item implements java.io.Serializable {
-
- private Long itmId;
- private ItemGroup itemGroup;
- private Vat vat;
- private String itmIdent;
- private String itmName;
- private Double itmPrice1;
- private Double itmPrice2;
- private LovState.Unit itmUnit;
- private LovState.State itmState;
- private Set orderLines = new HashSet<>(0);
- @SuppressWarnings("unused")
- private String prpShortName;
- private Double itmAccount;
-
- public Item() {
- }
-
- @Caption("ItmId")
- @Id
- @GeneratedValue(strategy = IDENTITY)
-
- @Column(name = "itmId", unique = true, nullable = false, columnDefinition = "bigint identity")
- public Long getItmId() {
- return this.itmId;
- }
-
- public void setItmId(final Long itmId) {
- this.itmId = itmId;
- }
-
- @Caption("ItemGroup")
- @ManyToOne(fetch = FetchType.EAGER)
- @JoinColumn(name = "itmitgId", columnDefinition = "bigint")
- public ItemGroup getItemGroup() {
- return this.itemGroup;
- }
-
- public void setItemGroup(final ItemGroup itemGroup) {
- this.itemGroup = itemGroup;
- }
-
- @Caption("Vat")
- @ManyToOne(fetch = FetchType.EAGER)
- @JoinColumn(name = "itmvatId", columnDefinition = "bigint")
- public Vat getVat() {
- return this.vat;
- }
-
- public void setVat(final Vat vat) {
- this.vat = vat;
- }
-
- @Caption("ItmIdent")
- @Column(name = "itmIdent", unique = true, nullable = false, columnDefinition = "nvarchar")
- public String getItmIdent() {
- return this.itmIdent;
- }
-
- public void setItmIdent(final String itmIdent) {
- this.itmIdent = itmIdent;
- }
-
- @Caption("ItmName")
- @Column(name = "itmName", columnDefinition = "nvarchar")
- public String getItmName() {
- return this.itmName;
- }
-
- public void setItmName(final String itmName) {
- this.itmName = itmName;
- }
-
- @Caption("ItmPrice1")
- @Column(name = "itmPrice1", columnDefinition = "numeric", precision = 10, scale = 3)
- public Double getItmPrice1() {
- return this.itmPrice1;
- }
-
- public void setItmPrice1(final Double itmPrice1) {
- this.itmPrice1 = itmPrice1;
- }
-
- @Caption("ItmPrice2")
- @Column(name = "itmPrice2", columnDefinition = "numeric", precision = 10, scale = 3)
- public Double getItmPrice2() {
- return this.itmPrice2;
- }
-
- public void setItmPrice2(final Double itmPrice2) {
- this.itmPrice2 = itmPrice2;
- }
-
- @Caption("ItmUnit")
- @Column(name = "itmUnit", columnDefinition = "int")
- public LovState.Unit getItmUnit() {
- return this.itmUnit;
- }
-
- public void setItmUnit(final LovState.Unit itmUnit) {
- this.itmUnit = itmUnit;
- }
-
- @Caption("ItmState")
- @Column(name = "itmState", columnDefinition = "smallint")
- public LovState.State getItmState() {
- return this.itmState;
- }
-
- public void setItmState(final LovState.State itmState) {
- this.itmState = itmState;
- }
-
- @Caption("OrderLines")
- @OneToMany(fetch = FetchType.LAZY, mappedBy = "item")
- public Set getOrderLines() {
- return this.orderLines;
- }
-
- public void setOrderLines(final Set orderLines) {
- this.orderLines = orderLines;
- }
-
- @Column(name = "PRPSHORTNAME", insertable = false, updatable = false)
- @Transient
- public String getPrpShortName() {
- final StringBuffer bf = new StringBuffer("");
- bf.append(this.itmIdent).append(" ").append(this.itmName);
- return bf.toString();
- }
-
- public void setPrpShortName(final String noname) {
- this.prpShortName = noname;
- }
-
- @Caption("Konto")
- @Column(name = "itmAccount", precision = 10, scale = 3, columnDefinition = "numeric")
- public Double getItmAccount() {
- return this.itmAccount;
- }
-
- public void setItmAccount(final Double noname) {
- this.itmAccount = noname;
- }
-
-}
+package ch.xwr.seicentobilling.entities;
+
+import static javax.persistence.GenerationType.IDENTITY;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import javax.persistence.UniqueConstraint;
+
+import com.xdev.dal.DAO;
+import com.xdev.util.Caption;
+
+import ch.xwr.seicentobilling.business.LovState;
+import ch.xwr.seicentobilling.dal.ItemDAO;
+
+/**
+ * Item
+ */
+@DAO(daoClass = ItemDAO.class)
+@Caption("{%itmIdent}")
+@Entity
+@Table(name = "Item", schema = "dbo", uniqueConstraints = @UniqueConstraint(columnNames = "itmIdent"))
+public class Item implements java.io.Serializable {
+
+ private Long itmId;
+ private ItemGroup itemGroup;
+ private Vat vat;
+ private String itmIdent;
+ private String itmName;
+ private Double itmPrice1;
+ private Double itmPrice2;
+ private LovState.Unit itmUnit;
+ private LovState.State itmState;
+ private Set orderLines = new HashSet<>(0);
+ @SuppressWarnings("unused")
+ private String prpShortName;
+ private Double itmAccount;
+ private LovState.itmPriceLevel itmPriceLevel;
+
+ public Item() {
+ }
+
+ @Caption("ItmId")
+ @Id
+ @GeneratedValue(strategy = IDENTITY)
+
+ @Column(name = "itmId", unique = true, nullable = false, columnDefinition = "bigint identity")
+ public Long getItmId() {
+ return this.itmId;
+ }
+
+ public void setItmId(final Long itmId) {
+ this.itmId = itmId;
+ }
+
+ @Caption("ItemGroup")
+ @ManyToOne(fetch = FetchType.EAGER)
+ @JoinColumn(name = "itmitgId", columnDefinition = "bigint")
+ public ItemGroup getItemGroup() {
+ return this.itemGroup;
+ }
+
+ public void setItemGroup(final ItemGroup itemGroup) {
+ this.itemGroup = itemGroup;
+ }
+
+ @Caption("Vat")
+ @ManyToOne(fetch = FetchType.EAGER)
+ @JoinColumn(name = "itmvatId", columnDefinition = "bigint")
+ public Vat getVat() {
+ return this.vat;
+ }
+
+ public void setVat(final Vat vat) {
+ this.vat = vat;
+ }
+
+ @Caption("ItmIdent")
+ @Column(name = "itmIdent", unique = true, nullable = false, columnDefinition = "nvarchar")
+ public String getItmIdent() {
+ return this.itmIdent;
+ }
+
+ public void setItmIdent(final String itmIdent) {
+ this.itmIdent = itmIdent;
+ }
+
+ @Caption("ItmName")
+ @Column(name = "itmName", columnDefinition = "nvarchar")
+ public String getItmName() {
+ return this.itmName;
+ }
+
+ public void setItmName(final String itmName) {
+ this.itmName = itmName;
+ }
+
+ @Caption("ItmPrice1")
+ @Column(name = "itmPrice1", columnDefinition = "numeric", precision = 10, scale = 3)
+ public Double getItmPrice1() {
+ return this.itmPrice1;
+ }
+
+ public void setItmPrice1(final Double itmPrice1) {
+ this.itmPrice1 = itmPrice1;
+ }
+
+ @Caption("ItmPrice2")
+ @Column(name = "itmPrice2", columnDefinition = "numeric", precision = 10, scale = 3)
+ public Double getItmPrice2() {
+ return this.itmPrice2;
+ }
+
+ public void setItmPrice2(final Double itmPrice2) {
+ this.itmPrice2 = itmPrice2;
+ }
+
+ @Caption("ItmUnit")
+ @Column(name = "itmUnit", columnDefinition = "int")
+ public LovState.Unit getItmUnit() {
+ return this.itmUnit;
+ }
+
+ public void setItmUnit(final LovState.Unit itmUnit) {
+ this.itmUnit = itmUnit;
+ }
+
+ @Caption("ItmState")
+ @Column(name = "itmState", columnDefinition = "smallint")
+ public LovState.State getItmState() {
+ return this.itmState;
+ }
+
+ public void setItmState(final LovState.State itmState) {
+ this.itmState = itmState;
+ }
+
+ @Caption("OrderLines")
+ @OneToMany(fetch = FetchType.LAZY, mappedBy = "item")
+ public Set getOrderLines() {
+ return this.orderLines;
+ }
+
+ public void setOrderLines(final Set orderLines) {
+ this.orderLines = orderLines;
+ }
+
+ @Column(name = "PRPSHORTNAME", insertable = false, updatable = false)
+ @Transient
+ public String getPrpShortName() {
+ final StringBuffer bf = new StringBuffer("");
+ bf.append(this.itmName).append(" - ").append(this.itmIdent);
+ return bf.toString();
+ }
+
+ public void setPrpShortName(final String noname) {
+ this.prpShortName = noname;
+ }
+
+ @Caption("Konto")
+ @Column(name = "itmAccount", precision = 10, scale = 3, columnDefinition = "numeric")
+ public Double getItmAccount() {
+ return this.itmAccount;
+ }
+
+ public void setItmAccount(final Double noname) {
+ this.itmAccount = noname;
+ }
+
+ @Caption("Preis Level")
+ @Column(name = "itmPriceLevel", columnDefinition = "smallint")
+ public LovState.itmPriceLevel getItmPriceLevel() {
+ return this.itmPriceLevel;
+ }
+
+ public void setItmPriceLevel(final LovState.itmPriceLevel itmPriceLevel) {
+ this.itmPriceLevel = itmPriceLevel;
+ }
+
+}
diff --git a/src/ch/xwr/seicentobilling/entities/Project.java b/src/ch/xwr/seicentobilling/entities/Project.java
index b6f129b..0778bd8 100644
--- a/src/ch/xwr/seicentobilling/entities/Project.java
+++ b/src/ch/xwr/seicentobilling/entities/Project.java
@@ -1,361 +1,383 @@
-package ch.xwr.seicentobilling.entities;
-
-import static javax.persistence.GenerationType.IDENTITY;
-
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.Lob;
-import javax.persistence.ManyToOne;
-import javax.persistence.OneToMany;
-import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-import javax.persistence.UniqueConstraint;
-
-import com.xdev.dal.DAO;
-import com.xdev.util.Caption;
-
-import ch.xwr.seicentobilling.business.LovState;
-import ch.xwr.seicentobilling.dal.ProjectDAO;
-
-/**
- * Project
- */
-@DAO(daoClass = ProjectDAO.class)
-@Caption("{%proName}")
-@Entity
-@Table(name = "Project", schema = "dbo", uniqueConstraints = @UniqueConstraint(columnNames = "proName"))
-public class Project implements java.io.Serializable {
-
- private Long proId;
- private CostAccount costAccount;
- private Customer customer;
- private Project project;
- private Vat vat;
- private String proName;
- private String proExtReference;
- private Date proStartDate;
- private Date proEndDate;
- private Integer proHours;
- private Integer proIntensityPercent;
- private Date proLastBill;
- private double proRate;
- private LovState.ProModel proModel;
- private LovState.State proState;
- private String proDescription;
- private String proRemark;
- private LovState.ProState proProjectState;
- private Double proHoursEffective;
- private Set projects = new HashSet<>(0);
- private Set resPlannings = new HashSet<>(0);
- private Set projectLines = new HashSet<>(0);
- private Set orders = new HashSet<>(0);
- private Set expenses = new HashSet<>(0);
- private String proContact;
- private Address address;
- private Boolean internal;
-
- public Project() {
- }
-
- @Caption("ProId")
- @Id
- @GeneratedValue(strategy = IDENTITY)
-
- @Column(name = "proId", unique = true, nullable = false, columnDefinition = "bigint identity")
- public Long getProId() {
- return this.proId;
- }
-
- public void setProId(final Long proId) {
- this.proId = proId;
- }
-
- @Caption("Kostenstelle")
- @ManyToOne(fetch = FetchType.EAGER)
- @JoinColumn(name = "procsaId", columnDefinition = "bigint")
- public CostAccount getCostAccount() {
- return this.costAccount;
- }
-
- public void setCostAccount(final CostAccount costAccount) {
- this.costAccount = costAccount;
- }
-
- @Caption("Kunde")
- @ManyToOne(fetch = FetchType.EAGER)
- @JoinColumn(name = "procusId", nullable = false, columnDefinition = "bigint")
- public Customer getCustomer() {
- return this.customer;
- }
-
- public void setCustomer(final Customer customer) {
- this.customer = customer;
- }
-
- @Caption("Project")
- @ManyToOne(fetch = FetchType.EAGER)
- @JoinColumn(name = "proproId", columnDefinition = "bigint")
- public Project getProject() {
- return this.project;
- }
-
- public void setProject(final Project project) {
- this.project = project;
- }
-
- @Caption("Mwst")
- @ManyToOne(fetch = FetchType.EAGER)
- @JoinColumn(name = "provatId", columnDefinition = "bigint")
- public Vat getVat() {
- return this.vat;
- }
-
- public void setVat(final Vat vat) {
- this.vat = vat;
- }
-
- @Caption("Projektname")
- @Column(name = "proName", unique = true, nullable = false, columnDefinition = "nvarchar")
- public String getProName() {
- return this.proName;
- }
-
- public void setProName(final String proName) {
- this.proName = proName;
- }
-
- @Caption("ProExtReference")
- @Column(name = "proExtReference", columnDefinition = "nvarchar")
- public String getProExtReference() {
- return this.proExtReference;
- }
-
- public void setProExtReference(final String proExtReference) {
- this.proExtReference = proExtReference;
- }
-
- @Caption("Projektstart")
- @Temporal(TemporalType.DATE)
- @Column(name = "proStartDate", nullable = false, columnDefinition = "date", length = 10)
- public Date getProStartDate() {
- return this.proStartDate;
- }
-
- public void setProStartDate(final Date proStartDate) {
- this.proStartDate = proStartDate;
- }
-
- @Caption("Projektende")
- @Temporal(TemporalType.DATE)
- @Column(name = "proEndDate", columnDefinition = "date", length = 10)
- public Date getProEndDate() {
- return this.proEndDate;
- }
-
- public void setProEndDate(final Date proEndDate) {
- this.proEndDate = proEndDate;
- }
-
- @Caption("Stundensoll")
- @Column(name = "proHours", columnDefinition = "int")
- public Integer getProHours() {
- if (this.proHours == null) {
- this.proHours = new Integer(1);
- }
- return this.proHours;
- }
-
- public void setProHours(final Integer proHours) {
- this.proHours = proHours;
- }
-
- @Caption("ProIntensityPercent")
- @Column(name = "proIntensityPercent", columnDefinition = "int")
- public Integer getProIntensityPercent() {
- return this.proIntensityPercent;
- }
-
- public void setProIntensityPercent(final Integer proIntensityPercent) {
- this.proIntensityPercent = proIntensityPercent;
- }
-
- @Caption("ProLastBill")
- @Temporal(TemporalType.DATE)
- @Column(name = "proLastBill", columnDefinition = "date", length = 10)
- public Date getProLastBill() {
- return this.proLastBill;
- }
-
- public void setProLastBill(final Date proLastBill) {
- this.proLastBill = proLastBill;
- }
-
- @Caption("Ansatz")
- @Column(name = "proRate", nullable = false, columnDefinition = "decimal", precision = 6)
- public double getProRate() {
- return this.proRate;
- }
-
- public void setProRate(final double proRate) {
- this.proRate = proRate;
- }
-
- @Caption("Modell")
- @Column(name = "proModel", columnDefinition = "smallint")
- public LovState.ProModel getProModel() {
- return this.proModel;
- }
-
- public void setProModel(final LovState.ProModel proModel) {
- this.proModel = proModel;
- }
-
- @Caption("Status")
- @Column(name = "proState", columnDefinition = "smallint")
- public LovState.State getProState() {
- return this.proState;
- }
-
- public void setProState(final LovState.State proState) {
- this.proState = proState;
- }
-
- @Caption("ProDescription")
- @Lob
- @Column(name = "proDescription", columnDefinition = "ntext")
- public String getProDescription() {
- return this.proDescription;
- }
-
- public void setProDescription(final String proDescription) {
- this.proDescription = proDescription;
- }
-
- @Caption("ProRemark")
- @Lob
- @Column(name = "proRemark", columnDefinition = "ntext")
- public String getProRemark() {
- return this.proRemark;
- }
-
- public void setProRemark(final String proRemark) {
- this.proRemark = proRemark;
- }
-
- @Caption("Projektampel")
- @Column(name = "proProjectState", columnDefinition = "smallint")
- public LovState.ProState getProProjectState() {
- return this.proProjectState;
- }
-
- public void setProProjectState(final LovState.ProState proProjectState) {
- this.proProjectState = proProjectState;
- }
-
- @Caption("Stundenist")
- @Column(name = "proHoursEffective", columnDefinition = "decimal", precision = 18, updatable=false, insertable=false, nullable=false)
- public Double getProHoursEffective() {
- if (this.proHoursEffective == null) {
- this.proHoursEffective = new Double(0.);
- }
- return this.proHoursEffective;
- }
-
- public void setProHoursEffective(final Double proHoursEffective) {
- this.proHoursEffective = proHoursEffective;
- }
-
- @Caption("Projects")
- @OneToMany(fetch = FetchType.LAZY, mappedBy = "project")
- public Set getProjects() {
- return this.projects;
- }
-
- public void setProjects(final Set projects) {
- this.projects = projects;
- }
-
- @Caption("ResPlannings")
- @OneToMany(fetch = FetchType.LAZY, mappedBy = "project")
- public Set getResPlannings() {
- return this.resPlannings;
- }
-
- public void setResPlannings(final Set resPlannings) {
- this.resPlannings = resPlannings;
- }
-
- @Caption("ProjectLines")
- @OneToMany(fetch = FetchType.LAZY, mappedBy = "project")
- public Set getProjectLines() {
- return this.projectLines;
- }
-
- public void setProjectLines(final Set projectLines) {
- this.projectLines = projectLines;
- }
-
- @Caption("Orders")
- @OneToMany(fetch = FetchType.LAZY, mappedBy = "project")
- public Set getOrders() {
- return this.orders;
- }
-
- public void setOrders(final Set orders) {
- this.orders = orders;
- }
-
- @Caption("Expenses")
- @OneToMany(fetch = FetchType.LAZY, mappedBy = "project")
- public Set getExpenses() {
- return this.expenses;
- }
-
- public void setExpenses(final Set expenses) {
- this.expenses = expenses;
- }
-
- @Caption("Ansprechpartner")
- @Column(name = "proContact", length = 40, columnDefinition = "nvarchar")
- public String getProContact() {
- return this.proContact;
- }
-
- public void setProContact(final String contact) {
- this.proContact = contact;
- }
-
- @Caption("Billingaddress")
- @ManyToOne(fetch = FetchType.EAGER)
- @JoinColumn(name = "proadrId", columnDefinition = "bigint")
- public Address getAddress() {
- return this.address;
- }
-
- public void setAddress(final Address address) {
- this.address = address;
- }
-
- @Caption("Intern")
- @Column(name = "proInternal", columnDefinition = "bit")
- public Boolean getInternal() {
- if (this.internal == null) {
- return false;
- }
- return this.internal;
- }
-
- public void setInternal(final Boolean internal) {
- this.internal = internal;
- }
-
-}
+package ch.xwr.seicentobilling.entities;
+
+import static javax.persistence.GenerationType.IDENTITY;
+
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.Lob;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.UniqueConstraint;
+
+import com.xdev.dal.DAO;
+import com.xdev.util.Caption;
+
+import ch.xwr.seicentobilling.business.LovState;
+import ch.xwr.seicentobilling.dal.ProjectDAO;
+
+/**
+ * Project
+ */
+@DAO(daoClass = ProjectDAO.class)
+@Caption("{%proName}")
+@Entity
+@Table(name = "Project", schema = "dbo", uniqueConstraints = @UniqueConstraint(columnNames = "proName"))
+public class Project implements java.io.Serializable {
+
+ private Long proId;
+ private CostAccount costAccount;
+ private Customer customer;
+ private Project project;
+ private Vat vat;
+ private String proName;
+ private String proExtReference;
+ private Date proStartDate;
+ private Date proEndDate;
+ private Integer proHours;
+ private Integer proIntensityPercent;
+ private Date proLastBill;
+ private double proRate;
+ private LovState.ProModel proModel;
+ private LovState.State proState;
+ private String proDescription;
+ private String proRemark;
+ private LovState.ProState proProjectState;
+ private Double proHoursEffective;
+ private Set projects = new HashSet<>(0);
+ private Set resPlannings = new HashSet<>(0);
+ private Set projectLines = new HashSet<>(0);
+ private Set orders = new HashSet<>(0);
+ private Set expenses = new HashSet<>(0);
+ private String proContact;
+ private Address address;
+ private Boolean internal;
+ private LovState.ProOrderStrategy proOrdergenerationStrategy;
+ private Set projectAllocations = new HashSet<>(0);
+
+ public Project() {
+ }
+
+ @Caption("ProId")
+ @Id
+ @GeneratedValue(strategy = IDENTITY)
+
+ @Column(name = "proId", unique = true, nullable = false, columnDefinition = "bigint identity")
+ public Long getProId() {
+ return this.proId;
+ }
+
+ public void setProId(final Long proId) {
+ this.proId = proId;
+ }
+
+ @Caption("Kostenstelle")
+ @ManyToOne(fetch = FetchType.EAGER)
+ @JoinColumn(name = "procsaId", columnDefinition = "bigint")
+ public CostAccount getCostAccount() {
+ return this.costAccount;
+ }
+
+ public void setCostAccount(final CostAccount costAccount) {
+ this.costAccount = costAccount;
+ }
+
+ @Caption("Kunde")
+ @ManyToOne(fetch = FetchType.EAGER)
+ @JoinColumn(name = "procusId", nullable = false, columnDefinition = "bigint")
+ public Customer getCustomer() {
+ return this.customer;
+ }
+
+ public void setCustomer(final Customer customer) {
+ this.customer = customer;
+ }
+
+ @Caption("Project")
+ @ManyToOne(fetch = FetchType.EAGER)
+ @JoinColumn(name = "proproId", columnDefinition = "bigint")
+ public Project getProject() {
+ return this.project;
+ }
+
+ public void setProject(final Project project) {
+ this.project = project;
+ }
+
+ @Caption("Mwst")
+ @ManyToOne(fetch = FetchType.EAGER)
+ @JoinColumn(name = "provatId", columnDefinition = "bigint")
+ public Vat getVat() {
+ return this.vat;
+ }
+
+ public void setVat(final Vat vat) {
+ this.vat = vat;
+ }
+
+ @Caption("Projektname")
+ @Column(name = "proName", unique = true, nullable = false, columnDefinition = "nvarchar")
+ public String getProName() {
+ return this.proName;
+ }
+
+ public void setProName(final String proName) {
+ this.proName = proName;
+ }
+
+ @Caption("ProExtReference")
+ @Column(name = "proExtReference", columnDefinition = "nvarchar")
+ public String getProExtReference() {
+ return this.proExtReference;
+ }
+
+ public void setProExtReference(final String proExtReference) {
+ this.proExtReference = proExtReference;
+ }
+
+ @Caption("Projektstart")
+ @Temporal(TemporalType.DATE)
+ @Column(name = "proStartDate", nullable = false, columnDefinition = "date", length = 10)
+ public Date getProStartDate() {
+ return this.proStartDate;
+ }
+
+ public void setProStartDate(final Date proStartDate) {
+ this.proStartDate = proStartDate;
+ }
+
+ @Caption("Projektende")
+ @Temporal(TemporalType.DATE)
+ @Column(name = "proEndDate", columnDefinition = "date", length = 10)
+ public Date getProEndDate() {
+ return this.proEndDate;
+ }
+
+ public void setProEndDate(final Date proEndDate) {
+ this.proEndDate = proEndDate;
+ }
+
+ @Caption("Stundensoll")
+ @Column(name = "proHours", columnDefinition = "int")
+ public Integer getProHours() {
+ if (this.proHours == null) {
+ this.proHours = new Integer(1);
+ }
+ return this.proHours;
+ }
+
+ public void setProHours(final Integer proHours) {
+ this.proHours = proHours;
+ }
+
+ @Caption("ProIntensityPercent")
+ @Column(name = "proIntensityPercent", columnDefinition = "int")
+ public Integer getProIntensityPercent() {
+ return this.proIntensityPercent;
+ }
+
+ public void setProIntensityPercent(final Integer proIntensityPercent) {
+ this.proIntensityPercent = proIntensityPercent;
+ }
+
+ @Caption("ProLastBill")
+ @Temporal(TemporalType.DATE)
+ @Column(name = "proLastBill", columnDefinition = "date", length = 10)
+ public Date getProLastBill() {
+ return this.proLastBill;
+ }
+
+ public void setProLastBill(final Date proLastBill) {
+ this.proLastBill = proLastBill;
+ }
+
+ @Caption("Ansatz")
+ @Column(name = "proRate", nullable = false, columnDefinition = "decimal", precision = 6)
+ public double getProRate() {
+ return this.proRate;
+ }
+
+ public void setProRate(final double proRate) {
+ this.proRate = proRate;
+ }
+
+ @Caption("Modell")
+ @Column(name = "proModel", columnDefinition = "smallint")
+ public LovState.ProModel getProModel() {
+ return this.proModel;
+ }
+
+ public void setProModel(final LovState.ProModel proModel) {
+ this.proModel = proModel;
+ }
+
+ @Caption("Status")
+ @Column(name = "proState", columnDefinition = "smallint")
+ public LovState.State getProState() {
+ return this.proState;
+ }
+
+ public void setProState(final LovState.State proState) {
+ this.proState = proState;
+ }
+
+ @Caption("ProDescription")
+ @Lob
+ @Column(name = "proDescription", columnDefinition = "ntext")
+ public String getProDescription() {
+ return this.proDescription;
+ }
+
+ public void setProDescription(final String proDescription) {
+ this.proDescription = proDescription;
+ }
+
+ @Caption("ProRemark")
+ @Lob
+ @Column(name = "proRemark", columnDefinition = "ntext")
+ public String getProRemark() {
+ return this.proRemark;
+ }
+
+ public void setProRemark(final String proRemark) {
+ this.proRemark = proRemark;
+ }
+
+ @Caption("Projektampel")
+ @Column(name = "proProjectState", columnDefinition = "smallint")
+ public LovState.ProState getProProjectState() {
+ return this.proProjectState;
+ }
+
+ public void setProProjectState(final LovState.ProState proProjectState) {
+ this.proProjectState = proProjectState;
+ }
+
+ @Caption("Stundenist")
+ @Column(name = "proHoursEffective", columnDefinition = "decimal", precision = 18, updatable=false, insertable=false, nullable=false)
+ public Double getProHoursEffective() {
+ if (this.proHoursEffective == null) {
+ this.proHoursEffective = new Double(0.);
+ }
+ return this.proHoursEffective;
+ }
+
+ public void setProHoursEffective(final Double proHoursEffective) {
+ this.proHoursEffective = proHoursEffective;
+ }
+
+ @Caption("Projects")
+ @OneToMany(fetch = FetchType.LAZY, mappedBy = "project")
+ public Set getProjects() {
+ return this.projects;
+ }
+
+ public void setProjects(final Set projects) {
+ this.projects = projects;
+ }
+
+ @Caption("ResPlannings")
+ @OneToMany(fetch = FetchType.LAZY, mappedBy = "project")
+ public Set getResPlannings() {
+ return this.resPlannings;
+ }
+
+ public void setResPlannings(final Set resPlannings) {
+ this.resPlannings = resPlannings;
+ }
+
+ @Caption("ProjectLines")
+ @OneToMany(fetch = FetchType.LAZY, mappedBy = "project")
+ public Set getProjectLines() {
+ return this.projectLines;
+ }
+
+ public void setProjectLines(final Set projectLines) {
+ this.projectLines = projectLines;
+ }
+
+ @Caption("Orders")
+ @OneToMany(fetch = FetchType.LAZY, mappedBy = "project")
+ public Set getOrders() {
+ return this.orders;
+ }
+
+ public void setOrders(final Set orders) {
+ this.orders = orders;
+ }
+
+ @Caption("Expenses")
+ @OneToMany(fetch = FetchType.LAZY, mappedBy = "project")
+ public Set getExpenses() {
+ return this.expenses;
+ }
+
+ public void setExpenses(final Set expenses) {
+ this.expenses = expenses;
+ }
+
+ @Caption("Ansprechpartner")
+ @Column(name = "proContact", length = 40, columnDefinition = "nvarchar")
+ public String getProContact() {
+ return this.proContact;
+ }
+
+ public void setProContact(final String contact) {
+ this.proContact = contact;
+ }
+
+ @Caption("Billingaddress")
+ @ManyToOne(fetch = FetchType.EAGER)
+ @JoinColumn(name = "proadrId", columnDefinition = "bigint")
+ public Address getAddress() {
+ return this.address;
+ }
+
+ public void setAddress(final Address address) {
+ this.address = address;
+ }
+
+ @Caption("Intern")
+ @Column(name = "proInternal", columnDefinition = "bit")
+ public Boolean getInternal() {
+ if (this.internal == null) {
+ return false;
+ }
+ return this.internal;
+ }
+
+ public void setInternal(final Boolean internal) {
+ this.internal = internal;
+ }
+
+ @Caption("Rechnungsstrategie")
+ @Column(name = "proOrdergenerationStrategy", columnDefinition = "smallint")
+ public LovState.ProOrderStrategy getProOrdergenerationStrategy() {
+ return this.proOrdergenerationStrategy;
+ }
+
+ public void setProOrdergenerationStrategy(final LovState.ProOrderStrategy proOrdergenerationStrategy) {
+ this.proOrdergenerationStrategy = proOrdergenerationStrategy;
+ }
+
+ @Caption("Projektressourcen")
+ @OneToMany(fetch = FetchType.LAZY, mappedBy = "project")
+ public Set getProjectAllocations() {
+ return this.projectAllocations;
+ }
+
+ public void setProjectAllocations(final Set projectAllocations) {
+ this.projectAllocations = projectAllocations;
+ }
+
+}
diff --git a/src/ch/xwr/seicentobilling/entities/ProjectAllocation.java b/src/ch/xwr/seicentobilling/entities/ProjectAllocation.java
new file mode 100644
index 0000000..33f3b89
--- /dev/null
+++ b/src/ch/xwr/seicentobilling/entities/ProjectAllocation.java
@@ -0,0 +1,154 @@
+package ch.xwr.seicentobilling.entities;
+
+import static javax.persistence.GenerationType.IDENTITY;
+
+import java.util.Date;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+import com.xdev.dal.DAO;
+import com.xdev.util.Caption;
+
+import ch.xwr.seicentobilling.business.LovState;
+import ch.xwr.seicentobilling.dal.ProjectAllocationDAO;
+
+/**
+ * Project
+ */
+@DAO(daoClass = ProjectAllocationDAO.class)
+@Caption("{%praId}")
+@Entity
+@Table(name = "ProjectAllocation", schema = "dbo")
+public class ProjectAllocation implements java.io.Serializable {
+
+ private Long praId;
+ private CostAccount costAccount;
+ private Project project;
+ private Date praStartDate;
+ private Date praEndDate;
+ private int praHours;
+ private int praIntensityPercent;
+ private double praRate;
+ private String praRemark;
+ private LovState.State praState;
+
+ public ProjectAllocation() {
+ }
+
+ @Caption("PraId")
+ @Id
+ @GeneratedValue(strategy = IDENTITY)
+
+ @Column(name = "praId", unique = true, nullable = false, columnDefinition = "bigint identity")
+ public Long getPraId() {
+ return this.praId;
+ }
+
+ public void setPraId(final Long proId) {
+ this.praId = proId;
+ }
+
+ @Caption("Projektstart")
+ @Temporal(TemporalType.DATE)
+ @Column(name = "praStartDate", nullable = false, columnDefinition = "date", length = 10)
+ public Date getPraStartDate() {
+ return this.praStartDate;
+ }
+
+ public void setPraStartDate(final Date praStartDate) {
+ this.praStartDate = praStartDate;
+ }
+
+ @Caption("Projektende")
+ @Temporal(TemporalType.DATE)
+ @Column(name = "praEndDate", nullable = false, columnDefinition = "date", length = 10)
+ public Date getPraEndDate() {
+ return this.praEndDate;
+ }
+
+ public void setPraEndDate(final Date praEndDate) {
+ this.praEndDate = praEndDate;
+ }
+
+ @Caption("Stundensoll")
+ @Column(name = "praHours", columnDefinition = "int")
+ public int getPraHours() {
+ return this.praHours;
+ }
+
+ public void setPraHours(final int praHours) {
+ this.praHours = praHours;
+ }
+
+ @Caption("Intensität")
+ @Column(name = "praIntensityPercent", columnDefinition = "int")
+ public int getPraIntensityPercent() {
+ return this.praIntensityPercent;
+ }
+
+ public void setPraIntensityPercent(final int praIntensityPercent) {
+ this.praIntensityPercent = praIntensityPercent;
+ }
+
+ @Caption("Ansatz")
+ @Column(name = "praRate", nullable = false, columnDefinition = "decimal", precision = 6)
+ public double getPraRate() {
+ return this.praRate;
+ }
+
+ public void setPraRate(final double praRate) {
+ this.praRate = praRate;
+ }
+
+ @Caption("Bemerkung")
+ @Column(name = "praRemark", columnDefinition = "nvarchar")
+ public String getPraRemark() {
+ return this.praRemark;
+ }
+
+ public void setPraRemark(final String praRemark) {
+ this.praRemark = praRemark;
+ }
+
+ @Caption("Status")
+ @Column(name = "praState", columnDefinition = "smallint")
+ public LovState.State getPraState() {
+ return this.praState;
+ }
+
+ public void setPraState(final LovState.State praState) {
+ this.praState = praState;
+ }
+
+ @Caption("Kostenstelle")
+ @ManyToOne(fetch = FetchType.EAGER)
+ @JoinColumn(name = "pracsaId", columnDefinition = "bigint")
+ public CostAccount getCostAccount() {
+ return this.costAccount;
+ }
+
+ public void setCostAccount(final CostAccount costAccount) {
+ this.costAccount = costAccount;
+ }
+
+ @Caption("Projekt")
+ @ManyToOne(fetch = FetchType.EAGER)
+ @JoinColumn(name = "praproId", columnDefinition = "bigint")
+ public Project getProject() {
+ return this.project;
+ }
+
+ public void setProject(final Project project) {
+ this.project = project;
+ }
+
+}
diff --git a/src/ch/xwr/seicentobilling/ui/desktop/ExpensePopup.java b/src/ch/xwr/seicentobilling/ui/desktop/ExpensePopup.java
index 5df264e..94ce502 100644
--- a/src/ch/xwr/seicentobilling/ui/desktop/ExpensePopup.java
+++ b/src/ch/xwr/seicentobilling/ui/desktop/ExpensePopup.java
@@ -220,8 +220,8 @@ public void uploadSucceeded(final SucceededEvent event) {
// This method gets called when the upload finished successfully
System.out.println("________________ UPLOAD SUCCEEDED 2");
- if (ExpensePopup.this.urcv.getFiup().length() > (ExpensePopup.this.urcv.getMaxImageSize() * 2)) {
- final int ikb = ExpensePopup.this.urcv.getMaxImageSize() * 2 / 1024;
+ if (ExpensePopup.this.urcv.getFiup().length() > (ExpensePopup.this.urcv.getMaxImageSize() * 4)) {
+ final int ikb = ExpensePopup.this.urcv.getMaxImageSize() * 4 / 1024;
Notification.show("Datei ist zu gross", "Max Size: " + ikb + " KB " + ExpensePopup.this.urcv.getFiup().getName(),Type.TRAY_NOTIFICATION);
ExpensePopup.this.urcv.removeUploadedFile();
diff --git a/src/ch/xwr/seicentobilling/ui/desktop/ItemTabView.java b/src/ch/xwr/seicentobilling/ui/desktop/ItemTabView.java
index 133094d..5743247 100644
--- a/src/ch/xwr/seicentobilling/ui/desktop/ItemTabView.java
+++ b/src/ch/xwr/seicentobilling/ui/desktop/ItemTabView.java
@@ -1,517 +1,524 @@
-package ch.xwr.seicentobilling.ui.desktop;
-
-import javax.persistence.PersistenceException;
-
-import com.vaadin.data.Property;
-import com.vaadin.server.FontAwesome;
-import com.vaadin.shared.ui.MarginInfo;
-import com.vaadin.ui.Alignment;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.Notification;
-import com.vaadin.ui.UI;
-import com.vaadin.ui.Window;
-import com.vaadin.ui.Window.CloseEvent;
-import com.vaadin.ui.Window.CloseListener;
-import com.xdev.dal.DAOs;
-import com.xdev.res.StringResourceUtils;
-import com.xdev.ui.XdevButton;
-import com.xdev.ui.XdevFieldGroup;
-import com.xdev.ui.XdevGridLayout;
-import com.xdev.ui.XdevHorizontalLayout;
-import com.xdev.ui.XdevHorizontalSplitPanel;
-import com.xdev.ui.XdevLabel;
-import com.xdev.ui.XdevTextField;
-import com.xdev.ui.XdevVerticalLayout;
-import com.xdev.ui.XdevView;
-import com.xdev.ui.entitycomponent.combobox.XdevComboBox;
-import com.xdev.ui.entitycomponent.table.XdevTable;
-import com.xdev.ui.filter.XdevContainerFilterComponent;
-import com.xdev.ui.masterdetail.MasterDetail;
-import com.xdev.util.ConverterBuilder;
-
-import ch.xwr.seicentobilling.business.ConfirmDialog;
-import ch.xwr.seicentobilling.business.LovState;
-import ch.xwr.seicentobilling.business.NumberRangeHandler;
-import ch.xwr.seicentobilling.business.RowObjectManager;
-import ch.xwr.seicentobilling.dal.ItemDAO;
-import ch.xwr.seicentobilling.dal.ItemGroupDAO;
-import ch.xwr.seicentobilling.dal.VatDAO;
-import ch.xwr.seicentobilling.entities.Item;
-import ch.xwr.seicentobilling.entities.ItemGroup;
-import ch.xwr.seicentobilling.entities.ItemGroup_;
-import ch.xwr.seicentobilling.entities.Item_;
-import ch.xwr.seicentobilling.entities.Vat;
-
-public class ItemTabView extends XdevView {
-
- /**
- *
- */
- public ItemTabView() {
- super();
- this.initUI();
-
- //Type
- this.cbxState.addItems((Object[])LovState.State.values());
- this.cbxUnit.addItems((Object[])LovState.Unit.values());
-
- //set RO Fields
- setROFields();
-
- }
-
- private void setROFields() {
-
- boolean hasData = true;
- if (this.fieldGroup.getItemDataSource() == null) {
- hasData = false;
- }
- this.cmdSave.setEnabled(hasData);
- //this.tabSheet.setEnabled(hasData);
- this.form.setEnabled(hasData);
-
- }
-
- /**
- * Event handler delegate method for the {@link XdevButton} {@link #cmdReset}.
- *
- * @see Button.ClickListener#buttonClick(Button.ClickEvent)
- * @eventHandlerDelegate Do NOT delete, used by UI designer!
- */
- private void cmdReset_buttonClick(final Button.ClickEvent event) {
- if (isNew()) {
- cmdNew_buttonClick(event);
- } else {
- this.fieldGroup.discard();
- }
- setROFields();
- }
-
- /**
- * Event handler delegate method for the {@link XdevButton} {@link #cmdSave}.
- *
- * @see Button.ClickListener#buttonClick(Button.ClickEvent)
- * @eventHandlerDelegate Do NOT delete, used by UI designer!
- */
- private void cmdSave_buttonClick(final Button.ClickEvent event) {
- final boolean isNew = isNew(); //assign before save. is always false after save
-
- this.fieldGroup.save();
- setROFields();
- checkItemNumber(isNew, true);
-
- final RowObjectManager man = new RowObjectManager();
- man.updateObject(this.fieldGroup.getItemDataSource().getBean().getItmId(), this.fieldGroup.getItemDataSource().getBean().getClass().getSimpleName());
-
- Notification.show("Save clicked", "Daten wurden gespeichert", Notification.Type.TRAY_NOTIFICATION);
-
- }
-
- private void checkItemNumber(final boolean isNew, final boolean commitNbr) {
- if (! isNew) {
- return;
- }
-
- Integer nbr = null;
- try {
- nbr = Integer.parseInt(this.txtItmIdent.getValue());
- } catch (final Exception e){
- nbr = new Integer(0);
- }
-
- final NumberRangeHandler handler = new NumberRangeHandler();
- if (!commitNbr) {
- if (nbr > 0) {
- return ;
- }
- this.txtItmIdent.setValue(handler.getNewItemNumber(false, nbr).toString());
- } else {
- handler.getNewItemNumber(true, nbr);
- }
-
- }
-
- private boolean isNew() {
- if (this.fieldGroup.getItemDataSource() == null) {
- return true;
- }
- final Item bean = this.fieldGroup.getItemDataSource().getBean();
- if (bean.getItmId() == null || bean.getItmId() < 1) {
- return true;
- }
- return false;
- }
-
- /**
- * Event handler delegate method for the {@link XdevButton} {@link #cmdNew}.
- *
- * @see Button.ClickListener#buttonClick(Button.ClickEvent)
- * @eventHandlerDelegate Do NOT delete, used by UI designer!
- */
- private void cmdNew_buttonClick(final Button.ClickEvent event) {
- this.fieldGroup.setItemDataSource(getNewDaoWithDefaults());
- checkItemNumber(true, false);
- setROFields();
-
- }
-
- private Item getNewDaoWithDefaults() {
- final Item dao = new Item();
-
- dao.setItmState(LovState.State.active);
- dao.setItmPrice1(new Double(0));
- dao.setItmUnit(LovState.Unit.hour);
- return dao;
- }
-
- /**
- * Event handler delegate method for the {@link XdevButton} {@link #cmdDelete}.
- *
- * @see Button.ClickListener#buttonClick(Button.ClickEvent)
- * @eventHandlerDelegate Do NOT delete, used by UI designer!
- */
- private void cmdDelete_buttonClick(final Button.ClickEvent event) {
- if (this.table.getSelectedItem() == null) {
- Notification.show("Datensatz löschen", "Es wurde keine Zeile selektiert in der Tabelle",
- Notification.Type.WARNING_MESSAGE);
- return;
- }
-
- ConfirmDialog.show(getUI(), "Datensatz löschen", "Wirklich löschen?", new CloseListener() {
- @Override
- public void windowClose(final CloseEvent e) {
- String retval = UI.getCurrent().getSession().getAttribute(String.class);
- if (retval == null) {
- retval = "cmdCancel";
- }
-
- if (retval.equals("cmdOk")) {
- doDelete();
- }
- }
-
- private void doDelete() {
- try {
- final Item bean = ItemTabView.this.table.getSelectedItem().getBean();
-
- final ItemDAO dao = new ItemDAO();
- dao.remove(bean);
- dao.flush();
-
- // Delete Record
- final RowObjectManager man = new RowObjectManager();
- man.deleteObject(bean.getItmId(), bean.getClass().getSimpleName());
-
- ItemTabView.this.table.removeItem(bean);
- ItemTabView.this.table.select(null);
- ItemTabView.this.fieldGroup.clear();
-
- ItemTabView.this.table.getBeanContainerDataSource().refresh();
-
- try {
- ItemTabView.this.table.select(ItemTabView.this.table.getCurrentPageFirstItemId());
- } catch (final Exception e) {
- //ignore
- ItemTabView.this.fieldGroup.setItemDataSource(new Item());
- }
- Notification.show("Datensatz löschen", "Datensatz wurde gelöscht!", Notification.Type.TRAY_NOTIFICATION);
-
- } catch (final PersistenceException cx) {
- String msg = cx.getMessage();
- if (cx.getCause() != null) {
- msg = cx.getCause().getMessage();
- if (cx.getCause().getCause() != null) {
- msg = cx.getCause().getCause().getMessage();
- }
- }
- Notification.show("Fehler beim Löschen", msg, Notification.Type.ERROR_MESSAGE);
- cx.printStackTrace();
- }
- }
-
- });
-
- }
-
- /**
- * Event handler delegate method for the {@link XdevButton} {@link #cmdReload}.
- *
- * @see Button.ClickListener#buttonClick(Button.ClickEvent)
- * @eventHandlerDelegate Do NOT delete, used by UI designer!
- */
- private void cmdReload_buttonClick(final Button.ClickEvent event) {
- this.table.refreshRowCache();
- this.table.getBeanContainerDataSource().refresh();
- this.table.sort();
- }
-
- /**
- * Event handler delegate method for the {@link XdevButton} {@link #cmdInfo}.
- *
- * @see Button.ClickListener#buttonClick(Button.ClickEvent)
- * @eventHandlerDelegate Do NOT delete, used by UI designer!
- */
- private void cmdInfo_buttonClick(final Button.ClickEvent event) {
- final Item bean = this.fieldGroup.getItemDataSource().getBean();
-
- final Window win = RowObjectView.getPopupWindow();
-
- //UI.getCurrent().getSession().setAttribute(String.class, bean.getClass().getSimpleName());
- win.setContent(new RowObjectView(bean.getItmId(), bean.getClass().getSimpleName()));
- this.getUI().addWindow(win);
-
- }
-
- /**
- * Event handler delegate method for the {@link XdevTable} {@link #table}.
- *
- * @see Property.ValueChangeListener#valueChange(Property.ValueChangeEvent)
- * @eventHandlerDelegate Do NOT delete, used by UI designer!
- */
- private void table_valueChange(final Property.ValueChangeEvent event) {
- if (this.table.getSelectedItem() != null) {
- //final Item bean = this.table.getSelectedItem().getBean();
- setROFields();
- }
-
- }
-
- /*
- * WARNING: Do NOT edit!
The content of this method is always regenerated by
- * the UI designer.
- */
- //
- private void initUI() {
- this.horizontalSplitPanel = new XdevHorizontalSplitPanel();
- this.verticalLayout = new XdevVerticalLayout();
- this.containerFilterComponent = new XdevContainerFilterComponent();
- this.actionLayout = new XdevHorizontalLayout();
- this.cmdNew = new XdevButton();
- this.cmdDelete = new XdevButton();
- this.cmdReload = new XdevButton();
- this.cmdInfo = new XdevButton();
- this.table = new XdevTable<>();
- this.form = new XdevGridLayout();
- this.cbxUnit = new XdevComboBox<>();
- this.cbxState = new XdevComboBox<>();
- this.lblItmIdent = new XdevLabel();
- this.txtItmIdent = new XdevTextField();
- this.lblItmName = new XdevLabel();
- this.txtItmName = new XdevTextField();
- this.lblItmPrice1 = new XdevLabel();
- this.txtItmPrice1 = new XdevTextField();
- this.lblItmPrice2 = new XdevLabel();
- this.txtItmPrice2 = new XdevTextField();
- this.lblItmUnit = new XdevLabel();
- this.lblItemGroup = new XdevLabel();
- this.cmbItemGroup = new XdevComboBox<>();
- this.lblVat = new XdevLabel();
- this.cmbVat = new XdevComboBox<>();
- this.lblAccount = new XdevLabel();
- this.txtAccount = new XdevTextField();
- this.lblItmState = new XdevLabel();
- this.horizontalLayout = new XdevHorizontalLayout();
- this.cmdSave = new XdevButton();
- this.cmdReset = new XdevButton();
- this.fieldGroup = new XdevFieldGroup<>(Item.class);
-
- this.horizontalSplitPanel.setStyleName("large");
- this.horizontalSplitPanel.setSplitPosition(50.0F, Unit.PERCENTAGE);
- this.verticalLayout.setMargin(new MarginInfo(false));
- this.containerFilterComponent.setPrefixMatchOnly(false);
- this.actionLayout.setSpacing(false);
- this.actionLayout.setMargin(new MarginInfo(false));
- this.cmdNew.setIcon(FontAwesome.PLUS_CIRCLE);
- this.cmdNew.setDescription("Neuer Datensatz");
- this.cmdDelete.setIcon(FontAwesome.MINUS_CIRCLE);
- this.cmdReload.setIcon(FontAwesome.REFRESH);
- this.cmdInfo.setIcon(FontAwesome.INFO_CIRCLE);
- this.table.setColumnReorderingAllowed(true);
- this.table.setColumnCollapsingAllowed(true);
- this.table.setContainerDataSource(Item.class, DAOs.get(ItemDAO.class).findAll());
- this.table.setVisibleColumns(Item_.itmIdent.getName(), Item_.itmName.getName(), Item_.itmPrice1.getName(),
- Item_.itmUnit.getName(), Item_.itemGroup.getName(), Item_.vat.getName(), Item_.itmState.getName());
- this.table.setColumnHeader("itmIdent", "Ident");
- this.table.setColumnHeader("itmName", "Name");
- this.table.setColumnHeader("itmPrice1", "Preis 1");
- this.table.setConverter("itmPrice1", ConverterBuilder.stringToDouble().currency().build());
- this.table.setColumnHeader("itmUnit", "Einheit");
- this.table.setColumnHeader("itemGroup", "Gruppe");
- this.table.setColumnHeader("vat", "Mwst");
- this.table.setColumnCollapsed("vat", true);
- this.table.setColumnHeader("itmState", "Status");
- this.lblItmIdent.setValue(StringResourceUtils.optLocalizeString("{$lblItmIdent.value}", this));
- this.txtItmIdent.setTabIndex(3);
- this.txtItmIdent.setRequired(true);
- this.txtItmIdent.setMaxLength(40);
- this.lblItmName.setValue(StringResourceUtils.optLocalizeString("{$lblItmName.value}", this));
- this.txtItmName.setTabIndex(4);
- this.txtItmName.setRequired(true);
- this.txtItmName.setMaxLength(60);
- this.lblItmPrice1.setValue(StringResourceUtils.optLocalizeString("{$lblItmPrice1.value}", this));
- this.txtItmPrice1.setConverter(ConverterBuilder.stringToDouble().currency().build());
- this.txtItmPrice1.setTabIndex(5);
- this.txtItmPrice1.setRequired(true);
- this.lblItmPrice2.setValue(StringResourceUtils.optLocalizeString("{$lblItmPrice2.value}", this));
- this.txtItmPrice2.setConverter(ConverterBuilder.stringToDouble().currency().build());
- this.txtItmPrice2.setTabIndex(6);
- this.lblItmUnit.setValue(StringResourceUtils.optLocalizeString("{$lblItmUnit.value}", this));
- this.lblItemGroup.setValue(StringResourceUtils.optLocalizeString("{$lblItemGroup.value}", this));
- this.cmbItemGroup.setTabIndex(1);
- this.cmbItemGroup.setContainerDataSource(ItemGroup.class, DAOs.get(ItemGroupDAO.class).findAll());
- this.cmbItemGroup.setItemCaptionPropertyId(ItemGroup_.itgName.getName());
- this.lblVat.setValue(StringResourceUtils.optLocalizeString("{$lblVat.value}", this));
- this.cmbVat.setTabIndex(2);
- this.cmbVat.setRequired(true);
- this.cmbVat.setItemCaptionFromAnnotation(false);
- this.cmbVat.setContainerDataSource(Vat.class, DAOs.get(VatDAO.class).findAllActive());
- this.cmbVat.setItemCaptionPropertyId("fullName");
- this.lblAccount.setDescription("Externe BuHa Ertrags-Konto Nummer");
- this.lblAccount.setValue("Konto#");
- this.txtAccount.setConverter(ConverterBuilder.stringToDouble().groupingUsed(false).build());
- this.lblItmState.setValue(StringResourceUtils.optLocalizeString("{$lblItmState.value}", this));
- this.horizontalLayout.setMargin(new MarginInfo(false));
- this.cmdSave.setIcon(FontAwesome.SAVE);
- this.cmdSave.setCaption(StringResourceUtils.optLocalizeString("{$cmdSave.caption}", this));
- this.cmdSave.setTabIndex(11);
- this.cmdReset.setIcon(FontAwesome.UNDO);
- this.cmdReset.setCaption(StringResourceUtils.optLocalizeString("{$cmdReset.caption}", this));
- this.cmdReset.setTabIndex(10);
- this.fieldGroup.bind(this.cmbItemGroup, Item_.itemGroup.getName());
- this.fieldGroup.bind(this.cmbVat, Item_.vat.getName());
- this.fieldGroup.bind(this.txtItmIdent, Item_.itmIdent.getName());
- this.fieldGroup.bind(this.txtItmName, Item_.itmName.getName());
- this.fieldGroup.bind(this.txtItmPrice1, Item_.itmPrice1.getName());
- this.fieldGroup.bind(this.txtItmPrice2, Item_.itmPrice2.getName());
- this.fieldGroup.bind(this.cbxUnit, Item_.itmUnit.getName());
- this.fieldGroup.bind(this.txtAccount, Item_.itmAccount.getName());
- this.fieldGroup.bind(this.cbxState, Item_.itmState.getName());
-
- MasterDetail.connect(this.table, this.fieldGroup);
-
- this.containerFilterComponent.setContainer(this.table.getBeanContainerDataSource(), "itmIdent", "itmName",
- "itmPrice1", "itmUnit", "itmState", "itemGroup", "vat");
- this.containerFilterComponent.setSearchableProperties("itmIdent", "itmName");
-
- this.cmdNew.setSizeUndefined();
- this.actionLayout.addComponent(this.cmdNew);
- this.actionLayout.setComponentAlignment(this.cmdNew, Alignment.MIDDLE_CENTER);
- this.cmdDelete.setSizeUndefined();
- this.actionLayout.addComponent(this.cmdDelete);
- this.actionLayout.setComponentAlignment(this.cmdDelete, Alignment.MIDDLE_CENTER);
- this.cmdReload.setSizeUndefined();
- this.actionLayout.addComponent(this.cmdReload);
- this.actionLayout.setComponentAlignment(this.cmdReload, Alignment.MIDDLE_CENTER);
- this.cmdInfo.setSizeUndefined();
- this.actionLayout.addComponent(this.cmdInfo);
- this.actionLayout.setComponentAlignment(this.cmdInfo, Alignment.MIDDLE_CENTER);
- final CustomComponent actionLayout_spacer = new CustomComponent();
- actionLayout_spacer.setSizeFull();
- this.actionLayout.addComponent(actionLayout_spacer);
- this.actionLayout.setExpandRatio(actionLayout_spacer, 1.0F);
- this.containerFilterComponent.setWidth(100, Unit.PERCENTAGE);
- this.containerFilterComponent.setHeight(-1, Unit.PIXELS);
- this.verticalLayout.addComponent(this.containerFilterComponent);
- this.verticalLayout.setComponentAlignment(this.containerFilterComponent, Alignment.MIDDLE_CENTER);
- this.actionLayout.setWidth(100, Unit.PERCENTAGE);
- this.actionLayout.setHeight(-1, Unit.PIXELS);
- this.verticalLayout.addComponent(this.actionLayout);
- this.verticalLayout.setComponentAlignment(this.actionLayout, Alignment.MIDDLE_CENTER);
- this.table.setSizeFull();
- this.verticalLayout.addComponent(this.table);
- this.verticalLayout.setComponentAlignment(this.table, Alignment.MIDDLE_CENTER);
- this.verticalLayout.setExpandRatio(this.table, 100.0F);
- this.cmdSave.setSizeUndefined();
- this.horizontalLayout.addComponent(this.cmdSave);
- this.horizontalLayout.setComponentAlignment(this.cmdSave, Alignment.MIDDLE_CENTER);
- this.cmdReset.setSizeUndefined();
- this.horizontalLayout.addComponent(this.cmdReset);
- this.horizontalLayout.setComponentAlignment(this.cmdReset, Alignment.MIDDLE_RIGHT);
- this.form.setColumns(2);
- this.form.setRows(11);
- this.cbxUnit.setSizeUndefined();
- this.form.addComponent(this.cbxUnit, 1, 4);
- this.cbxState.setSizeUndefined();
- this.form.addComponent(this.cbxState, 1, 8);
- this.lblItmIdent.setSizeUndefined();
- this.form.addComponent(this.lblItmIdent, 0, 0);
- this.txtItmIdent.setWidth(100, Unit.PERCENTAGE);
- this.txtItmIdent.setHeight(-1, Unit.PIXELS);
- this.form.addComponent(this.txtItmIdent, 1, 0);
- this.lblItmName.setSizeUndefined();
- this.form.addComponent(this.lblItmName, 0, 1);
- this.txtItmName.setWidth(100, Unit.PERCENTAGE);
- this.txtItmName.setHeight(-1, Unit.PIXELS);
- this.form.addComponent(this.txtItmName, 1, 1);
- this.lblItmPrice1.setSizeUndefined();
- this.form.addComponent(this.lblItmPrice1, 0, 2);
- this.txtItmPrice1.setWidth(100, Unit.PERCENTAGE);
- this.txtItmPrice1.setHeight(-1, Unit.PIXELS);
- this.form.addComponent(this.txtItmPrice1, 1, 2);
- this.lblItmPrice2.setSizeUndefined();
- this.form.addComponent(this.lblItmPrice2, 0, 3);
- this.txtItmPrice2.setWidth(100, Unit.PERCENTAGE);
- this.txtItmPrice2.setHeight(-1, Unit.PIXELS);
- this.form.addComponent(this.txtItmPrice2, 1, 3);
- this.lblItmUnit.setSizeUndefined();
- this.form.addComponent(this.lblItmUnit, 0, 4);
- this.lblItemGroup.setSizeUndefined();
- this.form.addComponent(this.lblItemGroup, 0, 5);
- this.cmbItemGroup.setWidth(100, Unit.PERCENTAGE);
- this.cmbItemGroup.setHeight(-1, Unit.PIXELS);
- this.form.addComponent(this.cmbItemGroup, 1, 5);
- this.lblVat.setSizeUndefined();
- this.form.addComponent(this.lblVat, 0, 6);
- this.cmbVat.setWidth(100, Unit.PERCENTAGE);
- this.cmbVat.setHeight(-1, Unit.PIXELS);
- this.form.addComponent(this.cmbVat, 1, 6);
- this.lblAccount.setSizeUndefined();
- this.form.addComponent(this.lblAccount, 0, 7);
- this.txtAccount.setSizeUndefined();
- this.form.addComponent(this.txtAccount, 1, 7);
- this.lblItmState.setSizeUndefined();
- this.form.addComponent(this.lblItmState, 0, 8);
- this.horizontalLayout.setSizeUndefined();
- this.form.addComponent(this.horizontalLayout, 0, 9, 1, 9);
- this.form.setComponentAlignment(this.horizontalLayout, Alignment.MIDDLE_CENTER);
- this.form.setColumnExpandRatio(1, 100.0F);
- final CustomComponent form_vSpacer = new CustomComponent();
- form_vSpacer.setSizeFull();
- this.form.addComponent(form_vSpacer, 0, 10, 1, 10);
- this.form.setRowExpandRatio(10, 1.0F);
- this.verticalLayout.setSizeFull();
- this.horizontalSplitPanel.setFirstComponent(this.verticalLayout);
- this.form.setSizeFull();
- this.horizontalSplitPanel.setSecondComponent(this.form);
- this.horizontalSplitPanel.setSizeFull();
- this.setContent(this.horizontalSplitPanel);
- this.setSizeFull();
-
- this.cmdNew.addClickListener(event -> this.cmdNew_buttonClick(event));
- this.cmdDelete.addClickListener(event -> this.cmdDelete_buttonClick(event));
- this.cmdReload.addClickListener(event -> this.cmdReload_buttonClick(event));
- this.cmdInfo.addClickListener(event -> this.cmdInfo_buttonClick(event));
- this.table.addValueChangeListener(event -> this.table_valueChange(event));
- this.cmdSave.addClickListener(event -> this.cmdSave_buttonClick(event));
- this.cmdReset.addClickListener(event -> this.cmdReset_buttonClick(event));
- } //
-
- //
- private XdevButton cmdNew, cmdDelete, cmdReload, cmdInfo, cmdSave, cmdReset;
- private XdevLabel lblItmIdent, lblItmName, lblItmPrice1, lblItmPrice2, lblItmUnit, lblItemGroup, lblVat, lblAccount,
- lblItmState;
- private XdevFieldGroup- fieldGroup;
- private XdevGridLayout form;
- private XdevHorizontalSplitPanel horizontalSplitPanel;
- private XdevContainerFilterComponent containerFilterComponent;
- private XdevComboBox cmbItemGroup;
- private XdevHorizontalLayout actionLayout, horizontalLayout;
- private XdevComboBox cmbVat;
- private XdevComboBox> cbxUnit, cbxState;
- private XdevTextField txtItmIdent, txtItmName, txtItmPrice1, txtItmPrice2, txtAccount;
- private XdevVerticalLayout verticalLayout;
- private XdevTable
- table;
- //
-
-}
+package ch.xwr.seicentobilling.ui.desktop;
+
+import java.util.List;
+
+import javax.persistence.PersistenceException;
+
+import com.vaadin.data.Property;
+import com.vaadin.server.FontAwesome;
+import com.vaadin.shared.ui.MarginInfo;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.Notification;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.Window;
+import com.vaadin.ui.Window.CloseEvent;
+import com.vaadin.ui.Window.CloseListener;
+import com.xdev.dal.DAOs;
+import com.xdev.res.StringResourceUtils;
+import com.xdev.ui.XdevButton;
+import com.xdev.ui.XdevFieldGroup;
+import com.xdev.ui.XdevGridLayout;
+import com.xdev.ui.XdevHorizontalLayout;
+import com.xdev.ui.XdevHorizontalSplitPanel;
+import com.xdev.ui.XdevLabel;
+import com.xdev.ui.XdevTextField;
+import com.xdev.ui.XdevVerticalLayout;
+import com.xdev.ui.XdevView;
+import com.xdev.ui.entitycomponent.combobox.XdevComboBox;
+import com.xdev.ui.entitycomponent.table.XdevTable;
+import com.xdev.ui.filter.XdevContainerFilterComponent;
+import com.xdev.ui.masterdetail.MasterDetail;
+import com.xdev.util.ConverterBuilder;
+
+import ch.xwr.seicentobilling.business.ConfirmDialog;
+import ch.xwr.seicentobilling.business.LovState;
+import ch.xwr.seicentobilling.business.NumberRangeHandler;
+import ch.xwr.seicentobilling.business.RowObjectManager;
+import ch.xwr.seicentobilling.dal.ItemDAO;
+import ch.xwr.seicentobilling.dal.ItemGroupDAO;
+import ch.xwr.seicentobilling.dal.VatDAO;
+import ch.xwr.seicentobilling.entities.Item;
+import ch.xwr.seicentobilling.entities.ItemGroup;
+import ch.xwr.seicentobilling.entities.ItemGroup_;
+import ch.xwr.seicentobilling.entities.Item_;
+import ch.xwr.seicentobilling.entities.Vat;
+
+public class ItemTabView extends XdevView {
+
+ /**
+ *
+ */
+ public ItemTabView() {
+ super();
+ this.initUI();
+
+ //Type
+ this.cbxState.addItems((Object[])LovState.State.values());
+ this.cbxUnit.addItems((Object[])LovState.Unit.values());
+ this.cbxPriceLevel.addItems((Object[])LovState.itmPriceLevel.values());
+
+ //set RO Fields
+ setROFields();
+
+ }
+
+ private void setROFields() {
+
+ boolean hasData = true;
+ if (this.fieldGroup.getItemDataSource() == null) {
+ hasData = false;
+ }
+ this.cmdSave.setEnabled(hasData);
+ //this.tabSheet.setEnabled(hasData);
+ this.form.setEnabled(hasData);
+
+ }
+
+ /**
+ * Event handler delegate method for the {@link XdevButton} {@link #cmdReset}.
+ *
+ * @see Button.ClickListener#buttonClick(Button.ClickEvent)
+ * @eventHandlerDelegate Do NOT delete, used by UI designer!
+ */
+ private void cmdReset_buttonClick(final Button.ClickEvent event) {
+ if (isNew()) {
+ cmdNew_buttonClick(event);
+ } else {
+ this.fieldGroup.discard();
+ }
+ setROFields();
+ }
+
+ /**
+ * Event handler delegate method for the {@link XdevButton} {@link #cmdSave}.
+ *
+ * @see Button.ClickListener#buttonClick(Button.ClickEvent)
+ * @eventHandlerDelegate Do NOT delete, used by UI designer!
+ */
+ private void cmdSave_buttonClick(final Button.ClickEvent event) {
+ final boolean isNew = isNew(); //assign before save. is always false after save
+
+ this.fieldGroup.save();
+ setROFields();
+ checkItemNumber(isNew, true);
+
+ final RowObjectManager man = new RowObjectManager();
+ man.updateObject(this.fieldGroup.getItemDataSource().getBean().getItmId(), this.fieldGroup.getItemDataSource().getBean().getClass().getSimpleName());
+
+ Notification.show("Save clicked", "Daten wurden gespeichert", Notification.Type.TRAY_NOTIFICATION);
+
+ if (isNew) {
+ cmdReload_buttonClick(event);
+ }
+ }
+
+ private void checkItemNumber(final boolean isNew, final boolean commitNbr) {
+ if (! isNew) {
+ return;
+ }
+
+ Integer nbr = null;
+ try {
+ nbr = Integer.parseInt(this.txtItmIdent.getValue());
+ } catch (final Exception e){
+ nbr = new Integer(0);
+ }
+
+ final NumberRangeHandler handler = new NumberRangeHandler();
+ if (!commitNbr) {
+ if (nbr > 0) {
+ return ;
+ }
+ this.txtItmIdent.setValue(handler.getNewItemNumber(false, nbr).toString());
+ } else {
+ handler.getNewItemNumber(true, nbr);
+ }
+
+ }
+
+ private boolean isNew() {
+ if (this.fieldGroup.getItemDataSource() == null) {
+ return true;
+ }
+ final Item bean = this.fieldGroup.getItemDataSource().getBean();
+ if (bean.getItmId() == null || bean.getItmId() < 1) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Event handler delegate method for the {@link XdevButton} {@link #cmdNew}.
+ *
+ * @see Button.ClickListener#buttonClick(Button.ClickEvent)
+ * @eventHandlerDelegate Do NOT delete, used by UI designer!
+ */
+ private void cmdNew_buttonClick(final Button.ClickEvent event) {
+ this.fieldGroup.setItemDataSource(getNewDaoWithDefaults());
+ checkItemNumber(true, false);
+ setROFields();
+
+ }
+
+ private Item getNewDaoWithDefaults() {
+ final Item dao = new Item();
+
+ dao.setItmState(LovState.State.active);
+ dao.setItmPrice1(new Double(0));
+ dao.setItmUnit(LovState.Unit.hour);
+ return dao;
+ }
+
+ /**
+ * Event handler delegate method for the {@link XdevButton} {@link #cmdDelete}.
+ *
+ * @see Button.ClickListener#buttonClick(Button.ClickEvent)
+ * @eventHandlerDelegate Do NOT delete, used by UI designer!
+ */
+ private void cmdDelete_buttonClick(final Button.ClickEvent event) {
+ if (this.table.getSelectedItem() == null) {
+ Notification.show("Datensatz löschen", "Es wurde keine Zeile selektiert in der Tabelle",
+ Notification.Type.WARNING_MESSAGE);
+ return;
+ }
+
+ ConfirmDialog.show(getUI(), "Datensatz löschen", "Wirklich löschen?", new CloseListener() {
+ @Override
+ public void windowClose(final CloseEvent e) {
+ String retval = UI.getCurrent().getSession().getAttribute(String.class);
+ if (retval == null) {
+ retval = "cmdCancel";
+ }
+
+ if (retval.equals("cmdOk")) {
+ doDelete();
+ }
+ }
+
+ private void doDelete() {
+ try {
+ final Item bean = ItemTabView.this.table.getSelectedItem().getBean();
+
+ final ItemDAO dao = new ItemDAO();
+ dao.remove(bean);
+ dao.flush();
+
+ // Delete Record
+ final RowObjectManager man = new RowObjectManager();
+ man.deleteObject(bean.getItmId(), bean.getClass().getSimpleName());
+
+ ItemTabView.this.table.removeItem(bean);
+ ItemTabView.this.table.select(null);
+ ItemTabView.this.fieldGroup.clear();
+
+ ItemTabView.this.table.getBeanContainerDataSource().refresh();
+
+ try {
+ ItemTabView.this.table.select(ItemTabView.this.table.getCurrentPageFirstItemId());
+ } catch (final Exception e) {
+ //ignore
+ ItemTabView.this.fieldGroup.setItemDataSource(new Item());
+ }
+ Notification.show("Datensatz löschen", "Datensatz wurde gelöscht!", Notification.Type.TRAY_NOTIFICATION);
+
+ } catch (final PersistenceException cx) {
+ String msg = cx.getMessage();
+ if (cx.getCause() != null) {
+ msg = cx.getCause().getMessage();
+ if (cx.getCause().getCause() != null) {
+ msg = cx.getCause().getCause().getMessage();
+ }
+ }
+ Notification.show("Fehler beim Löschen", msg, Notification.Type.ERROR_MESSAGE);
+ cx.printStackTrace();
+ }
+ }
+
+ });
+
+ }
+
+ /**
+ * Event handler delegate method for the {@link XdevButton} {@link #cmdReload}.
+ *
+ * @see Button.ClickListener#buttonClick(Button.ClickEvent)
+ * @eventHandlerDelegate Do NOT delete, used by UI designer!
+ */
+ private void cmdReload_buttonClick(final Button.ClickEvent event) {
+ this.table.removeAllItems();
+
+ this.table.refreshRowCache();
+ final List- lst = new ItemDAO().findAllSortedByName();
+ this.table.getBeanContainerDataSource().addAll(lst);
+ }
+
+ /**
+ * Event handler delegate method for the {@link XdevButton} {@link #cmdInfo}.
+ *
+ * @see Button.ClickListener#buttonClick(Button.ClickEvent)
+ * @eventHandlerDelegate Do NOT delete, used by UI designer!
+ */
+ private void cmdInfo_buttonClick(final Button.ClickEvent event) {
+ final Item bean = this.fieldGroup.getItemDataSource().getBean();
+
+ final Window win = RowObjectView.getPopupWindow();
+
+ //UI.getCurrent().getSession().setAttribute(String.class, bean.getClass().getSimpleName());
+ win.setContent(new RowObjectView(bean.getItmId(), bean.getClass().getSimpleName()));
+ this.getUI().addWindow(win);
+
+ }
+
+ /**
+ * Event handler delegate method for the {@link XdevTable} {@link #table}.
+ *
+ * @see Property.ValueChangeListener#valueChange(Property.ValueChangeEvent)
+ * @eventHandlerDelegate Do NOT delete, used by UI designer!
+ */
+ private void table_valueChange(final Property.ValueChangeEvent event) {
+ if (this.table.getSelectedItem() != null) {
+ //final Item bean = this.table.getSelectedItem().getBean();
+ setROFields();
+ }
+
+ }
+
+ /*
+ * WARNING: Do NOT edit!
The content of this method is always regenerated by
+ * the UI designer.
+ */
+ //
+ private void initUI() {
+ this.horizontalSplitPanel = new XdevHorizontalSplitPanel();
+ this.verticalLayout = new XdevVerticalLayout();
+ this.containerFilterComponent = new XdevContainerFilterComponent();
+ this.actionLayout = new XdevHorizontalLayout();
+ this.cmdNew = new XdevButton();
+ this.cmdDelete = new XdevButton();
+ this.cmdReload = new XdevButton();
+ this.cmdInfo = new XdevButton();
+ this.table = new XdevTable<>();
+ this.form = new XdevGridLayout();
+ this.cbxUnit = new XdevComboBox<>();
+ this.cbxState = new XdevComboBox<>();
+ this.lblItmIdent = new XdevLabel();
+ this.txtItmIdent = new XdevTextField();
+ this.lblItmName = new XdevLabel();
+ this.txtItmName = new XdevTextField();
+ this.lblItmPrice1 = new XdevLabel();
+ this.txtItmPrice1 = new XdevTextField();
+ this.lblVat = new XdevLabel();
+ this.cmbVat = new XdevComboBox<>();
+ this.lblItmPriceLevel = new XdevLabel();
+ this.cbxPriceLevel = new XdevComboBox<>();
+ this.lblItmUnit = new XdevLabel();
+ this.lblItemGroup = new XdevLabel();
+ this.cmbItemGroup = new XdevComboBox<>();
+ this.lblAccount = new XdevLabel();
+ this.txtAccount = new XdevTextField();
+ this.lblItmState = new XdevLabel();
+ this.horizontalLayout = new XdevHorizontalLayout();
+ this.cmdSave = new XdevButton();
+ this.cmdReset = new XdevButton();
+ this.fieldGroup = new XdevFieldGroup<>(Item.class);
+
+ this.horizontalSplitPanel.setStyleName("large");
+ this.horizontalSplitPanel.setSplitPosition(50.0F, Unit.PERCENTAGE);
+ this.verticalLayout.setMargin(new MarginInfo(false));
+ this.containerFilterComponent.setPrefixMatchOnly(false);
+ this.actionLayout.setSpacing(false);
+ this.actionLayout.setMargin(new MarginInfo(false));
+ this.cmdNew.setIcon(FontAwesome.PLUS_CIRCLE);
+ this.cmdNew.setDescription("Neuer Datensatz");
+ this.cmdDelete.setIcon(FontAwesome.MINUS_CIRCLE);
+ this.cmdReload.setIcon(FontAwesome.REFRESH);
+ this.cmdInfo.setIcon(FontAwesome.INFO_CIRCLE);
+ this.table.setColumnReorderingAllowed(true);
+ this.table.setColumnCollapsingAllowed(true);
+ this.table.setContainerDataSource(Item.class, DAOs.get(ItemDAO.class).findAll());
+ this.table.setVisibleColumns(Item_.itmIdent.getName(), Item_.itmName.getName(), Item_.itmPrice1.getName(),
+ Item_.itmUnit.getName(), Item_.itemGroup.getName(), Item_.vat.getName(), Item_.itmState.getName());
+ this.table.setColumnHeader("itmIdent", "Ident");
+ this.table.setColumnHeader("itmName", "Name");
+ this.table.setColumnHeader("itmPrice1", "Preis 1");
+ this.table.setConverter("itmPrice1", ConverterBuilder.stringToDouble().currency().build());
+ this.table.setColumnHeader("itmUnit", "Einheit");
+ this.table.setColumnHeader("itemGroup", "Gruppe");
+ this.table.setColumnHeader("vat", "Mwst");
+ this.table.setColumnCollapsed("vat", true);
+ this.table.setColumnHeader("itmState", "Status");
+ this.lblItmIdent.setValue(StringResourceUtils.optLocalizeString("{$lblItmIdent.value}", this));
+ this.txtItmIdent.setTabIndex(3);
+ this.txtItmIdent.setRequired(true);
+ this.txtItmIdent.setMaxLength(40);
+ this.lblItmName.setValue(StringResourceUtils.optLocalizeString("{$lblItmName.value}", this));
+ this.txtItmName.setTabIndex(4);
+ this.txtItmName.setRequired(true);
+ this.txtItmName.setMaxLength(60);
+ this.lblItmPrice1.setValue(StringResourceUtils.optLocalizeString("{$lblItmPrice1.value}", this));
+ this.txtItmPrice1.setConverter(ConverterBuilder.stringToDouble().currency().build());
+ this.txtItmPrice1.setTabIndex(5);
+ this.txtItmPrice1.setRequired(true);
+ this.lblVat.setValue(StringResourceUtils.optLocalizeString("{$lblVat.value}", this));
+ this.cmbVat.setTabIndex(2);
+ this.cmbVat.setRequired(true);
+ this.cmbVat.setItemCaptionFromAnnotation(false);
+ this.cmbVat.setContainerDataSource(Vat.class, DAOs.get(VatDAO.class).findAllActive());
+ this.cmbVat.setItemCaptionPropertyId("fullName");
+ this.lblItmPriceLevel.setDescription("Priorität für Preisermittlung");
+ this.lblItmPriceLevel.setValue("Preis Prio");
+ this.cbxPriceLevel.setRequired(true);
+ this.lblItmUnit.setValue(StringResourceUtils.optLocalizeString("{$lblItmUnit.value}", this));
+ this.lblItemGroup.setValue(StringResourceUtils.optLocalizeString("{$lblItemGroup.value}", this));
+ this.cmbItemGroup.setTabIndex(1);
+ this.cmbItemGroup.setContainerDataSource(ItemGroup.class, DAOs.get(ItemGroupDAO.class).findAll());
+ this.cmbItemGroup.setItemCaptionPropertyId(ItemGroup_.itgName.getName());
+ this.lblAccount.setDescription("Externe BuHa Ertrags-Konto Nummer");
+ this.lblAccount.setValue("Konto#");
+ this.txtAccount.setConverter(ConverterBuilder.stringToDouble().groupingUsed(false).build());
+ this.lblItmState.setValue(StringResourceUtils.optLocalizeString("{$lblItmState.value}", this));
+ this.horizontalLayout.setMargin(new MarginInfo(false));
+ this.cmdSave.setIcon(FontAwesome.SAVE);
+ this.cmdSave.setCaption(StringResourceUtils.optLocalizeString("{$cmdSave.caption}", this));
+ this.cmdSave.setTabIndex(11);
+ this.cmdReset.setIcon(FontAwesome.UNDO);
+ this.cmdReset.setCaption(StringResourceUtils.optLocalizeString("{$cmdReset.caption}", this));
+ this.cmdReset.setTabIndex(10);
+ this.fieldGroup.bind(this.cmbItemGroup, Item_.itemGroup.getName());
+ this.fieldGroup.bind(this.cmbVat, Item_.vat.getName());
+ this.fieldGroup.bind(this.txtItmIdent, Item_.itmIdent.getName());
+ this.fieldGroup.bind(this.txtItmName, Item_.itmName.getName());
+ this.fieldGroup.bind(this.txtItmPrice1, Item_.itmPrice1.getName());
+ this.fieldGroup.bind(this.cbxUnit, Item_.itmUnit.getName());
+ this.fieldGroup.bind(this.txtAccount, Item_.itmAccount.getName());
+ this.fieldGroup.bind(this.cbxState, Item_.itmState.getName());
+ this.fieldGroup.bind(this.cbxPriceLevel, Item_.itmPriceLevel.getName());
+
+ MasterDetail.connect(this.table, this.fieldGroup);
+
+ this.containerFilterComponent.setContainer(this.table.getBeanContainerDataSource(), "itmIdent", "itmName",
+ "itmPrice1", "itmUnit", "itmState", "itemGroup", "vat");
+ this.containerFilterComponent.setSearchableProperties("itmIdent", "itmName");
+
+ this.cmdNew.setSizeUndefined();
+ this.actionLayout.addComponent(this.cmdNew);
+ this.actionLayout.setComponentAlignment(this.cmdNew, Alignment.MIDDLE_CENTER);
+ this.cmdDelete.setSizeUndefined();
+ this.actionLayout.addComponent(this.cmdDelete);
+ this.actionLayout.setComponentAlignment(this.cmdDelete, Alignment.MIDDLE_CENTER);
+ this.cmdReload.setSizeUndefined();
+ this.actionLayout.addComponent(this.cmdReload);
+ this.actionLayout.setComponentAlignment(this.cmdReload, Alignment.MIDDLE_CENTER);
+ this.cmdInfo.setSizeUndefined();
+ this.actionLayout.addComponent(this.cmdInfo);
+ this.actionLayout.setComponentAlignment(this.cmdInfo, Alignment.MIDDLE_CENTER);
+ final CustomComponent actionLayout_spacer = new CustomComponent();
+ actionLayout_spacer.setSizeFull();
+ this.actionLayout.addComponent(actionLayout_spacer);
+ this.actionLayout.setExpandRatio(actionLayout_spacer, 1.0F);
+ this.containerFilterComponent.setWidth(100, Unit.PERCENTAGE);
+ this.containerFilterComponent.setHeight(-1, Unit.PIXELS);
+ this.verticalLayout.addComponent(this.containerFilterComponent);
+ this.verticalLayout.setComponentAlignment(this.containerFilterComponent, Alignment.MIDDLE_CENTER);
+ this.actionLayout.setWidth(100, Unit.PERCENTAGE);
+ this.actionLayout.setHeight(-1, Unit.PIXELS);
+ this.verticalLayout.addComponent(this.actionLayout);
+ this.verticalLayout.setComponentAlignment(this.actionLayout, Alignment.MIDDLE_CENTER);
+ this.table.setSizeFull();
+ this.verticalLayout.addComponent(this.table);
+ this.verticalLayout.setComponentAlignment(this.table, Alignment.MIDDLE_CENTER);
+ this.verticalLayout.setExpandRatio(this.table, 100.0F);
+ this.cmdSave.setSizeUndefined();
+ this.horizontalLayout.addComponent(this.cmdSave);
+ this.horizontalLayout.setComponentAlignment(this.cmdSave, Alignment.MIDDLE_CENTER);
+ this.cmdReset.setSizeUndefined();
+ this.horizontalLayout.addComponent(this.cmdReset);
+ this.horizontalLayout.setComponentAlignment(this.cmdReset, Alignment.MIDDLE_RIGHT);
+ this.form.setColumns(2);
+ this.form.setRows(11);
+ this.cbxUnit.setSizeUndefined();
+ this.form.addComponent(this.cbxUnit, 1, 5);
+ this.cbxState.setSizeUndefined();
+ this.form.addComponent(this.cbxState, 1, 8);
+ this.lblItmIdent.setSizeUndefined();
+ this.form.addComponent(this.lblItmIdent, 0, 0);
+ this.txtItmIdent.setWidth(100, Unit.PERCENTAGE);
+ this.txtItmIdent.setHeight(-1, Unit.PIXELS);
+ this.form.addComponent(this.txtItmIdent, 1, 0);
+ this.lblItmName.setSizeUndefined();
+ this.form.addComponent(this.lblItmName, 0, 1);
+ this.txtItmName.setWidth(100, Unit.PERCENTAGE);
+ this.txtItmName.setHeight(-1, Unit.PIXELS);
+ this.form.addComponent(this.txtItmName, 1, 1);
+ this.lblItmPrice1.setSizeUndefined();
+ this.form.addComponent(this.lblItmPrice1, 0, 2);
+ this.txtItmPrice1.setWidth(100, Unit.PERCENTAGE);
+ this.txtItmPrice1.setHeight(-1, Unit.PIXELS);
+ this.form.addComponent(this.txtItmPrice1, 1, 2);
+ this.lblVat.setSizeUndefined();
+ this.form.addComponent(this.lblVat, 0, 3);
+ this.cmbVat.setWidth(100, Unit.PERCENTAGE);
+ this.cmbVat.setHeight(-1, Unit.PIXELS);
+ this.form.addComponent(this.cmbVat, 1, 3);
+ this.lblItmPriceLevel.setSizeUndefined();
+ this.form.addComponent(this.lblItmPriceLevel, 0, 4);
+ this.cbxPriceLevel.setSizeUndefined();
+ this.form.addComponent(this.cbxPriceLevel, 1, 4);
+ this.lblItmUnit.setSizeUndefined();
+ this.form.addComponent(this.lblItmUnit, 0, 5);
+ this.lblItemGroup.setSizeUndefined();
+ this.form.addComponent(this.lblItemGroup, 0, 6);
+ this.cmbItemGroup.setWidth(100, Unit.PERCENTAGE);
+ this.cmbItemGroup.setHeight(-1, Unit.PIXELS);
+ this.form.addComponent(this.cmbItemGroup, 1, 6);
+ this.lblAccount.setSizeUndefined();
+ this.form.addComponent(this.lblAccount, 0, 7);
+ this.txtAccount.setSizeUndefined();
+ this.form.addComponent(this.txtAccount, 1, 7);
+ this.lblItmState.setSizeUndefined();
+ this.form.addComponent(this.lblItmState, 0, 8);
+ this.horizontalLayout.setSizeUndefined();
+ this.form.addComponent(this.horizontalLayout, 0, 9, 1, 9);
+ this.form.setComponentAlignment(this.horizontalLayout, Alignment.MIDDLE_CENTER);
+ this.form.setColumnExpandRatio(1, 100.0F);
+ final CustomComponent form_vSpacer = new CustomComponent();
+ form_vSpacer.setSizeFull();
+ this.form.addComponent(form_vSpacer, 0, 10, 1, 10);
+ this.form.setRowExpandRatio(10, 1.0F);
+ this.verticalLayout.setSizeFull();
+ this.horizontalSplitPanel.setFirstComponent(this.verticalLayout);
+ this.form.setSizeFull();
+ this.horizontalSplitPanel.setSecondComponent(this.form);
+ this.horizontalSplitPanel.setSizeFull();
+ this.setContent(this.horizontalSplitPanel);
+ this.setSizeFull();
+
+ this.cmdNew.addClickListener(event -> this.cmdNew_buttonClick(event));
+ this.cmdDelete.addClickListener(event -> this.cmdDelete_buttonClick(event));
+ this.cmdReload.addClickListener(event -> this.cmdReload_buttonClick(event));
+ this.cmdInfo.addClickListener(event -> this.cmdInfo_buttonClick(event));
+ this.table.addValueChangeListener(event -> this.table_valueChange(event));
+ this.cmdSave.addClickListener(event -> this.cmdSave_buttonClick(event));
+ this.cmdReset.addClickListener(event -> this.cmdReset_buttonClick(event));
+ } //
+
+ //
+ private XdevButton cmdNew, cmdDelete, cmdReload, cmdInfo, cmdSave, cmdReset;
+ private XdevLabel lblItmIdent, lblItmName, lblItmPrice1, lblVat, lblItmPriceLevel, lblItmUnit, lblItemGroup, lblAccount,
+ lblItmState;
+ private XdevFieldGroup- fieldGroup;
+ private XdevGridLayout form;
+ private XdevHorizontalSplitPanel horizontalSplitPanel;
+ private XdevContainerFilterComponent containerFilterComponent;
+ private XdevComboBox cmbItemGroup;
+ private XdevHorizontalLayout actionLayout, horizontalLayout;
+ private XdevComboBox cmbVat;
+ private XdevComboBox> cbxUnit, cbxState, cbxPriceLevel;
+ private XdevTextField txtItmIdent, txtItmName, txtItmPrice1, txtAccount;
+ private XdevVerticalLayout verticalLayout;
+ private XdevTable
- table;
+ //
+
+}
diff --git a/src/ch/xwr/seicentobilling/ui/desktop/ItemTabView.ui.xml b/src/ch/xwr/seicentobilling/ui/desktop/ItemTabView.ui.xml
index e7d0654..25ec89e 100644
--- a/src/ch/xwr/seicentobilling/ui/desktop/ItemTabView.ui.xml
+++ b/src/ch/xwr/seicentobilling/ui/desktop/ItemTabView.ui.xml
@@ -1,183 +1,185 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- click.buttonClick
-
-
-
- click.buttonClick
-
-
-
- click.buttonClick
-
-
-
- click.buttonClick
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- valueChange.valueChange
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- click.buttonClick
-
-
-
- click.buttonClick
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ click.buttonClick
+
+
+
+ click.buttonClick
+
+
+
+ click.buttonClick
+
+
+
+ click.buttonClick
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ valueChange.valueChange
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ click.buttonClick
+
+
+
+ click.buttonClick
+
+
+
+
+
+
diff --git a/src/ch/xwr/seicentobilling/ui/desktop/OrderLinePopup.java b/src/ch/xwr/seicentobilling/ui/desktop/OrderLinePopup.java
index ad689a4..4ec1256 100644
--- a/src/ch/xwr/seicentobilling/ui/desktop/OrderLinePopup.java
+++ b/src/ch/xwr/seicentobilling/ui/desktop/OrderLinePopup.java
@@ -1,470 +1,491 @@
-package ch.xwr.seicentobilling.ui.desktop;
-
-import java.util.List;
-
-import com.vaadin.data.Property;
-import com.vaadin.data.validator.StringLengthValidator;
-import com.vaadin.event.ShortcutAction;
-import com.vaadin.server.FontAwesome;
-import com.vaadin.shared.ui.MarginInfo;
-import com.vaadin.ui.Alignment;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.Notification;
-import com.vaadin.ui.UI;
-import com.vaadin.ui.Window;
-import com.xdev.dal.DAOs;
-import com.xdev.res.StringResourceUtils;
-import com.xdev.ui.XdevButton;
-import com.xdev.ui.XdevFieldGroup;
-import com.xdev.ui.XdevGridLayout;
-import com.xdev.ui.XdevHorizontalLayout;
-import com.xdev.ui.XdevLabel;
-import com.xdev.ui.XdevTextField;
-import com.xdev.ui.XdevView;
-import com.xdev.ui.entitycomponent.combobox.XdevComboBox;
-import com.xdev.util.ConverterBuilder;
-
-import ch.xwr.seicentobilling.business.LovState;
-import ch.xwr.seicentobilling.business.OrderCalculator;
-import ch.xwr.seicentobilling.business.RowObjectManager;
-import ch.xwr.seicentobilling.business.Seicento;
-import ch.xwr.seicentobilling.business.helper.SeicentoCrud;
-import ch.xwr.seicentobilling.dal.CostAccountDAO;
-import ch.xwr.seicentobilling.dal.ItemDAO;
-import ch.xwr.seicentobilling.dal.OrderDAO;
-import ch.xwr.seicentobilling.dal.OrderLineDAO;
-import ch.xwr.seicentobilling.dal.VatDAO;
-import ch.xwr.seicentobilling.dal.VatLineDAO;
-import ch.xwr.seicentobilling.entities.CostAccount;
-import ch.xwr.seicentobilling.entities.CostAccount_;
-import ch.xwr.seicentobilling.entities.Item;
-import ch.xwr.seicentobilling.entities.Order;
-import ch.xwr.seicentobilling.entities.OrderLine;
-import ch.xwr.seicentobilling.entities.OrderLine_;
-import ch.xwr.seicentobilling.entities.Order_;
-import ch.xwr.seicentobilling.entities.Vat;
-import ch.xwr.seicentobilling.entities.VatLine;
-
-public class OrderLinePopup extends XdevView {
- OrderCalculator CALC = new OrderCalculator();
-
- /**
- *
- */
- public OrderLinePopup() {
- super();
- this.initUI();
-
- this.setHeight(Seicento.calculateThemeHeight(this.getHeight(),UI.getCurrent().getTheme()));
-
- // State
- this.comboBoxState.addItems((Object[]) LovState.State.values());
- // this.comboBoxWorktype.addItems((Object[])LovState.WorkType.values());
-
- // get Parameter
- final Long beanId = (Long) UI.getCurrent().getSession().getAttribute("beanId");
- final Long objId = (Long) UI.getCurrent().getSession().getAttribute("objId");
- OrderLine bean = null;
- Order obj = null;
-
- if (beanId == null) {
- // new
- final OrderDAO objDao = new OrderDAO();
- obj = objDao.find(objId);
-
- bean = new OrderLine();
- bean.setOrderhdr(obj);
- bean.setOdlState(LovState.State.active);
- bean.setOdlQuantity(1);
- bean.setOdlNumber(this.CALC.getNextLineNumber(obj));
-
- } else {
- final OrderLineDAO dao = new OrderLineDAO();
- bean = dao.find(beanId.longValue());
- }
-
- setBeanGui(bean);
- setROFields();
- }
-
- private void setROFields() {
- this.txtOdlAmountBrut.setEnabled(false);
- this.txtOdlAmountNet.setEnabled(false);
- this.txtOdlVatAmount.setEnabled(false);
- this.cmbOrder.setEnabled(false);
-
- }
-
- private void setBeanGui(final OrderLine bean) {
- // set Bean + Fields
- this.fieldGroup.setItemDataSource(bean);
-
- // this.comboBoxObject.setEnabled(false);
- // this.textFieldName.setEnabled(false);
- // this.textFieldMime.setEnabled(false);
- }
-
- public static Window getPopupWindow() {
- final Window win = new Window();
- //win.setWidth("720");
- //win.setHeight("540");
- win.center();
- win.setModal(true);
- win.setContent(new OrderLinePopup());
-
- return win;
- }
-
- /**
- * Event handler delegate method for the {@link XdevButton}
- * {@link #cmdCancel}.
- *
- * @see Button.ClickListener#buttonClick(Button.ClickEvent)
- * @eventHandlerDelegate Do NOT delete, used by UI designer!
- */
- private void cmdCancel_buttonClick(final Button.ClickEvent event) {
- UI.getCurrent().getSession().setAttribute(String.class, "cmdCancel");
- this.fieldGroup.discard();
- ((Window) this.getParent()).close();
- }
-
- /**
- * Event handler delegate method for the {@link XdevButton}
- * {@link #cmdSave}.
- *
- * @see Button.ClickListener#buttonClick(Button.ClickEvent)
- * @eventHandlerDelegate Do NOT delete, used by UI designer!
- */
- private void cmdSave_buttonClick(final Button.ClickEvent event) {
- UI.getCurrent().getSession().setAttribute(String.class, "cmdSave");
-
- try {
- if (!this.fieldGroup.isValid()){
- SeicentoCrud.validateField(this.fieldGroup);
- return;
- }
-
- if (SeicentoCrud.doSave(this.fieldGroup)) {
- final RowObjectManager man = new RowObjectManager();
- man.updateObject(this.fieldGroup.getItemDataSource().getBean().getOdlId(),
- this.fieldGroup.getItemDataSource().getBean().getClass().getSimpleName());
-
- ((Window) this.getParent()).close();
- }
-
-
- } catch (final Exception e) {
- Notification.show("Fehler beim Speichern", e.getMessage(), Notification.Type.ERROR_MESSAGE);
- e.printStackTrace();
- }
- }
-
- /**
- * Event handler delegate method for the {@link XdevComboBox}
- * {@link #cmbItem}.
- *
- * @see Property.ValueChangeListener#valueChange(Property.ValueChangeEvent)
- * @eventHandlerDelegate Do NOT delete, used by UI designer!
- */
- private void cmbItem_valueChange(final Property.ValueChangeEvent event) {
- if (!this.fieldGroup.isModified()) {
- return;
- }
- // if (event.getProperty().)
- final Item itm = (Item) event.getProperty().getValue();
-
- if (itm.getItmPrice1() != null) {
- this.txtOdlPrice.setValue(itm.getItmPrice1().toString());
- }
- if (itm.getVat() != null) {
- this.cmbVat.setValue(itm.getVat());
- }
-
- // loadDataFromEmp(emp);
- }
-
- /**
- * Event handler delegate method for the {@link XdevTextField}
- * {@link #txtOdlQuantity}.
- *
- * @see Property.ValueChangeListener#valueChange(Property.ValueChangeEvent)
- * @eventHandlerDelegate Do NOT delete, used by UI designer!
- */
- private void txtOdlQuantity_valueChange(final Property.ValueChangeEvent event) {
- if (!this.fieldGroup.isModified()) {
- return;
- }
-
- calculateItem();
- }
-
- private void calculateItem() {
- this.CALC.commitFields(this.fieldGroup);
- final OrderLine newodl = this.CALC.calculateLine(this.fieldGroup.getItemDataSource().getBean());
-
- this.fieldGroup.setItemDataSource(newodl);
- setROFields();
-
- }
-
- /**
- * Event handler delegate method for the {@link XdevTextField}
- * {@link #txtOdlPrice}.
- *
- * @see Property.ValueChangeListener#valueChange(Property.ValueChangeEvent)
- * @eventHandlerDelegate Do NOT delete, used by UI designer!
- */
- private void txtOdlPrice_valueChange(final Property.ValueChangeEvent event) {
- if (!this.fieldGroup.isModified()) {
- return;
- }
-
- calculateItem();
- }
-
- /**
- * Event handler delegate method for the {@link XdevComboBox}
- * {@link #cmbVat}.
- *
- * @see Property.ValueChangeListener#valueChange(Property.ValueChangeEvent)
- * @eventHandlerDelegate Do NOT delete, used by UI designer!
- */
- private void cmbVat_valueChange(final Property.ValueChangeEvent event) {
- if (!this.fieldGroup.isModified()) {
- return;
- }
-
- calculateItem();
- fetchVatRate();
- }
-
- private void fetchVatRate() {
- final OrderLine newodl = this.fieldGroup.getItemDataSource().getBean();
-
- //TFS-240
- final VatLineDAO dao = new VatLineDAO();
- final List lst = dao.findByVatAndDate(newodl.getVat(), newodl.getOrderhdr().getOrdBillDate());
- double rate = 0;
- if (lst == null || lst.isEmpty()) {
- rate = 0;
- } else {
- final VatLine vl = lst.get(0);
- rate = vl.getVanRate().doubleValue();
- }
- this.lblVat.setValue("MwSt " + rate + "%");
-
- }
-
- /*
- * WARNING: Do NOT edit!
The content of this method is always regenerated by
- * the UI designer.
- */
- //
- private void initUI() {
- this.form = new XdevGridLayout();
- this.comboBoxState = new XdevComboBox<>();
- this.lblOrder = new XdevLabel();
- this.cmbOrder = new XdevComboBox<>();
- this.lblOdlNumber = new XdevLabel();
- this.txtOdlNumber = new XdevTextField();
- this.lblItem = new XdevLabel();
- this.cmbItem = new XdevComboBox<>();
- this.lblVat = new XdevLabel();
- this.cmbVat = new XdevComboBox<>();
- this.lblOdlQuantity = new XdevLabel();
- this.txtOdlQuantity = new XdevTextField();
- this.lblOdlPrice = new XdevLabel();
- this.txtOdlPrice = new XdevTextField();
- this.lblOdlText = new XdevLabel();
- this.txtOdlText = new XdevTextField();
- this.lblCostAccount = new XdevLabel();
- this.cmbCostAccount = new XdevComboBox<>();
- this.lblOdlAmountBrut = new XdevLabel();
- this.txtOdlAmountBrut = new XdevTextField();
- this.lblOdlVatAmount = new XdevLabel();
- this.txtOdlVatAmount = new XdevTextField();
- this.lblOdlAmountNet = new XdevLabel();
- this.txtOdlAmountNet = new XdevTextField();
- this.lblOdlState = new XdevLabel();
- this.horizontalLayout = new XdevHorizontalLayout();
- this.cmdSave = new XdevButton();
- this.cmdCancel = new XdevButton();
- this.fieldGroup = new XdevFieldGroup<>(OrderLine.class);
-
- this.form.setIcon(FontAwesome.BOOK);
- this.form.setCaption("Auftragszeile erfassen");
- this.comboBoxState.setTabIndex(12);
- this.lblOrder.setValue(StringResourceUtils.optLocalizeString("{$lblOrder.value}", this));
- this.cmbOrder.setTabIndex(1);
- this.cmbOrder.setItemCaptionFromAnnotation(false);
- this.cmbOrder.setContainerDataSource(Order.class, DAOs.get(OrderDAO.class).findAll());
- this.cmbOrder.setItemCaptionPropertyId(Order_.ordNumber.getName());
- this.lblOdlNumber.setValue(StringResourceUtils.optLocalizeString("{$lblOdlNumber.value}", this));
- this.txtOdlNumber.setTabIndex(2);
- this.lblItem.setValue(StringResourceUtils.optLocalizeString("{$lblItem.value}", this));
- this.cmbItem.setTabIndex(3);
- this.cmbItem.setRequired(true);
- this.cmbItem.setItemCaptionFromAnnotation(false);
- this.cmbItem.setContainerDataSource(Item.class, DAOs.get(ItemDAO.class).findAll());
- this.cmbItem.setItemCaptionPropertyId("prpShortName");
- this.lblVat.setValue(StringResourceUtils.optLocalizeString("{$lblVat.value}", this));
- this.cmbVat.setTabIndex(4);
- this.cmbVat.setItemCaptionFromAnnotation(false);
- this.cmbVat.setContainerDataSource(Vat.class, DAOs.get(VatDAO.class).findAllActive());
- this.cmbVat.setItemCaptionPropertyId("fullName");
- this.lblOdlQuantity.setValue(StringResourceUtils.optLocalizeString("{$lblOdlQuantity.value}", this));
- this.txtOdlQuantity
- .setConverter(ConverterBuilder.stringToDouble().minimumFractionDigits(1).maximumFractionDigits(2).build());
- this.txtOdlQuantity.setTabIndex(5);
- this.lblOdlPrice.setValue(StringResourceUtils.optLocalizeString("{$lblOdlPrice.value}", this));
- this.txtOdlPrice
- .setConverter(ConverterBuilder.stringToDouble().minimumFractionDigits(2).maximumFractionDigits(2).build());
- this.txtOdlPrice.setTabIndex(6);
- this.lblOdlText.setValue(StringResourceUtils.optLocalizeString("{$lblOdlText.value}", this));
- this.txtOdlText.setTabIndex(7);
- this.txtOdlText
- .addValidator(new StringLengthValidator("Der Text darf maximal 80 Zeichen lang sein!", null, 80, true));
- this.lblCostAccount.setValue(StringResourceUtils.optLocalizeString("{$lblCostAccount.value}", this));
- this.cmbCostAccount.setTabIndex(8);
- this.cmbCostAccount.setRequired(true);
- this.cmbCostAccount.setItemCaptionFromAnnotation(false);
- this.cmbCostAccount.setContainerDataSource(CostAccount.class, DAOs.get(CostAccountDAO.class).findAll());
- this.cmbCostAccount.setItemCaptionPropertyId(CostAccount_.csaName.getName());
- this.lblOdlAmountBrut.setValue(StringResourceUtils.optLocalizeString("{$lblOdlAmountBrut.value}", this));
- this.txtOdlAmountBrut.setConverter(ConverterBuilder.stringToDouble().currency().build());
- this.txtOdlAmountBrut.setTabIndex(9);
- this.lblOdlVatAmount.setValue(StringResourceUtils.optLocalizeString("{$lblOdlVatAmount.value}", this));
- this.txtOdlVatAmount.setConverter(ConverterBuilder.stringToDouble().currency().build());
- this.txtOdlVatAmount.setTabIndex(11);
- this.lblOdlAmountNet.setValue(StringResourceUtils.optLocalizeString("{$lblOdlAmountNet.value}", this));
- this.txtOdlAmountNet.setConverter(ConverterBuilder.stringToDouble().currency().build());
- this.txtOdlAmountNet.setTabIndex(10);
- this.lblOdlState.setValue(StringResourceUtils.optLocalizeString("{$lblOdlState.value}", this));
- this.horizontalLayout.setMargin(new MarginInfo(true, false, false, false));
- this.cmdSave.setIcon(FontAwesome.SAVE);
- this.cmdSave.setCaption(StringResourceUtils.optLocalizeString("{$cmdSave.caption}", this));
- this.cmdSave.setTabIndex(13);
- this.cmdSave.setClickShortcut(ShortcutAction.KeyCode.ENTER);
- this.cmdCancel.setIcon(FontAwesome.CLOSE);
- this.cmdCancel.setCaption(StringResourceUtils.optLocalizeString("{$cmdReset.caption}", this));
- this.cmdCancel.setTabIndex(14);
- this.cmdCancel.setClickShortcut(ShortcutAction.KeyCode.ESCAPE);
- this.fieldGroup.bind(this.cmbOrder, OrderLine_.orderhdr.getName());
- this.fieldGroup.bind(this.txtOdlNumber, OrderLine_.odlNumber.getName());
- this.fieldGroup.bind(this.cmbItem, OrderLine_.item.getName());
- this.fieldGroup.bind(this.txtOdlQuantity, OrderLine_.odlQuantity.getName());
- this.fieldGroup.bind(this.cmbCostAccount, OrderLine_.costAccount.getName());
- this.fieldGroup.bind(this.txtOdlPrice, OrderLine_.odlPrice.getName());
- this.fieldGroup.bind(this.cmbVat, OrderLine_.vat.getName());
- this.fieldGroup.bind(this.txtOdlAmountBrut, OrderLine_.odlAmountBrut.getName());
- this.fieldGroup.bind(this.txtOdlAmountNet, OrderLine_.odlAmountNet.getName());
- this.fieldGroup.bind(this.txtOdlText, OrderLine_.odlText.getName());
- this.fieldGroup.bind(this.txtOdlVatAmount, OrderLine_.odlVatAmount.getName());
- this.fieldGroup.bind(this.comboBoxState, OrderLine_.odlState.getName());
-
- this.cmdSave.setSizeUndefined();
- this.horizontalLayout.addComponent(this.cmdSave);
- this.horizontalLayout.setComponentAlignment(this.cmdSave, Alignment.MIDDLE_CENTER);
- this.cmdCancel.setSizeUndefined();
- this.horizontalLayout.addComponent(this.cmdCancel);
- this.horizontalLayout.setComponentAlignment(this.cmdCancel, Alignment.MIDDLE_CENTER);
- final CustomComponent horizontalLayout_spacer = new CustomComponent();
- horizontalLayout_spacer.setSizeFull();
- this.horizontalLayout.addComponent(horizontalLayout_spacer);
- this.horizontalLayout.setExpandRatio(horizontalLayout_spacer, 1.0F);
- this.form.setColumns(4);
- this.form.setRows(11);
- this.comboBoxState.setSizeUndefined();
- this.form.addComponent(this.comboBoxState, 1, 8);
- this.lblOrder.setSizeUndefined();
- this.form.addComponent(this.lblOrder, 0, 0);
- this.cmbOrder.setWidth(100, Unit.PERCENTAGE);
- this.cmbOrder.setHeight(-1, Unit.PIXELS);
- this.form.addComponent(this.cmbOrder, 1, 0);
- this.lblOdlNumber.setSizeUndefined();
- this.form.addComponent(this.lblOdlNumber, 0, 1);
- this.txtOdlNumber.setSizeUndefined();
- this.form.addComponent(this.txtOdlNumber, 1, 1);
- this.lblItem.setSizeUndefined();
- this.form.addComponent(this.lblItem, 0, 2);
- this.cmbItem.setWidth(100, Unit.PERCENTAGE);
- this.cmbItem.setHeight(-1, Unit.PIXELS);
- this.form.addComponent(this.cmbItem, 1, 2);
- this.lblVat.setSizeUndefined();
- this.form.addComponent(this.lblVat, 2, 2);
- this.cmbVat.setWidth(100, Unit.PERCENTAGE);
- this.cmbVat.setHeight(-1, Unit.PIXELS);
- this.form.addComponent(this.cmbVat, 3, 2);
- this.lblOdlQuantity.setSizeUndefined();
- this.form.addComponent(this.lblOdlQuantity, 0, 3);
- this.txtOdlQuantity.setSizeUndefined();
- this.form.addComponent(this.txtOdlQuantity, 1, 3);
- this.lblOdlPrice.setSizeUndefined();
- this.form.addComponent(this.lblOdlPrice, 2, 3);
- this.txtOdlPrice.setSizeUndefined();
- this.form.addComponent(this.txtOdlPrice, 3, 3);
- this.lblOdlText.setSizeUndefined();
- this.form.addComponent(this.lblOdlText, 0, 4);
- this.txtOdlText.setWidth(100, Unit.PERCENTAGE);
- this.txtOdlText.setHeight(-1, Unit.PIXELS);
- this.form.addComponent(this.txtOdlText, 1, 4, 3, 4);
- this.lblCostAccount.setSizeUndefined();
- this.form.addComponent(this.lblCostAccount, 0, 5);
- this.cmbCostAccount.setWidth(100, Unit.PERCENTAGE);
- this.cmbCostAccount.setHeight(-1, Unit.PIXELS);
- this.form.addComponent(this.cmbCostAccount, 1, 5);
- this.lblOdlAmountBrut.setSizeUndefined();
- this.form.addComponent(this.lblOdlAmountBrut, 0, 6);
- this.txtOdlAmountBrut.setSizeUndefined();
- this.form.addComponent(this.txtOdlAmountBrut, 1, 6);
- this.lblOdlVatAmount.setSizeUndefined();
- this.form.addComponent(this.lblOdlVatAmount, 2, 6);
- this.txtOdlVatAmount.setSizeUndefined();
- this.form.addComponent(this.txtOdlVatAmount, 3, 6);
- this.lblOdlAmountNet.setSizeUndefined();
- this.form.addComponent(this.lblOdlAmountNet, 0, 7);
- this.txtOdlAmountNet.setSizeUndefined();
- this.form.addComponent(this.txtOdlAmountNet, 1, 7);
- this.lblOdlState.setSizeUndefined();
- this.form.addComponent(this.lblOdlState, 0, 8);
- this.horizontalLayout.setWidth(100, Unit.PERCENTAGE);
- this.horizontalLayout.setHeight(-1, Unit.PIXELS);
- this.form.addComponent(this.horizontalLayout, 0, 9, 2, 9);
- this.form.setComponentAlignment(this.horizontalLayout, Alignment.MIDDLE_CENTER);
- this.form.setColumnExpandRatio(1, 100.0F);
- this.form.setColumnExpandRatio(3, 100.0F);
- final CustomComponent form_vSpacer = new CustomComponent();
- form_vSpacer.setSizeFull();
- this.form.addComponent(form_vSpacer, 0, 10, 3, 10);
- this.form.setRowExpandRatio(10, 1.0F);
- this.form.setSizeFull();
- this.setContent(this.form);
- this.setWidth(860, Unit.PIXELS);
- this.setHeight(600, Unit.PIXELS);
-
- this.cmbItem.addValueChangeListener(event -> this.cmbItem_valueChange(event));
- this.cmbVat.addValueChangeListener(event -> this.cmbVat_valueChange(event));
- this.txtOdlQuantity.addValueChangeListener(event -> this.txtOdlQuantity_valueChange(event));
- this.txtOdlPrice.addValueChangeListener(event -> this.txtOdlPrice_valueChange(event));
- this.cmdSave.addClickListener(event -> this.cmdSave_buttonClick(event));
- this.cmdCancel.addClickListener(event -> this.cmdCancel_buttonClick(event));
- } //
-
- //
- private XdevComboBox- cmbItem;
- private XdevLabel lblOrder, lblOdlNumber, lblItem, lblVat, lblOdlQuantity, lblOdlPrice, lblOdlText, lblCostAccount,
- lblOdlAmountBrut, lblOdlVatAmount, lblOdlAmountNet, lblOdlState;
- private XdevButton cmdSave, cmdCancel;
- private XdevComboBox cmbCostAccount;
- private XdevComboBox cmbVat;
- private XdevHorizontalLayout horizontalLayout;
- private XdevComboBox> comboBoxState;
- private XdevGridLayout form;
- private XdevComboBox cmbOrder;
- private XdevTextField txtOdlNumber, txtOdlQuantity, txtOdlPrice, txtOdlText, txtOdlAmountBrut, txtOdlVatAmount,
- txtOdlAmountNet;
- private XdevFieldGroup fieldGroup;
- //
-
-}
+package ch.xwr.seicentobilling.ui.desktop;
+
+import java.util.List;
+
+import com.vaadin.data.Property;
+import com.vaadin.data.validator.StringLengthValidator;
+import com.vaadin.event.ShortcutAction;
+import com.vaadin.server.FontAwesome;
+import com.vaadin.shared.ui.MarginInfo;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.Notification;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.Window;
+import com.xdev.dal.DAOs;
+import com.xdev.res.StringResourceUtils;
+import com.xdev.ui.XdevButton;
+import com.xdev.ui.XdevFieldGroup;
+import com.xdev.ui.XdevGridLayout;
+import com.xdev.ui.XdevHorizontalLayout;
+import com.xdev.ui.XdevLabel;
+import com.xdev.ui.XdevTextField;
+import com.xdev.ui.XdevView;
+import com.xdev.ui.entitycomponent.combobox.XdevComboBox;
+import com.xdev.util.ConverterBuilder;
+
+import ch.xwr.seicentobilling.business.LovState;
+import ch.xwr.seicentobilling.business.OrderCalculator;
+import ch.xwr.seicentobilling.business.RowObjectManager;
+import ch.xwr.seicentobilling.business.Seicento;
+import ch.xwr.seicentobilling.business.helper.SeicentoCrud;
+import ch.xwr.seicentobilling.dal.CostAccountDAO;
+import ch.xwr.seicentobilling.dal.ItemDAO;
+import ch.xwr.seicentobilling.dal.OrderDAO;
+import ch.xwr.seicentobilling.dal.OrderLineDAO;
+import ch.xwr.seicentobilling.dal.VatDAO;
+import ch.xwr.seicentobilling.dal.VatLineDAO;
+import ch.xwr.seicentobilling.entities.CostAccount;
+import ch.xwr.seicentobilling.entities.CostAccount_;
+import ch.xwr.seicentobilling.entities.Item;
+import ch.xwr.seicentobilling.entities.Order;
+import ch.xwr.seicentobilling.entities.OrderLine;
+import ch.xwr.seicentobilling.entities.OrderLine_;
+import ch.xwr.seicentobilling.entities.Order_;
+import ch.xwr.seicentobilling.entities.Project;
+import ch.xwr.seicentobilling.entities.Vat;
+import ch.xwr.seicentobilling.entities.VatLine;
+
+public class OrderLinePopup extends XdevView {
+ OrderCalculator CALC = new OrderCalculator();
+
+ /**
+ *
+ */
+ public OrderLinePopup() {
+ super();
+ this.initUI();
+
+ this.setHeight(Seicento.calculateThemeHeight(this.getHeight(),UI.getCurrent().getTheme()));
+
+ // State
+ this.comboBoxState.addItems((Object[]) LovState.State.values());
+ // this.comboBoxWorktype.addItems((Object[])LovState.WorkType.values());
+
+ // get Parameter
+ final Long beanId = (Long) UI.getCurrent().getSession().getAttribute("beanId");
+ final Long objId = (Long) UI.getCurrent().getSession().getAttribute("objId");
+ OrderLine bean = null;
+ Order obj = null;
+
+ if (beanId == null) {
+ this.cmbItem.clear();
+ this.cmbItem.addItems(new ItemDAO().findAllActiveSortedByName());
+
+ this.cmbCostAccount.clear();
+ this.cmbCostAccount.addItems(new CostAccountDAO().findAllActive());
+ // new
+ final OrderDAO objDao = new OrderDAO();
+ obj = objDao.find(objId);
+
+ bean = new OrderLine();
+ bean.setOrderhdr(obj);
+ bean.setOdlState(LovState.State.active);
+ bean.setOdlQuantity(1);
+ bean.setOdlNumber(this.CALC.getNextLineNumber(obj));
+
+ } else {
+ final OrderLineDAO dao = new OrderLineDAO();
+ bean = dao.find(beanId.longValue());
+
+ this.cmbItem.clear();
+ this.cmbItem.addItems(new ItemDAO().findAllSortedByName());
+ //cmbItem.setData(dao);
+ this.cmbCostAccount.clear();
+ this.cmbCostAccount.addItems(new CostAccountDAO().findAllOrderByName());
+
+ }
+
+ setBeanGui(bean);
+ setROFields();
+ }
+
+ private void setROFields() {
+ this.txtOdlAmountBrut.setEnabled(false);
+ this.txtOdlAmountNet.setEnabled(false);
+ this.txtOdlVatAmount.setEnabled(false);
+ this.cmbOrder.setEnabled(false);
+
+ }
+
+ private void setBeanGui(final OrderLine bean) {
+ // set Bean + Fields
+ this.fieldGroup.setItemDataSource(bean);
+
+ // this.comboBoxObject.setEnabled(false);
+ // this.textFieldName.setEnabled(false);
+ // this.textFieldMime.setEnabled(false);
+ }
+
+ public static Window getPopupWindow() {
+ final Window win = new Window();
+ //win.setWidth("720");
+ //win.setHeight("540");
+ win.center();
+ win.setModal(true);
+ win.setContent(new OrderLinePopup());
+
+ return win;
+ }
+
+ /**
+ * Event handler delegate method for the {@link XdevButton}
+ * {@link #cmdCancel}.
+ *
+ * @see Button.ClickListener#buttonClick(Button.ClickEvent)
+ * @eventHandlerDelegate Do NOT delete, used by UI designer!
+ */
+ private void cmdCancel_buttonClick(final Button.ClickEvent event) {
+ UI.getCurrent().getSession().setAttribute(String.class, "cmdCancel");
+ this.fieldGroup.discard();
+ ((Window) this.getParent()).close();
+ }
+
+ /**
+ * Event handler delegate method for the {@link XdevButton}
+ * {@link #cmdSave}.
+ *
+ * @see Button.ClickListener#buttonClick(Button.ClickEvent)
+ * @eventHandlerDelegate Do NOT delete, used by UI designer!
+ */
+ private void cmdSave_buttonClick(final Button.ClickEvent event) {
+ UI.getCurrent().getSession().setAttribute(String.class, "cmdSave");
+
+ try {
+ if (!this.fieldGroup.isValid()){
+ SeicentoCrud.validateField(this.fieldGroup);
+ return;
+ }
+
+ if (SeicentoCrud.doSave(this.fieldGroup)) {
+ final RowObjectManager man = new RowObjectManager();
+ man.updateObject(this.fieldGroup.getItemDataSource().getBean().getOdlId(),
+ this.fieldGroup.getItemDataSource().getBean().getClass().getSimpleName());
+
+ ((Window) this.getParent()).close();
+ }
+
+
+ } catch (final Exception e) {
+ Notification.show("Fehler beim Speichern", e.getMessage(), Notification.Type.ERROR_MESSAGE);
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Event handler delegate method for the {@link XdevComboBox}
+ * {@link #cmbItem}.
+ *
+ * @see Property.ValueChangeListener#valueChange(Property.ValueChangeEvent)
+ * @eventHandlerDelegate Do NOT delete, used by UI designer!
+ */
+ private void cmbItem_valueChange(final Property.ValueChangeEvent event) {
+ if (!this.fieldGroup.isModified()) {
+ return;
+ }
+ // if (event.getProperty().)
+ final Item itm = (Item) event.getProperty().getValue();
+
+ final Project proj = this.fieldGroup.getItemDataSource().getBean().getOrderhdr().getProject();
+ if (itm.getItmPriceLevel() == LovState.itmPriceLevel.project && proj != null ) {
+ if (proj.getProRate() > 0) {
+ this.txtOdlPrice.setValue("" + proj.getProRate());
+ }
+ if (proj.getVat() != null) {
+ this.cmbVat.setValue(proj.getVat());
+ }
+ } else {
+ if (itm.getItmPrice1() != null) {
+ this.txtOdlPrice.setValue(itm.getItmPrice1().toString());
+ }
+ if (itm.getVat() != null) {
+ this.cmbVat.setValue(itm.getVat());
+ }
+ }
+ }
+
+ /**
+ * Event handler delegate method for the {@link XdevTextField}
+ * {@link #txtOdlQuantity}.
+ *
+ * @see Property.ValueChangeListener#valueChange(Property.ValueChangeEvent)
+ * @eventHandlerDelegate Do NOT delete, used by UI designer!
+ */
+ private void txtOdlQuantity_valueChange(final Property.ValueChangeEvent event) {
+ if (!this.fieldGroup.isModified()) {
+ return;
+ }
+
+ calculateItem();
+ }
+
+ private void calculateItem() {
+ this.CALC.commitFields(this.fieldGroup);
+ final OrderLine newodl = this.CALC.calculateLine(this.fieldGroup.getItemDataSource().getBean());
+
+ this.fieldGroup.setItemDataSource(newodl);
+ setROFields();
+
+ }
+
+ /**
+ * Event handler delegate method for the {@link XdevTextField}
+ * {@link #txtOdlPrice}.
+ *
+ * @see Property.ValueChangeListener#valueChange(Property.ValueChangeEvent)
+ * @eventHandlerDelegate Do NOT delete, used by UI designer!
+ */
+ private void txtOdlPrice_valueChange(final Property.ValueChangeEvent event) {
+ if (!this.fieldGroup.isModified()) {
+ return;
+ }
+
+ calculateItem();
+ }
+
+ /**
+ * Event handler delegate method for the {@link XdevComboBox}
+ * {@link #cmbVat}.
+ *
+ * @see Property.ValueChangeListener#valueChange(Property.ValueChangeEvent)
+ * @eventHandlerDelegate Do NOT delete, used by UI designer!
+ */
+ private void cmbVat_valueChange(final Property.ValueChangeEvent event) {
+ if (!this.fieldGroup.isModified()) {
+ return;
+ }
+
+ calculateItem();
+ fetchVatRate();
+ }
+
+ private void fetchVatRate() {
+ final OrderLine newodl = this.fieldGroup.getItemDataSource().getBean();
+
+ //TFS-240
+ final VatLineDAO dao = new VatLineDAO();
+ final List lst = dao.findByVatAndDate(newodl.getVat(), newodl.getOrderhdr().getOrdBillDate());
+ double rate = 0;
+ if (lst == null || lst.isEmpty()) {
+ rate = 0;
+ } else {
+ final VatLine vl = lst.get(0);
+ rate = vl.getVanRate().doubleValue();
+ }
+ this.lblVat.setValue("MwSt " + rate + "%");
+
+ }
+
+ /*
+ * WARNING: Do NOT edit!
The content of this method is always regenerated by
+ * the UI designer.
+ */
+ //
+ private void initUI() {
+ this.form = new XdevGridLayout();
+ this.comboBoxState = new XdevComboBox<>();
+ this.lblOrder = new XdevLabel();
+ this.cmbOrder = new XdevComboBox<>();
+ this.lblOdlNumber = new XdevLabel();
+ this.txtOdlNumber = new XdevTextField();
+ this.lblItem = new XdevLabel();
+ this.cmbItem = new XdevComboBox<>();
+ this.lblVat = new XdevLabel();
+ this.cmbVat = new XdevComboBox<>();
+ this.lblOdlQuantity = new XdevLabel();
+ this.txtOdlQuantity = new XdevTextField();
+ this.lblOdlPrice = new XdevLabel();
+ this.txtOdlPrice = new XdevTextField();
+ this.lblOdlText = new XdevLabel();
+ this.txtOdlText = new XdevTextField();
+ this.lblCostAccount = new XdevLabel();
+ this.cmbCostAccount = new XdevComboBox<>();
+ this.lblOdlAmountBrut = new XdevLabel();
+ this.txtOdlAmountBrut = new XdevTextField();
+ this.lblOdlVatAmount = new XdevLabel();
+ this.txtOdlVatAmount = new XdevTextField();
+ this.lblOdlAmountNet = new XdevLabel();
+ this.txtOdlAmountNet = new XdevTextField();
+ this.lblOdlState = new XdevLabel();
+ this.horizontalLayout = new XdevHorizontalLayout();
+ this.cmdSave = new XdevButton();
+ this.cmdCancel = new XdevButton();
+ this.fieldGroup = new XdevFieldGroup<>(OrderLine.class);
+
+ this.form.setIcon(FontAwesome.BOOK);
+ this.form.setCaption("Auftragszeile erfassen");
+ this.comboBoxState.setTabIndex(12);
+ this.lblOrder.setValue(StringResourceUtils.optLocalizeString("{$lblOrder.value}", this));
+ this.cmbOrder.setTabIndex(1);
+ this.cmbOrder.setItemCaptionFromAnnotation(false);
+ this.cmbOrder.setContainerDataSource(Order.class, DAOs.get(OrderDAO.class).findAll());
+ this.cmbOrder.setItemCaptionPropertyId(Order_.ordNumber.getName());
+ this.lblOdlNumber.setValue(StringResourceUtils.optLocalizeString("{$lblOdlNumber.value}", this));
+ this.txtOdlNumber.setTabIndex(2);
+ this.lblItem.setValue(StringResourceUtils.optLocalizeString("{$lblItem.value}", this));
+ this.cmbItem.setTabIndex(3);
+ this.cmbItem.setRequired(true);
+ this.cmbItem.setItemCaptionFromAnnotation(false);
+ this.cmbItem.setContainerDataSource(Item.class, false);
+ this.cmbItem.setItemCaptionPropertyId("prpShortName");
+ this.lblVat.setValue(StringResourceUtils.optLocalizeString("{$lblVat.value}", this));
+ this.cmbVat.setTabIndex(4);
+ this.cmbVat.setItemCaptionFromAnnotation(false);
+ this.cmbVat.setContainerDataSource(Vat.class, DAOs.get(VatDAO.class).findAllActive());
+ this.cmbVat.setItemCaptionPropertyId("fullName");
+ this.lblOdlQuantity.setValue(StringResourceUtils.optLocalizeString("{$lblOdlQuantity.value}", this));
+ this.txtOdlQuantity
+ .setConverter(ConverterBuilder.stringToDouble().minimumFractionDigits(1).maximumFractionDigits(2).build());
+ this.txtOdlQuantity.setTabIndex(5);
+ this.lblOdlPrice.setValue(StringResourceUtils.optLocalizeString("{$lblOdlPrice.value}", this));
+ this.txtOdlPrice
+ .setConverter(ConverterBuilder.stringToDouble().minimumFractionDigits(2).maximumFractionDigits(2).build());
+ this.txtOdlPrice.setTabIndex(6);
+ this.lblOdlText.setValue(StringResourceUtils.optLocalizeString("{$lblOdlText.value}", this));
+ this.txtOdlText.setTabIndex(7);
+ this.txtOdlText
+ .addValidator(new StringLengthValidator("Der Text darf maximal 80 Zeichen lang sein!", null, 80, true));
+ this.lblCostAccount.setValue(StringResourceUtils.optLocalizeString("{$lblCostAccount.value}", this));
+ this.cmbCostAccount.setTabIndex(8);
+ this.cmbCostAccount.setRequired(true);
+ this.cmbCostAccount.setItemCaptionFromAnnotation(false);
+ this.cmbCostAccount.setContainerDataSource(CostAccount.class, false);
+ this.cmbCostAccount.setItemCaptionPropertyId(CostAccount_.csaName.getName());
+ this.lblOdlAmountBrut.setValue(StringResourceUtils.optLocalizeString("{$lblOdlAmountBrut.value}", this));
+ this.txtOdlAmountBrut.setConverter(ConverterBuilder.stringToDouble().currency().build());
+ this.txtOdlAmountBrut.setTabIndex(9);
+ this.lblOdlVatAmount.setValue(StringResourceUtils.optLocalizeString("{$lblOdlVatAmount.value}", this));
+ this.txtOdlVatAmount.setConverter(ConverterBuilder.stringToDouble().currency().build());
+ this.txtOdlVatAmount.setTabIndex(11);
+ this.lblOdlAmountNet.setValue(StringResourceUtils.optLocalizeString("{$lblOdlAmountNet.value}", this));
+ this.txtOdlAmountNet.setConverter(ConverterBuilder.stringToDouble().currency().build());
+ this.txtOdlAmountNet.setTabIndex(10);
+ this.lblOdlState.setValue(StringResourceUtils.optLocalizeString("{$lblOdlState.value}", this));
+ this.horizontalLayout.setMargin(new MarginInfo(true, false, false, false));
+ this.cmdSave.setIcon(FontAwesome.SAVE);
+ this.cmdSave.setCaption(StringResourceUtils.optLocalizeString("{$cmdSave.caption}", this));
+ this.cmdSave.setTabIndex(13);
+ this.cmdSave.setClickShortcut(ShortcutAction.KeyCode.ENTER);
+ this.cmdCancel.setIcon(FontAwesome.CLOSE);
+ this.cmdCancel.setCaption(StringResourceUtils.optLocalizeString("{$cmdReset.caption}", this));
+ this.cmdCancel.setTabIndex(14);
+ this.cmdCancel.setClickShortcut(ShortcutAction.KeyCode.ESCAPE);
+ this.fieldGroup.bind(this.cmbOrder, OrderLine_.orderhdr.getName());
+ this.fieldGroup.bind(this.txtOdlNumber, OrderLine_.odlNumber.getName());
+ this.fieldGroup.bind(this.cmbItem, OrderLine_.item.getName());
+ this.fieldGroup.bind(this.txtOdlQuantity, OrderLine_.odlQuantity.getName());
+ this.fieldGroup.bind(this.cmbCostAccount, OrderLine_.costAccount.getName());
+ this.fieldGroup.bind(this.txtOdlPrice, OrderLine_.odlPrice.getName());
+ this.fieldGroup.bind(this.cmbVat, OrderLine_.vat.getName());
+ this.fieldGroup.bind(this.txtOdlAmountBrut, OrderLine_.odlAmountBrut.getName());
+ this.fieldGroup.bind(this.txtOdlAmountNet, OrderLine_.odlAmountNet.getName());
+ this.fieldGroup.bind(this.txtOdlText, OrderLine_.odlText.getName());
+ this.fieldGroup.bind(this.txtOdlVatAmount, OrderLine_.odlVatAmount.getName());
+ this.fieldGroup.bind(this.comboBoxState, OrderLine_.odlState.getName());
+
+ this.cmdSave.setSizeUndefined();
+ this.horizontalLayout.addComponent(this.cmdSave);
+ this.horizontalLayout.setComponentAlignment(this.cmdSave, Alignment.MIDDLE_CENTER);
+ this.cmdCancel.setSizeUndefined();
+ this.horizontalLayout.addComponent(this.cmdCancel);
+ this.horizontalLayout.setComponentAlignment(this.cmdCancel, Alignment.MIDDLE_CENTER);
+ final CustomComponent horizontalLayout_spacer = new CustomComponent();
+ horizontalLayout_spacer.setSizeFull();
+ this.horizontalLayout.addComponent(horizontalLayout_spacer);
+ this.horizontalLayout.setExpandRatio(horizontalLayout_spacer, 1.0F);
+ this.form.setColumns(4);
+ this.form.setRows(11);
+ this.comboBoxState.setSizeUndefined();
+ this.form.addComponent(this.comboBoxState, 1, 8);
+ this.lblOrder.setSizeUndefined();
+ this.form.addComponent(this.lblOrder, 0, 0);
+ this.cmbOrder.setWidth(100, Unit.PERCENTAGE);
+ this.cmbOrder.setHeight(-1, Unit.PIXELS);
+ this.form.addComponent(this.cmbOrder, 1, 0);
+ this.lblOdlNumber.setSizeUndefined();
+ this.form.addComponent(this.lblOdlNumber, 0, 1);
+ this.txtOdlNumber.setSizeUndefined();
+ this.form.addComponent(this.txtOdlNumber, 1, 1);
+ this.lblItem.setSizeUndefined();
+ this.form.addComponent(this.lblItem, 0, 2);
+ this.cmbItem.setWidth(100, Unit.PERCENTAGE);
+ this.cmbItem.setHeight(-1, Unit.PIXELS);
+ this.form.addComponent(this.cmbItem, 1, 2);
+ this.lblVat.setSizeUndefined();
+ this.form.addComponent(this.lblVat, 2, 2);
+ this.cmbVat.setWidth(100, Unit.PERCENTAGE);
+ this.cmbVat.setHeight(-1, Unit.PIXELS);
+ this.form.addComponent(this.cmbVat, 3, 2);
+ this.lblOdlQuantity.setSizeUndefined();
+ this.form.addComponent(this.lblOdlQuantity, 0, 3);
+ this.txtOdlQuantity.setSizeUndefined();
+ this.form.addComponent(this.txtOdlQuantity, 1, 3);
+ this.lblOdlPrice.setSizeUndefined();
+ this.form.addComponent(this.lblOdlPrice, 2, 3);
+ this.txtOdlPrice.setSizeUndefined();
+ this.form.addComponent(this.txtOdlPrice, 3, 3);
+ this.lblOdlText.setSizeUndefined();
+ this.form.addComponent(this.lblOdlText, 0, 4);
+ this.txtOdlText.setWidth(100, Unit.PERCENTAGE);
+ this.txtOdlText.setHeight(-1, Unit.PIXELS);
+ this.form.addComponent(this.txtOdlText, 1, 4, 3, 4);
+ this.lblCostAccount.setSizeUndefined();
+ this.form.addComponent(this.lblCostAccount, 0, 5);
+ this.cmbCostAccount.setWidth(100, Unit.PERCENTAGE);
+ this.cmbCostAccount.setHeight(-1, Unit.PIXELS);
+ this.form.addComponent(this.cmbCostAccount, 1, 5);
+ this.lblOdlAmountBrut.setSizeUndefined();
+ this.form.addComponent(this.lblOdlAmountBrut, 0, 6);
+ this.txtOdlAmountBrut.setSizeUndefined();
+ this.form.addComponent(this.txtOdlAmountBrut, 1, 6);
+ this.lblOdlVatAmount.setSizeUndefined();
+ this.form.addComponent(this.lblOdlVatAmount, 2, 6);
+ this.txtOdlVatAmount.setSizeUndefined();
+ this.form.addComponent(this.txtOdlVatAmount, 3, 6);
+ this.lblOdlAmountNet.setSizeUndefined();
+ this.form.addComponent(this.lblOdlAmountNet, 0, 7);
+ this.txtOdlAmountNet.setSizeUndefined();
+ this.form.addComponent(this.txtOdlAmountNet, 1, 7);
+ this.lblOdlState.setSizeUndefined();
+ this.form.addComponent(this.lblOdlState, 0, 8);
+ this.horizontalLayout.setWidth(100, Unit.PERCENTAGE);
+ this.horizontalLayout.setHeight(-1, Unit.PIXELS);
+ this.form.addComponent(this.horizontalLayout, 0, 9, 2, 9);
+ this.form.setComponentAlignment(this.horizontalLayout, Alignment.MIDDLE_CENTER);
+ this.form.setColumnExpandRatio(1, 100.0F);
+ this.form.setColumnExpandRatio(3, 100.0F);
+ final CustomComponent form_vSpacer = new CustomComponent();
+ form_vSpacer.setSizeFull();
+ this.form.addComponent(form_vSpacer, 0, 10, 3, 10);
+ this.form.setRowExpandRatio(10, 1.0F);
+ this.form.setSizeFull();
+ this.setContent(this.form);
+ this.setWidth(860, Unit.PIXELS);
+ this.setHeight(600, Unit.PIXELS);
+
+ this.cmbItem.addValueChangeListener(event -> this.cmbItem_valueChange(event));
+ this.cmbVat.addValueChangeListener(event -> this.cmbVat_valueChange(event));
+ this.txtOdlQuantity.addValueChangeListener(event -> this.txtOdlQuantity_valueChange(event));
+ this.txtOdlPrice.addValueChangeListener(event -> this.txtOdlPrice_valueChange(event));
+ this.cmdSave.addClickListener(event -> this.cmdSave_buttonClick(event));
+ this.cmdCancel.addClickListener(event -> this.cmdCancel_buttonClick(event));
+ } //
+
+ //
+ private XdevComboBox- cmbItem;
+ private XdevLabel lblOrder, lblOdlNumber, lblItem, lblVat, lblOdlQuantity, lblOdlPrice, lblOdlText, lblCostAccount,
+ lblOdlAmountBrut, lblOdlVatAmount, lblOdlAmountNet, lblOdlState;
+ private XdevButton cmdSave, cmdCancel;
+ private XdevComboBox cmbCostAccount;
+ private XdevComboBox cmbVat;
+ private XdevHorizontalLayout horizontalLayout;
+ private XdevComboBox> comboBoxState;
+ private XdevGridLayout form;
+ private XdevComboBox cmbOrder;
+ private XdevTextField txtOdlNumber, txtOdlQuantity, txtOdlPrice, txtOdlText, txtOdlAmountBrut, txtOdlVatAmount,
+ txtOdlAmountNet;
+ private XdevFieldGroup fieldGroup;
+ //
+
+}
diff --git a/src/ch/xwr/seicentobilling/ui/desktop/OrderLinePopup.ui.xml b/src/ch/xwr/seicentobilling/ui/desktop/OrderLinePopup.ui.xml
index feaadb3..e6541cd 100644
--- a/src/ch/xwr/seicentobilling/ui/desktop/OrderLinePopup.ui.xml
+++ b/src/ch/xwr/seicentobilling/ui/desktop/OrderLinePopup.ui.xml
@@ -1,171 +1,169 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- valueChange.valueChange
-
-
-
-
-
-
-
-
-
-
-
-
-
- valueChange.valueChange
-
-
-
-
-
-
-
- valueChange.valueChange
-
-
-
-
-
-
-
- valueChange.valueChange
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- click.buttonClick
-
-
-
- click.buttonClick
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ valueChange.valueChange
+
+
+
+
+
+
+
+
+
+
+
+
+
+ valueChange.valueChange
+
+
+
+
+
+
+
+ valueChange.valueChange
+
+
+
+
+
+
+
+ valueChange.valueChange
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ click.buttonClick
+
+
+
+ click.buttonClick
+
+
+
+
+
diff --git a/src/ch/xwr/seicentobilling/ui/desktop/OrderTabView.java b/src/ch/xwr/seicentobilling/ui/desktop/OrderTabView.java
index 4e5b455..92966dc 100644
--- a/src/ch/xwr/seicentobilling/ui/desktop/OrderTabView.java
+++ b/src/ch/xwr/seicentobilling/ui/desktop/OrderTabView.java
@@ -62,6 +62,7 @@
import ch.xwr.seicentobilling.dal.OrderDAO;
import ch.xwr.seicentobilling.dal.OrderLineDAO;
import ch.xwr.seicentobilling.dal.PaymentConditionDAO;
+import ch.xwr.seicentobilling.dal.ProjectDAO;
import ch.xwr.seicentobilling.entities.City_;
import ch.xwr.seicentobilling.entities.Customer;
import ch.xwr.seicentobilling.entities.Customer_;
@@ -74,6 +75,7 @@
import ch.xwr.seicentobilling.entities.Project;
import ch.xwr.seicentobilling.entities.Project_;
import ch.xwr.seicentobilling.ui.desktop.crm.CustomerLookupPopup;
+import ch.xwr.seicentobilling.ui.desktop.project.ProjectLookupPopup;
public class OrderTabView extends XdevView {
OrderCalculator CALC = new OrderCalculator();
@@ -147,6 +149,7 @@ private void setROFields() {
this.dateOrdPayDate.setEnabled(false);
this.dateOrdDueDate.setEnabled(false);
this.cmbCustomer.setEnabled(false);
+ this.cmbProject.setEnabled(false);
boolean hasData = true;
if (this.fieldGroup.getItemDataSource() == null) {
@@ -194,6 +197,7 @@ private void table_valueChange(final Property.ValueChangeEvent event) {
reloadTableLineList();
prepareCustomerCombo(bean2.getCustomer());
+ prepareProjectCombo(bean2.getProject());
setROFields();
}
@@ -510,13 +514,14 @@ private void cmdReload_buttonClick(final Button.ClickEvent event) {
// reassign filter
this.containerFilterComponent.setFilterData(fd);
- final Order bean = this.fieldGroup.getItemDataSource().getBean();
- if (bean != null) {
- //final boolean exi = this.table.containsId(bean);
- //final com.vaadin.data.Item x = this.table.getItem(bean);
- this.table.select(bean);
+ if (this.fieldGroup.getItemDataSource() != null) {
+ final Order bean = this.fieldGroup.getItemDataSource().getBean();
+ if (bean != null) {
+ //final boolean exi = this.table.containsId(bean);
+ //final com.vaadin.data.Item x = this.table.getItem(bean);
+ this.table.select(bean);
+ }
}
-
}
/**
@@ -602,7 +607,7 @@ private void cmbPaymentCondition_valueChange(final Property.ValueChangeEvent eve
if (!this.fieldGroup.isModified()) {
return;
}
- if (this.cmbPaymentCondition.getSelectedItem() != null) {
+ if (this.cmbPaymentCondition.getSelectedItem() != null && this.dateOrdDueDate.isEnabled()) {
// final PaymentCondition bean = (PaymentCondition)
// event.getProperty().getValue();
final PaymentCondition bean = this.cmbPaymentCondition.getSelectedItem().getBean();
@@ -610,6 +615,7 @@ private void cmbPaymentCondition_valueChange(final Property.ValueChangeEvent eve
final Calendar now = Calendar.getInstance(); // Gets the current date and time
now.setTime(this.dateOrdBillDate.getValue());
now.add(Calendar.DAY_OF_MONTH, bean.getPacNbrOfDays());
+
this.dateOrdDueDate.setValue(now.getTime());
}
@@ -953,6 +959,36 @@ public void windowClose(final CloseEvent e) {
}
+ private void popupProjectLookup() {
+ final Window win = ProjectLookupPopup.getPopupWindow();
+
+ final ProjectLookupPopup pop = (ProjectLookupPopup) win.getContent();
+ pop.setAllowNullSelection(true);
+
+ win.addCloseListener(new CloseListener() {
+ @Override
+ public void windowClose(final CloseEvent e) {
+ final Long beanId = (Long) UI.getCurrent().getSession().getAttribute("beanId");
+
+ if (beanId != null) {
+
+ if (beanId > 0) {
+ final Project bean = new ProjectDAO().find(beanId);
+ prepareProjectCombo(bean);
+ } else {
+ if (beanId < 0) {
+ prepareProjectCombo(null);
+ }
+ }
+ }
+
+ }
+
+ });
+ this.getUI().addWindow(win);
+
+ }
+
private void prepareCustomerCombo(final Customer bean) {
if (bean != null) {
this.fieldGroup.setReadOnly(false);
@@ -962,6 +998,18 @@ private void prepareCustomerCombo(final Customer bean) {
}
}
+ private void prepareProjectCombo(final Project bean) {
+ if (bean != null) {
+ this.fieldGroup.setReadOnly(false);
+
+ this.cmbProject.addItem(bean);
+ this.cmbProject.setValue(bean);
+ } else {
+ this.cmbProject.clear();
+ this.fieldGroup.getItemDataSource().getBean().setProject(null);
+ }
+ }
+
/**
* Event handler delegate method for the {@link XdevButton} {@link #btnSearch}.
*
@@ -972,6 +1020,17 @@ private void btnSearch_buttonClick(final Button.ClickEvent event) {
popupCustomerLookup();
}
+ /**
+ * Event handler delegate method for the {@link XdevButton}
+ * {@link #btnSearchProject}.
+ *
+ * @see Button.ClickListener#buttonClick(Button.ClickEvent)
+ * @eventHandlerDelegate Do NOT delete, used by UI designer!
+ */
+ private void btnSearchProject_buttonClick(final Button.ClickEvent event) {
+ popupProjectLookup();
+ }
+
/*
* WARNING: Do NOT edit!
The content of this method is always regenerated by
* the UI designer.
@@ -1008,10 +1067,12 @@ private void initUI() {
this.dateOrdOrderDate = new XdevPopupDateField();
this.lblOrdText = new XdevLabel();
this.textArea = new XdevTextArea();
- this.lblProject = new XdevLabel();
- this.cmbProject = new XdevComboBox<>();
this.lblPaymentCondition = new XdevLabel();
this.cmbPaymentCondition = new XdevComboBox<>();
+ this.lblProject = new XdevLabel();
+ this.horizontalLayoutPro = new XdevHorizontalLayout();
+ this.cmbProject = new XdevComboBox<>();
+ this.btnSearchProject = new XdevButton();
this.lblOrdAmountBrut = new XdevLabel();
this.txtOrdAmountBrut = new XdevTextField();
this.lblOrdAmountNet = new XdevLabel();
@@ -1126,15 +1187,20 @@ private void initUI() {
this.lblOrdText.setValue(StringResourceUtils.optLocalizeString("{$lblOrdText.value}", this));
this.textArea.setRows(2);
this.textArea.setMaxLength(256);
- this.lblProject.setValue(StringResourceUtils.optLocalizeString("{$lblProject.value}", this));
- this.cmbProject.setContainerDataSource(Project.class);
- this.cmbProject.setItemCaptionPropertyId(Project_.proName.getName());
this.lblPaymentCondition.setValue(StringResourceUtils.optLocalizeString("{$lblPaymentCondition.value}", this));
this.cmbPaymentCondition.setRequired(true);
this.cmbPaymentCondition.setItemCaptionFromAnnotation(false);
this.cmbPaymentCondition.setContainerDataSource(PaymentCondition.class,
DAOs.get(PaymentConditionDAO.class).findAllActive());
this.cmbPaymentCondition.setItemCaptionPropertyId(PaymentCondition_.pacName.getName());
+ this.lblProject.setValue(StringResourceUtils.optLocalizeString("{$lblProject.value}", this));
+ this.horizontalLayoutPro.setMargin(new MarginInfo(false));
+ this.cmbProject.setEnabled(false);
+ this.cmbProject.setContainerDataSource(Project.class, DAOs.get(ProjectDAO.class).findAll());
+ this.cmbProject.setItemCaptionPropertyId(Project_.proName.getName());
+ this.btnSearchProject.setIcon(FontAwesome.SEARCH);
+ this.btnSearchProject.setCaption("");
+ this.btnSearchProject.setDescription("Suchen...");
this.lblOrdAmountBrut.setValue(StringResourceUtils.optLocalizeString("{$lblOrdAmountBrut.value}", this));
this.txtOrdAmountBrut.setConverter(ConverterBuilder.stringToDouble().currency().build());
this.lblOrdAmountNet.setValue(StringResourceUtils.optLocalizeString("{$lblOrdAmountNet.value}", this));
@@ -1263,6 +1329,13 @@ private void initUI() {
this.btnSearch.setSizeUndefined();
this.horizontalLayoutCus.addComponent(this.btnSearch);
this.horizontalLayoutCus.setExpandRatio(this.btnSearch, 20.0F);
+ this.cmbProject.setWidth(100, Unit.PERCENTAGE);
+ this.cmbProject.setHeight(-1, Unit.PIXELS);
+ this.horizontalLayoutPro.addComponent(this.cmbProject);
+ this.horizontalLayoutPro.setExpandRatio(this.cmbProject, 40.0F);
+ this.btnSearchProject.setSizeUndefined();
+ this.horizontalLayoutPro.addComponent(this.btnSearchProject);
+ this.horizontalLayoutPro.setExpandRatio(this.btnSearchProject, 20.0F);
this.gridLayoutHdr.setColumns(4);
this.gridLayoutHdr.setRows(8);
this.lblOrdNumber.setSizeUndefined();
@@ -1287,16 +1360,16 @@ private void initUI() {
this.textArea.setWidth(100, Unit.PERCENTAGE);
this.textArea.setHeight(-1, Unit.PIXELS);
this.gridLayoutHdr.addComponent(this.textArea, 1, 3, 3, 3);
- this.lblProject.setSizeUndefined();
- this.gridLayoutHdr.addComponent(this.lblProject, 0, 4);
- this.cmbProject.setWidth(100, Unit.PERCENTAGE);
- this.cmbProject.setHeight(-1, Unit.PIXELS);
- this.gridLayoutHdr.addComponent(this.cmbProject, 1, 4);
this.lblPaymentCondition.setSizeUndefined();
- this.gridLayoutHdr.addComponent(this.lblPaymentCondition, 2, 4);
+ this.gridLayoutHdr.addComponent(this.lblPaymentCondition, 0, 4);
this.cmbPaymentCondition.setWidth(100, Unit.PERCENTAGE);
this.cmbPaymentCondition.setHeight(-1, Unit.PIXELS);
- this.gridLayoutHdr.addComponent(this.cmbPaymentCondition, 3, 4);
+ this.gridLayoutHdr.addComponent(this.cmbPaymentCondition, 1, 4);
+ this.lblProject.setSizeUndefined();
+ this.gridLayoutHdr.addComponent(this.lblProject, 2, 4);
+ this.horizontalLayoutPro.setWidth(100, Unit.PERCENTAGE);
+ this.horizontalLayoutPro.setHeight(-1, Unit.PIXELS);
+ this.gridLayoutHdr.addComponent(this.horizontalLayoutPro, 3, 4);
this.lblOrdAmountBrut.setSizeUndefined();
this.gridLayoutHdr.addComponent(this.lblOrdAmountBrut, 0, 5);
this.txtOrdAmountBrut.setSizeUndefined();
@@ -1309,7 +1382,7 @@ private void initUI() {
this.gridLayoutHdr.addComponent(this.lblOrdAmountVat, 0, 6);
this.txtOrdAmountVat.setSizeUndefined();
this.gridLayoutHdr.addComponent(this.txtOrdAmountVat, 1, 6);
- this.gridLayoutHdr.setColumnExpandRatio(1, 10.0F);
+ this.gridLayoutHdr.setColumnExpandRatio(1, 20.0F);
this.gridLayoutHdr.setColumnExpandRatio(3, 10.0F);
final CustomComponent gridLayoutHdr_vSpacer = new CustomComponent();
gridLayoutHdr_vSpacer.setSizeFull();
@@ -1418,6 +1491,7 @@ private void initUI() {
this.cmbCustomer.addValueChangeListener(event -> this.cmbCustomer_valueChange(event));
this.btnSearch.addClickListener(event -> this.btnSearch_buttonClick(event));
this.cmbPaymentCondition.addValueChangeListener(event -> this.cmbPaymentCondition_valueChange(event));
+ this.btnSearchProject.addClickListener(event -> this.btnSearchProject_buttonClick(event));
this.cmdNewLine.addClickListener(event -> this.cmdNewLine_buttonClick(event));
this.cmdDeleteLine.addClickListener(event -> this.cmdDeleteLine_buttonClick(event));
this.cmdReloadLine.addClickListener(event -> this.cmdReloadLine_buttonClick(event));
@@ -1430,20 +1504,21 @@ private void initUI() {
//
private XdevButton cmdNew, cmdDelete, cmdReload, cmdInfo, cmdCopy, cmdReport, cmdPdfReport, cmdAdmin, btnSearch,
- cmdNewLine, cmdDeleteLine, cmdReloadLine, cmdInfoLine, cmdEditLine, cmdSave, cmdReset;
- private XdevLabel lblOrdNumber, lblCustomer, lblOrdBillDate, lblOrdOrderDate, lblOrdText, lblProject,
- lblPaymentCondition, lblOrdAmountBrut, lblOrdAmountNet, lblOrdAmountVat, lblOrdCreated, lblOrdPayDate,
- lblOrdDueDate, lblOrdBookedOn, lblOrdState;
+ btnSearchProject, cmdNewLine, cmdDeleteLine, cmdReloadLine, cmdInfoLine, cmdEditLine, cmdSave, cmdReset;
+ private XdevLabel lblOrdCreated, lblOrdPayDate, lblOrdDueDate, lblOrdBookedOn, lblOrdState, lblOrdNumber, lblCustomer,
+ lblOrdBillDate, lblOrdOrderDate, lblOrdText, lblPaymentCondition, lblProject, lblOrdAmountBrut, lblOrdAmountNet,
+ lblOrdAmountVat;
private XdevComboBox cmbPaymentCondition;
private XdevTabSheet tabSheet;
- private XdevGridLayout form, gridLayoutHdr, gridLayoutDetails;
+ private XdevGridLayout form, gridLayoutDetails, gridLayoutHdr;
private XdevComboBox cmbProject;
private XdevHorizontalSplitPanel horizontalSplitPanel;
private XdevContainerFilterComponent containerFilterComponent;
- private XdevHorizontalLayout actionLayout, horizontalLayoutCus, horizontalLayoutAction, horizontalLayout;
+ private XdevHorizontalLayout actionLayout, horizontalLayoutCus, horizontalLayoutPro, horizontalLayoutAction,
+ horizontalLayout;
private XdevVerticalSplitPanel verticalSplitPanel;
- private XdevPopupDateField dateOrdBillDate, dateOrdOrderDate, dateOrdCreated, dateOrdPayDate, dateOrdDueDate,
- dateOrdBookedOn;
+ private XdevPopupDateField dateOrdCreated, dateOrdPayDate, dateOrdDueDate, dateOrdBookedOn, dateOrdBillDate,
+ dateOrdOrderDate;
private XdevTextArea textArea;
private XdevTable tableLine;
private XdevComboBox> comboBoxState;
diff --git a/src/ch/xwr/seicentobilling/ui/desktop/OrderTabView.ui.xml b/src/ch/xwr/seicentobilling/ui/desktop/OrderTabView.ui.xml
index 648aad6..02f8a34 100644
--- a/src/ch/xwr/seicentobilling/ui/desktop/OrderTabView.ui.xml
+++ b/src/ch/xwr/seicentobilling/ui/desktop/OrderTabView.ui.xml
@@ -127,13 +127,13 @@
-
+
-
+
@@ -154,7 +154,7 @@
-
+
@@ -166,25 +166,13 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
@@ -194,12 +182,32 @@
valueChange.valueChange
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ click.buttonClick
+
+
-
+
@@ -213,7 +221,7 @@
-
+
diff --git a/src/ch/xwr/seicentobilling/ui/desktop/ProjectTabView.java b/src/ch/xwr/seicentobilling/ui/desktop/ProjectTabView.java
index f604271..99fb8a1 100644
--- a/src/ch/xwr/seicentobilling/ui/desktop/ProjectTabView.java
+++ b/src/ch/xwr/seicentobilling/ui/desktop/ProjectTabView.java
@@ -51,6 +51,7 @@
import com.xdev.ui.XdevVerticalLayout;
import com.xdev.ui.XdevVerticalSplitPanel;
import com.xdev.ui.XdevView;
+import com.xdev.ui.entitycomponent.XdevBeanContainer;
import com.xdev.ui.entitycomponent.combobox.XdevComboBox;
import com.xdev.ui.entitycomponent.table.XdevTable;
import com.xdev.ui.filter.FilterData;
@@ -72,6 +73,7 @@
import ch.xwr.seicentobilling.dal.CostAccountDAO;
import ch.xwr.seicentobilling.dal.CustomerDAO;
import ch.xwr.seicentobilling.dal.OrderDAO;
+import ch.xwr.seicentobilling.dal.ProjectAllocationDAO;
import ch.xwr.seicentobilling.dal.ProjectDAO;
import ch.xwr.seicentobilling.dal.VatDAO;
import ch.xwr.seicentobilling.entities.Address;
@@ -81,9 +83,12 @@
import ch.xwr.seicentobilling.entities.Order;
import ch.xwr.seicentobilling.entities.Order_;
import ch.xwr.seicentobilling.entities.Project;
+import ch.xwr.seicentobilling.entities.ProjectAllocation;
+import ch.xwr.seicentobilling.entities.ProjectAllocation_;
import ch.xwr.seicentobilling.entities.Project_;
import ch.xwr.seicentobilling.entities.Vat;
import ch.xwr.seicentobilling.ui.desktop.crm.CustomerLookupPopup;
+import ch.xwr.seicentobilling.ui.desktop.project.ProjectAllocationPopup;
public class ProjectTabView extends XdevView {
/** Logger initialized */
@@ -106,6 +111,7 @@ public ProjectTabView() {
this.cbxState.addItems((Object[]) LovState.State.values());
this.cbxProModel.addItems((Object[]) LovState.ProModel.values());
this.cbxProState.addItems((Object[]) LovState.ProState.values());
+ this.cbxProOrderStrategy.addItems((Object[]) LovState.ProOrderStrategy.values());
// sort Table
final Object[] properties = { "proStartDate", "proEndDate" };
@@ -117,17 +123,21 @@ public ProjectTabView() {
// set RO Fields
setROFields();
- setDefaultFilter();
- checkAutoLoad();
+ if (checkAutoLoad()) {
+
+ } else {
+ setDefaultFilter();
+ }
}
- private void checkAutoLoad() {
+ private boolean checkAutoLoad() {
final String proName = (String) UI.getCurrent().getSession().getAttribute("proName");
Long proId = new Long(0);
try {
proId = Long.parseLong((String) UI.getCurrent().getSession().getAttribute("proId"));
} catch (final Exception ignore) {
}
+
UI.getCurrent().getSession().setAttribute("proName", "");
UI.getCurrent().getSession().setAttribute("proId", "");
@@ -146,11 +156,16 @@ private void checkAutoLoad() {
}
if (pro != null) {
+ this.table.removeAllItems();
+ this.table.addItem(pro);
+
if (this.table.containsId(pro)) {
this.table.select(pro);
}
this.fieldGroup.setItemDataSource(pro);
+ return true;
}
+ return false;
}
private void setVatDefault() {
@@ -423,6 +438,9 @@ private void displayChildTables(final Project npro) {
this.tableProject.removeAllItems();
this.tableProject.addItems(new ProjectDAO().findAllChildren(npro.getProId()));
+ this.tableProjectAllocation.clear();
+ this.tableProjectAllocation.removeAllItems();
+ this.tableProjectAllocation.addItems(new ProjectAllocationDAO().findByProject(npro));
}
}
@@ -627,7 +645,7 @@ private void calculateTargetHours() {
}
this.txtProHours.setValue("" + ihours);
- System.out.println("set hours: " + ihours);
+ //System.out.println("set hours: " + ihours);
}
}
@@ -665,12 +683,26 @@ public LocalDate convertToLocalDateViaInstant(final Date dateToConvert) {
* @eventHandlerDelegate Do NOT delete, used by UI designer!
*/
private void dateProEndDate_valueChange(final Property.ValueChangeEvent event) {
+ validateDateFromTo();
+
if (this.dateProEndDate.isModified()) {
calculateTargetHours();
}
}
+ private void validateDateFromTo() {
+ final Date dateFrom = this.dateProStartDate.getValue();
+ final Date dateTo = this.dateProEndDate.getValue();
+
+ if (dateTo != null) {
+ if (dateFrom != null && dateTo.before(dateFrom)) {
+ this.dateProEndDate.setValue(dateFrom);
+ }
+ }
+
+ }
+
/**
* Event handler delegate method for the {@link XdevTextField}
* {@link #txtProIntensityPercent}.
@@ -684,6 +716,186 @@ private void txtProIntensityPercent_valueChange(final Property.ValueChangeEvent
}
}
+ /**
+ * Event handler delegate method for the {@link XdevButton}
+ * {@link #cmdInfoAddress}.
+ *
+ * @see Button.ClickListener#buttonClick(Button.ClickEvent)
+ * @eventHandlerDelegate Do NOT delete, used by UI designer!
+ */
+ private void cmdInfoAddress_buttonClick(final Button.ClickEvent event) {
+ final ProjectAllocation bean = this.tableProjectAllocation.getSelectedItem().getBean();
+
+ final Window win = RowObjectView.getPopupWindow();
+
+ // UI.getCurrent().getSession().setAttribute(String.class,
+ // bean.getClass().getSimpleName());
+ win.setContent(new RowObjectView(bean.getPraId(), bean.getClass().getSimpleName()));
+ this.getUI().addWindow(win);
+
+ }
+
+ /**
+ * Event handler delegate method for the {@link XdevButton}
+ * {@link #cmdReloadAddress}.
+ *
+ * @see Button.ClickListener#buttonClick(Button.ClickEvent)
+ * @eventHandlerDelegate Do NOT delete, used by UI designer!
+ */
+ private void cmdReloadAddress_buttonClick(final Button.ClickEvent event) {
+ this.tableProjectAllocation.refreshRowCache();
+ this.tableProjectAllocation.getBeanContainerDataSource().refresh();
+ this.tableProjectAllocation.sort();
+
+ }
+
+ /**
+ * Event handler delegate method for the {@link XdevButton}
+ * {@link #cmdDeleteAddress}.
+ *
+ * @see Button.ClickListener#buttonClick(Button.ClickEvent)
+ * @eventHandlerDelegate Do NOT delete, used by UI designer!
+ */
+ private void cmdDeleteAddress_buttonClick(final Button.ClickEvent event) {
+ if (this.tableProjectAllocation.getSelectedItem() == null) {
+ Notification.show("Datensatz löschen", "Es wurde keine Zeile selektiert in der Tabelle",
+ Notification.Type.WARNING_MESSAGE);
+ return;
+ }
+
+ ConfirmDialog.show(getUI(), "Datensatz löschen", "Wirklich löschen?", new CloseListener() {
+ @Override
+ public void windowClose(final CloseEvent e) {
+ String retval = UI.getCurrent().getSession().getAttribute(String.class);
+ if (retval == null) {
+ retval = "cmdCancel";
+ }
+
+ if (retval.equals("cmdOk")) {
+ doDelete();
+ }
+ }
+
+ private void doDelete() {
+ final ProjectAllocation bean = ProjectTabView.this.tableProjectAllocation.getSelectedItem().getBean();
+ // Delete Record
+ final RowObjectManager man = new RowObjectManager();
+ man.deleteObject(bean.getPraId(), bean.getClass().getSimpleName());
+
+ final ProjectAllocationDAO dao = new ProjectAllocationDAO();
+ dao.remove(bean);
+ //ProjectTabView.this.fieldGroup.getItemDataSource().getBean().getProjectAllocations().remove(bean); //Works on Customer/Address??
+ ProjectTabView.this.tableProjectAllocation.removeItem(bean);
+
+ try {
+ ProjectTabView.this.tableProjectAllocation
+ .select(ProjectTabView.this.tableProjectAllocation.getCurrentPageFirstItemId());
+ } catch (final Exception e) {
+ // ignore
+ // CustomerTabView.this.fieldGroupActivity.setItemDataSource(new Activity());
+ }
+ Notification.show("Datensatz löschen", "Datensatz wurde gelöscht!",
+ Notification.Type.TRAY_NOTIFICATION);
+ }
+
+ });
+
+ }
+
+ /**
+ * Event handler delegate method for the {@link XdevButton}
+ * {@link #cmdNewAddress}.
+ *
+ * @see Button.ClickListener#buttonClick(Button.ClickEvent)
+ * @eventHandlerDelegate Do NOT delete, used by UI designer!
+ */
+ private void cmdNewAddress_buttonClick(final Button.ClickEvent event) {
+ final Long beanId = null;
+ final Long objId = getCurrentRecord();
+ if (objId < 0) {
+ return;
+ }
+
+ UI.getCurrent().getSession().setAttribute("beanId", beanId);
+ UI.getCurrent().getSession().setAttribute("objId", objId);
+
+ popupProjectAllocation();
+
+ }
+
+ private void popupProjectAllocation() {
+ final Window win = ProjectAllocationPopup.getPopupWindow(); //ProjectAllocationPopup
+
+ win.addCloseListener(new CloseListener() {
+ @Override
+ public void windowClose(final CloseEvent e) {
+ reloadProjectAllocationList();
+ }
+
+ });
+ this.getUI().addWindow(win);
+
+
+ }
+
+ private void reloadProjectAllocationList() {
+ Project bean = null;
+ if (this.table.getSelectedItem() != null) {
+ bean = this.table.getSelectedItem().getBean();
+ }
+
+ final XdevBeanContainer myCustomerList = this.tableProjectAllocation.getBeanContainerDataSource();
+ myCustomerList.removeAll();
+ myCustomerList.addAll(new ProjectAllocationDAO().findByProject(bean));
+
+ if (bean != null) {
+ this.tableProjectAllocation.refreshRowCache();
+ this.tableProjectAllocation.getBeanContainerDataSource().refresh();
+ }
+
+ }
+
+ private Long getCurrentRecord() {
+ if (this.fieldGroup.getItemDataSource().getBean() != null) {
+ return this.fieldGroup.getItemDataSource().getBean().getProId();
+ }
+ return new Long(-1);
+ }
+
+
+ /**
+ * Event handler delegate method for the {@link XdevButton}
+ * {@link #cmdEditAddress}.
+ *
+ * @see Button.ClickListener#buttonClick(Button.ClickEvent)
+ * @eventHandlerDelegate Do NOT delete, used by UI designer!
+ */
+ private void cmdEditAddress_buttonClick(final Button.ClickEvent event) {
+ if (this.tableProjectAllocation.getSelectedItem() == null) {
+ return;
+ }
+
+ final Long beanId = this.tableProjectAllocation.getSelectedItem().getBean().getPraId();
+ final Long objId = null;
+
+ UI.getCurrent().getSession().setAttribute("beanId", beanId);
+ UI.getCurrent().getSession().setAttribute("objId", objId);
+
+ popupProjectAllocation();
+
+ }
+
+ /**
+ * Event handler delegate method for the {@link XdevPopupDateField}
+ * {@link #dateProStartDate}.
+ *
+ * @see Property.ValueChangeListener#valueChange(Property.ValueChangeEvent)
+ * @eventHandlerDelegate Do NOT delete, used by UI designer!
+ */
+ private void dateProStartDate_valueChange(final Property.ValueChangeEvent event) {
+ validateDateFromTo();
+ }
+
/*
* WARNING: Do NOT edit!
The content of this method is always regenerated by
* the UI designer.
@@ -739,6 +951,8 @@ private void initUI() {
this.lblProModel = new XdevLabel();
this.cbxProModel = new XdevComboBox<>();
this.cbxInternal = new XdevCheckBox();
+ this.lblProOrderStrategy = new XdevLabel();
+ this.cbxProOrderStrategy = new XdevComboBox<>();
this.lblProject = new XdevLabel();
this.cmbProject = new XdevComboBox<>();
this.lblProDescription = new XdevLabel();
@@ -749,6 +963,15 @@ private void initUI() {
this.cbxProState = new XdevComboBox<>();
this.lblProLastBill = new XdevLabel();
this.dateProLastBill = new XdevPopupDateField();
+ this.gridLayoutRess = new XdevGridLayout();
+ this.verticalLayoutRess = new XdevVerticalLayout();
+ this.horizontalLayoutRess = new XdevHorizontalLayout();
+ this.cmdNewAddress = new XdevButton();
+ this.cmdDeleteAddress = new XdevButton();
+ this.cmdEditAddress = new XdevButton();
+ this.cmdReloadAddress = new XdevButton();
+ this.cmdInfoAddress = new XdevButton();
+ this.tableProjectAllocation = new XdevTable<>();
this.gridLayoutRef = new XdevGridLayout();
this.verticalSplitPanel = new XdevVerticalSplitPanel();
this.verticalLayoutBill = new XdevVerticalLayout();
@@ -872,6 +1095,8 @@ private void initUI() {
this.lblProState.setValue(StringResourceUtils.optLocalizeString("{$lblProState.value}", this));
this.lblProModel.setValue(StringResourceUtils.optLocalizeString("{$lblProModel.value}", this));
this.cbxInternal.setCaption("Internes Projekt");
+ this.lblProOrderStrategy.setValue("Rechnungsstrategie");
+ this.cbxProOrderStrategy.setRequired(true);
this.lblProject.setValue(StringResourceUtils.optLocalizeString("{$lblProject.value}", this));
this.cmbProject.setContainerDataSource(Project.class, DAOs.get(ProjectDAO.class).findAllActive());
this.cmbProject.setItemCaptionPropertyId(Project_.proName.getName());
@@ -881,6 +1106,34 @@ private void initUI() {
this.textAreaRem.setRows(2);
this.lblProProjectState.setValue(StringResourceUtils.optLocalizeString("{$lblProProjectState.value}", this));
this.lblProLastBill.setValue(StringResourceUtils.optLocalizeString("{$lblProLastBill.value}", this));
+ this.gridLayoutRess.setMargin(new MarginInfo(false));
+ this.verticalLayoutRess.setMargin(new MarginInfo(false));
+ this.horizontalLayoutRess.setSpacing(false);
+ this.horizontalLayoutRess.setMargin(new MarginInfo(false));
+ this.cmdNewAddress.setIcon(FontAwesome.PLUS_CIRCLE);
+ this.cmdNewAddress.setDescription(StringResourceUtils.optLocalizeString("{$cmdNew.description}", this));
+ this.cmdDeleteAddress.setIcon(FontAwesome.MINUS_CIRCLE);
+ this.cmdEditAddress.setIcon(FontAwesome.PENCIL);
+ this.cmdReloadAddress.setIcon(FontAwesome.REFRESH);
+ this.cmdInfoAddress.setIcon(FontAwesome.INFO_CIRCLE);
+ this.tableProjectAllocation.setColumnReorderingAllowed(true);
+ this.tableProjectAllocation.setCaption("Projekt Ressourcen");
+ this.tableProjectAllocation.setColumnCollapsingAllowed(true);
+ this.tableProjectAllocation.setContainerDataSource(ProjectAllocation.class, false);
+ this.tableProjectAllocation.setVisibleColumns(ProjectAllocation_.costAccount.getName(),
+ ProjectAllocation_.praStartDate.getName(), ProjectAllocation_.praEndDate.getName(),
+ ProjectAllocation_.praHours.getName(), ProjectAllocation_.praIntensityPercent.getName(),
+ ProjectAllocation_.praRate.getName(), ProjectAllocation_.praRemark.getName(),
+ ProjectAllocation_.praState.getName());
+ this.tableProjectAllocation.setConverter("praStartDate", ConverterBuilder.stringToDate().dateOnly().build());
+ this.tableProjectAllocation.setConverter("praEndDate", ConverterBuilder.stringToDate().dateOnly().build());
+ this.tableProjectAllocation.setColumnAlignment("praHours", Table.Align.RIGHT);
+ this.tableProjectAllocation.setConverter("praHours", ConverterBuilder.stringToDouble().build());
+ this.tableProjectAllocation.setColumnAlignment("praIntensityPercent", Table.Align.RIGHT);
+ this.tableProjectAllocation.setConverter("praIntensityPercent", ConverterBuilder.stringToDouble().build());
+ this.tableProjectAllocation.setColumnAlignment("praRate", Table.Align.RIGHT);
+ this.tableProjectAllocation.setConverter("praRate", ConverterBuilder.stringToDouble().currency().build());
+ this.tableProjectAllocation.setColumnCollapsed("praState", true);
this.gridLayoutRef.setMargin(new MarginInfo(false));
this.verticalSplitPanel.setStyleName("large");
this.verticalSplitPanel.setSplitPosition(60.0F, Unit.PERCENTAGE);
@@ -936,6 +1189,7 @@ private void initUI() {
this.fieldGroup.bind(this.txtProContact, Project_.proContact.getName());
this.fieldGroup.bind(this.cmbBillingAddress, Project_.address.getName());
this.fieldGroup.bind(this.cbxInternal, Project_.internal.getName());
+ this.fieldGroup.bind(this.cbxProOrderStrategy, Project_.proOrdergenerationStrategy.getName());
this.containerFilterComponent.setContainer(this.table.getBeanContainerDataSource(), "proName", "costAccount",
"customer", "proStartDate", "proEndDate", "vat", "proProjectState", "proModel", "proState");
@@ -1057,43 +1311,83 @@ private void initUI() {
this.gridLayout.addComponent(gridLayout_vSpacer, 0, 10, 3, 10);
this.gridLayout.setRowExpandRatio(10, 1.0F);
this.gridLayoutDesc.setColumns(3);
- this.gridLayoutDesc.setRows(7);
+ this.gridLayoutDesc.setRows(8);
this.lblProModel.setSizeUndefined();
this.gridLayoutDesc.addComponent(this.lblProModel, 0, 0);
this.cbxProModel.setSizeUndefined();
this.gridLayoutDesc.addComponent(this.cbxProModel, 1, 0);
this.cbxInternal.setSizeUndefined();
this.gridLayoutDesc.addComponent(this.cbxInternal, 2, 0);
+ this.lblProOrderStrategy.setSizeUndefined();
+ this.gridLayoutDesc.addComponent(this.lblProOrderStrategy, 0, 1);
+ this.cbxProOrderStrategy.setSizeUndefined();
+ this.gridLayoutDesc.addComponent(this.cbxProOrderStrategy, 1, 1);
this.lblProject.setSizeUndefined();
- this.gridLayoutDesc.addComponent(this.lblProject, 0, 1);
+ this.gridLayoutDesc.addComponent(this.lblProject, 0, 2);
this.cmbProject.setWidth(100, Unit.PERCENTAGE);
this.cmbProject.setHeight(-1, Unit.PIXELS);
- this.gridLayoutDesc.addComponent(this.cmbProject, 1, 1, 2, 1);
+ this.gridLayoutDesc.addComponent(this.cmbProject, 1, 2, 2, 2);
this.lblProDescription.setSizeUndefined();
- this.gridLayoutDesc.addComponent(this.lblProDescription, 0, 2);
+ this.gridLayoutDesc.addComponent(this.lblProDescription, 0, 3);
this.textArea.setWidth(100, Unit.PERCENTAGE);
this.textArea.setHeight(-1, Unit.PIXELS);
- this.gridLayoutDesc.addComponent(this.textArea, 1, 2, 2, 2);
+ this.gridLayoutDesc.addComponent(this.textArea, 1, 3, 2, 3);
this.lblProRemark.setSizeUndefined();
- this.gridLayoutDesc.addComponent(this.lblProRemark, 0, 3);
+ this.gridLayoutDesc.addComponent(this.lblProRemark, 0, 4);
this.textAreaRem.setWidth(100, Unit.PERCENTAGE);
this.textAreaRem.setHeight(-1, Unit.PIXELS);
- this.gridLayoutDesc.addComponent(this.textAreaRem, 1, 3, 2, 3);
+ this.gridLayoutDesc.addComponent(this.textAreaRem, 1, 4, 2, 4);
this.lblProProjectState.setSizeUndefined();
- this.gridLayoutDesc.addComponent(this.lblProProjectState, 0, 4);
+ this.gridLayoutDesc.addComponent(this.lblProProjectState, 0, 5);
this.cbxProState.setSizeUndefined();
- this.gridLayoutDesc.addComponent(this.cbxProState, 1, 4);
+ this.gridLayoutDesc.addComponent(this.cbxProState, 1, 5);
this.lblProLastBill.setSizeUndefined();
- this.gridLayoutDesc.addComponent(this.lblProLastBill, 0, 5);
+ this.gridLayoutDesc.addComponent(this.lblProLastBill, 0, 6);
this.dateProLastBill.setWidth(100, Unit.PERCENTAGE);
this.dateProLastBill.setHeight(-1, Unit.PIXELS);
- this.gridLayoutDesc.addComponent(this.dateProLastBill, 1, 5);
+ this.gridLayoutDesc.addComponent(this.dateProLastBill, 1, 6);
this.gridLayoutDesc.setColumnExpandRatio(1, 100.0F);
this.gridLayoutDesc.setColumnExpandRatio(2, 100.0F);
final CustomComponent gridLayoutDesc_vSpacer = new CustomComponent();
gridLayoutDesc_vSpacer.setSizeFull();
- this.gridLayoutDesc.addComponent(gridLayoutDesc_vSpacer, 0, 6, 2, 6);
- this.gridLayoutDesc.setRowExpandRatio(6, 1.0F);
+ this.gridLayoutDesc.addComponent(gridLayoutDesc_vSpacer, 0, 7, 2, 7);
+ this.gridLayoutDesc.setRowExpandRatio(7, 1.0F);
+ this.cmdNewAddress.setSizeUndefined();
+ this.horizontalLayoutRess.addComponent(this.cmdNewAddress);
+ this.horizontalLayoutRess.setComponentAlignment(this.cmdNewAddress, Alignment.MIDDLE_CENTER);
+ this.cmdDeleteAddress.setSizeUndefined();
+ this.horizontalLayoutRess.addComponent(this.cmdDeleteAddress);
+ this.horizontalLayoutRess.setComponentAlignment(this.cmdDeleteAddress, Alignment.MIDDLE_CENTER);
+ this.cmdEditAddress.setSizeUndefined();
+ this.horizontalLayoutRess.addComponent(this.cmdEditAddress);
+ this.horizontalLayoutRess.setComponentAlignment(this.cmdEditAddress, Alignment.MIDDLE_CENTER);
+ this.cmdReloadAddress.setSizeUndefined();
+ this.horizontalLayoutRess.addComponent(this.cmdReloadAddress);
+ this.horizontalLayoutRess.setComponentAlignment(this.cmdReloadAddress, Alignment.MIDDLE_CENTER);
+ this.cmdInfoAddress.setSizeUndefined();
+ this.horizontalLayoutRess.addComponent(this.cmdInfoAddress);
+ this.horizontalLayoutRess.setComponentAlignment(this.cmdInfoAddress, Alignment.MIDDLE_CENTER);
+ final CustomComponent horizontalLayoutRess_spacer = new CustomComponent();
+ horizontalLayoutRess_spacer.setSizeFull();
+ this.horizontalLayoutRess.addComponent(horizontalLayoutRess_spacer);
+ this.horizontalLayoutRess.setExpandRatio(horizontalLayoutRess_spacer, 1.0F);
+ this.horizontalLayoutRess.setWidth(100, Unit.PERCENTAGE);
+ this.horizontalLayoutRess.setHeight(-1, Unit.PIXELS);
+ this.verticalLayoutRess.addComponent(this.horizontalLayoutRess);
+ this.verticalLayoutRess.setComponentAlignment(this.horizontalLayoutRess, Alignment.MIDDLE_CENTER);
+ this.tableProjectAllocation.setWidth(100, Unit.PERCENTAGE);
+ this.tableProjectAllocation.setHeight(-1, Unit.PIXELS);
+ this.verticalLayoutRess.addComponent(this.tableProjectAllocation);
+ final CustomComponent verticalLayoutRess_spacer = new CustomComponent();
+ verticalLayoutRess_spacer.setSizeFull();
+ this.verticalLayoutRess.addComponent(verticalLayoutRess_spacer);
+ this.verticalLayoutRess.setExpandRatio(verticalLayoutRess_spacer, 1.0F);
+ this.gridLayoutRess.setColumns(1);
+ this.gridLayoutRess.setRows(2);
+ this.verticalLayoutRess.setSizeFull();
+ this.gridLayoutRess.addComponent(this.verticalLayoutRess, 0, 1);
+ this.gridLayoutRess.setColumnExpandRatio(0, 10.0F);
+ this.gridLayoutRess.setRowExpandRatio(1, 10.0F);
this.tableOrder.setSizeFull();
this.verticalLayoutBill.addComponent(this.tableOrder);
this.verticalLayoutBill.setComponentAlignment(this.tableOrder, Alignment.MIDDLE_CENTER);
@@ -1116,6 +1410,8 @@ private void initUI() {
this.gridLayoutDesc.setSizeFull();
this.tabSheet.addTab(this.gridLayoutDesc, StringResourceUtils.optLocalizeString("{$gridLayout2.caption}", this),
null);
+ this.gridLayoutRess.setSizeFull();
+ this.tabSheet.addTab(this.gridLayoutRess, "Ressourcen", null);
this.gridLayoutRef.setSizeFull();
this.tabSheet.addTab(this.gridLayoutRef, "Referenzen", null);
this.tabSheet.setSelectedTab(this.gridLayout);
@@ -1153,39 +1449,47 @@ private void initUI() {
this.table.addItemClickListener(event -> this.table_itemClick(event));
this.cmbCustomer.addValueChangeListener(event -> this.cmbCustomer_valueChange(event));
this.btnSearch.addClickListener(event -> this.btnSearch_buttonClick(event));
+ this.dateProStartDate.addValueChangeListener(event -> this.dateProStartDate_valueChange(event));
this.dateProEndDate.addValueChangeListener(event -> this.dateProEndDate_valueChange(event));
this.txtProIntensityPercent.addValueChangeListener(event -> this.txtProIntensityPercent_valueChange(event));
+ this.cmdNewAddress.addClickListener(event -> this.cmdNewAddress_buttonClick(event));
+ this.cmdDeleteAddress.addClickListener(event -> this.cmdDeleteAddress_buttonClick(event));
+ this.cmdEditAddress.addClickListener(event -> this.cmdEditAddress_buttonClick(event));
+ this.cmdReloadAddress.addClickListener(event -> this.cmdReloadAddress_buttonClick(event));
+ this.cmdInfoAddress.addClickListener(event -> this.cmdInfoAddress_buttonClick(event));
this.cmdSave.addClickListener(event -> this.cmdSave_buttonClick(event));
this.cmdReset.addClickListener(event -> this.cmdReset_buttonClick(event));
} //
//
- private XdevButton cmdNew, cmdDelete, cmdReload, cmdPlan, cmdReport, cmdInfo, btnSearch, cmdSave, cmdReset;
- private XdevLabel lblProModel, lblProject, lblProDescription, lblProRemark, lblProProjectState, lblProLastBill,
- lblCustomer, lblProName, lblProExtReference, lblProContact, lblProStartDate, lblProEndDate,
+ private XdevButton cmdNew, cmdDelete, cmdReload, cmdPlan, cmdReport, cmdInfo, btnSearch, cmdNewAddress,
+ cmdDeleteAddress, cmdEditAddress, cmdReloadAddress, cmdInfoAddress, cmdSave, cmdReset;
+ private XdevLabel lblCustomer, lblProName, lblProExtReference, lblProContact, lblProStartDate, lblProEndDate,
lblProIntensityPercent, label4, lblProHours, lblProHoursEffective, lblProRate, lblVat, lblCostAccount,
- lblBillingAddress, lblProState;
+ lblBillingAddress, lblProState, lblProModel, lblProOrderStrategy, lblProject, lblProDescription, lblProRemark,
+ lblProProjectState, lblProLastBill;
private XdevComboBox cmbCostAccount;
private XdevFieldGroup fieldGroup;
private XdevComboBox cmbBillingAddress;
private XdevTabSheet tabSheet;
- private XdevGridLayout gridLayoutData, gridLayoutDesc, gridLayoutRef, gridLayout;
+ private XdevGridLayout gridLayoutData, gridLayout, gridLayoutDesc, gridLayoutRess, gridLayoutRef;
private XdevComboBox cmbProject;
private XdevHorizontalSplitPanel horizontalSplitPanel;
private XdevContainerFilterComponent containerFilterComponent;
- private XdevHorizontalLayout actionLayout, horizontalLayoutCus, horizontalLayout;
- private XdevVerticalSplitPanel verticalSplitPanel;
+ private XdevTable tableProjectAllocation;
+ private XdevHorizontalLayout actionLayout, horizontalLayoutCus, horizontalLayoutRess, horizontalLayout;
private XdevComboBox cmbVat;
+ private XdevVerticalSplitPanel verticalSplitPanel;
+ private XdevPopupDateField dateProStartDate, dateProEndDate, dateProLastBill;
private XdevTextArea textArea, textAreaRem;
- private XdevPopupDateField dateProLastBill, dateProStartDate, dateProEndDate;
private XdevTable table, tableProject;
- private XdevComboBox> cbxProModel, cbxProState, cbxState;
+ private XdevComboBox> cbxState, cbxProModel, cbxProOrderStrategy, cbxProState;
+ private XdevComboBox cmbCustomer;
private XdevCheckBox cbxInternal;
private XdevTable tableOrder;
- private XdevComboBox cmbCustomer;
private XdevTextField txtProName, txtProExtReference, txtProContact, txtProIntensityPercent, txtProHours,
txtProHoursEffective, txtProRate;
- private XdevVerticalLayout verticalLayout, verticalLayoutBill, verticalLayoutSubProject;
+ private XdevVerticalLayout verticalLayout, verticalLayoutRess, verticalLayoutBill, verticalLayoutSubProject;
//
}
diff --git a/src/ch/xwr/seicentobilling/ui/desktop/ProjectTabView.ui.xml b/src/ch/xwr/seicentobilling/ui/desktop/ProjectTabView.ui.xml
index b86b9f2..07252b5 100644
--- a/src/ch/xwr/seicentobilling/ui/desktop/ProjectTabView.ui.xml
+++ b/src/ch/xwr/seicentobilling/ui/desktop/ProjectTabView.ui.xml
@@ -4,11 +4,13 @@
+
+
@@ -152,6 +154,7 @@
+ valueChange.valueChange
@@ -253,11 +256,20 @@
-
+
+
+
+
+
+
+
+
+
+
-
+
@@ -267,33 +279,88 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+ click.buttonClick
+
+
+
+ click.buttonClick
+
+
+
+ click.buttonClick
+
+
+
+ click.buttonClick
+
+
+
+ click.buttonClick
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -375,6 +442,7 @@
+
diff --git a/src/ch/xwr/seicentobilling/ui/desktop/billing/OrderGenerateTabView.java b/src/ch/xwr/seicentobilling/ui/desktop/billing/OrderGenerateTabView.java
index 557d468..7de398f 100644
--- a/src/ch/xwr/seicentobilling/ui/desktop/billing/OrderGenerateTabView.java
+++ b/src/ch/xwr/seicentobilling/ui/desktop/billing/OrderGenerateTabView.java
@@ -1,679 +1,675 @@
-package ch.xwr.seicentobilling.ui.desktop.billing;
-
-import java.text.DateFormat;
-import java.text.DecimalFormat;
-import java.text.SimpleDateFormat;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-
-import com.vaadin.data.Item;
-import com.vaadin.data.Property;
-import com.vaadin.external.org.slf4j.Logger;
-import com.vaadin.external.org.slf4j.LoggerFactory;
-import com.vaadin.server.FontAwesome;
-import com.vaadin.shared.ui.MarginInfo;
-import com.vaadin.ui.Alignment;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.Notification;
-import com.vaadin.ui.Table.Align;
-import com.xdev.ui.XdevButton;
-import com.xdev.ui.XdevCheckBox;
-import com.xdev.ui.XdevGridLayout;
-import com.xdev.ui.XdevHorizontalSplitPanel;
-import com.xdev.ui.XdevLabel;
-import com.xdev.ui.XdevPanel;
-import com.xdev.ui.XdevPopupDateField;
-import com.xdev.ui.XdevTabSheet;
-import com.xdev.ui.XdevTextField;
-import com.xdev.ui.XdevTreeTable;
-import com.xdev.ui.XdevVerticalLayout;
-import com.xdev.ui.XdevView;
-import com.xdev.ui.entitycomponent.XdevBeanItemContainer;
-import com.xdev.ui.entitycomponent.combobox.XdevComboBox;
-
-import ch.xwr.seicentobilling.business.LovState.BookingType;
-import ch.xwr.seicentobilling.business.OrderGenerator;
-import ch.xwr.seicentobilling.business.Seicento;
-import ch.xwr.seicentobilling.business.helper.RowObjectAddonHandler;
-import ch.xwr.seicentobilling.business.model.billing.BillDto;
-import ch.xwr.seicentobilling.business.model.billing.BillLine;
-import ch.xwr.seicentobilling.business.model.billing.GuiGeneratorFields;
-import ch.xwr.seicentobilling.dal.CostAccountDAO;
-import ch.xwr.seicentobilling.dal.ItemDAO;
-import ch.xwr.seicentobilling.dal.OrderDAO;
-import ch.xwr.seicentobilling.dal.PeriodeDAO;
-import ch.xwr.seicentobilling.entities.CostAccount;
-import ch.xwr.seicentobilling.entities.Order;
-import ch.xwr.seicentobilling.entities.Periode;
-
-public class OrderGenerateTabView extends XdevView {
- /** Logger initialized */
- private static final Logger _logger = LoggerFactory.getLogger(OrderGenerateTabView.class);
-
- private final GuiGeneratorFields guifld = new GuiGeneratorFields();
- private CostAccount user = null;
-
- /**
- *
- */
- public OrderGenerateTabView() {
- super();
- this.initUI();
-
- loadFields();
- if (!loadParams()) {
- this.cmdPropose.setEnabled(false);
- Notification.show("Parameter konnten nicht geladen werden. Bitte Artikel + Texte überprüfen.", Notification.Type.ERROR_MESSAGE);
- }
- }
-
-
- private boolean loadParams() {
- try {
- final RowObjectAddonHandler objman = new RowObjectAddonHandler(null); //company Level
- final RowObjectAddonHandler objUsr = new RowObjectAddonHandler(this.user.getCsaId(), "CostAccount"); //userlevel
-
- //Order (Header)
- this.textFieldOrderText.setValue(getTextParams(objman, objUsr, "headerText"));
-
- //project
- this.textFieldProjectLine.setValue(getTextParams(objman, objUsr, "lineTextProject"));
- //expense
- this.textFieldExpenseLine.setValue(getTextParams(objman, objUsr, "lineTextExpense"));
- //journey
- this.textFieldJourneyLine.setValue(getTextParams(objman, objUsr, "lineTextJourney"));
-
- //items
- final ch.xwr.seicentobilling.entities.Item itm1 = SearchItem(objman, "itemIdentProject");
- this.textFieldItemProject.setValue(itm1.getPrpShortName());
- //
- final ch.xwr.seicentobilling.entities.Item itm2 = SearchItem(objman, "itemIdentExpense");
- this.textFieldItemExpense.setValue(itm2.getPrpShortName());
- //
- final ch.xwr.seicentobilling.entities.Item itm3 = SearchItem(objman, "itemIdentJourney");
- this.textFieldItemJourney.setValue(itm3.getPrpShortName());
- //
- final String cbxValue = objUsr.getRowParameter("billing", "generator", "cbxLastText");
- if (cbxValue.toLowerCase().equals("true")) {
- this.checkBoxTextLast.setValue(true);
- }
-
- this.gridLayoutArtikel.setEnabled(false);
- this.gridLayoutArtikel.setReadOnly(true);
-
- //init model
- this.guifld.setItemProject(itm1);
- this.guifld.setItemExpense(itm2);
- this.guifld.setItemJourney(itm3);
-
- return true;
-
- } catch (final Exception e) {
- _logger.error("Could not load Params for Ordergeneration");
- _logger.error(e.getStackTrace().toString());
- }
-
- return false;
- }
-
-
- private String getTextParams(final RowObjectAddonHandler objman, final RowObjectAddonHandler objUsr, final String key) {
- String txtValue = objUsr.getRowParameter("billing", "generator", key);
-
- if (txtValue == null || txtValue.isEmpty()) {
- txtValue = objman.getRowParameter("billing", "generator", key);
- }
-
- return txtValue;
- }
-
-
- private ch.xwr.seicentobilling.entities.Item SearchItem(final RowObjectAddonHandler objman, final String key) {
- final String value = objman.getRowParameter("billing", "generator", key);
-
- final ItemDAO dao = new ItemDAO();
- final List lst = dao.findByIdent(value);
- if (lst != null && lst.size() > 0) {
- return lst.get(0);
- }
- return null;
- }
-
-
- private void loadFields() {
- final CostAccountDAO dao = new CostAccountDAO();
- final List ls1 = dao.findAll();
-
- CostAccount bean = Seicento.getLoggedInCostAccount();
- if (bean == null) {
- bean = ls1.get(0); // Dev Mode
- }
- this.user = bean;
-
- final XdevBeanItemContainer myCustomerList = new XdevBeanItemContainer<>(CostAccount.class);
- myCustomerList.addAll(ls1);
- this.comboBoxCostAccount.setContainerDataSource(myCustomerList);
-
- if (this.comboBoxCostAccount.containsId(bean)) {
- this.comboBoxCostAccount.select(bean);
- } else {
- this.comboBoxCostAccount.setValue(bean);
- }
-
- this.dateBilldate.setValue(new Date());
- }
-
-
-
- private void InitTreeGrid(final List lst) {
- //reset
- this.treeGrid.removeAllItems();
- this.treeGrid.removeContainerProperty("");
- this.treeGrid.removeContainerProperty("Kunde");
- this.treeGrid.removeContainerProperty("Projekt");
- this.treeGrid.removeContainerProperty("Betrag");
- this.treeGrid.removeContainerProperty("L-Rechnung");
- this.treeGrid.removeContainerProperty("Objekt");
-
- //rebuild
- this.treeGrid.addContainerProperty("", XdevCheckBox.class, true);
- this.treeGrid.addContainerProperty("Kunde", String.class, null);
- this.treeGrid.addContainerProperty("Projekt", String.class, null);
- this.treeGrid.addContainerProperty("Betrag", String.class, null);
- this.treeGrid.addContainerProperty("L-Rechnung", String.class, null);
- this.treeGrid.addContainerProperty("Objekt", BillDto.class, null);
-
- Object[] detail = null;
- int icount = 0;
- for (final BillDto billDto : lst) {
- final Object[] parent = getParentLine(billDto);
- this.treeGrid.addItem(parent, icount);
- final int iParent = icount;
-
- detail = getDetailGridLine("Spesen", billDto.getExpenseHours());
- if (detail != null) {
- icount++;
- this.treeGrid.addItem(detail, icount);
- this.treeGrid.setParent(icount, iParent);
-
- }
- detail = getDetailGridLine("Reisezeit", billDto.getJourneyHours());
- if (detail != null) {
- icount++;
- this.treeGrid.addItem(detail, icount);
- this.treeGrid.setParent(icount, iParent);
- }
- detail = getDetailGridLine("Dienstleistung", billDto.getProjectHours());
- if (detail != null) {
- icount++;
- this.treeGrid.addItem(detail, icount);
- this.treeGrid.setParent(icount, iParent);
- }
-
- icount++;
- }
-
- // Collapse the tree
- for (final Object itemId: this.treeGrid.getContainerDataSource().getItemIds()) {
- this.treeGrid.setCollapsed(itemId, true);
-
- // As we're at it, also disallow children from
- // the current leaves
- if (! this.treeGrid.hasChildren(itemId)) {
- this.treeGrid.setChildrenAllowed(itemId, true);
- }
- }
-
- this.treeGrid.setVisibleColumns("", "Kunde", "Projekt", "Betrag", "L-Rechnung");
- this.treeGrid.setColumnAlignments(Align.LEFT,Align.LEFT,Align.LEFT,Align.RIGHT,Align.LEFT);
- }
-
-
- private Object[] getParentLine(final BillDto billDto) {
- final XdevCheckBox cbo = new XdevCheckBox();
- cbo.setValue(true);
- if (billDto.getProject().getInternal() == null || billDto.getProject().getInternal()) {
- cbo.setValue(false);
- cbo.setEnabled(false);
- }
- final String cusName = billDto.getCustomer().getFullname();
- final String proName = billDto.getProject().getProName();
- final String amount = getAmtString(billDto.getTotalAmount(), true);
- final String ldate = getLastBillDate(billDto);
-
- final Object[] retval = new Object[] {cbo, cusName, proName, amount, ldate, billDto};
- return retval;
- }
-
-
- private String getLastBillDate(final BillDto billDto) {
- final String pattern = "dd.MM.yyyy";
- final DateFormat df = new SimpleDateFormat(pattern);
-
-
- final OrderDAO dao = new OrderDAO();
- final List lst = dao.findByCustomer(billDto.getCustomer());
- for (final Iterator iterator = lst.iterator(); iterator.hasNext();) {
- final Order order = iterator.next();
- if (order.getProject() != null) {
- if (order.getProject().getProId().equals(billDto.getProject().getProId())) {
- return df.format(order.getOrdBillDate());
- }
- }
- }
-
- return "";
- }
-
-
- private String getAmtString(final Double amount, final boolean currency) {
- final DecimalFormat decimalFormat = new DecimalFormat("#,##0.00");
- final String numberAsString = " " + decimalFormat.format(amount);
- final int ilen = numberAsString.length();
- final String retval = numberAsString.substring(ilen - 11);
- if (currency ) {
- return "CHF" + retval;
- }
- return retval;
- }
-
-
- private Object[] getDetailGridLine(final String text, final List list) {
- Double amt = new Double(0);
- if (list!= null && ! list.isEmpty()) {
- for (int i = 0; i < list.size(); i++) {
- final BillLine tmp = list.get(i);
- amt = amt + tmp.getAmount();
- }
- }
-
- if (amt > 0) {
- final String samt = getAmtString(amt, false);
- final Object[] retval = new Object[]{null, null, text, samt, null, null};
- return retval;
- }
-
- return null;
- }
-
-
- /**
- * Event handler delegate method for the {@link XdevButton}
- * {@link #cmdGenerate}.
- *
- * @see Button.ClickListener#buttonClick(Button.ClickEvent)
- * @eventHandlerDelegate Do NOT delete, used by UI designer!
- */
- @SuppressWarnings("unchecked")
- private void cmdGenerate_buttonClick(final Button.ClickEvent event) {
- if (isModelValid()) {
- int icount = 0;
- String billnbrs = "";
- final OrderGenerator gen = new OrderGenerator();
- for (final Object itemId: this.treeGrid.getContainerDataSource().getItemIds()) {
- final Item item = this.treeGrid.getItem(itemId);
- final XdevCheckBox cbo = (XdevCheckBox) item.getItemProperty("").getValue();
- final BillDto bill = (BillDto) item.getItemProperty("Objekt").getValue();
-
- if (cbo != null && cbo.getValue() && bill != null) {
- final Order newOrd = gen.createBill(bill, this.guifld);
- //System.out.println("Order created " + newOrd.getOrdNumber());
- icount++;
-
- if (icount == 1) {
- billnbrs = "" + newOrd.getOrdNumber();
- } else {
- billnbrs = billnbrs + ", " + newOrd.getOrdNumber();
- }
-
- cbo.setValue(false);
- item.getItemProperty("L-Rechnung").setValue( "Neu: " + newOrd.getOrdNumber());
- }
- }
-
- Notification.show("Rechnungen erstellen ausgeführt", Notification.Type.TRAY_NOTIFICATION);
- if (icount > 0) {
- Notification.show("Rechnungen generieren", "" + icount + " Rechnung(en) erstellt mit Nr: " + billnbrs + ".",
- Notification.Type.HUMANIZED_MESSAGE);
- }
-
- markPeriodeAsGenerated();
-
- } else {
- Notification.show("Rechnungen generieren", "ungültige Parameter - Generierung kann nicht starten.",
- Notification.Type.WARNING_MESSAGE);
-
- }
- }
-
- private void markPeriodeAsGenerated() {
- final PeriodeDAO dao = new PeriodeDAO();
-
- final Periode per = this.comboBoxPeriode.getSelectedItem().getBean();
- per.setPerBookedProject(BookingType.gebucht);
- dao.save(per);
- }
-
-
- private boolean isModelValid() {
- this.guifld.setBillDate(this.dateBilldate.getValue());
- this.guifld.setBillText(this.textFieldOrderText.getValue());
- this.guifld.setCopyTextFromLastBill(this.checkBoxTextLast.getValue());
- this.guifld.setLineTextExpense(this.textFieldExpenseLine.getValue());
- this.guifld.setLineTextJourney(this.textFieldJourneyLine.getValue());
- this.guifld.setLineTextProject(this.textFieldProjectLine.getValue());
-
- if (this.guifld.getBillDate() == null) {
- return false;
- }
- if (this.guifld.getItemExpense() == null) {
- return false;
- }
- if (this.guifld.getItemJourney() == null) {
- return false;
- }
- if (this.guifld.getItemProject() == null) {
- return false;
- }
-
- return true;
- }
-
-
- /**
- * Event handler delegate method for the {@link XdevButton} {@link #cmdPropose}.
- *
- * @see Button.ClickListener#buttonClick(Button.ClickEvent)
- * @eventHandlerDelegate Do NOT delete, used by UI designer!
- */
- private void cmdPropose_buttonClick(final Button.ClickEvent event) {
- // here we read it....
- if (this.comboBoxCostAccount.getSelectedItem() == null || this.comboBoxPeriode.getSelectedItem() == null) {
- Notification.show("Rechnungen generieren", "Bitte Periode wählen", Notification.Type.WARNING_MESSAGE);
- return;
- }
-
- final Periode per = this.comboBoxPeriode.getSelectedItem().getBean();
- final OrderGenerator gen = new OrderGenerator();
- final List lst = gen.proposeDraft(per);
-
- if (per.getPerBookedProject().equals(BookingType.gebucht)) {
- Notification.show("Rechnungsvorschlag", "Für diese Periode wurden bereits Rechnungen generiert!!", Notification.Type.WARNING_MESSAGE);
- }
-
- // publish list to grid
- InitTreeGrid(lst);
- // this.table.
- final Collection> lsSize = this.treeGrid.getContainerDataSource().getItemIds();
- if (lsSize.size() > 0) {
- this.cmdGenerate.setEnabled(true);
- } else {
- this.cmdGenerate.setEnabled(false);
- }
-
- }
-
-
- /**
- * Event handler delegate method for the {@link XdevComboBox}
- * {@link #comboBoxCostAccount}.
- *
- * @see Property.ValueChangeListener#valueChange(Property.ValueChangeEvent)
- * @eventHandlerDelegate Do NOT delete, used by UI designer!
- */
- private void comboBoxCostAccount_valueChange(final Property.ValueChangeEvent event) {
- final CostAccount cst = (CostAccount) event.getProperty().getValue();
- // if (this.comboBoxCostAccount.getSelectedItem() != null) {
- if (cst != null) {
- final CostAccount bean = this.comboBoxCostAccount.getSelectedItem().getBean();
-
- // this.comboBoxPeriode.getContainerDataSource().removeAllItems();
-
- final XdevBeanItemContainer myList = new XdevBeanItemContainer<>(Periode.class);
- myList.addAll(new PeriodeDAO().findByCostAccount(bean));
- this.comboBoxPeriode.setContainerDataSource(myList);
-
- final Periode beanp = myList.firstItemId();
- if (beanp != null) {
- this.comboBoxPeriode.select(beanp);
- }
- }
-
- }
-
-
- /**
- * Event handler delegate method for the {@link XdevButton}
- * {@link #cmdSaveText}.
- *
- * @see Button.ClickListener#buttonClick(Button.ClickEvent)
- * @eventHandlerDelegate Do NOT delete, used by UI designer!
- */
- private void cmdSaveText_buttonClick(final Button.ClickEvent event) {
- //save text to User
- final RowObjectAddonHandler objman = new RowObjectAddonHandler(this.user.getCsaId(), "CostAccount");
-
- objman.putRowParameter("billing", "generator", "headerText", this.textFieldOrderText.getValue());
- objman.putRowParameter("billing", "generator", "lineTextProject", this.textFieldProjectLine.getValue());
- objman.putRowParameter("billing", "generator", "lineTextExpense", this.textFieldExpenseLine.getValue());
- objman.putRowParameter("billing", "generator", "lineTextJourney", this.textFieldJourneyLine.getValue());
-
- objman.putRowParameter("billing", "generator", "cbxLastText", this.checkBoxTextLast.getValue().toString());
- }
-
-
- /*
- * WARNING: Do NOT edit!
The content of this method is always regenerated by
- * the UI designer.
- */
- //
- private void initUI() {
- this.horizontalSplitPanel = new XdevHorizontalSplitPanel();
- this.verticalLayoutLeft = new XdevVerticalLayout();
- this.panel = new XdevPanel();
- this.tabSheet = new XdevTabSheet();
- this.gridLayout = new XdevGridLayout();
- this.label = new XdevLabel();
- this.comboBoxCostAccount = new XdevComboBox<>();
- this.label2 = new XdevLabel();
- this.comboBoxPeriode = new XdevComboBox<>();
- this.label3 = new XdevLabel();
- this.dateBilldate = new XdevPopupDateField();
- this.checkBoxTextLast = new XdevCheckBox();
- this.cmdPropose = new XdevButton();
- this.cmdGenerate = new XdevButton();
- this.label4 = new XdevLabel();
- this.gridLayoutTexte = new XdevGridLayout();
- this.labelInfoToolTip = new XdevLabel();
- this.label5 = new XdevLabel();
- this.textFieldOrderText = new XdevTextField();
- this.label6 = new XdevLabel();
- this.textFieldProjectLine = new XdevTextField();
- this.label7 = new XdevLabel();
- this.textFieldExpenseLine = new XdevTextField();
- this.label8 = new XdevLabel();
- this.textFieldJourneyLine = new XdevTextField();
- this.cmdSaveText = new XdevButton();
- this.gridLayoutArtikel = new XdevGridLayout();
- this.label11 = new XdevLabel();
- this.textFieldItemProject = new XdevTextField();
- this.label12 = new XdevLabel();
- this.textFieldItemExpense = new XdevTextField();
- this.label13 = new XdevLabel();
- this.textFieldItemJourney = new XdevTextField();
- this.verticalLayoutRight = new XdevVerticalLayout();
- this.treeGrid = new XdevTreeTable();
-
- this.horizontalSplitPanel.setStyleName("large");
- this.horizontalSplitPanel.setSplitPosition(35.0F, Unit.PERCENTAGE);
- this.verticalLayoutLeft.setMargin(new MarginInfo(false));
- this.panel.setCaption("Rechnungen generieren");
- this.tabSheet.setStyleName("framed");
- this.label.setValue("Kostenstelle");
- this.comboBoxCostAccount.setContainerDataSource(CostAccount.class, false);
- this.label2.setValue("Periode wählen");
- this.comboBoxPeriode.setContainerDataSource(Periode.class, false);
- this.label3.setValue("Rechnungsdatum");
- this.checkBoxTextLast.setCaption("Text von letzer Rechnung");
- this.cmdPropose.setCaption("Vorschlag generieren");
- this.cmdGenerate.setCaption("Rechnungen erstellen");
- this.cmdGenerate.setEnabled(false);
- this.label4.setIcon(FontAwesome.INFO_CIRCLE);
- this.label4.setValue("MwSt-Ansatz wird für alle Positionen vom Projekt übernommen!");
- this.labelInfoToolTip.setIcon(FontAwesome.INFO_CIRCLE);
- this.labelInfoToolTip.setDescription("Es ist ein Tooltip vorhanden auf den Labeln und dem Button.");
- this.label5.setDescription(
- "Rechnungstext - mögliche Platzhalter {proExtReference} {proName}, {proContact}, {csaName}, {perYear}, {perMonth}, {perMonthText}");
- this.label5.setValue("Textzeile Rechnung");
- this.label6.setDescription("mögliche Platzhalter: {csaName}, {csaCode}, , {perYear}, {perMonth}, {perMonthText}");
- this.label6.setValue("Textzeile Dienstleistung");
- this.label7.setDescription("siehe Dienstleistung");
- this.label7.setValue("Textzeile Spesen");
- this.label8.setDescription("siehe Dienstleistung");
- this.label8.setValue("Textzeile Reisezeit");
- this.cmdSaveText.setCaption("Texte speichern");
- this.cmdSaveText.setDescription("Speichert die Texte als persönliche Einstellungen.");
- this.label11.setValue("Artikel Dienstleistung");
- this.label12.setValue("Artikel Spesen");
- this.label13.setValue("Artikel Reisezeit");
- this.verticalLayoutRight.setMargin(new MarginInfo(false, false, true, false));
- this.treeGrid.setSelectable(true);
- this.treeGrid.setMultiSelect(true);
-
- this.gridLayout.setColumns(3);
- this.gridLayout.setRows(8);
- this.label.setSizeUndefined();
- this.gridLayout.addComponent(this.label, 0, 0);
- this.comboBoxCostAccount.setSizeUndefined();
- this.gridLayout.addComponent(this.comboBoxCostAccount, 1, 0);
- this.label2.setSizeUndefined();
- this.gridLayout.addComponent(this.label2, 0, 1);
- this.comboBoxPeriode.setSizeUndefined();
- this.gridLayout.addComponent(this.comboBoxPeriode, 1, 1);
- this.label3.setSizeUndefined();
- this.gridLayout.addComponent(this.label3, 0, 2);
- this.dateBilldate.setSizeUndefined();
- this.gridLayout.addComponent(this.dateBilldate, 1, 2);
- this.checkBoxTextLast.setSizeUndefined();
- this.gridLayout.addComponent(this.checkBoxTextLast, 1, 3);
- this.cmdPropose.setSizeUndefined();
- this.gridLayout.addComponent(this.cmdPropose, 1, 4);
- this.cmdGenerate.setSizeUndefined();
- this.gridLayout.addComponent(this.cmdGenerate, 1, 5);
- this.label4.setWidth(100, Unit.PERCENTAGE);
- this.label4.setHeight(-1, Unit.PIXELS);
- this.gridLayout.addComponent(this.label4, 0, 6, 1, 6);
- final CustomComponent gridLayout_hSpacer = new CustomComponent();
- gridLayout_hSpacer.setSizeFull();
- this.gridLayout.addComponent(gridLayout_hSpacer, 2, 0, 2, 6);
- this.gridLayout.setColumnExpandRatio(2, 1.0F);
- final CustomComponent gridLayout_vSpacer = new CustomComponent();
- gridLayout_vSpacer.setSizeFull();
- this.gridLayout.addComponent(gridLayout_vSpacer, 0, 7, 1, 7);
- this.gridLayout.setRowExpandRatio(7, 1.0F);
- this.gridLayoutTexte.setColumns(2);
- this.gridLayoutTexte.setRows(7);
- this.labelInfoToolTip.setSizeUndefined();
- this.gridLayoutTexte.addComponent(this.labelInfoToolTip, 0, 0);
- this.label5.setSizeUndefined();
- this.gridLayoutTexte.addComponent(this.label5, 0, 1);
- this.textFieldOrderText.setWidth(100, Unit.PERCENTAGE);
- this.textFieldOrderText.setHeight(-1, Unit.PIXELS);
- this.gridLayoutTexte.addComponent(this.textFieldOrderText, 1, 1);
- this.label6.setSizeUndefined();
- this.gridLayoutTexte.addComponent(this.label6, 0, 2);
- this.textFieldProjectLine.setWidth(100, Unit.PERCENTAGE);
- this.textFieldProjectLine.setHeight(-1, Unit.PIXELS);
- this.gridLayoutTexte.addComponent(this.textFieldProjectLine, 1, 2);
- this.label7.setSizeUndefined();
- this.gridLayoutTexte.addComponent(this.label7, 0, 3);
- this.textFieldExpenseLine.setWidth(100, Unit.PERCENTAGE);
- this.textFieldExpenseLine.setHeight(-1, Unit.PIXELS);
- this.gridLayoutTexte.addComponent(this.textFieldExpenseLine, 1, 3);
- this.label8.setSizeUndefined();
- this.gridLayoutTexte.addComponent(this.label8, 0, 4);
- this.textFieldJourneyLine.setWidth(100, Unit.PERCENTAGE);
- this.textFieldJourneyLine.setHeight(-1, Unit.PIXELS);
- this.gridLayoutTexte.addComponent(this.textFieldJourneyLine, 1, 4);
- this.cmdSaveText.setSizeUndefined();
- this.gridLayoutTexte.addComponent(this.cmdSaveText, 1, 5);
- this.gridLayoutTexte.setColumnExpandRatio(1, 10.0F);
- final CustomComponent gridLayoutTexte_vSpacer = new CustomComponent();
- gridLayoutTexte_vSpacer.setSizeFull();
- this.gridLayoutTexte.addComponent(gridLayoutTexte_vSpacer, 0, 6, 1, 6);
- this.gridLayoutTexte.setRowExpandRatio(6, 1.0F);
- this.gridLayoutArtikel.setColumns(2);
- this.gridLayoutArtikel.setRows(4);
- this.label11.setSizeUndefined();
- this.gridLayoutArtikel.addComponent(this.label11, 0, 0);
- this.textFieldItemProject.setWidth(100, Unit.PERCENTAGE);
- this.textFieldItemProject.setHeight(-1, Unit.PIXELS);
- this.gridLayoutArtikel.addComponent(this.textFieldItemProject, 1, 0);
- this.label12.setSizeUndefined();
- this.gridLayoutArtikel.addComponent(this.label12, 0, 1);
- this.textFieldItemExpense.setWidth(100, Unit.PERCENTAGE);
- this.textFieldItemExpense.setHeight(-1, Unit.PIXELS);
- this.gridLayoutArtikel.addComponent(this.textFieldItemExpense, 1, 1);
- this.label13.setSizeUndefined();
- this.gridLayoutArtikel.addComponent(this.label13, 0, 2);
- this.textFieldItemJourney.setWidth(100, Unit.PERCENTAGE);
- this.textFieldItemJourney.setHeight(-1, Unit.PIXELS);
- this.gridLayoutArtikel.addComponent(this.textFieldItemJourney, 1, 2);
- this.gridLayoutArtikel.setColumnExpandRatio(1, 10.0F);
- final CustomComponent gridLayoutArtikel_vSpacer = new CustomComponent();
- gridLayoutArtikel_vSpacer.setSizeFull();
- this.gridLayoutArtikel.addComponent(gridLayoutArtikel_vSpacer, 0, 3, 1, 3);
- this.gridLayoutArtikel.setRowExpandRatio(3, 1.0F);
- this.gridLayout.setSizeFull();
- this.tabSheet.addTab(this.gridLayout, "Main", null);
- this.gridLayoutTexte.setSizeFull();
- this.tabSheet.addTab(this.gridLayoutTexte, "Texte", null);
- this.gridLayoutArtikel.setSizeFull();
- this.tabSheet.addTab(this.gridLayoutArtikel, "Artikel", null);
- this.tabSheet.setSelectedTab(this.gridLayout);
- this.tabSheet.setSizeFull();
- this.panel.setContent(this.tabSheet);
- this.panel.setSizeFull();
- this.verticalLayoutLeft.addComponent(this.panel);
- this.verticalLayoutLeft.setComponentAlignment(this.panel, Alignment.MIDDLE_CENTER);
- this.verticalLayoutLeft.setExpandRatio(this.panel, 10.0F);
- this.treeGrid.setSizeFull();
- this.verticalLayoutRight.addComponent(this.treeGrid);
- this.verticalLayoutRight.setComponentAlignment(this.treeGrid, Alignment.MIDDLE_CENTER);
- this.verticalLayoutRight.setExpandRatio(this.treeGrid, 100.0F);
- this.verticalLayoutLeft.setSizeFull();
- this.horizontalSplitPanel.setFirstComponent(this.verticalLayoutLeft);
- this.verticalLayoutRight.setSizeFull();
- this.horizontalSplitPanel.setSecondComponent(this.verticalLayoutRight);
- this.horizontalSplitPanel.setSizeFull();
- this.setContent(this.horizontalSplitPanel);
- this.setSizeFull();
-
- this.comboBoxCostAccount.addValueChangeListener(event -> this.comboBoxCostAccount_valueChange(event));
- this.cmdPropose.addClickListener(event -> this.cmdPropose_buttonClick(event));
- this.cmdGenerate.addClickListener(event -> this.cmdGenerate_buttonClick(event));
- this.cmdSaveText.addClickListener(event -> this.cmdSaveText_buttonClick(event));
- } //
-
- //
- private XdevLabel label, label2, label3, label4, labelInfoToolTip, label5, label6, label7, label8, label11, label12,
- label13;
- private XdevButton cmdPropose, cmdGenerate, cmdSaveText;
- private XdevComboBox comboBoxCostAccount;
- private XdevPanel panel;
- private XdevTabSheet tabSheet;
- private XdevGridLayout gridLayout, gridLayoutTexte, gridLayoutArtikel;
- private XdevHorizontalSplitPanel horizontalSplitPanel;
- private XdevComboBox comboBoxPeriode;
- private XdevPopupDateField dateBilldate;
- private XdevCheckBox checkBoxTextLast;
- private XdevTreeTable treeGrid;
- private XdevTextField textFieldOrderText, textFieldProjectLine, textFieldExpenseLine, textFieldJourneyLine,
- textFieldItemProject, textFieldItemExpense, textFieldItemJourney;
- private XdevVerticalLayout verticalLayoutLeft, verticalLayoutRight;
- //
-
-}
+package ch.xwr.seicentobilling.ui.desktop.billing;
+
+import java.text.DateFormat;
+import java.text.DecimalFormat;
+import java.text.SimpleDateFormat;
+import java.util.Collection;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+import com.vaadin.data.Item;
+import com.vaadin.data.Property;
+import com.vaadin.external.org.slf4j.Logger;
+import com.vaadin.external.org.slf4j.LoggerFactory;
+import com.vaadin.server.FontAwesome;
+import com.vaadin.shared.ui.MarginInfo;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.Notification;
+import com.vaadin.ui.Table.Align;
+import com.xdev.ui.XdevButton;
+import com.xdev.ui.XdevCheckBox;
+import com.xdev.ui.XdevGridLayout;
+import com.xdev.ui.XdevHorizontalSplitPanel;
+import com.xdev.ui.XdevLabel;
+import com.xdev.ui.XdevPanel;
+import com.xdev.ui.XdevPopupDateField;
+import com.xdev.ui.XdevTabSheet;
+import com.xdev.ui.XdevTextField;
+import com.xdev.ui.XdevTreeTable;
+import com.xdev.ui.XdevVerticalLayout;
+import com.xdev.ui.XdevView;
+import com.xdev.ui.entitycomponent.XdevBeanItemContainer;
+import com.xdev.ui.entitycomponent.combobox.XdevComboBox;
+
+import ch.xwr.seicentobilling.business.LovState;
+import ch.xwr.seicentobilling.business.LovState.BookingType;
+import ch.xwr.seicentobilling.business.OrderGenerator;
+import ch.xwr.seicentobilling.business.Seicento;
+import ch.xwr.seicentobilling.business.helper.RowObjectAddonHandler;
+import ch.xwr.seicentobilling.business.model.billing.BillDto;
+import ch.xwr.seicentobilling.business.model.billing.BillLine;
+import ch.xwr.seicentobilling.business.model.billing.GuiGeneratorFields;
+import ch.xwr.seicentobilling.dal.CostAccountDAO;
+import ch.xwr.seicentobilling.dal.ItemDAO;
+import ch.xwr.seicentobilling.dal.OrderDAO;
+import ch.xwr.seicentobilling.dal.PeriodeDAO;
+import ch.xwr.seicentobilling.entities.CostAccount;
+import ch.xwr.seicentobilling.entities.Order;
+import ch.xwr.seicentobilling.entities.Periode;
+
+public class OrderGenerateTabView extends XdevView {
+ /** Logger initialized */
+ private static final Logger _logger = LoggerFactory.getLogger(OrderGenerateTabView.class);
+
+ private final GuiGeneratorFields guifld = new GuiGeneratorFields();
+ private CostAccount user = null;
+
+ /**
+ *
+ */
+ public OrderGenerateTabView() {
+ super();
+ this.initUI();
+
+ loadFields();
+ if (!loadParams()) {
+ this.cmdPropose.setEnabled(false);
+ Notification.show("Parameter konnten nicht geladen werden. Bitte Artikel + Texte überprüfen.", Notification.Type.ERROR_MESSAGE);
+ }
+ }
+
+
+ private boolean loadParams() {
+ try {
+ final RowObjectAddonHandler objman = new RowObjectAddonHandler(null); //company Level
+ final RowObjectAddonHandler objUsr = new RowObjectAddonHandler(this.user.getCsaId(), "CostAccount"); //userlevel
+
+ //Order (Header)
+ this.textFieldOrderText.setValue(getTextParams(objman, objUsr, "headerText"));
+
+ //project
+ this.textFieldProjectLine.setValue(getTextParams(objman, objUsr, "lineTextProject"));
+ //expense
+ this.textFieldExpenseLine.setValue(getTextParams(objman, objUsr, "lineTextExpense"));
+ //journey
+ this.textFieldJourneyLine.setValue(getTextParams(objman, objUsr, "lineTextJourney"));
+
+ //items
+ final ch.xwr.seicentobilling.entities.Item itm1 = SearchItem(objman, "itemIdentProject");
+ this.textFieldItemProject.setValue(itm1.getPrpShortName());
+ //
+ final ch.xwr.seicentobilling.entities.Item itm2 = SearchItem(objman, "itemIdentExpense");
+ this.textFieldItemExpense.setValue(itm2.getPrpShortName());
+ //
+ final ch.xwr.seicentobilling.entities.Item itm3 = SearchItem(objman, "itemIdentJourney");
+ this.textFieldItemJourney.setValue(itm3.getPrpShortName());
+ //
+ final String cbxValue = objUsr.getRowParameter("billing", "generator", "cbxLastText");
+ if (cbxValue.toLowerCase().equals("true")) {
+ this.checkBoxTextLast.setValue(true);
+ }
+
+ this.gridLayoutArtikel.setEnabled(false);
+ this.gridLayoutArtikel.setReadOnly(true);
+
+ //init model
+ this.guifld.setItemProject(itm1);
+ this.guifld.setItemExpense(itm2);
+ this.guifld.setItemJourney(itm3);
+
+ return true;
+
+ } catch (final Exception e) {
+ _logger.error("Could not load Params for Ordergeneration");
+ _logger.error(e.getStackTrace().toString());
+ }
+
+ return false;
+ }
+
+
+ private String getTextParams(final RowObjectAddonHandler objman, final RowObjectAddonHandler objUsr, final String key) {
+ String txtValue = objUsr.getRowParameter("billing", "generator", key);
+
+ if (txtValue == null || txtValue.isEmpty()) {
+ txtValue = objman.getRowParameter("billing", "generator", key);
+ }
+
+ return txtValue;
+ }
+
+
+ private ch.xwr.seicentobilling.entities.Item SearchItem(final RowObjectAddonHandler objman, final String key) {
+ final String value = objman.getRowParameter("billing", "generator", key);
+
+ final ItemDAO dao = new ItemDAO();
+ final List lst = dao.findByIdent(value);
+ if (lst != null && lst.size() > 0) {
+ return lst.get(0);
+ }
+ return null;
+ }
+
+
+ private void loadFields() {
+ final CostAccountDAO dao = new CostAccountDAO();
+ final List ls1 = dao.findAll();
+
+ CostAccount bean = Seicento.getLoggedInCostAccount();
+ if (bean == null) {
+ bean = ls1.get(0); // Dev Mode
+ }
+ this.user = bean;
+
+ final XdevBeanItemContainer myCustomerList = new XdevBeanItemContainer<>(CostAccount.class);
+ myCustomerList.addAll(ls1);
+ this.comboBoxCostAccount.setContainerDataSource(myCustomerList);
+
+ if (this.comboBoxCostAccount.containsId(bean)) {
+ this.comboBoxCostAccount.select(bean);
+ } else {
+ this.comboBoxCostAccount.setValue(bean);
+ }
+
+ this.dateBilldate.setValue(new Date());
+ }
+
+
+
+ private void InitTreeGrid(final List lst) {
+ //reset
+ this.treeGrid.removeAllItems();
+ this.treeGrid.removeContainerProperty("");
+ this.treeGrid.removeContainerProperty("Kunde");
+ this.treeGrid.removeContainerProperty("Projekt");
+ this.treeGrid.removeContainerProperty("Betrag");
+ this.treeGrid.removeContainerProperty("L-Rechnung");
+ this.treeGrid.removeContainerProperty("Objekt");
+
+ //rebuild
+ this.treeGrid.addContainerProperty("", XdevCheckBox.class, true);
+ this.treeGrid.addContainerProperty("Kunde", String.class, null);
+ this.treeGrid.addContainerProperty("Projekt", String.class, null);
+ this.treeGrid.addContainerProperty("Betrag", String.class, null);
+ this.treeGrid.addContainerProperty("L-Rechnung", String.class, null);
+ this.treeGrid.addContainerProperty("Objekt", BillDto.class, null);
+
+ Object[] detail = null;
+ int icount = 0;
+ for (final BillDto billDto : lst) {
+ final Object[] parent = getParentLine(billDto);
+ this.treeGrid.addItem(parent, icount);
+ final int iParent = icount;
+
+ final List list = billDto.getLines();
+ if (list!= null && ! list.isEmpty()) {
+ for (int i = 0; i < list.size(); i++) {
+ final BillLine line = list.get(i);
+ detail = getDetailGridLine(line);
+ if (detail != null) {
+ icount++;
+ this.treeGrid.addItem(detail, icount);
+ this.treeGrid.setParent(icount, iParent);
+ }
+ }
+ }
+
+ icount++;
+ }
+
+ // Collapse the tree
+ for (final Object itemId: this.treeGrid.getContainerDataSource().getItemIds()) {
+ this.treeGrid.setCollapsed(itemId, true);
+
+ // As we're at it, also disallow children from
+ // the current leaves
+ if (! this.treeGrid.hasChildren(itemId)) {
+ this.treeGrid.setChildrenAllowed(itemId, true);
+ }
+ }
+
+ this.treeGrid.setVisibleColumns("", "Kunde", "Projekt", "Betrag", "L-Rechnung");
+ this.treeGrid.setColumnAlignments(Align.LEFT,Align.LEFT,Align.LEFT,Align.RIGHT,Align.LEFT);
+ }
+
+
+ private Object[] getParentLine(final BillDto billDto) {
+ final XdevCheckBox cbo = new XdevCheckBox();
+ cbo.setValue(true);
+ if (billDto.getProject().getInternal() == null || billDto.getProject().getInternal()) {
+ cbo.setValue(false);
+ cbo.setEnabled(false);
+ }
+ if (billDto.getProject().getProOrdergenerationStrategy() == LovState.ProOrderStrategy.zusammenziehen) {
+ if (!billDto.getProject().getCostAccount().getCsaId().equals(billDto.getCostaccount().getCsaId())) {
+ //will be billed by main CostAccount #426
+ cbo.setValue(false);
+ cbo.setEnabled(false);
+ }
+ }
+
+ final String cusName = billDto.getCustomer().getFullname();
+ final String proName = billDto.getProject().getProName();
+ final String amount = getAmtString(billDto.getTotalAmount(), true);
+ final String ldate = getLastBillDate(billDto);
+
+ final Object[] retval = new Object[] {cbo, cusName, proName, amount, ldate, billDto};
+ return retval;
+ }
+
+
+ private String getLastBillDate(final BillDto billDto) {
+ final String pattern = "dd.MM.yyyy";
+ final DateFormat df = new SimpleDateFormat(pattern);
+
+
+ final OrderDAO dao = new OrderDAO();
+ final List lst = dao.findByCustomer(billDto.getCustomer());
+ for (final Iterator iterator = lst.iterator(); iterator.hasNext();) {
+ final Order order = iterator.next();
+ if (order.getProject() != null) {
+ if (order.getProject().getProId().equals(billDto.getProject().getProId())) {
+ return df.format(order.getOrdBillDate());
+ }
+ }
+ }
+
+ return "";
+ }
+
+
+ private String getAmtString(final Double amount, final boolean currency) {
+ final DecimalFormat decimalFormat = new DecimalFormat("#,##0.00");
+ final String numberAsString = " " + decimalFormat.format(amount);
+ final int ilen = numberAsString.length();
+ final String retval = numberAsString.substring(ilen - 11);
+ if (currency ) {
+ return "CHF" + retval;
+ }
+ return retval;
+ }
+
+
+ private Object[] getDetailGridLine(final BillLine line) {
+ final Double amt = line.getAmount();
+
+ if (amt > 0) {
+ final String samt = getAmtString(amt, false);
+ final Object[] retval = new Object[]{null, null, line.getText(), samt, null, null};
+ return retval;
+ }
+
+ return null;
+ }
+
+ /**
+ * Event handler delegate method for the {@link XdevButton}
+ * {@link #cmdGenerate}.
+ *
+ * @see Button.ClickListener#buttonClick(Button.ClickEvent)
+ * @eventHandlerDelegate Do NOT delete, used by UI designer!
+ */
+ @SuppressWarnings("unchecked")
+ private void cmdGenerate_buttonClick(final Button.ClickEvent event) {
+ if (isModelValid()) {
+ int icount = 0;
+ String billnbrs = "";
+ final OrderGenerator gen = new OrderGenerator();
+ for (final Object itemId: this.treeGrid.getContainerDataSource().getItemIds()) {
+ final Item item = this.treeGrid.getItem(itemId);
+ final XdevCheckBox cbo = (XdevCheckBox) item.getItemProperty("").getValue();
+ final BillDto bill = (BillDto) item.getItemProperty("Objekt").getValue();
+
+ if (cbo != null && cbo.getValue() && bill != null) {
+ final Order newOrd = gen.createBill(bill, this.guifld);
+ //System.out.println("Order created " + newOrd.getOrdNumber());
+ icount++;
+
+ if (icount == 1) {
+ billnbrs = "" + newOrd.getOrdNumber();
+ } else {
+ billnbrs = billnbrs + ", " + newOrd.getOrdNumber();
+ }
+
+ cbo.setValue(false);
+ item.getItemProperty("L-Rechnung").setValue( "Neu: " + newOrd.getOrdNumber());
+ }
+ }
+
+ Notification.show("Rechnungen erstellen ausgeführt", Notification.Type.TRAY_NOTIFICATION);
+ if (icount > 0) {
+ Notification.show("Rechnungen generieren", "" + icount + " Rechnung(en) erstellt mit Nr: " + billnbrs + ".",
+ Notification.Type.HUMANIZED_MESSAGE);
+ }
+
+ markPeriodeAsGenerated();
+
+ } else {
+ Notification.show("Rechnungen generieren", "ungültige Parameter - Generierung kann nicht starten.",
+ Notification.Type.WARNING_MESSAGE);
+
+ }
+ }
+
+ private void markPeriodeAsGenerated() {
+ final PeriodeDAO dao = new PeriodeDAO();
+
+ final Periode per = this.comboBoxPeriode.getSelectedItem().getBean();
+ per.setPerBookedProject(BookingType.gebucht);
+ dao.save(per);
+ }
+
+
+ private boolean isModelValid() {
+ this.guifld.setBillDate(this.dateBilldate.getValue());
+ this.guifld.setBillText(this.textFieldOrderText.getValue());
+ this.guifld.setCopyTextFromLastBill(this.checkBoxTextLast.getValue());
+ this.guifld.setLineTextExpense(this.textFieldExpenseLine.getValue());
+ this.guifld.setLineTextJourney(this.textFieldJourneyLine.getValue());
+ this.guifld.setLineTextProject(this.textFieldProjectLine.getValue());
+
+ if (this.guifld.getBillDate() == null) {
+ return false;
+ }
+ if (this.guifld.getItemExpense() == null) {
+ return false;
+ }
+ if (this.guifld.getItemJourney() == null) {
+ return false;
+ }
+ if (this.guifld.getItemProject() == null) {
+ return false;
+ }
+
+ return true;
+ }
+
+
+ /**
+ * Event handler delegate method for the {@link XdevButton} {@link #cmdPropose}.
+ *
+ * @see Button.ClickListener#buttonClick(Button.ClickEvent)
+ * @eventHandlerDelegate Do NOT delete, used by UI designer!
+ */
+ private void cmdPropose_buttonClick(final Button.ClickEvent event) {
+ // here we read it....
+ if (this.comboBoxCostAccount.getSelectedItem() == null || this.comboBoxPeriode.getSelectedItem() == null) {
+ Notification.show("Rechnungen generieren", "Bitte Periode wählen", Notification.Type.WARNING_MESSAGE);
+ return;
+ }
+ isModelValid(); //just for text
+
+ final Periode per = this.comboBoxPeriode.getSelectedItem().getBean();
+ final OrderGenerator gen = new OrderGenerator();
+ final List lst = gen.proposeDraft(per, this.guifld);
+
+ if (per.getPerBookedProject().equals(BookingType.gebucht)) {
+ Notification.show("Rechnungsvorschlag", "Für diese Periode wurden bereits Rechnungen generiert!!", Notification.Type.WARNING_MESSAGE);
+ }
+
+ // publish list to grid
+ InitTreeGrid(lst);
+ // this.table.
+ final Collection> lsSize = this.treeGrid.getContainerDataSource().getItemIds();
+ if (lsSize.size() > 0) {
+ this.cmdGenerate.setEnabled(true);
+ } else {
+ this.cmdGenerate.setEnabled(false);
+ }
+
+ }
+
+
+ /**
+ * Event handler delegate method for the {@link XdevComboBox}
+ * {@link #comboBoxCostAccount}.
+ *
+ * @see Property.ValueChangeListener#valueChange(Property.ValueChangeEvent)
+ * @eventHandlerDelegate Do NOT delete, used by UI designer!
+ */
+ private void comboBoxCostAccount_valueChange(final Property.ValueChangeEvent event) {
+ final CostAccount cst = (CostAccount) event.getProperty().getValue();
+ // if (this.comboBoxCostAccount.getSelectedItem() != null) {
+ if (cst != null) {
+ final CostAccount bean = this.comboBoxCostAccount.getSelectedItem().getBean();
+
+ // this.comboBoxPeriode.getContainerDataSource().removeAllItems();
+
+ final XdevBeanItemContainer myList = new XdevBeanItemContainer<>(Periode.class);
+ myList.addAll(new PeriodeDAO().findByCostAccount(bean));
+ this.comboBoxPeriode.setContainerDataSource(myList);
+
+ final Periode beanp = myList.firstItemId();
+ if (beanp != null) {
+ this.comboBoxPeriode.select(beanp);
+ }
+ }
+
+ }
+
+
+ /**
+ * Event handler delegate method for the {@link XdevButton}
+ * {@link #cmdSaveText}.
+ *
+ * @see Button.ClickListener#buttonClick(Button.ClickEvent)
+ * @eventHandlerDelegate Do NOT delete, used by UI designer!
+ */
+ private void cmdSaveText_buttonClick(final Button.ClickEvent event) {
+ //save text to User
+ final RowObjectAddonHandler objman = new RowObjectAddonHandler(this.user.getCsaId(), "CostAccount");
+
+ objman.putRowParameter("billing", "generator", "headerText", this.textFieldOrderText.getValue());
+ objman.putRowParameter("billing", "generator", "lineTextProject", this.textFieldProjectLine.getValue());
+ objman.putRowParameter("billing", "generator", "lineTextExpense", this.textFieldExpenseLine.getValue());
+ objman.putRowParameter("billing", "generator", "lineTextJourney", this.textFieldJourneyLine.getValue());
+
+ objman.putRowParameter("billing", "generator", "cbxLastText", this.checkBoxTextLast.getValue().toString());
+ }
+
+
+ /*
+ * WARNING: Do NOT edit!
The content of this method is always regenerated by
+ * the UI designer.
+ */
+ //
+ private void initUI() {
+ this.horizontalSplitPanel = new XdevHorizontalSplitPanel();
+ this.verticalLayoutLeft = new XdevVerticalLayout();
+ this.panel = new XdevPanel();
+ this.tabSheet = new XdevTabSheet();
+ this.gridLayout = new XdevGridLayout();
+ this.label = new XdevLabel();
+ this.comboBoxCostAccount = new XdevComboBox<>();
+ this.label2 = new XdevLabel();
+ this.comboBoxPeriode = new XdevComboBox<>();
+ this.label3 = new XdevLabel();
+ this.dateBilldate = new XdevPopupDateField();
+ this.checkBoxTextLast = new XdevCheckBox();
+ this.cmdPropose = new XdevButton();
+ this.cmdGenerate = new XdevButton();
+ this.label4 = new XdevLabel();
+ this.gridLayoutTexte = new XdevGridLayout();
+ this.labelInfoToolTip = new XdevLabel();
+ this.label5 = new XdevLabel();
+ this.textFieldOrderText = new XdevTextField();
+ this.label6 = new XdevLabel();
+ this.textFieldProjectLine = new XdevTextField();
+ this.label7 = new XdevLabel();
+ this.textFieldExpenseLine = new XdevTextField();
+ this.label8 = new XdevLabel();
+ this.textFieldJourneyLine = new XdevTextField();
+ this.cmdSaveText = new XdevButton();
+ this.gridLayoutArtikel = new XdevGridLayout();
+ this.label11 = new XdevLabel();
+ this.textFieldItemProject = new XdevTextField();
+ this.label12 = new XdevLabel();
+ this.textFieldItemExpense = new XdevTextField();
+ this.label13 = new XdevLabel();
+ this.textFieldItemJourney = new XdevTextField();
+ this.verticalLayoutRight = new XdevVerticalLayout();
+ this.treeGrid = new XdevTreeTable();
+
+ this.horizontalSplitPanel.setStyleName("large");
+ this.horizontalSplitPanel.setSplitPosition(35.0F, Unit.PERCENTAGE);
+ this.verticalLayoutLeft.setMargin(new MarginInfo(false));
+ this.panel.setCaption("Rechnungen generieren");
+ this.tabSheet.setStyleName("framed");
+ this.label.setValue("Kostenstelle");
+ this.comboBoxCostAccount.setContainerDataSource(CostAccount.class, false);
+ this.label2.setValue("Periode wählen");
+ this.comboBoxPeriode.setContainerDataSource(Periode.class, false);
+ this.label3.setValue("Rechnungsdatum");
+ this.checkBoxTextLast.setCaption("Text von letzer Rechnung");
+ this.cmdPropose.setCaption("Vorschlag generieren");
+ this.cmdGenerate.setCaption("Rechnungen erstellen");
+ this.cmdGenerate.setEnabled(false);
+ this.label4.setIcon(FontAwesome.INFO_CIRCLE);
+ this.label4.setValue("MwSt-Ansatz wird für alle Positionen vom Projekt übernommen!");
+ this.labelInfoToolTip.setIcon(FontAwesome.INFO_CIRCLE);
+ this.labelInfoToolTip.setDescription("Es ist ein Tooltip vorhanden auf den Labeln und dem Button.");
+ this.label5.setDescription(
+ "Rechnungstext - mögliche Platzhalter {proExtReference} {proName}, {proContact}, {csaName}, {perYear}, {perMonth}, {perMonthText}");
+ this.label5.setValue("Textzeile Rechnung");
+ this.label6.setDescription("mögliche Platzhalter: {csaName}, {csaCode}, , {perYear}, {perMonth}, {perMonthText}");
+ this.label6.setValue("Textzeile Dienstleistung");
+ this.label7.setDescription("siehe Dienstleistung");
+ this.label7.setValue("Textzeile Spesen");
+ this.label8.setDescription("siehe Dienstleistung");
+ this.label8.setValue("Textzeile Reisezeit");
+ this.cmdSaveText.setCaption("Texte speichern");
+ this.cmdSaveText.setDescription("Speichert die Texte als persönliche Einstellungen.");
+ this.label11.setValue("Artikel Dienstleistung");
+ this.label12.setValue("Artikel Spesen");
+ this.label13.setValue("Artikel Reisezeit");
+ this.verticalLayoutRight.setMargin(new MarginInfo(false, false, true, false));
+ this.treeGrid.setSelectable(true);
+ this.treeGrid.setMultiSelect(true);
+
+ this.gridLayout.setColumns(3);
+ this.gridLayout.setRows(8);
+ this.label.setSizeUndefined();
+ this.gridLayout.addComponent(this.label, 0, 0);
+ this.comboBoxCostAccount.setSizeUndefined();
+ this.gridLayout.addComponent(this.comboBoxCostAccount, 1, 0);
+ this.label2.setSizeUndefined();
+ this.gridLayout.addComponent(this.label2, 0, 1);
+ this.comboBoxPeriode.setSizeUndefined();
+ this.gridLayout.addComponent(this.comboBoxPeriode, 1, 1);
+ this.label3.setSizeUndefined();
+ this.gridLayout.addComponent(this.label3, 0, 2);
+ this.dateBilldate.setSizeUndefined();
+ this.gridLayout.addComponent(this.dateBilldate, 1, 2);
+ this.checkBoxTextLast.setSizeUndefined();
+ this.gridLayout.addComponent(this.checkBoxTextLast, 1, 3);
+ this.cmdPropose.setSizeUndefined();
+ this.gridLayout.addComponent(this.cmdPropose, 1, 4);
+ this.cmdGenerate.setSizeUndefined();
+ this.gridLayout.addComponent(this.cmdGenerate, 1, 5);
+ this.label4.setWidth(100, Unit.PERCENTAGE);
+ this.label4.setHeight(-1, Unit.PIXELS);
+ this.gridLayout.addComponent(this.label4, 0, 6, 1, 6);
+ final CustomComponent gridLayout_hSpacer = new CustomComponent();
+ gridLayout_hSpacer.setSizeFull();
+ this.gridLayout.addComponent(gridLayout_hSpacer, 2, 0, 2, 6);
+ this.gridLayout.setColumnExpandRatio(2, 1.0F);
+ final CustomComponent gridLayout_vSpacer = new CustomComponent();
+ gridLayout_vSpacer.setSizeFull();
+ this.gridLayout.addComponent(gridLayout_vSpacer, 0, 7, 1, 7);
+ this.gridLayout.setRowExpandRatio(7, 1.0F);
+ this.gridLayoutTexte.setColumns(2);
+ this.gridLayoutTexte.setRows(7);
+ this.labelInfoToolTip.setSizeUndefined();
+ this.gridLayoutTexte.addComponent(this.labelInfoToolTip, 0, 0);
+ this.label5.setSizeUndefined();
+ this.gridLayoutTexte.addComponent(this.label5, 0, 1);
+ this.textFieldOrderText.setWidth(100, Unit.PERCENTAGE);
+ this.textFieldOrderText.setHeight(-1, Unit.PIXELS);
+ this.gridLayoutTexte.addComponent(this.textFieldOrderText, 1, 1);
+ this.label6.setSizeUndefined();
+ this.gridLayoutTexte.addComponent(this.label6, 0, 2);
+ this.textFieldProjectLine.setWidth(100, Unit.PERCENTAGE);
+ this.textFieldProjectLine.setHeight(-1, Unit.PIXELS);
+ this.gridLayoutTexte.addComponent(this.textFieldProjectLine, 1, 2);
+ this.label7.setSizeUndefined();
+ this.gridLayoutTexte.addComponent(this.label7, 0, 3);
+ this.textFieldExpenseLine.setWidth(100, Unit.PERCENTAGE);
+ this.textFieldExpenseLine.setHeight(-1, Unit.PIXELS);
+ this.gridLayoutTexte.addComponent(this.textFieldExpenseLine, 1, 3);
+ this.label8.setSizeUndefined();
+ this.gridLayoutTexte.addComponent(this.label8, 0, 4);
+ this.textFieldJourneyLine.setWidth(100, Unit.PERCENTAGE);
+ this.textFieldJourneyLine.setHeight(-1, Unit.PIXELS);
+ this.gridLayoutTexte.addComponent(this.textFieldJourneyLine, 1, 4);
+ this.cmdSaveText.setSizeUndefined();
+ this.gridLayoutTexte.addComponent(this.cmdSaveText, 1, 5);
+ this.gridLayoutTexte.setColumnExpandRatio(1, 10.0F);
+ final CustomComponent gridLayoutTexte_vSpacer = new CustomComponent();
+ gridLayoutTexte_vSpacer.setSizeFull();
+ this.gridLayoutTexte.addComponent(gridLayoutTexte_vSpacer, 0, 6, 1, 6);
+ this.gridLayoutTexte.setRowExpandRatio(6, 1.0F);
+ this.gridLayoutArtikel.setColumns(2);
+ this.gridLayoutArtikel.setRows(4);
+ this.label11.setSizeUndefined();
+ this.gridLayoutArtikel.addComponent(this.label11, 0, 0);
+ this.textFieldItemProject.setWidth(100, Unit.PERCENTAGE);
+ this.textFieldItemProject.setHeight(-1, Unit.PIXELS);
+ this.gridLayoutArtikel.addComponent(this.textFieldItemProject, 1, 0);
+ this.label12.setSizeUndefined();
+ this.gridLayoutArtikel.addComponent(this.label12, 0, 1);
+ this.textFieldItemExpense.setWidth(100, Unit.PERCENTAGE);
+ this.textFieldItemExpense.setHeight(-1, Unit.PIXELS);
+ this.gridLayoutArtikel.addComponent(this.textFieldItemExpense, 1, 1);
+ this.label13.setSizeUndefined();
+ this.gridLayoutArtikel.addComponent(this.label13, 0, 2);
+ this.textFieldItemJourney.setWidth(100, Unit.PERCENTAGE);
+ this.textFieldItemJourney.setHeight(-1, Unit.PIXELS);
+ this.gridLayoutArtikel.addComponent(this.textFieldItemJourney, 1, 2);
+ this.gridLayoutArtikel.setColumnExpandRatio(1, 10.0F);
+ final CustomComponent gridLayoutArtikel_vSpacer = new CustomComponent();
+ gridLayoutArtikel_vSpacer.setSizeFull();
+ this.gridLayoutArtikel.addComponent(gridLayoutArtikel_vSpacer, 0, 3, 1, 3);
+ this.gridLayoutArtikel.setRowExpandRatio(3, 1.0F);
+ this.gridLayout.setSizeFull();
+ this.tabSheet.addTab(this.gridLayout, "Main", null);
+ this.gridLayoutTexte.setSizeFull();
+ this.tabSheet.addTab(this.gridLayoutTexte, "Texte", null);
+ this.gridLayoutArtikel.setSizeFull();
+ this.tabSheet.addTab(this.gridLayoutArtikel, "Artikel", null);
+ this.tabSheet.setSelectedTab(this.gridLayout);
+ this.tabSheet.setSizeFull();
+ this.panel.setContent(this.tabSheet);
+ this.panel.setSizeFull();
+ this.verticalLayoutLeft.addComponent(this.panel);
+ this.verticalLayoutLeft.setComponentAlignment(this.panel, Alignment.MIDDLE_CENTER);
+ this.verticalLayoutLeft.setExpandRatio(this.panel, 10.0F);
+ this.treeGrid.setSizeFull();
+ this.verticalLayoutRight.addComponent(this.treeGrid);
+ this.verticalLayoutRight.setComponentAlignment(this.treeGrid, Alignment.MIDDLE_CENTER);
+ this.verticalLayoutRight.setExpandRatio(this.treeGrid, 100.0F);
+ this.verticalLayoutLeft.setSizeFull();
+ this.horizontalSplitPanel.setFirstComponent(this.verticalLayoutLeft);
+ this.verticalLayoutRight.setSizeFull();
+ this.horizontalSplitPanel.setSecondComponent(this.verticalLayoutRight);
+ this.horizontalSplitPanel.setSizeFull();
+ this.setContent(this.horizontalSplitPanel);
+ this.setSizeFull();
+
+ this.comboBoxCostAccount.addValueChangeListener(event -> this.comboBoxCostAccount_valueChange(event));
+ this.cmdPropose.addClickListener(event -> this.cmdPropose_buttonClick(event));
+ this.cmdGenerate.addClickListener(event -> this.cmdGenerate_buttonClick(event));
+ this.cmdSaveText.addClickListener(event -> this.cmdSaveText_buttonClick(event));
+ } //
+
+ //
+ private XdevLabel label, label2, label3, label4, labelInfoToolTip, label5, label6, label7, label8, label11, label12,
+ label13;
+ private XdevButton cmdPropose, cmdGenerate, cmdSaveText;
+ private XdevComboBox comboBoxCostAccount;
+ private XdevPanel panel;
+ private XdevTabSheet tabSheet;
+ private XdevGridLayout gridLayout, gridLayoutTexte, gridLayoutArtikel;
+ private XdevHorizontalSplitPanel horizontalSplitPanel;
+ private XdevComboBox comboBoxPeriode;
+ private XdevPopupDateField dateBilldate;
+ private XdevCheckBox checkBoxTextLast;
+ private XdevTreeTable treeGrid;
+ private XdevTextField textFieldOrderText, textFieldProjectLine, textFieldExpenseLine, textFieldJourneyLine,
+ textFieldItemProject, textFieldItemExpense, textFieldItemJourney;
+ private XdevVerticalLayout verticalLayoutLeft, verticalLayoutRight;
+ //
+
+}
diff --git a/src/ch/xwr/seicentobilling/ui/desktop/project/ProjectAllocationPopup.java b/src/ch/xwr/seicentobilling/ui/desktop/project/ProjectAllocationPopup.java
new file mode 100644
index 0000000..8e91e49
--- /dev/null
+++ b/src/ch/xwr/seicentobilling/ui/desktop/project/ProjectAllocationPopup.java
@@ -0,0 +1,362 @@
+package ch.xwr.seicentobilling.ui.desktop.project;
+
+import java.util.Date;
+
+import com.vaadin.data.Property;
+import com.vaadin.data.validator.IntegerRangeValidator;
+import com.vaadin.event.ShortcutAction;
+import com.vaadin.server.FontAwesome;
+import com.vaadin.shared.ui.MarginInfo;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.Notification;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.Window;
+import com.xdev.dal.DAOs;
+import com.xdev.ui.XdevButton;
+import com.xdev.ui.XdevFieldGroup;
+import com.xdev.ui.XdevGridLayout;
+import com.xdev.ui.XdevHorizontalLayout;
+import com.xdev.ui.XdevLabel;
+import com.xdev.ui.XdevPanel;
+import com.xdev.ui.XdevPopupDateField;
+import com.xdev.ui.XdevTextField;
+import com.xdev.ui.XdevView;
+import com.xdev.ui.entitycomponent.combobox.XdevComboBox;
+
+import ch.xwr.seicentobilling.business.LovState;
+import ch.xwr.seicentobilling.business.RowObjectManager;
+import ch.xwr.seicentobilling.business.Seicento;
+import ch.xwr.seicentobilling.dal.CostAccountDAO;
+import ch.xwr.seicentobilling.dal.ProjectAllocationDAO;
+import ch.xwr.seicentobilling.dal.ProjectDAO;
+import ch.xwr.seicentobilling.entities.CostAccount;
+import ch.xwr.seicentobilling.entities.CostAccount_;
+import ch.xwr.seicentobilling.entities.Project;
+import ch.xwr.seicentobilling.entities.ProjectAllocation;
+import ch.xwr.seicentobilling.entities.ProjectAllocation_;
+import ch.xwr.seicentobilling.entities.Project_;
+
+public class ProjectAllocationPopup extends XdevView {
+
+ /**
+ *
+ */
+ public ProjectAllocationPopup() {
+ super();
+ this.initUI();
+
+ this.setHeight(Seicento.calculateThemeHeight(this.getHeight(),UI.getCurrent().getTheme()));
+
+ // State
+ this.comboBoxState.addItems((Object[]) LovState.State.values());
+ //this.comboBoxType.addItems((Object[]) LovCrm.AddressType.values());
+ //this.comboBoxSalutation.addItems((Object[]) LovCrm.Salutation.values());
+
+ // this.comboBoxAccount.addItems((Object[])LovState.Accounts.values());
+ // loadDummyCb();
+
+ // get Parameter
+ final Long beanId = (Long) UI.getCurrent().getSession().getAttribute("beanId");
+ final Long objId = (Long) UI.getCurrent().getSession().getAttribute("objId");
+ ProjectAllocation bean = null;
+ Project obj = null;
+
+ if (beanId == null) {
+
+ CostAccount beanCsa = Seicento.getLoggedInCostAccount();
+ if (beanCsa == null) {
+ beanCsa = new CostAccountDAO().findAll().get(0); //Dev Mode
+ }
+ final ProjectDAO proDao = new ProjectDAO();
+ obj = proDao.find(objId);
+
+ this.cmbCostAccount.clear();
+ this.cmbCostAccount.addItems(new CostAccountDAO().findAllActive());
+
+
+ bean = new ProjectAllocation();
+ bean.setPraState(LovState.State.active);
+ bean.setProject(obj);
+ //act.setCostAccount(beanCsa);
+ bean.setPraStartDate(obj.getProStartDate());
+ bean.setPraEndDate(obj.getProEndDate());
+ bean.setPraRate(obj.getProRate());
+
+
+ } else {
+ final ProjectAllocationDAO dao = new ProjectAllocationDAO();
+ bean = dao.find(beanId.longValue());
+
+ this.cmbCostAccount.clear();
+ this.cmbCostAccount.addItems(new CostAccountDAO().findAllOrderByName());
+
+ }
+
+ setBeanGui(bean);
+
+
+ }
+
+ public static Window getPopupWindow() {
+ final Window win = new Window();
+ //win.setWidth("920");
+ //win.setHeight("610");
+ win.center();
+ win.setModal(true);
+ win.setContent(new ProjectAllocationPopup());
+
+ return win;
+ }
+
+ private void setBeanGui(final ProjectAllocation bean) {
+ // set Bean + Fields
+ this.fieldGroup.setItemDataSource(bean);
+
+ // set RO Fields
+ setROFields();
+
+ //postLoadAccountAction(bean);
+ //this.txtExpText.focus();
+ }
+
+
+ private void setROFields() {
+ this.cmbProject.setEnabled(false);
+// this.cmbPeriode.setEnabled(false);
+ }
+
+ /**
+ * Event handler delegate method for the {@link XdevButton} {@link #cmdCancel}.
+ *
+ * @see Button.ClickListener#buttonClick(Button.ClickEvent)
+ * @eventHandlerDelegate Do NOT delete, used by UI designer!
+ */
+ private void cmdCancel_buttonClick(final Button.ClickEvent event) {
+ this.fieldGroup.discard();
+ ((Window) this.getParent()).close();
+ }
+
+ /**
+ * Event handler delegate method for the {@link XdevButton} {@link #cmdSave}.
+ *
+ * @see Button.ClickListener#buttonClick(Button.ClickEvent)
+ * @eventHandlerDelegate Do NOT delete, used by UI designer!
+ */
+ private void cmdSave_buttonClick(final Button.ClickEvent event) {
+ UI.getCurrent().getSession().setAttribute(String.class, "cmdSave");
+
+ try {
+ this.fieldGroup.save();
+ final RowObjectManager man = new RowObjectManager();
+ man.updateObject(this.fieldGroup.getItemDataSource().getBean().getPraId(),
+ this.fieldGroup.getItemDataSource().getBean().getClass().getSimpleName());
+
+ ((Window) this.getParent()).close();
+ Notification.show("Save clicked", "Daten wurden gespeichert", Notification.Type.TRAY_NOTIFICATION);
+ } catch (final Exception e) {
+ Notification.show("Fehler beim Speichern", e.getMessage(), Notification.Type.ERROR_MESSAGE);
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Event handler delegate method for the {@link XdevPopupDateField}
+ * {@link #datePraEndDate}.
+ *
+ * @see Property.ValueChangeListener#valueChange(Property.ValueChangeEvent)
+ * @eventHandlerDelegate Do NOT delete, used by UI designer!
+ */
+ private void datePraEndDate_valueChange(final Property.ValueChangeEvent event) {
+ validateDateFromTo();
+
+ }
+
+ private void validateDateFromTo() {
+ final Date dateFrom = this.datePraStartDate.getValue();
+ final Date dateTo = this.datePraEndDate.getValue();
+
+ if (dateTo != null) {
+ if (dateFrom != null && dateTo.before(dateFrom)) {
+ this.datePraEndDate.setValue(dateFrom);
+ }
+ }
+
+ }
+
+ /**
+ * Event handler delegate method for the {@link XdevPopupDateField}
+ * {@link #datePraStartDate}.
+ *
+ * @see Property.ValueChangeListener#valueChange(Property.ValueChangeEvent)
+ * @eventHandlerDelegate Do NOT delete, used by UI designer!
+ */
+ private void datePraStartDate_valueChange(final Property.ValueChangeEvent event) {
+ validateDateFromTo();
+ }
+
+ /*
+ * WARNING: Do NOT edit!
The content of this method is always regenerated by
+ * the UI designer.
+ */
+ //
+ private void initUI() {
+ this.panel = new XdevPanel();
+ this.form = new XdevGridLayout();
+ this.lblProject = new XdevLabel();
+ this.cmbProject = new XdevComboBox<>();
+ this.lblCostAccount = new XdevLabel();
+ this.cmbCostAccount = new XdevComboBox<>();
+ this.lblPraStartDate = new XdevLabel();
+ this.datePraStartDate = new XdevPopupDateField();
+ this.lblPraEndDate = new XdevLabel();
+ this.datePraEndDate = new XdevPopupDateField();
+ this.lblPraHours = new XdevLabel();
+ this.txtPraHours = new XdevTextField();
+ this.lblPraIntensityPercent = new XdevLabel();
+ this.txtPraIntensityPercent = new XdevTextField();
+ this.lblPraRate = new XdevLabel();
+ this.txtPraRate = new XdevTextField();
+ this.lblPraRemark = new XdevLabel();
+ this.txtPraRemark = new XdevTextField();
+ this.lblPraState = new XdevLabel();
+ this.comboBoxState = new XdevComboBox<>();
+ this.horizontalLayout = new XdevHorizontalLayout();
+ this.cmdSave = new XdevButton();
+ this.cmdCancel = new XdevButton();
+ this.fieldGroup = new XdevFieldGroup<>(ProjectAllocation.class);
+
+ this.panel.setCaption("Projektressourcen");
+ this.panel.setTabIndex(0);
+ this.lblProject.setValue("Projekt");
+ this.cmbProject.setTabIndex(10);
+ this.cmbProject.setContainerDataSource(Project.class, DAOs.get(ProjectDAO.class).findAll());
+ this.cmbProject.setItemCaptionPropertyId(Project_.proName.getName());
+ this.lblCostAccount.setValue("Kostenstelle");
+ this.cmbCostAccount.setTabIndex(9);
+ this.cmbCostAccount.setRequired(true);
+ this.cmbCostAccount.setItemCaptionFromAnnotation(false);
+ this.cmbCostAccount.setContainerDataSource(CostAccount.class, DAOs.get(CostAccountDAO.class).findAllActive());
+ this.cmbCostAccount.setItemCaptionPropertyId(CostAccount_.csaName.getName());
+ this.lblPraStartDate.setValue("Projektstart");
+ this.datePraStartDate.setTabIndex(2);
+ this.datePraStartDate.setRequired(true);
+ this.lblPraEndDate.setValue("Projektende");
+ this.datePraEndDate.setTabIndex(3);
+ this.lblPraHours.setValue("Stundensoll");
+ this.txtPraHours.setTabIndex(4);
+ this.txtPraHours.setRequired(true);
+ this.txtPraHours.addValidator(new IntegerRangeValidator("Der Wert muss grösser 0 sein!", 1, null));
+ this.lblPraIntensityPercent.setValue("Intensität");
+ this.txtPraIntensityPercent.setTabIndex(5);
+ this.lblPraRate.setValue("Ansatz");
+ this.txtPraRate.setTabIndex(6);
+ this.lblPraRemark.setValue("Bemerkung");
+ this.txtPraRemark.setTabIndex(7);
+ this.lblPraState.setValue("Status");
+ this.comboBoxState.setRequired(true);
+ this.horizontalLayout.setMargin(new MarginInfo(false));
+ this.cmdSave.setIcon(FontAwesome.SAVE);
+ this.cmdSave.setCaption("Speichern");
+ this.cmdSave.setClickShortcut(ShortcutAction.KeyCode.ENTER);
+ this.cmdCancel.setIcon(FontAwesome.CLOSE);
+ this.cmdCancel.setCaption("Abbrechen");
+ this.cmdCancel.setClickShortcut(ShortcutAction.KeyCode.ESCAPE);
+ this.fieldGroup.bind(this.datePraStartDate, ProjectAllocation_.praStartDate.getName());
+ this.fieldGroup.bind(this.datePraEndDate, ProjectAllocation_.praEndDate.getName());
+ this.fieldGroup.bind(this.txtPraHours, ProjectAllocation_.praHours.getName());
+ this.fieldGroup.bind(this.txtPraIntensityPercent, ProjectAllocation_.praIntensityPercent.getName());
+ this.fieldGroup.bind(this.txtPraRate, ProjectAllocation_.praRate.getName());
+ this.fieldGroup.bind(this.txtPraRemark, ProjectAllocation_.praRemark.getName());
+ this.fieldGroup.bind(this.comboBoxState, ProjectAllocation_.praState.getName());
+ this.fieldGroup.bind(this.cmbCostAccount, ProjectAllocation_.costAccount.getName());
+ this.fieldGroup.bind(this.cmbProject, ProjectAllocation_.project.getName());
+
+ this.cmdSave.setSizeUndefined();
+ this.horizontalLayout.addComponent(this.cmdSave);
+ this.horizontalLayout.setComponentAlignment(this.cmdSave, Alignment.MIDDLE_LEFT);
+ this.cmdCancel.setSizeUndefined();
+ this.horizontalLayout.addComponent(this.cmdCancel);
+ this.horizontalLayout.setComponentAlignment(this.cmdCancel, Alignment.MIDDLE_LEFT);
+ this.form.setColumns(4);
+ this.form.setRows(9);
+ this.lblProject.setSizeUndefined();
+ this.form.addComponent(this.lblProject, 0, 0);
+ this.cmbProject.setWidth(100, Unit.PERCENTAGE);
+ this.cmbProject.setHeight(-1, Unit.PIXELS);
+ this.form.addComponent(this.cmbProject, 1, 0);
+ this.lblCostAccount.setSizeUndefined();
+ this.form.addComponent(this.lblCostAccount, 0, 1);
+ this.cmbCostAccount.setWidth(100, Unit.PERCENTAGE);
+ this.cmbCostAccount.setHeight(-1, Unit.PIXELS);
+ this.form.addComponent(this.cmbCostAccount, 1, 1);
+ this.lblPraStartDate.setSizeUndefined();
+ this.form.addComponent(this.lblPraStartDate, 0, 2);
+ this.datePraStartDate.setSizeUndefined();
+ this.form.addComponent(this.datePraStartDate, 1, 2);
+ this.lblPraEndDate.setSizeUndefined();
+ this.form.addComponent(this.lblPraEndDate, 2, 2);
+ this.datePraEndDate.setWidth(100, Unit.PERCENTAGE);
+ this.datePraEndDate.setHeight(-1, Unit.PIXELS);
+ this.form.addComponent(this.datePraEndDate, 3, 2);
+ this.lblPraHours.setSizeUndefined();
+ this.form.addComponent(this.lblPraHours, 0, 3);
+ this.txtPraHours.setSizeUndefined();
+ this.form.addComponent(this.txtPraHours, 1, 3);
+ this.lblPraIntensityPercent.setSizeUndefined();
+ this.form.addComponent(this.lblPraIntensityPercent, 2, 3);
+ this.txtPraIntensityPercent.setWidth(100, Unit.PERCENTAGE);
+ this.txtPraIntensityPercent.setHeight(-1, Unit.PIXELS);
+ this.form.addComponent(this.txtPraIntensityPercent, 3, 3);
+ this.lblPraRate.setSizeUndefined();
+ this.form.addComponent(this.lblPraRate, 0, 4);
+ this.txtPraRate.setSizeUndefined();
+ this.form.addComponent(this.txtPraRate, 1, 4);
+ this.lblPraRemark.setSizeUndefined();
+ this.form.addComponent(this.lblPraRemark, 0, 5);
+ this.txtPraRemark.setWidth(100, Unit.PERCENTAGE);
+ this.txtPraRemark.setHeight(-1, Unit.PIXELS);
+ this.form.addComponent(this.txtPraRemark, 1, 5);
+ this.lblPraState.setSizeUndefined();
+ this.form.addComponent(this.lblPraState, 0, 6);
+ this.comboBoxState.setSizeUndefined();
+ this.form.addComponent(this.comboBoxState, 1, 6);
+ this.horizontalLayout.setSizeUndefined();
+ this.form.addComponent(this.horizontalLayout, 0, 7, 1, 7);
+ this.form.setComponentAlignment(this.horizontalLayout, Alignment.TOP_RIGHT);
+ this.form.setColumnExpandRatio(1, 100.0F);
+ this.form.setColumnExpandRatio(3, 100.0F);
+ final CustomComponent form_vSpacer = new CustomComponent();
+ form_vSpacer.setSizeFull();
+ this.form.addComponent(form_vSpacer, 0, 8, 3, 8);
+ this.form.setRowExpandRatio(8, 1.0F);
+ this.form.setSizeFull();
+ this.panel.setContent(this.form);
+ this.panel.setSizeFull();
+ this.setContent(this.panel);
+ this.setWidth(900, Unit.PIXELS);
+ this.setHeight(520, Unit.PIXELS);
+
+ this.datePraStartDate.addValueChangeListener(event -> this.datePraStartDate_valueChange(event));
+ this.datePraEndDate.addValueChangeListener(event -> this.datePraEndDate_valueChange(event));
+ this.cmdSave.addClickListener(event -> this.cmdSave_buttonClick(event));
+ this.cmdCancel.addClickListener(event -> this.cmdCancel_buttonClick(event));
+ } //
+
+ //
+ private XdevLabel lblProject, lblCostAccount, lblPraStartDate, lblPraEndDate, lblPraHours, lblPraIntensityPercent,
+ lblPraRate, lblPraRemark, lblPraState;
+ private XdevButton cmdSave, cmdCancel;
+ private XdevComboBox cmbCostAccount;
+ private XdevHorizontalLayout horizontalLayout;
+ private XdevPopupDateField datePraStartDate, datePraEndDate;
+ private XdevComboBox> comboBoxState;
+ private XdevPanel panel;
+ private XdevGridLayout form;
+ private XdevTextField txtPraHours, txtPraIntensityPercent, txtPraRate, txtPraRemark;
+ private XdevComboBox cmbProject;
+ private XdevFieldGroup fieldGroup;
+ //
+
+}
diff --git a/src/ch/xwr/seicentobilling/ui/desktop/project/ProjectAllocationPopup.ui.xml b/src/ch/xwr/seicentobilling/ui/desktop/project/ProjectAllocationPopup.ui.xml
new file mode 100644
index 0000000..c1f3f73
--- /dev/null
+++ b/src/ch/xwr/seicentobilling/ui/desktop/project/ProjectAllocationPopup.ui.xml
@@ -0,0 +1,133 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ valueChange.valueChange
+
+
+
+
+
+
+ valueChange.valueChange
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ click.buttonClick
+
+
+
+ click.buttonClick
+
+
+
+
+
+
diff --git a/src/ch/xwr/seicentobilling/ui/desktop/project/ProjectLookupPopup.java b/src/ch/xwr/seicentobilling/ui/desktop/project/ProjectLookupPopup.java
index 0d88621..2186e69 100644
--- a/src/ch/xwr/seicentobilling/ui/desktop/project/ProjectLookupPopup.java
+++ b/src/ch/xwr/seicentobilling/ui/desktop/project/ProjectLookupPopup.java
@@ -1,6 +1,5 @@
package ch.xwr.seicentobilling.ui.desktop.project;
-import com.vaadin.event.ItemClickEvent;
import com.vaadin.event.ShortcutAction;
import com.vaadin.shared.ui.MarginInfo;
import com.vaadin.ui.Alignment;
@@ -11,6 +10,7 @@
import com.xdev.ui.XdevButton;
import com.xdev.ui.XdevHorizontalLayout;
import com.xdev.ui.XdevPanel;
+import com.xdev.ui.XdevTabSheet;
import com.xdev.ui.XdevVerticalLayout;
import com.xdev.ui.XdevView;
import com.xdev.ui.entitycomponent.table.XdevTable;
@@ -22,14 +22,19 @@
import ch.xwr.seicentobilling.business.Seicento;
import ch.xwr.seicentobilling.dal.CostAccountDAO;
+import ch.xwr.seicentobilling.dal.ProjectAllocationDAO;
import ch.xwr.seicentobilling.dal.ProjectDAO;
import ch.xwr.seicentobilling.entities.CostAccount;
+import ch.xwr.seicentobilling.entities.CostAccount_;
import ch.xwr.seicentobilling.entities.Customer_;
import ch.xwr.seicentobilling.entities.Project;
+import ch.xwr.seicentobilling.entities.ProjectAllocation;
+import ch.xwr.seicentobilling.entities.ProjectAllocation_;
import ch.xwr.seicentobilling.entities.Project_;
public class ProjectLookupPopup extends XdevView {
- private Project _proBean = null;
+ //private final Project _proBean = null;
+ private boolean allowNullSelection = false;
/**
*
@@ -45,10 +50,24 @@ public ProjectLookupPopup() {
setDefaultFilter();
+ setDefaultFilter2();
//this.table.focus();
this.containerFilterComponent.getSearchTextField().focus();
}
+ private void setDefaultFilter2() {
+ CostAccount bean = Seicento.getLoggedInCostAccount();
+ if (bean == null) {
+ bean = new CostAccountDAO().findAll().get(0); // Dev Mode
+ }
+
+ //final LovState.State[] valState = new LovState.State[] { LovState.State.active };
+ final CostAccount[] val2 = new CostAccount[] { bean };
+ final FilterData[] fd = new FilterData[] { new FilterData("costAccount", new FilterOperator.Is(), val2)};
+
+ this.containerFilterComponent2.setFilterData(fd);
+ }
+
private void setDefaultFilter() {
CostAccount bean = Seicento.getLoggedInCostAccount();
if (bean == null) {
@@ -93,6 +112,13 @@ private void btnSelect_buttonClick(final Button.ClickEvent event) {
UI.getCurrent().getSession().setAttribute("beanId", beanId.getProId());
((Window) this.getParent()).close();
+ } else {
+ if (isAllowNullSelection()) {
+ UI.getCurrent().getSession().setAttribute("beanId", -1L);
+
+ ((Window) this.getParent()).close();
+
+ }
}
}
@@ -103,24 +129,46 @@ private void btnSelect_buttonClick(final Button.ClickEvent event) {
* @eventHandlerDelegate Do NOT delete, used by UI designer!
*/
private void btnCancel_buttonClick(final Button.ClickEvent event) {
+ UI.getCurrent().getSession().setAttribute("beanId", 0L);
((Window) this.getParent()).close();
}
/**
- * Event handler delegate method for the {@link XdevTable} {@link #table}.
+ * Event handler delegate method for the {@link XdevButton} {@link #btnSelect2}.
*
- * @see ItemClickEvent.ItemClickListener#itemClick(ItemClickEvent)
+ * @see Button.ClickListener#buttonClick(Button.ClickEvent)
* @eventHandlerDelegate Do NOT delete, used by UI designer!
*/
- private void table_itemClick(final ItemClickEvent event) {
- if (this.table.getSelectedItem() != null) {
- this._proBean = this.table.getSelectedItem().getBean();
+ private void btnSelect2_buttonClick(final Button.ClickEvent event) {
+ if (this.table2.getVisibleItemIds().size() == 1) {
+ this.table2.select(this.table2.firstItemId());
}
- if (event.isDoubleClick() && this._proBean != null) {
- UI.getCurrent().getSession().setAttribute("beanId", this._proBean.getProId());
+
+ if (this.table2.getSelectedItem() != null) {
+ final Project beanId = this.table2.getSelectedItem().getBean().getProject();
+ UI.getCurrent().getSession().setAttribute("beanId", beanId.getProId());
((Window) this.getParent()).close();
+ } else {
+ if (isAllowNullSelection()) {
+ UI.getCurrent().getSession().setAttribute("beanId", -1L);
+
+ ((Window) this.getParent()).close();
+
+ }
}
+
+ }
+
+ /**
+ * Event handler delegate method for the {@link XdevButton} {@link #btnCancel2}.
+ *
+ * @see Button.ClickListener#buttonClick(Button.ClickEvent)
+ * @eventHandlerDelegate Do NOT delete, used by UI designer!
+ */
+ private void btnCancel2_buttonClick(final Button.ClickEvent event) {
+ UI.getCurrent().getSession().setAttribute("beanId", 0L);
+ ((Window) this.getParent()).close();
}
/*
@@ -130,15 +178,24 @@ private void table_itemClick(final ItemClickEvent event) {
//
private void initUI() {
this.panel = new XdevPanel();
+ this.tabSheet = new XdevTabSheet();
this.verticalLayout = new XdevVerticalLayout();
this.containerFilterComponent = new XdevContainerFilterComponent();
this.table = new XdevTable<>();
this.horizontalLayout = new XdevHorizontalLayout();
this.btnSelect = new XdevButton();
this.btnCancel = new XdevButton();
+ this.verticalLayout2 = new XdevVerticalLayout();
+ this.containerFilterComponent2 = new XdevContainerFilterComponent();
+ this.table2 = new XdevTable<>();
+ this.horizontalLayout2 = new XdevHorizontalLayout();
+ this.btnSelect2 = new XdevButton();
+ this.btnCancel2 = new XdevButton();
+ this.setResponsive(true);
this.panel.setCaption("Lookup Projekt");
this.panel.setTabIndex(0);
+ this.tabSheet.setStyleName("framed");
this.containerFilterComponent.setPrefixMatchOnly(false);
this.table.setColumnReorderingAllowed(true);
this.table.setPageLength(10);
@@ -163,59 +220,126 @@ private void initUI() {
this.table.setColumnCollapsed("proHours", true);
this.table.setColumnHeader("proIntensityPercent", "Auslastung");
this.table.setColumnCollapsed("proIntensityPercent", true);
- this.horizontalLayout.setMargin(new MarginInfo(false, true, false, true));
+ this.horizontalLayout.setMargin(new MarginInfo(false, true, true, true));
this.btnSelect.setCaption("Übernehmen");
this.btnSelect.setClickShortcut(ShortcutAction.KeyCode.ENTER);
this.btnCancel.setCaption("Schliessen");
this.btnCancel.setClickShortcut(ShortcutAction.KeyCode.ESCAPE);
+ this.containerFilterComponent2.setPrefixMatchOnly(false);
+ this.table2.setColumnReorderingAllowed(true);
+ this.table2.setPageLength(10);
+ this.table2.setColumnCollapsingAllowed(true);
+ this.table2.setContainerDataSource(ProjectAllocation.class,
+ DAOs.get(ProjectAllocationDAO.class).findAllActiveProjects(),
+ NestedProperty.of(ProjectAllocation_.project, Project_.proName),
+ NestedProperty.of("project.customer.shortname", String.class),
+ NestedProperty.of(ProjectAllocation_.costAccount, CostAccount_.csaName),
+ NestedProperty.of(ProjectAllocation_.project, Project_.proExtReference));
+ this.table2.setVisibleColumns(NestedProperty.path(ProjectAllocation_.project, Project_.proName),
+ "project.customer.shortname", NestedProperty.path(ProjectAllocation_.costAccount, CostAccount_.csaName),
+ NestedProperty.path(ProjectAllocation_.project, Project_.proExtReference),
+ ProjectAllocation_.praStartDate.getName(), ProjectAllocation_.praEndDate.getName(),
+ ProjectAllocation_.praHours.getName(), ProjectAllocation_.praRate.getName(),
+ ProjectAllocation_.praIntensityPercent.getName(), ProjectAllocation_.praRemark.getName());
+ this.table2.setConverter("praStartDate", ConverterBuilder.stringToDate().dateOnly().build());
+ this.table2.setConverter("praEndDate", ConverterBuilder.stringToDate().dateOnly().build());
+ this.table2.setConverter("praHours", ConverterBuilder.stringToDouble().build());
+ this.table2.setColumnCollapsed("praHours", true);
+ this.table2.setColumnCollapsed("praRate", true);
+ this.table2.setColumnCollapsed("praIntensityPercent", true);
+ this.table2.setColumnCollapsed("praRemark", true);
+ this.horizontalLayout2.setMargin(new MarginInfo(false, true, true, true));
+ this.btnSelect2.setCaption("Übernehmen");
+ this.btnSelect2.setClickShortcut(ShortcutAction.KeyCode.ENTER);
+ this.btnCancel2.setCaption("Schliessen");
+ this.btnCancel2.setClickShortcut(ShortcutAction.KeyCode.ESCAPE);
this.containerFilterComponent.setContainer(this.table.getBeanContainerDataSource(), "proName", "costAccount",
"customer", "proState");
this.containerFilterComponent.setSearchableProperties("proName", "proExtReference");
+ this.containerFilterComponent2.setContainer(this.table2.getBeanContainerDataSource(), "costAccount", "praStartDate",
+ "praEndDate");
+ this.containerFilterComponent2.setSearchableProperties("praRemark", "costAccount.csaCode", "project.proName",
+ "project.proExtReference");
- this.btnSelect.setWidth(-1, Unit.PIXELS);
- this.btnSelect.setHeight(100, Unit.PERCENTAGE);
+ this.btnSelect.setSizeUndefined();
this.horizontalLayout.addComponent(this.btnSelect);
this.horizontalLayout.setComponentAlignment(this.btnSelect, Alignment.MIDDLE_CENTER);
- this.btnCancel.setWidth(-1, Unit.PIXELS);
- this.btnCancel.setHeight(100, Unit.PERCENTAGE);
+ this.btnCancel.setSizeUndefined();
this.horizontalLayout.addComponent(this.btnCancel);
this.horizontalLayout.setComponentAlignment(this.btnCancel, Alignment.MIDDLE_CENTER);
this.horizontalLayout.setExpandRatio(this.btnCancel, 10.0F);
- this.containerFilterComponent.setWidth(100, Unit.PERCENTAGE);
- this.containerFilterComponent.setHeight(-1, Unit.PIXELS);
+ this.containerFilterComponent.setSizeFull();
this.verticalLayout.addComponent(this.containerFilterComponent);
this.verticalLayout.setComponentAlignment(this.containerFilterComponent, Alignment.MIDDLE_LEFT);
+ this.verticalLayout.setExpandRatio(this.containerFilterComponent, 10.0F);
this.table.setWidth(100, Unit.PERCENTAGE);
- this.table.setHeight(320, Unit.PIXELS);
+ this.table.setHeight(340, Unit.PIXELS);
this.verticalLayout.addComponent(this.table);
this.verticalLayout.setComponentAlignment(this.table, Alignment.MIDDLE_LEFT);
- this.verticalLayout.setExpandRatio(this.table, 50.0F);
+ this.verticalLayout.setExpandRatio(this.table, 10.0F);
this.horizontalLayout.setWidth(-1, Unit.PIXELS);
this.horizontalLayout.setHeight(100, Unit.PERCENTAGE);
this.verticalLayout.addComponent(this.horizontalLayout);
this.verticalLayout.setComponentAlignment(this.horizontalLayout, Alignment.MIDDLE_CENTER);
- this.verticalLayout.setExpandRatio(this.horizontalLayout, 30.0F);
+ this.verticalLayout.setExpandRatio(this.horizontalLayout, 10.0F);
+ this.btnSelect2.setSizeUndefined();
+ this.horizontalLayout2.addComponent(this.btnSelect2);
+ this.horizontalLayout2.setComponentAlignment(this.btnSelect2, Alignment.MIDDLE_CENTER);
+ this.btnCancel2.setSizeUndefined();
+ this.horizontalLayout2.addComponent(this.btnCancel2);
+ this.horizontalLayout2.setComponentAlignment(this.btnCancel2, Alignment.MIDDLE_CENTER);
+ this.horizontalLayout2.setExpandRatio(this.btnCancel2, 10.0F);
+ this.containerFilterComponent2.setSizeFull();
+ this.verticalLayout2.addComponent(this.containerFilterComponent2);
+ this.verticalLayout2.setComponentAlignment(this.containerFilterComponent2, Alignment.MIDDLE_LEFT);
+ this.verticalLayout2.setExpandRatio(this.containerFilterComponent2, 10.0F);
+ this.table2.setWidth(100, Unit.PERCENTAGE);
+ this.table2.setHeight(340, Unit.PIXELS);
+ this.verticalLayout2.addComponent(this.table2);
+ this.verticalLayout2.setComponentAlignment(this.table2, Alignment.MIDDLE_LEFT);
+ this.verticalLayout2.setExpandRatio(this.table2, 10.0F);
+ this.horizontalLayout2.setWidth(-1, Unit.PIXELS);
+ this.horizontalLayout2.setHeight(100, Unit.PERCENTAGE);
+ this.verticalLayout2.addComponent(this.horizontalLayout2);
+ this.verticalLayout2.setComponentAlignment(this.horizontalLayout2, Alignment.MIDDLE_CENTER);
+ this.verticalLayout2.setExpandRatio(this.horizontalLayout2, 10.0F);
this.verticalLayout.setSizeFull();
- this.panel.setContent(this.verticalLayout);
- this.panel.setWidth(100, Unit.PERCENTAGE);
- this.panel.setHeight(-1, Unit.PIXELS);
+ this.tabSheet.addTab(this.verticalLayout, "Main", null);
+ this.verticalLayout2.setSizeFull();
+ this.tabSheet.addTab(this.verticalLayout2, "Ressourcen", null);
+ this.tabSheet.setSelectedTab(this.verticalLayout);
+ this.tabSheet.setWidth(100, Unit.PERCENTAGE);
+ this.tabSheet.setHeight(-1, Unit.PIXELS);
+ this.panel.setContent(this.tabSheet);
+ this.panel.setSizeFull();
this.setContent(this.panel);
- this.setWidth(760, Unit.PIXELS);
- this.setHeight(520, Unit.PIXELS);
+ this.setWidth(900, Unit.PIXELS);
+ this.setHeight(580, Unit.PIXELS);
- this.table.addItemClickListener(event -> this.table_itemClick(event));
this.btnSelect.addClickListener(event -> this.btnSelect_buttonClick(event));
this.btnCancel.addClickListener(event -> this.btnCancel_buttonClick(event));
+ this.btnSelect2.addClickListener(event -> this.btnSelect2_buttonClick(event));
+ this.btnCancel2.addClickListener(event -> this.btnCancel2_buttonClick(event));
} //
+ public boolean isAllowNullSelection() {
+ return this.allowNullSelection;
+ }
+
+ public void setAllowNullSelection(final boolean allowNullSelection) {
+ this.allowNullSelection = allowNullSelection;
+ }
+
//
- private XdevButton btnSelect, btnCancel;
- private XdevHorizontalLayout horizontalLayout;
+ private XdevButton btnSelect, btnCancel, btnSelect2, btnCancel2;
+ private XdevTable table2;
+ private XdevHorizontalLayout horizontalLayout, horizontalLayout2;
private XdevTable table;
private XdevPanel panel;
- private XdevVerticalLayout verticalLayout;
- private XdevContainerFilterComponent containerFilterComponent;
+ private XdevTabSheet tabSheet;
+ private XdevVerticalLayout verticalLayout, verticalLayout2;
+ private XdevContainerFilterComponent containerFilterComponent, containerFilterComponent2;
//
}
diff --git a/src/ch/xwr/seicentobilling/ui/desktop/project/ProjectLookupPopup.ui.xml b/src/ch/xwr/seicentobilling/ui/desktop/project/ProjectLookupPopup.ui.xml
index 26e9f01..78ae426 100644
--- a/src/ch/xwr/seicentobilling/ui/desktop/project/ProjectLookupPopup.ui.xml
+++ b/src/ch/xwr/seicentobilling/ui/desktop/project/ProjectLookupPopup.ui.xml
@@ -5,9 +5,11 @@
+
+
@@ -15,47 +17,91 @@
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- itemClick.itemClick
-
-
-
-
-
- click.buttonClick
-
-
-
- click.buttonClick
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ click.buttonClick
+
+
+
+ click.buttonClick
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ click.buttonClick
+
+
+
+ click.buttonClick
+
+
+
+
diff --git a/src/ch/xwr/seicentobilling/ui/phone/AttachmentPopup.java b/src/ch/xwr/seicentobilling/ui/phone/AttachmentPopup.java
index f598049..77d53c8 100644
--- a/src/ch/xwr/seicentobilling/ui/phone/AttachmentPopup.java
+++ b/src/ch/xwr/seicentobilling/ui/phone/AttachmentPopup.java
@@ -135,11 +135,11 @@ public void uploadSucceeded(final SucceededEvent event) {
AttachmentPopup.this.fio = rec.getFiup();
AttachmentPopup.this.mimeType = rec.getMimeType();
- if (rec.getFiup().length() > (rec.getMaxImageSize() * 2)) {
+ if (rec.getFiup().length() > (rec.getMaxImageSize() * 4)) {
AttachmentPopup.this.upload.setEnabled(true);
AttachmentPopup.this.labelStatus.setValue("Datei ist zu gross!");
- final int ikb = rec.getMaxImageSize() * 2 / 1024;
+ final int ikb = rec.getMaxImageSize() * 4 / 1024;
Notification.show("Datei ist zu gross", "Max Size: " + ikb + " KB " + rec.getFiup().getName(),Type.TRAY_NOTIFICATION);
} else {