Změnou schváleného požadavku na služební cestu se přegeneruje vyúčtování.

closes #195
Verze_1.0
Josef Rokos 10 years ago
parent 884bc8267d
commit f13bc6e5c4

@ -1,10 +1,21 @@
package info.bukova.isspst.services.requirement; package info.bukova.isspst.services.requirement;
import info.bukova.isspst.data.TripBill;
import info.bukova.isspst.data.TripRequirement; import info.bukova.isspst.data.TripRequirement;
import java.util.List;
public interface TripRequirementService extends RequirementBaseService<TripRequirement> public interface TripRequirementService extends RequirementBaseService<TripRequirement>
{ {
public void loadPassangers(TripRequirement entity); public void loadPassangers(TripRequirement entity);
/**
* Vrátí seznam vyúčtování, která josu vázána k požadavku
*
* @param entity požadavek
* @return seznam vyúčtování
*/
public List<TripBill> getBills(TripRequirement entity);
} }

@ -9,13 +9,15 @@ import info.bukova.isspst.data.User;
import info.bukova.isspst.services.LazyLoader; import info.bukova.isspst.services.LazyLoader;
import info.bukova.isspst.services.tripbill.TripBillService; import info.bukova.isspst.services.tripbill.TripBillService;
import info.bukova.isspst.services.workgroups.WorkgroupService; import info.bukova.isspst.services.workgroups.WorkgroupService;
import java.util.Date;
import org.hibernate.LazyInitializationException; import org.hibernate.LazyInitializationException;
import org.hibernate.Query;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
public class TripRequirementServiceImpl extends RequirementBaseServiceImpl<TripRequirement> public class TripRequirementServiceImpl extends RequirementBaseServiceImpl<TripRequirement>
implements TripRequirementService, RequirementBaseService<TripRequirement> { implements TripRequirementService, RequirementBaseService<TripRequirement> {
@ -36,6 +38,23 @@ public class TripRequirementServiceImpl extends RequirementBaseServiceImpl<TripR
return tr; return tr;
} }
@Override
@Transactional
@PreAuthorize("hasPermission(this, 'PERM_EDIT') or hasPermission(#entity, this.getUpdateEntityPermission())")
public void update(TripRequirement entity) {
super.update(entity);
if (entity.getState() == RequirementState.APPROVED) {
TripBill newBill = tripBillService.createTripBill(entity);
for (TripBill bill : getBills(entity)) {
bill.getBillItems().clear();
bill.getBillItems().addAll(newBill.getBillItems());
tripBillService.calculate(bill);
tripBillService.update(bill);
}
}
}
@Override @Override
@Transactional @Transactional
@LazyLoader("form") @LazyLoader("form")
@ -53,6 +72,14 @@ public class TripRequirementServiceImpl extends RequirementBaseServiceImpl<TripR
} }
} }
@Override
@Transactional
public List<TripBill> getBills(TripRequirement entity) {
Query q = queryDao.getQuery("from TripBill bill where bill.requirement = :req");
q.setParameter("req", entity);
return q.list();
}
@Override @Override
protected void postApprove(TripRequirement entity) { protected void postApprove(TripRequirement entity) {
if (entity.getState() == RequirementState.APPROVED) { if (entity.getState() == RequirementState.APPROVED) {

@ -1,13 +1,7 @@
package info.bukova.isspst.ui.requirement; package info.bukova.isspst.ui.requirement;
import java.util.List; import info.bukova.isspst.StringUtils;
import info.bukova.isspst.data.RequirementState;
import org.zkoss.bind.annotation.BindingParam;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.Init;
import org.zkoss.bind.annotation.NotifyChange;
import org.zkoss.zk.ui.select.annotation.WireVariable;
import info.bukova.isspst.data.SettingsData; import info.bukova.isspst.data.SettingsData;
import info.bukova.isspst.data.TripRequirement; import info.bukova.isspst.data.TripRequirement;
import info.bukova.isspst.data.User; import info.bukova.isspst.data.User;
@ -19,6 +13,17 @@ import info.bukova.isspst.services.users.UserService;
import info.bukova.isspst.services.workgroups.WorkgroupService; import info.bukova.isspst.services.workgroups.WorkgroupService;
import info.bukova.isspst.ui.FormViewModel; import info.bukova.isspst.ui.FormViewModel;
import info.bukova.isspst.validators.TripRequirementFormValidator; import info.bukova.isspst.validators.TripRequirementFormValidator;
import org.zkoss.bind.annotation.BindingParam;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.Init;
import org.zkoss.bind.annotation.NotifyChange;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.select.annotation.WireVariable;
import org.zkoss.zul.Messagebox;
import org.zkoss.zul.Window;
import java.util.List;
public class TripRequirementForm extends FormViewModel<TripRequirement> { public class TripRequirementForm extends FormViewModel<TripRequirement> {
@ -33,6 +38,30 @@ public class TripRequirementForm extends FormViewModel<TripRequirement> {
@WireVariable @WireVariable
private TripRequirementService tripRequirementService; private TripRequirementService tripRequirementService;
private List<Workgroup> centres; private List<Workgroup> centres;
@Override
@NotifyChange("errMessages")
@Command
public void save(@BindingParam("window") Window win) {
final Window editWin = win;
if (getDataBean().getState() == RequirementState.APPROVED) {
Messagebox.show(StringUtils.localize("TripRequirementChangeWarn"), StringUtils.localize("TripRequirementSave"), Messagebox.YES
| Messagebox.NO, Messagebox.QUESTION, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
if (((Integer) event.getData()).intValue() == Messagebox.YES) {
TripRequirementForm.super.save(editWin);
} else {
editWin.detach();
}
}
});
} else {
super.save(win);
}
}
private List<User> users; private List<User> users;
private List<User> passengers; private List<User> passengers;
private User selUser; private User selUser;

@ -222,6 +222,9 @@ TripBillTo=Tam
TripBillBack=Zpět TripBillBack=Zpět
TripBillTotal=Celkem TripBillTotal=Celkem
TripRequirementChangeWarn=Editací schváleného požadavku se znovu vygeneruje vyúčtování. Opravdu chcete záznam uložit?
TripRequirementSave=Uložit požadavek?
CentresForRequirements=Střediska, pro která lze vkládat požadavky CentresForRequirements=Střediska, pro která lze vkládat požadavky
WorkgroupMembership=Členství v komisích WorkgroupMembership=Členství v komisích
LogedInUser=Přihlášený uživatel: LogedInUser=Přihlášený uživatel:

@ -51,6 +51,6 @@
<div id="mainData"> <div id="mainData">
<u:include src="${gridZul}" /> <u:include src="${gridZul}" />
</div> </div>
<div id="footer"> Verze 1.3 </div> <div id="footer"> Verze 1.5 </div>
</div> </div>
</html> </html>
Loading…
Cancel
Save