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);
|
||||
|
||||
Reference in New Issue
Block a user