From 14242fa41a11195f1024c699a3252c4b7366ee8d Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Fri, 2 Oct 2015 09:32:09 +0200 Subject: [PATCH] =?UTF-8?q?Vy=C3=BA=C4=8Dtov=C3=A1n=C3=AD=20slu=C5=BEebn?= =?UTF-8?q?=C3=ADch=20cest=20u=20spolucestuj=C3=ADc=C3=ADch=20lze=20nyn?= =?UTF-8?q?=C3=AD=20zru=C5=A1it=20u=20ka=C5=BEd=C3=A9ho=20zvl=C3=A1=C5=A1?= =?UTF-8?q?=C5=A5.=20Lze=20tak=20prov=C3=A9st=20dodate=C4=8Dnou=20opravu?= =?UTF-8?q?=20vy=C3=BA=C4=8Dtov=C3=A1n=C3=AD.=20closes=20#251?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../info/bukova/isspst/data/TripBill.java | 2 +- .../RequirementBaseServiceImpl.java | 20 +++++++++----- .../requirement/RequirementServiceImpl.java | 10 +++++++ .../signeddocs/SignedDocumentService.java | 1 + .../signeddocs/SignedDocumentServiceImpl.java | 9 +++++++ .../tripbill/TripBillApprovalService.java | 1 + .../tripbill/TripBillApprovalServiceImpl.java | 14 ++++++++++ .../isspst/ui/tripbill/TripBillSummaryVM.java | 26 ++++++++++++++++++- .../WEB-INF/locales/zk-label.properties | 3 +++ .../trips/requirements/tripBillSummary.zul | 1 + 10 files changed, 78 insertions(+), 9 deletions(-) diff --git a/src/main/java/info/bukova/isspst/data/TripBill.java b/src/main/java/info/bukova/isspst/data/TripBill.java index a819d286..369de0e2 100644 --- a/src/main/java/info/bukova/isspst/data/TripBill.java +++ b/src/main/java/info/bukova/isspst/data/TripBill.java @@ -60,7 +60,7 @@ public class TripBill extends BaseData implements EntityWithAttachment { @LazyCollection(LazyCollectionOption.TRUE) @IndexedEmbedded private List attachedFiles; - @OneToOne(fetch = FetchType.EAGER) + @OneToOne(fetch = FetchType.EAGER, orphanRemoval = true) @JoinColumn(name = "APPROVAL_ID") private TripBillApproval approval; @Column(name = "SAVED") diff --git a/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java b/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java index a022da7a..d58f9f0e 100644 --- a/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java @@ -131,7 +131,8 @@ public abstract class RequirementBaseServiceImpl exte } protected void postAdd(T entity) { - if (canApprove(entity)) { + Workflow wf = getNextWorkflow(entity); + if (canApprove(entity) && (wf.getSignature() == null || !wf.getSignature())) { approve(entity); } else { this.sendToApprovers(entity); @@ -280,7 +281,7 @@ public abstract class RequirementBaseServiceImpl exte if (signedPdf != null) { saveSignedDoc(e, signedPdf); - } else if (wf.getSignature() != null && wf.getSignature()) { + } else if (wf.getSignature() != null && wf.getSignature() && !signatureNotRequired(wf)) { throw new ApproveException("ErrApproveMustBeSigned"); } @@ -310,6 +311,15 @@ public abstract class RequirementBaseServiceImpl exte postApprove(e); } + /** + * Check pro automatické schválení, kdy není třeba podepisovat- nadlimitní nákupy se neautorizují... + * @param wf Další krok schválení + * @return true pokud není potřeba podepisovat. Zde vrací vždy false, v případě potřeby nutno překrýt. + */ + protected boolean signatureNotRequired(Workflow wf) { + return false; + } + protected void approve(T entity, User user) { approve(entity, user, new Date(), null); } @@ -549,11 +559,7 @@ public abstract class RequirementBaseServiceImpl exte public void update(T entity) { entity.getAuthorization().clear(); entity.setState(RequirementState.NEW); - - SignedDocument doc = signedDocumentService.getForEntity(entity); - if (doc != null) { - signedDocumentService.delFromApprove(doc); - } + signedDocumentService.deleteForEntity(entity); super.update(entity); sendToApprovers(entity); diff --git a/src/main/java/info/bukova/isspst/services/requirement/RequirementServiceImpl.java b/src/main/java/info/bukova/isspst/services/requirement/RequirementServiceImpl.java index a1dc8aa5..7ebad845 100644 --- a/src/main/java/info/bukova/isspst/services/requirement/RequirementServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/requirement/RequirementServiceImpl.java @@ -67,6 +67,16 @@ public class RequirementServiceImpl extends RequirementBaseServiceImpl { SignedDocumentItem getItem(DataModel entity, long reportId); void addFromApprove(SignedDocument document); void delFromApprove(SignedDocument document); + void deleteForEntity(DataModel entity); } diff --git a/src/main/java/info/bukova/isspst/services/signeddocs/SignedDocumentServiceImpl.java b/src/main/java/info/bukova/isspst/services/signeddocs/SignedDocumentServiceImpl.java index 4a6c0f86..f2cfea1c 100644 --- a/src/main/java/info/bukova/isspst/services/signeddocs/SignedDocumentServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/signeddocs/SignedDocumentServiceImpl.java @@ -83,5 +83,14 @@ public class SignedDocumentServiceImpl extends AbstractOwnedService { public TripBillApproval createApproval(TripBill bill); + public void cancelApproval(TripBill bill); } diff --git a/src/main/java/info/bukova/isspst/services/tripbill/TripBillApprovalServiceImpl.java b/src/main/java/info/bukova/isspst/services/tripbill/TripBillApprovalServiceImpl.java index 3610e997..4f3410f3 100644 --- a/src/main/java/info/bukova/isspst/services/tripbill/TripBillApprovalServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/tripbill/TripBillApprovalServiceImpl.java @@ -9,6 +9,7 @@ import info.bukova.isspst.data.TripBillApproval; 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 org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.transaction.annotation.Transactional; @@ -22,6 +23,10 @@ public class TripBillApprovalServiceImpl extends RequirementBaseServiceImpl { @GlobalCommand @NotifyChange("dataBean") public void reload() { - setDataBean(tripBillApprovalService.getById(bill.getApproval().getId())); + if (bill.getApproval() != null) { + setDataBean(tripBillApprovalService.getById(bill.getApproval().getId())); + } } public Map getSelTab() { return selTab; } + + @Command + public void cancelApproval() { + Messagebox.show(StringUtils.localize("TripBillCancelApprovalQuestion"), StringUtils.localize("TripBillCancelApprovalTitle"), Messagebox.YES + | Messagebox.NO, Messagebox.QUESTION, new EventListener() { + @Override + public void onEvent(Event event) throws Exception { + if (((Integer) event.getData()).intValue() == Messagebox.YES) { + tripBillApprovalService.cancelApproval(bill); + setDataBean(null); + BindUtils.postNotifyChange(null, null, TripBillSummaryVM.this, "bill"); + BindUtils.postNotifyChange(null, null, TripBillSummaryVM.this, "dataBean"); + BindUtils.postNotifyChange(null, null, TripBillSummaryVM.this, "canApprove"); + } + } + }); + } } diff --git a/src/main/webapp/WEB-INF/locales/zk-label.properties b/src/main/webapp/WEB-INF/locales/zk-label.properties index 1df6aba3..d1af6cac 100644 --- a/src/main/webapp/WEB-INF/locales/zk-label.properties +++ b/src/main/webapp/WEB-INF/locales/zk-label.properties @@ -241,6 +241,9 @@ TripBillBack=Zpět TripBillTotal=Celkem TripBillSaveApprove=Jestliže máte vše vyplněno, pošlete vyúčtování ke schválení. Vyúčtování zaslané ke schválení už nelze dále upravovat. Odeslat ke schválení? TripBillSave=Odeslat ke schválení? +TripBillCancelApproval=Zrušit schválení a povolit úpravy +TripBillCancelApprovalQuestion=Opravdu zrušít schválení tohoto vyúčtování? +TripBillCancelApprovalTitle=Zrušit schválení TripBillSummaryDetail=Detail diff --git a/src/main/webapp/main/trips/requirements/tripBillSummary.zul b/src/main/webapp/main/trips/requirements/tripBillSummary.zul index 556b6e00..38c39a31 100644 --- a/src/main/webapp/main/trips/requirements/tripBillSummary.zul +++ b/src/main/webapp/main/trips/requirements/tripBillSummary.zul @@ -35,6 +35,7 @@ +