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;
|
||||
|
||||
import info.bukova.isspst.storage.EntityWithAttachment;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import org.hibernate.annotations.LazyCollection;
|
||||
import org.hibernate.annotations.LazyCollectionOption;
|
||||
import org.hibernate.search.annotations.Analyze;
|
||||
import org.hibernate.search.annotations.Field;
|
||||
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.Column;
|
||||
@@ -16,14 +18,10 @@ import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.LazyCollection;
|
||||
import org.hibernate.annotations.LazyCollectionOption;
|
||||
import org.hibernate.search.annotations.Analyze;
|
||||
import org.hibernate.search.annotations.Field;
|
||||
import org.hibernate.search.annotations.Index;
|
||||
import org.hibernate.search.annotations.Indexed;
|
||||
import org.hibernate.search.annotations.IndexedEmbedded;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Table(name = "TRIP_BILL")
|
||||
@@ -65,6 +63,8 @@ public class TripBill extends BaseData implements EntityWithAttachment {
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "APPROVAL_ID")
|
||||
private TripBillApproval approval;
|
||||
@Column(name = "SAVED")
|
||||
private Boolean saved;
|
||||
|
||||
public TripBill() {
|
||||
billItems = new ArrayList<TripBillItem>();
|
||||
@@ -178,4 +178,12 @@ public class TripBill extends BaseData implements EntityWithAttachment {
|
||||
public void setApproval(TripBillApproval 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
|
||||
@Transactional
|
||||
public void loadLazyData(String group, T entity) {
|
||||
if (entity == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Method[] methods = this.getClass().getMethods();
|
||||
|
||||
for (Method m : methods) {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package info.bukova.isspst.services.tripbill;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import info.bukova.isspst.data.TripBill;
|
||||
import info.bukova.isspst.data.TripRequirement;
|
||||
import info.bukova.isspst.services.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface TripBillService extends Service<TripBill> {
|
||||
|
||||
public TripBill createTripBill(TripRequirement requirement);
|
||||
@@ -15,4 +15,11 @@ public interface TripBillService extends Service<TripBill> {
|
||||
public void loadOwner(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());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@PreAuthorize("hasPermission(this, 'PERM_EDIT') or hasPermission(#entity, this.getUpdateEntityPermission())")
|
||||
public void updateOwned(TripBill bill) {
|
||||
bill.setSaved(true);
|
||||
update(bill);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@PreAuthorize("hasPermission(this, 'PERM_EDIT') or hasPermission(#entity, this.getUpdateEntityPermission())")
|
||||
@@ -206,26 +214,27 @@ public class TripBillServiceImpl extends AbstractOwnedService<TripBill> implemen
|
||||
super.update(entity);
|
||||
|
||||
TripRequirement req = entity.getRequirement();
|
||||
Query q = dao.getQuery("from TripBill where requirement = :req and id != :id");
|
||||
q.setParameter("req", req);
|
||||
q.setParameter("id", entity.getId());
|
||||
|
||||
List<TripBill> bills = q.list();
|
||||
for (TripBill tb : bills) {
|
||||
tb.getBillItems().clear();
|
||||
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("id", entity.getId());
|
||||
|
||||
for (TripBillItem item : entity.getBillItems()) {
|
||||
tb.getBillItems().add(new TripBillItem(item));
|
||||
List<TripBill> bills = q.list();
|
||||
for (TripBill tb : bills) {
|
||||
tb.getBillItems().clear();
|
||||
|
||||
for (TripBillItem item : entity.getBillItems()) {
|
||||
tb.getBillItems().add(new TripBillItem(item));
|
||||
}
|
||||
|
||||
tb.setFreeCarfare(entity.isFreeCarfare());
|
||||
tb.setFreeHousing(entity.isFreeHousing());
|
||||
tb.setFreeMeals(entity.isFreeMeals());
|
||||
calculate(tb);
|
||||
super.update(tb);
|
||||
}
|
||||
|
||||
tb.setFreeCarfare(entity.isFreeCarfare());
|
||||
tb.setFreeHousing(entity.isFreeHousing());
|
||||
tb.setFreeMeals(entity.isFreeMeals());
|
||||
tb.setApproval(entity.getApproval());
|
||||
calculate(tb);
|
||||
super.update(tb);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -62,11 +62,14 @@ public class FormWithUpload<T extends DataModel> extends FormViewModel<T> {
|
||||
|
||||
@Override
|
||||
protected void doSave() {
|
||||
for (FileMetainfo info : forDelete) {
|
||||
documentStorage.removeFile(info);
|
||||
}
|
||||
|
||||
maintainAttachment();
|
||||
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);
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("bill", tb);
|
||||
Window win = (Window) Executions.createComponents("tripBillSummary.zul", null, params);
|
||||
Window win = (Window) Executions.createComponents("tripBillSummaryMaster.zul", null, params);
|
||||
win.doModal();
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ public class TripRequirementListCentre extends RequirementSubpage<TripRequiremen
|
||||
tripBillService.loadLazyData(tb);
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("bill", tb);
|
||||
Window win = (Window) Executions.createComponents("tripBillSummary.zul", null, params);
|
||||
Window win = (Window) Executions.createComponents("tripBillSummaryMaster.zul", null, params);
|
||||
win.doModal();
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ public class TripRequirementListWorkgroup extends RequirementSubpage<TripRequire
|
||||
tripBillService.loadLazyData(tb);
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("bill", tb);
|
||||
Window win = (Window) Executions.createComponents("tripBillSummary.zul", null, params);
|
||||
Window win = (Window) Executions.createComponents("tripBillSummaryMaster.zul", null, params);
|
||||
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.TripBillService;
|
||||
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.Command;
|
||||
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.Window;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TripBillForm extends FormWithUpload<TripBill> {
|
||||
|
||||
@WireVariable
|
||||
@@ -50,11 +49,7 @@ public class TripBillForm extends FormWithUpload<TripBill> {
|
||||
}
|
||||
|
||||
public boolean isBillDisabled() {
|
||||
if (getDataBean().getRequirement().getBillForPassengers() != null
|
||||
&& getDataBean().getRequirement().getBillForPassengers()
|
||||
&& !getDataBean().getOwnedBy().equals(getDataBean().getRequirement().getOwnedBy())) {
|
||||
return true;
|
||||
} else if (getDataBean().getApproval() != null) {
|
||||
if (getDataBean().getApproval() != null) {
|
||||
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;
|
||||
}
|
||||
|
||||
public void setBill(TripBill bill) {
|
||||
@Command
|
||||
@NotifyChange({"bill", "dataBean", "canApprove"})
|
||||
public void setBill(@BindingParam("bill") TripBill bill) {
|
||||
this.bill = bill;
|
||||
setDataBean(bill.getApproval());
|
||||
}
|
||||
|
||||
public List<TripBill> getBills() {
|
||||
List<TripBill> bills = new ArrayList<TripBill>();
|
||||
|
||||
bills.add(this.bill);
|
||||
for (TripBill b : tripRequirementService.getBills(bill.getRequirement())) {
|
||||
if (b.getId() != bill.getId()) {
|
||||
tripBillService.loadLazyData(b);
|
||||
|
||||
@@ -5,68 +5,37 @@
|
||||
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="billWin"
|
||||
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">
|
||||
<label value="@load(vm.bill.ownedBy)" style="font-weight: bold; font-size: larger"/>
|
||||
<hbox>
|
||||
<label value="${labels.RequirementsFormFrom}: "/>
|
||||
<label value="@load(vm.bill.requirement.from)"/>
|
||||
<label value="${labels.RequirementsFormTo}: "/>
|
||||
<label value="@load(vm.bill.requirement.to)"/>
|
||||
</hbox>
|
||||
<hbox>
|
||||
<label value="${labels.RequirementsFormStartDateTime}: "/>
|
||||
<label value="@load(vm.bill.requirement.tripDate) @converter('formatedDate', format=labels.DateFormat)"/>
|
||||
</hbox>
|
||||
<hbox>
|
||||
<label value="${labels.RequirementsFormEndDate}: "/>
|
||||
<label value="@load(vm.bill.requirement.endDate) @converter('formatedDate', format=labels.DateFormat)"/>
|
||||
</hbox>
|
||||
<hbox>
|
||||
<label value="${labels.RequirementsFormPurpose}: "/>
|
||||
<label value="@load(vm.bill.requirement.description)"/>
|
||||
</hbox>
|
||||
<hbox>
|
||||
<label value="${labels.TripBillTotal}:"/> <label value="@load(vm.bill.total) @converter(vm.standardBigDecimalConverter)"/>
|
||||
</hbox>
|
||||
<button label="${labels.TripBillSummaryDetail}"
|
||||
onClick="@command('showBill', bill=vm.bill)"
|
||||
sclass="nicebutton"/>
|
||||
<div visible="@load(not empty vm.bills)" vflex="1">
|
||||
<separator bar="true" width="100%"/>
|
||||
<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>
|
||||
<div id="billInt" vflex="1">
|
||||
<vbox width="350px" vflex="1">
|
||||
<label value="@load(vm.bill.ownedBy)" style="font-weight: bold; font-size: larger"/>
|
||||
<hbox>
|
||||
<label value="${labels.RequirementsFormFrom}: "/>
|
||||
<label value="@load(vm.bill.requirement.from)"/>
|
||||
<label value="${labels.RequirementsFormTo}: "/>
|
||||
<label value="@load(vm.bill.requirement.to)"/>
|
||||
</hbox>
|
||||
<hbox>
|
||||
<label value="${labels.RequirementsFormStartDateTime}: "/>
|
||||
<label value="@load(vm.bill.requirement.tripDate) @converter('formatedDate', format=labels.DateFormat)"/>
|
||||
</hbox>
|
||||
<hbox>
|
||||
<label value="${labels.RequirementsFormEndDate}: "/>
|
||||
<label value="@load(vm.bill.requirement.endDate) @converter('formatedDate', format=labels.DateFormat)"/>
|
||||
</hbox>
|
||||
<hbox>
|
||||
<label value="${labels.RequirementsFormPurpose}: "/>
|
||||
<label value="@load(vm.bill.requirement.description)"/>
|
||||
</hbox>
|
||||
<hbox>
|
||||
<label value="${labels.TripBillTotal}:"/> <label value="@load(vm.bill.total) @converter(vm.standardBigDecimalConverter)"/>
|
||||
</hbox>
|
||||
<button label="${labels.TripBillSummaryDetail}"
|
||||
onClick="@command('showBill', bill=vm.bill)"
|
||||
sclass="nicebutton"/>
|
||||
|
||||
<separator bar="true" hflex="1"/>
|
||||
<include src="../../approveStatus.zul" vflex="1"/>
|
||||
</hbox>
|
||||
</window>
|
||||
</vbox>
|
||||
</div>
|
||||
|
||||
</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