diff --git a/src/main/java/info/bukova/isspst/Constants.java b/src/main/java/info/bukova/isspst/Constants.java index c32d04da..52224642 100644 --- a/src/main/java/info/bukova/isspst/Constants.java +++ b/src/main/java/info/bukova/isspst/Constants.java @@ -36,7 +36,7 @@ import java.util.Map; public class Constants { - public final static long DB_VERSION = 6; + public final static long DB_VERSION = 7; public final static String DEF_ADMIN = "admin"; public final static String DEF_ADMIN_PASSWD = "admin"; diff --git a/src/main/java/info/bukova/isspst/data/RequirementBase.java b/src/main/java/info/bukova/isspst/data/RequirementBase.java index 6451f5d4..ee4c799f 100644 --- a/src/main/java/info/bukova/isspst/data/RequirementBase.java +++ b/src/main/java/info/bukova/isspst/data/RequirementBase.java @@ -63,6 +63,8 @@ public class RequirementBase extends BaseData implements FilterableRequirement, @JoinColumn(name = "SEASON_ID") @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) private Season season; + @Column(name = "APPROVE_DATE") + private Date approveDate; public RequirementBase() { authorization = new ArrayList(); @@ -166,4 +168,12 @@ public class RequirementBase extends BaseData implements FilterableRequirement, public void setSeason(Season season) { this.season = season; } + + public Date getApproveDate() { + return approveDate; + } + + public void setApproveDate(Date approveDate) { + this.approveDate = approveDate; + } } diff --git a/src/main/java/info/bukova/isspst/data/TripBillApproval.java b/src/main/java/info/bukova/isspst/data/TripBillApproval.java index 9733627d..c94d1942 100644 --- a/src/main/java/info/bukova/isspst/data/TripBillApproval.java +++ b/src/main/java/info/bukova/isspst/data/TripBillApproval.java @@ -22,8 +22,6 @@ public class TripBillApproval extends RequirementBase { @Transient private boolean billForPassenger; @Transient - private Date approveDate; - @Transient private Date tripDate; public boolean isBillForPassenger() { @@ -42,14 +40,6 @@ public class TripBillApproval extends RequirementBase { this.tripDate = tripDate; } - public Date getApproveDate() { - return approveDate; - } - - public void setApproveDate(Date approveDate) { - this.approveDate = approveDate; - } - @Override public String getNumser() { diff --git a/src/main/java/info/bukova/isspst/filters/TripBillApprovalFilter.java b/src/main/java/info/bukova/isspst/filters/TripBillApprovalFilter.java index ea9b4e54..0775ae8e 100644 --- a/src/main/java/info/bukova/isspst/filters/TripBillApprovalFilter.java +++ b/src/main/java/info/bukova/isspst/filters/TripBillApprovalFilter.java @@ -54,7 +54,7 @@ public class TripBillApprovalFilter implements Filter boolean foundPaid = BooleanUtils.isEqualByBooleanValue(item.getBill().getPaid(), condition.getBill().getPaid()); boolean foundPaidDate = DateTimeUtils.isEqualByDateForFilter(item.getBill().getPaidDate(), condition.getBill().getPaidDate()); boolean foundPassenger = (item.getBill().getOwnedBy() != item.getBill().getRequirement().getOwnedBy()) == condition.isBillForPassenger(); - boolean foundApproveDate = DateTimeUtils.isEqualByDateForFilter(item.getLastApproveDate(), condition.getApproveDate()); + boolean foundApproveDate = DateTimeUtils.isEqualByDateForFilter(item.getApproveDate(), condition.getApproveDate()); boolean foundTripDate = DateTimeUtils.isEqualByDateForFilter(item.getBill().getRequirement().getTripDate(), condition.getTripDate()); return foundNumser && foundReqDate && foundDescription && foundFrom && foundTo && foundWorkgroup && foundCentre && foundOwner && foundPaid && foundPaidDate && foundPassenger && foundApproveDate && foundTripDate; diff --git a/src/main/java/info/bukova/isspst/services/dbinfo/DbInfoServiceImpl.java b/src/main/java/info/bukova/isspst/services/dbinfo/DbInfoServiceImpl.java index c757edac..38ca8c06 100644 --- a/src/main/java/info/bukova/isspst/services/dbinfo/DbInfoServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/dbinfo/DbInfoServiceImpl.java @@ -1,9 +1,20 @@ package info.bukova.isspst.services.dbinfo; import info.bukova.isspst.Constants; +import info.bukova.isspst.dao.BaseDao; +import info.bukova.isspst.dao.RequirementDao; +import info.bukova.isspst.dao.TripBillApprovalDao; +import info.bukova.isspst.dao.TripRequirementDao; import info.bukova.isspst.data.DbInfo; +import info.bukova.isspst.data.RequirementBase; +import info.bukova.isspst.data.RequirementState; import info.bukova.isspst.services.AbstractService; +import info.bukova.isspst.services.requirement.RequirementBaseService; +import info.bukova.isspst.services.requirement.RequirementService; +import info.bukova.isspst.services.requirement.TripRequirementService; +import info.bukova.isspst.services.tripbill.TripBillApprovalService; import org.hibernate.SQLQuery; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; @@ -11,6 +22,20 @@ import java.util.List; public class DbInfoServiceImpl extends AbstractService implements DbInfoService { + @Autowired + private TripBillApprovalService tripBillApprovalService; + @Autowired + private TripBillApprovalDao tripBillApprovalDao; + @Autowired + private TripRequirementService tripRequirement; + @Autowired + private TripRequirementDao tripRequirementDao; + @Autowired + private RequirementService requirementService; + @Autowired + private RequirementDao requirementDao; + + private DbInfo getDbInfo() { DbInfo dbInfo = null; @@ -211,10 +236,26 @@ public class DbInfoServiceImpl extends AbstractService implements DbInfo sq.executeUpdate(); } + if (dbVersion < 7) { + setApproveDate((RequirementBaseService)tripBillApprovalService, (BaseDao)tripBillApprovalDao); + setApproveDate((RequirementBaseService)tripRequirement, (BaseDao)tripRequirementDao); + setApproveDate((RequirementBaseService)requirementService, (BaseDao)requirementDao); + } + this.updateDatabaseVersion(); } } + private void setApproveDate(RequirementBaseService service, BaseDao daoReq) { + for (RequirementBase req : service.getAll()) { + if (req.getState() == RequirementState.APPROVED) { + service.loadAuthItems(req); + req.setApproveDate(req.getLastApproveDate()); + daoReq.modify(req); + } + } + } + @Override @Transactional public void updateDatabaseVersion() diff --git a/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java b/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java index 08cb7b04..2dd12d69 100644 --- a/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java @@ -289,6 +289,7 @@ public abstract class RequirementBaseServiceImpl exte if (getNextWorkflow(e) == null) { e.setState(RequirementState.APPROVED); + e.setApproveDate(approveDate); } else { e.setState(RequirementState.PARTIALLY); } diff --git a/src/main/java/info/bukova/isspst/ui/tripbill/TripBillListAll.java b/src/main/java/info/bukova/isspst/ui/tripbill/TripBillListAll.java index 19219a17..946f4767 100644 --- a/src/main/java/info/bukova/isspst/ui/tripbill/TripBillListAll.java +++ b/src/main/java/info/bukova/isspst/ui/tripbill/TripBillListAll.java @@ -20,12 +20,7 @@ public class TripBillListAll extends TripBillListBase { @Override protected List getListFromService() { try { - List list = getReqService().getAll(); - for (TripBillApproval item : list) - { - getReqService().loadAuthItems(item); - } - return list; + return getReqService().getAll(); } catch (AccessDeniedException e) { BindUtils.postGlobalCommand(null, null, "disableAll", null); return new ArrayList(); diff --git a/src/main/java/info/bukova/isspst/ui/tripbill/TripBillListCentre.java b/src/main/java/info/bukova/isspst/ui/tripbill/TripBillListCentre.java index 1ede9888..9a6f868a 100644 --- a/src/main/java/info/bukova/isspst/ui/tripbill/TripBillListCentre.java +++ b/src/main/java/info/bukova/isspst/ui/tripbill/TripBillListCentre.java @@ -20,12 +20,7 @@ public class TripBillListCentre extends TripBillListBase { @Override protected List getListFromService() { try { - List list = getReqService().getCentreReq(); - for (TripBillApproval item : list) - { - getReqService().loadAuthItems(item); - } - return list; + return getReqService().getCentreReq(); } catch (AccessDeniedException e) { BindUtils.postGlobalCommand(null, null, "disableCentre", null); return new ArrayList(); diff --git a/src/main/java/info/bukova/isspst/ui/tripbill/TripBillListWorkgroup.java b/src/main/java/info/bukova/isspst/ui/tripbill/TripBillListWorkgroup.java index 02660a73..aee340bd 100644 --- a/src/main/java/info/bukova/isspst/ui/tripbill/TripBillListWorkgroup.java +++ b/src/main/java/info/bukova/isspst/ui/tripbill/TripBillListWorkgroup.java @@ -20,12 +20,7 @@ public class TripBillListWorkgroup extends TripBillListBase { @Override protected List getListFromService() { try { - List list = getReqService().getWorkgroupReq(); - for (TripBillApproval item : list) - { - getReqService().loadAuthItems(item); - } - return list; + return getReqService().getWorkgroupReq(); } catch (AccessDeniedException e) { BindUtils.postGlobalCommand(null, null, "disableWorkgroup", null); return new ArrayList(); diff --git a/src/main/webapp/WEB-INF/reports/tripBills.jasper b/src/main/webapp/WEB-INF/reports/tripBills.jasper index 2497cc65..37b667c4 100644 Binary files a/src/main/webapp/WEB-INF/reports/tripBills.jasper and b/src/main/webapp/WEB-INF/reports/tripBills.jasper differ diff --git a/src/main/webapp/WEB-INF/reports/tripBills.jrxml b/src/main/webapp/WEB-INF/reports/tripBills.jrxml index 0a9517dc..afc324a9 100644 --- a/src/main/webapp/WEB-INF/reports/tripBills.jrxml +++ b/src/main/webapp/WEB-INF/reports/tripBills.jrxml @@ -1,7 +1,9 @@ - + + + @@ -19,7 +21,7 @@ <band height="23" splitType="Stretch"> <staticText> - <reportElement x="203" y="0" width="212" height="20" uuid="bc6cd7eb-bb1a-4114-b37d-ac64e951ca84"/> + <reportElement x="0" y="0" width="550" height="20" uuid="bc6cd7eb-bb1a-4114-b37d-ac64e951ca84"/> <textElement textAlignment="Center"> <font size="14" isBold="true" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1250" isPdfEmbedded="true"/> </textElement> @@ -75,7 +77,7 @@ <text><![CDATA[Cíl]]></text> </staticText> <staticText> - <reportElement x="358" y="0" width="100" height="24" uuid="9eddb29b-3024-4f0d-90f5-e8e896add7c0"> + <reportElement x="358" y="0" width="97" height="24" uuid="9eddb29b-3024-4f0d-90f5-e8e896add7c0"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="df75863b-fbfb-4332-a9fa-dbacf818e85c"/> </reportElement> <textElement verticalAlignment="Middle"> @@ -84,7 +86,7 @@ <text><![CDATA[Žadatel]]></text> </staticText> <staticText> - <reportElement x="460" y="0" width="40" height="24" uuid="783dc31a-7f32-44d1-b455-6e8d25d5a943"> + <reportElement x="451" y="0" width="45" height="24" uuid="783dc31a-7f32-44d1-b455-6e8d25d5a943"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="ef5d98d4-a0b8-4098-be82-3ea9a1bc2213"/> </reportElement> <textElement verticalAlignment="Middle"> @@ -155,7 +157,7 @@ <textFieldExpression><![CDATA[$F{bill.requirement.to}]]></textFieldExpression> </textField> <textField> - <reportElement x="358" y="1" width="100" height="12" uuid="3a197226-28d7-4384-b74a-12e748bd0967"> + <reportElement x="358" y="1" width="97" height="12" uuid="3a197226-28d7-4384-b74a-12e748bd0967"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="df75863b-fbfb-4332-a9fa-dbacf818e85c"/> </reportElement> <textElement> @@ -164,7 +166,7 @@ <textFieldExpression><![CDATA[$F{bill.ownedBy}]]></textFieldExpression> </textField> <textField pattern="###0.00;-###0.00"> - <reportElement x="460" y="1" width="40" height="12" uuid="02a5e327-b7ab-4841-a895-0d285770e3c8"> + <reportElement x="451" y="1" width="45" height="12" uuid="02a5e327-b7ab-4841-a895-0d285770e3c8"> <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="ef5d98d4-a0b8-4098-be82-3ea9a1bc2213"/> </reportElement> <textElement textAlignment="Right"> diff --git a/src/main/webapp/WEB-INF/reports/tripBillsNP.jasper b/src/main/webapp/WEB-INF/reports/tripBillsNP.jasper index a58c2c5d..32d8b93d 100644 Binary files a/src/main/webapp/WEB-INF/reports/tripBillsNP.jasper and b/src/main/webapp/WEB-INF/reports/tripBillsNP.jasper differ diff --git a/src/main/webapp/WEB-INF/reports/tripBillsNP.jrxml b/src/main/webapp/WEB-INF/reports/tripBillsNP.jrxml index 0265782c..6dc9f0cc 100644 --- a/src/main/webapp/WEB-INF/reports/tripBillsNP.jrxml +++ b/src/main/webapp/WEB-INF/reports/tripBillsNP.jrxml @@ -1,7 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Created with Jaspersoft Studio version 6.6.0.final using JasperReports Library version 6.6.0 --> <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="TripBills" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="b63eddc4-7326-45c4-99b4-fc35d6e98179"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/> + <property name="ireport.zoom" value="1.4641000000000006"/> + <property name="ireport.x" value="0"/> + <property name="ireport.y" value="0"/> <queryString> <![CDATA[]]> </queryString> @@ -19,7 +21,7 @@ <title> <band height="23" splitType="Stretch"> <staticText> - <reportElement x="203" y="0" width="237" height="20" uuid="bc6cd7eb-bb1a-4114-b37d-ac64e951ca84"/> + <reportElement x="0" y="0" width="552" height="20" uuid="bc6cd7eb-bb1a-4114-b37d-ac64e951ca84"/> <textElement textAlignment="Center"> <font size="14" isBold="true" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1250" isPdfEmbedded="true"/> </textElement> diff --git a/src/main/webapp/main/trips/bill/tripBillGridInt.zul b/src/main/webapp/main/trips/bill/tripBillGridInt.zul index af96a821..320691f2 100644 --- a/src/main/webapp/main/trips/bill/tripBillGridInt.zul +++ b/src/main/webapp/main/trips/bill/tripBillGridInt.zul @@ -247,7 +247,7 @@ <listcell label="@load(each.bill.total) @converter(vm.standardBigDecimalConverter)"/> <listcell label="@load(each.bill.ownedBy)"/> <listcell label="@load(each.bill.ownedBy ne each.bill.requirement.ownedBy) @converter(vm.standardBoolConverter)"/> - <listcell label="@load(each.lastApproveDate) @converter('formatedDate', format=labels.DateFormat)"/> + <listcell label="@load(each.approveDate) @converter('formatedDate', format=labels.DateFormat)"/> <listcell label="@load(each.bill.paid) @converter(vm.standardBoolConverter)"/> <listcell label="@load(each.bill.paidDate) @converter('formatedDate', format=labels.DateFormat)"/> </listitem>