Opraveno generování e-mailu po odeslání vyúčtování služební cesty ke schválení. Text a URL se nyní vygeneruje správně.

closes #219
Verze_2.0
Josef Rokos 10 years ago
parent 933f5e784b
commit a6799064f7

@ -7,6 +7,7 @@ import info.bukova.isspst.data.Requirement;
import info.bukova.isspst.data.RequirementType;
import info.bukova.isspst.data.Role;
import info.bukova.isspst.data.TripBill;
import info.bukova.isspst.data.TripBillApproval;
import info.bukova.isspst.data.TripRequirement;
import info.bukova.isspst.reporting.Report;
import info.bukova.isspst.reporting.ReportMapping;
@ -155,6 +156,7 @@ public class Constants {
public final static Map<Class<?>, String> URL_MAP = Collections.unmodifiableMap(new HashMap<Class<?>, String>() {{
put(Requirement.class, "/main/orders/");
put(TripRequirement.class, "/main/trips/requirements/");
put(TripBillApproval.class, "/main/trips/requirements/");
put(Order.class, "/main/orders/created/");
put(TripBill.class, "/main/trips/bill/");
}} );

@ -0,0 +1,29 @@
package info.bukova.isspst;
import info.bukova.isspst.data.TripBillApproval;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
/**
* @author Pepa Rokos
*/
public class TripBillAprovalUrlResolver implements EntityUrlResolver {
@Autowired
private HttpServletRequest request;
@Override
public String entityUrl(Object entity) {
String defUrl = request.getRequestURL().toString();
defUrl = defUrl.substring(0, defUrl.indexOf(request.getServletPath()));
if (entity instanceof TripBillApproval) {
String url = Constants.URL_MAP.get(entity.getClass());
return defUrl + url + "?select=" + String.valueOf(((TripBillApproval)entity).getBill().getRequirement().getId());
}
return defUrl + "/app";
}
}

@ -14,7 +14,6 @@ import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
@ -60,7 +59,7 @@ public class TripBill extends BaseData implements EntityWithAttachment {
@LazyCollection(LazyCollectionOption.TRUE)
@IndexedEmbedded
private List<FileMetainfo> attachedFiles;
@ManyToOne(fetch = FetchType.EAGER)
@OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "APPROVAL_ID")
private TripBillApproval approval;
@Column(name = "SAVED")

@ -1,6 +1,9 @@
package info.bukova.isspst.data;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
/**
@ -11,4 +14,15 @@ import javax.persistence.Table;
@Table(name = "TRIP_BILL_APPROVAL")
public class TripBillApproval extends RequirementBase {
@OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "TRIPBILL_ID")
private TripBill bill;
public TripBill getBill() {
return bill;
}
public void setBill(TripBill bill) {
this.bill = bill;
}
}

@ -4,9 +4,11 @@ import info.bukova.isspst.Constants;
import info.bukova.isspst.data.NumberSeries;
import info.bukova.isspst.data.RequirementState;
import info.bukova.isspst.data.TripBill;
import info.bukova.isspst.data.TripBillApproval;
import info.bukova.isspst.data.TripRequirement;
import info.bukova.isspst.data.User;
import info.bukova.isspst.services.LazyLoader;
import info.bukova.isspst.services.tripbill.TripBillApprovalService;
import info.bukova.isspst.services.tripbill.TripBillService;
import info.bukova.isspst.services.workgroups.WorkgroupService;
import org.hibernate.Hibernate;
@ -28,6 +30,8 @@ public class TripRequirementServiceImpl extends RequirementBaseServiceImpl<TripR
private WorkgroupService workgroupService;
@Autowired
private TripBillService tripBillService;
@Autowired
private TripBillApprovalService tripBillApprovalService;
@Override
protected TripRequirement createEntity() {
@ -50,6 +54,12 @@ public class TripRequirementServiceImpl extends RequirementBaseServiceImpl<TripR
TripBill newBill = tripBillService.createTripBill(entity);
bill.getBillItems().clear();
bill.getBillItems().addAll(newBill.getBillItems());
TripBillApproval approval = bill.getApproval();
if (approval != null) {
tripBillApprovalService.delete(approval);
}
bill.setApproval(null);
tripBillService.calculate(bill);
tripBillService.update(bill);

@ -1,6 +1,7 @@
package info.bukova.isspst.services.tripbill;
import info.bukova.isspst.Constants;
import info.bukova.isspst.StringUtils;
import info.bukova.isspst.data.RequirementState;
import info.bukova.isspst.data.TripBill;
import info.bukova.isspst.data.TripBillApproval;
@ -33,6 +34,9 @@ public class TripBillApprovalServiceImpl extends RequirementBaseServiceImpl<Trip
approval.setReqDate(new Date());
approval.setType(reqTypeService.getTypeById(Constants.REQTYPE_BUSINESSTRIP));
approval.setState(RequirementState.NEW);
approval.setNumser(bill.getRequirement().getNumser());
approval.setDescription(StringUtils.localize("TravelOrdersFormTitle") + " \"" + bill.getOwnedBy() + "\" - " + bill.getRequirement().getDescription());
approval.setBill(bill);
bill.setApproval(approval);
return approval;
}

@ -71,7 +71,7 @@ public class TripBillSummaryVM extends RequirementSubpage<TripBillApproval> {
bills.add(this.bill);
if (bill.getApproval().getState() != RequirementState.APPROVED) {
if (bill.getApproval() != null && bill.getApproval().getState() != RequirementState.APPROVED) {
isSelectedTad = true;
selTab.put(bill.getId(), true);
} else {
@ -83,7 +83,7 @@ public class TripBillSummaryVM extends RequirementSubpage<TripBillApproval> {
tripBillService.loadLazyData(b);
bills.add(b);
if (!isSelectedTad && b.getApproval().getState() != RequirementState.APPROVED) {
if (!isSelectedTad && b.getApproval() != null && b.getApproval().getState() != RequirementState.APPROVED) {
setBill(b);
isSelectedTad = true;
} else {

@ -36,12 +36,15 @@
<bean id="commonUrlResolver" class="info.bukova.isspst.CommonUrlResolver"/>
<bean id="requirementUrlResolver" class="info.bukova.isspst.RequirementUrlResolver"/>
<bean id="tripBillApprovalUrlResolver" class="info.bukova.isspst.TripBillAprovalUrlResolver"/>
<bean id="urlResolverHolder" class="info.bukova.isspst.UrlResolverHolder">
<constructor-arg ref="commonUrlResolver"/>
<property name="resolvers">
<map>
<entry key="#{T(info.bukova.isspst.data.Requirement)}" value-ref="requirementUrlResolver"/>
<entry key="#{T(info.bukova.isspst.data.TripBillApproval)}" value-ref="tripBillApprovalUrlResolver"/>
</map>
</property>
</bean>

Loading…
Cancel
Save