Opraveno rušení schválení vyúčtování SC z agendy požadavků

closes #270
master
Josef Rokos 9 years ago
parent 9b2e2b3641
commit ea2708f303

@ -12,7 +12,10 @@ import info.bukova.isspst.services.IsspstException;
import info.bukova.isspst.services.requirement.RequirementBaseServiceImpl;
import info.bukova.isspst.services.requirement.RequirementTypeService;
import info.bukova.isspst.services.signeddocs.SignedDocumentService;
import info.bukova.isspst.storage.StorageException;
import org.hibernate.Query;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
@ -31,6 +34,8 @@ public class TripBillApprovalServiceImpl extends RequirementBaseServiceImpl<Trip
@Autowired
private SignedDocumentService signedDocumentService;
private final static Logger logger = LoggerFactory.getLogger(TripBillApproval.class);
@Override
public TripBillApproval createApproval(TripBill bill) {
if (bill.getApproval() != null) {
@ -72,9 +77,24 @@ public class TripBillApprovalServiceImpl extends RequirementBaseServiceImpl<Trip
@Transactional
@PreAuthorize("hasPermission(this, 'PERM_DELETE') or this.canApprove(#bill.approval)")
public void cancelApproval(TripBill bill) {
TripBillApproval approval = bill.getApproval();
if (approval != null) {
super.delete(approval);
}
removeApproval(bill);
}
private void removeApproval(TripBill bill) {
bill.setApproval(null);
signedDocumentService.deleteForEntity(bill);
tripBillService.update(bill);
try {
signedDocumentService.deleteForEntity(bill);
} catch (StorageException e) {
logger.warn(e.getMessage());
}
}
@Override
@ -96,7 +116,7 @@ public class TripBillApprovalServiceImpl extends RequirementBaseServiceImpl<Trip
if (bill != null) {
dao.delete(entity);
cancelApproval(bill);
removeApproval(bill);
} else {
super.delete(entity);
}

Loading…
Cancel
Save