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