Změněn způsob přenosu vyúčtování ke spolucestujícím: výúčtování se přenese pouze v případě, když ho ještě spolucestující needitoval. Do zeditovaného vyúčtování se vyúčtování žadatele už nepřenáší.
Vyúčtování spolucestujících se schvalují každé zvlášť. refs #212
This commit is contained in:
@@ -1,11 +1,13 @@
|
|||||||
package info.bukova.isspst.data;
|
package info.bukova.isspst.data;
|
||||||
|
|
||||||
import info.bukova.isspst.storage.EntityWithAttachment;
|
import info.bukova.isspst.storage.EntityWithAttachment;
|
||||||
|
import org.hibernate.annotations.LazyCollection;
|
||||||
import java.math.BigDecimal;
|
import org.hibernate.annotations.LazyCollectionOption;
|
||||||
import java.util.ArrayList;
|
import org.hibernate.search.annotations.Analyze;
|
||||||
import java.util.Date;
|
import org.hibernate.search.annotations.Field;
|
||||||
import java.util.List;
|
import org.hibernate.search.annotations.Index;
|
||||||
|
import org.hibernate.search.annotations.Indexed;
|
||||||
|
import org.hibernate.search.annotations.IndexedEmbedded;
|
||||||
|
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
@@ -16,14 +18,10 @@ import javax.persistence.ManyToOne;
|
|||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
import javax.persistence.OneToOne;
|
import javax.persistence.OneToOne;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import org.hibernate.annotations.LazyCollection;
|
import java.util.ArrayList;
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
import java.util.Date;
|
||||||
import org.hibernate.search.annotations.Analyze;
|
import java.util.List;
|
||||||
import org.hibernate.search.annotations.Field;
|
|
||||||
import org.hibernate.search.annotations.Index;
|
|
||||||
import org.hibernate.search.annotations.Indexed;
|
|
||||||
import org.hibernate.search.annotations.IndexedEmbedded;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "TRIP_BILL")
|
@Table(name = "TRIP_BILL")
|
||||||
@@ -65,6 +63,8 @@ public class TripBill extends BaseData implements EntityWithAttachment {
|
|||||||
@ManyToOne(fetch = FetchType.EAGER)
|
@ManyToOne(fetch = FetchType.EAGER)
|
||||||
@JoinColumn(name = "APPROVAL_ID")
|
@JoinColumn(name = "APPROVAL_ID")
|
||||||
private TripBillApproval approval;
|
private TripBillApproval approval;
|
||||||
|
@Column(name = "SAVED")
|
||||||
|
private Boolean saved;
|
||||||
|
|
||||||
public TripBill() {
|
public TripBill() {
|
||||||
billItems = new ArrayList<TripBillItem>();
|
billItems = new ArrayList<TripBillItem>();
|
||||||
@@ -178,4 +178,12 @@ public class TripBill extends BaseData implements EntityWithAttachment {
|
|||||||
public void setApproval(TripBillApproval approval) {
|
public void setApproval(TripBillApproval approval) {
|
||||||
this.approval = approval;
|
this.approval = approval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean getSaved() {
|
||||||
|
return saved;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSaved(Boolean saved) {
|
||||||
|
this.saved = saved;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -274,6 +274,10 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
|
|||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void loadLazyData(String group, T entity) {
|
public void loadLazyData(String group, T entity) {
|
||||||
|
if (entity == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Method[] methods = this.getClass().getMethods();
|
Method[] methods = this.getClass().getMethods();
|
||||||
|
|
||||||
for (Method m : methods) {
|
for (Method m : methods) {
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package info.bukova.isspst.services.tripbill;
|
package info.bukova.isspst.services.tripbill;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import info.bukova.isspst.data.TripBill;
|
import info.bukova.isspst.data.TripBill;
|
||||||
import info.bukova.isspst.data.TripRequirement;
|
import info.bukova.isspst.data.TripRequirement;
|
||||||
import info.bukova.isspst.services.Service;
|
import info.bukova.isspst.services.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface TripBillService extends Service<TripBill> {
|
public interface TripBillService extends Service<TripBill> {
|
||||||
|
|
||||||
public TripBill createTripBill(TripRequirement requirement);
|
public TripBill createTripBill(TripRequirement requirement);
|
||||||
@@ -15,4 +15,11 @@ public interface TripBillService extends Service<TripBill> {
|
|||||||
public void loadOwner(TripBill bill);
|
public void loadOwner(TripBill bill);
|
||||||
public void loadPassengers(TripBill bill);
|
public void loadPassengers(TripBill bill);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Uloží vyúčtování a nastaví příznak přenosu vyúčtování od žadatele
|
||||||
|
*
|
||||||
|
* @param bill
|
||||||
|
*/
|
||||||
|
public void updateOwned(TripBill bill);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -199,6 +199,14 @@ public class TripBillServiceImpl extends AbstractOwnedService<TripBill> implemen
|
|||||||
bill.getRequirement().setPassengers(tr.getPassengers());
|
bill.getRequirement().setPassengers(tr.getPassengers());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
@PreAuthorize("hasPermission(this, 'PERM_EDIT') or hasPermission(#entity, this.getUpdateEntityPermission())")
|
||||||
|
public void updateOwned(TripBill bill) {
|
||||||
|
bill.setSaved(true);
|
||||||
|
update(bill);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@PreAuthorize("hasPermission(this, 'PERM_EDIT') or hasPermission(#entity, this.getUpdateEntityPermission())")
|
@PreAuthorize("hasPermission(this, 'PERM_EDIT') or hasPermission(#entity, this.getUpdateEntityPermission())")
|
||||||
@@ -206,7 +214,9 @@ public class TripBillServiceImpl extends AbstractOwnedService<TripBill> implemen
|
|||||||
super.update(entity);
|
super.update(entity);
|
||||||
|
|
||||||
TripRequirement req = entity.getRequirement();
|
TripRequirement req = entity.getRequirement();
|
||||||
Query q = dao.getQuery("from TripBill where requirement = :req and id != :id");
|
|
||||||
|
if (req.getOwnedBy().equals(entity.getOwnedBy())) {
|
||||||
|
Query q = dao.getQuery("from TripBill where requirement = :req and id != :id and (saved = false or saved is null)");
|
||||||
q.setParameter("req", req);
|
q.setParameter("req", req);
|
||||||
q.setParameter("id", entity.getId());
|
q.setParameter("id", entity.getId());
|
||||||
|
|
||||||
@@ -221,11 +231,10 @@ public class TripBillServiceImpl extends AbstractOwnedService<TripBill> implemen
|
|||||||
tb.setFreeCarfare(entity.isFreeCarfare());
|
tb.setFreeCarfare(entity.isFreeCarfare());
|
||||||
tb.setFreeHousing(entity.isFreeHousing());
|
tb.setFreeHousing(entity.isFreeHousing());
|
||||||
tb.setFreeMeals(entity.isFreeMeals());
|
tb.setFreeMeals(entity.isFreeMeals());
|
||||||
tb.setApproval(entity.getApproval());
|
|
||||||
calculate(tb);
|
calculate(tb);
|
||||||
super.update(tb);
|
super.update(tb);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -62,11 +62,14 @@ public class FormWithUpload<T extends DataModel> extends FormViewModel<T> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doSave() {
|
protected void doSave() {
|
||||||
for (FileMetainfo info : forDelete) {
|
maintainAttachment();
|
||||||
documentStorage.removeFile(info);
|
|
||||||
}
|
|
||||||
|
|
||||||
super.doSave();
|
super.doSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void maintainAttachment() {
|
||||||
|
for (FileMetainfo info : forDelete) {
|
||||||
|
documentStorage.removeFile(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ public class TripRequirementListAll extends RequirementSubpage<TripRequirement>
|
|||||||
tripBillService.loadLazyData(tb);
|
tripBillService.loadLazyData(tb);
|
||||||
Map<String, Object> params = new HashMap<String, Object>();
|
Map<String, Object> params = new HashMap<String, Object>();
|
||||||
params.put("bill", tb);
|
params.put("bill", tb);
|
||||||
Window win = (Window) Executions.createComponents("tripBillSummary.zul", null, params);
|
Window win = (Window) Executions.createComponents("tripBillSummaryMaster.zul", null, params);
|
||||||
win.doModal();
|
win.doModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ public class TripRequirementListCentre extends RequirementSubpage<TripRequiremen
|
|||||||
tripBillService.loadLazyData(tb);
|
tripBillService.loadLazyData(tb);
|
||||||
Map<String, Object> params = new HashMap<String, Object>();
|
Map<String, Object> params = new HashMap<String, Object>();
|
||||||
params.put("bill", tb);
|
params.put("bill", tb);
|
||||||
Window win = (Window) Executions.createComponents("tripBillSummary.zul", null, params);
|
Window win = (Window) Executions.createComponents("tripBillSummaryMaster.zul", null, params);
|
||||||
win.doModal();
|
win.doModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ public class TripRequirementListWorkgroup extends RequirementSubpage<TripRequire
|
|||||||
tripBillService.loadLazyData(tb);
|
tripBillService.loadLazyData(tb);
|
||||||
Map<String, Object> params = new HashMap<String, Object>();
|
Map<String, Object> params = new HashMap<String, Object>();
|
||||||
params.put("bill", tb);
|
params.put("bill", tb);
|
||||||
Window win = (Window) Executions.createComponents("tripBillSummary.zul", null, params);
|
Window win = (Window) Executions.createComponents("tripBillSummaryMaster.zul", null, params);
|
||||||
win.doModal();
|
win.doModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,10 +8,6 @@ import info.bukova.isspst.services.settings.GlobalSettingsService;
|
|||||||
import info.bukova.isspst.services.tripbill.TripBillApprovalService;
|
import info.bukova.isspst.services.tripbill.TripBillApprovalService;
|
||||||
import info.bukova.isspst.services.tripbill.TripBillService;
|
import info.bukova.isspst.services.tripbill.TripBillService;
|
||||||
import info.bukova.isspst.ui.FormWithUpload;
|
import info.bukova.isspst.ui.FormWithUpload;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.zkoss.bind.annotation.BindingParam;
|
import org.zkoss.bind.annotation.BindingParam;
|
||||||
import org.zkoss.bind.annotation.Command;
|
import org.zkoss.bind.annotation.Command;
|
||||||
import org.zkoss.bind.annotation.Init;
|
import org.zkoss.bind.annotation.Init;
|
||||||
@@ -22,6 +18,9 @@ import org.zkoss.zk.ui.select.annotation.WireVariable;
|
|||||||
import org.zkoss.zul.Messagebox;
|
import org.zkoss.zul.Messagebox;
|
||||||
import org.zkoss.zul.Window;
|
import org.zkoss.zul.Window;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class TripBillForm extends FormWithUpload<TripBill> {
|
public class TripBillForm extends FormWithUpload<TripBill> {
|
||||||
|
|
||||||
@WireVariable
|
@WireVariable
|
||||||
@@ -50,11 +49,7 @@ public class TripBillForm extends FormWithUpload<TripBill> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBillDisabled() {
|
public boolean isBillDisabled() {
|
||||||
if (getDataBean().getRequirement().getBillForPassengers() != null
|
if (getDataBean().getApproval() != null) {
|
||||||
&& getDataBean().getRequirement().getBillForPassengers()
|
|
||||||
&& !getDataBean().getOwnedBy().equals(getDataBean().getRequirement().getOwnedBy())) {
|
|
||||||
return true;
|
|
||||||
} else if (getDataBean().getApproval() != null) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,4 +88,10 @@ public class TripBillForm extends FormWithUpload<TripBill> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doSave() {
|
||||||
|
maintainAttachment();
|
||||||
|
tripBillService.updateOwned(getDataBean());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,13 +49,17 @@ public class TripBillSummaryVM extends RequirementSubpage<TripBillApproval> {
|
|||||||
return bill;
|
return bill;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBill(TripBill bill) {
|
@Command
|
||||||
|
@NotifyChange({"bill", "dataBean", "canApprove"})
|
||||||
|
public void setBill(@BindingParam("bill") TripBill bill) {
|
||||||
this.bill = bill;
|
this.bill = bill;
|
||||||
|
setDataBean(bill.getApproval());
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TripBill> getBills() {
|
public List<TripBill> getBills() {
|
||||||
List<TripBill> bills = new ArrayList<TripBill>();
|
List<TripBill> bills = new ArrayList<TripBill>();
|
||||||
|
|
||||||
|
bills.add(this.bill);
|
||||||
for (TripBill b : tripRequirementService.getBills(bill.getRequirement())) {
|
for (TripBill b : tripRequirementService.getBills(bill.getRequirement())) {
|
||||||
if (b.getId() != bill.getId()) {
|
if (b.getId() != bill.getId()) {
|
||||||
tripBillService.loadLazyData(b);
|
tripBillService.loadLazyData(b);
|
||||||
|
|||||||
@@ -5,19 +5,7 @@
|
|||||||
xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd">
|
xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd">
|
||||||
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
|
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
|
||||||
|
|
||||||
<window id="billWin"
|
<div id="billInt" vflex="1">
|
||||||
closable="true"
|
|
||||||
width="700px"
|
|
||||||
height="450px"
|
|
||||||
border="normal"
|
|
||||||
position="center"
|
|
||||||
apply="org.zkoss.bind.BindComposer"
|
|
||||||
viewModel="@id('vm') @init('info.bukova.isspst.ui.tripbill.TripBillSummaryVM')">
|
|
||||||
<caption
|
|
||||||
src="/img/pickup-032.png"
|
|
||||||
zclass="form-caption"
|
|
||||||
label="${labels.TravelOrdersFormTitle}" />
|
|
||||||
<hbox vflex="1">
|
|
||||||
<vbox width="350px" vflex="1">
|
<vbox width="350px" vflex="1">
|
||||||
<label value="@load(vm.bill.ownedBy)" style="font-weight: bold; font-size: larger"/>
|
<label value="@load(vm.bill.ownedBy)" style="font-weight: bold; font-size: larger"/>
|
||||||
<hbox>
|
<hbox>
|
||||||
@@ -44,29 +32,10 @@
|
|||||||
<button label="${labels.TripBillSummaryDetail}"
|
<button label="${labels.TripBillSummaryDetail}"
|
||||||
onClick="@command('showBill', bill=vm.bill)"
|
onClick="@command('showBill', bill=vm.bill)"
|
||||||
sclass="nicebutton"/>
|
sclass="nicebutton"/>
|
||||||
<div visible="@load(not empty vm.bills)" vflex="1">
|
|
||||||
<separator bar="true" width="100%"/>
|
<separator bar="true" hflex="1"/>
|
||||||
<label value="${labels.RequirementsFormPassengers}:"/>
|
|
||||||
<grid model="@load(vm.bills)" vflex="1">
|
|
||||||
<columns>
|
|
||||||
<column />
|
|
||||||
<column width="90px"/>
|
|
||||||
</columns>
|
|
||||||
<rows>
|
|
||||||
<template name="model">
|
|
||||||
<row>
|
|
||||||
<label value="@load(each.ownedBy)"/>
|
|
||||||
<button label="${labels.TripBillSummaryDetail}"
|
|
||||||
sclass="nicebutton"
|
|
||||||
onClick="@command('showBill', bill=each)"/>
|
|
||||||
</row>
|
|
||||||
</template>
|
|
||||||
</rows>
|
|
||||||
</grid>
|
|
||||||
</div>
|
|
||||||
</vbox>
|
|
||||||
<include src="../../approveStatus.zul" vflex="1"/>
|
<include src="../../approveStatus.zul" vflex="1"/>
|
||||||
</hbox>
|
</vbox>
|
||||||
</window>
|
</div>
|
||||||
|
|
||||||
</zk>
|
</zk>
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?page title="${labels.TravelOrdersFormTitle}" contentType="text/html;charset=UTF-8"?>
|
||||||
|
|
||||||
|
<zk xmlns="http://www.zkoss.org/2005/zul"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd">
|
||||||
|
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
|
||||||
|
|
||||||
|
<window id="win"
|
||||||
|
closable="true"
|
||||||
|
width="900px"
|
||||||
|
height="550px"
|
||||||
|
border="normal"
|
||||||
|
position="center"
|
||||||
|
apply="org.zkoss.bind.BindComposer"
|
||||||
|
viewModel="@id('vm') @init('info.bukova.isspst.ui.tripbill.TripBillSummaryVM')">
|
||||||
|
<caption
|
||||||
|
src="/img/pickup-032.png"
|
||||||
|
zclass="form-caption"
|
||||||
|
label="${labels.TravelOrdersFormTitle}" />
|
||||||
|
|
||||||
|
<tabbox vflex="1">
|
||||||
|
<tabs children="@load(vm.bills)">
|
||||||
|
<template name="children">
|
||||||
|
<tab label="@load(each.ownedBy)" onClick="@command('setBill', bill=each)"/>
|
||||||
|
</template>
|
||||||
|
</tabs>
|
||||||
|
<tabpanels children="@load(vm.bills)">
|
||||||
|
<template name="children">
|
||||||
|
<tabpanel>
|
||||||
|
<include vflex="1" src="tripBillSummary.zul"/>
|
||||||
|
</tabpanel>
|
||||||
|
</template>
|
||||||
|
</tabpanels>
|
||||||
|
</tabbox>
|
||||||
|
|
||||||
|
</window>
|
||||||
|
|
||||||
|
</zk>
|
||||||
Reference in New Issue
Block a user