1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.fp.document.authorization;
17
18 import java.util.List;
19
20 import org.kuali.ole.fp.document.DistributionOfIncomeAndExpenseDocument;
21 import org.kuali.ole.sys.OLEPropertyConstants;
22 import org.kuali.ole.sys.businessobject.AccountingLine;
23 import org.kuali.ole.sys.businessobject.ElectronicPaymentClaim;
24 import org.kuali.ole.sys.document.AccountingDocument;
25 import org.kuali.rice.krad.util.ObjectUtils;
26
27
28
29
30
31 public class DistributionOfIncomeAndExpenseAccountingLineAuthorizer extends FinancialProcessingAccountingLineAuthorizer {
32
33
34
35
36
37
38
39 @Override
40 public boolean determineEditPermissionOnField(AccountingDocument accountingDocument, AccountingLine accountingLine, String accountingLineCollectionProperty, String fieldName, boolean editablePage) {
41 final boolean canModify = super.determineEditPermissionOnField(accountingDocument, accountingLine, accountingLineCollectionProperty, fieldName, editablePage);
42 if (canModify && accountingLine.isSourceAccountingLine()) {
43 return !hasElectronicPaymentClaims(accountingDocument);
44 }
45
46 return canModify;
47 }
48
49
50
51
52
53 @Override
54 public boolean renderNewLine(AccountingDocument accountingDocument, String accountingGroupProperty) {
55 final boolean shouldRender = super.renderNewLine(accountingDocument, accountingGroupProperty);
56 if (shouldRender && accountingGroupProperty.contains("source")) {
57 return !hasElectronicPaymentClaims(accountingDocument);
58 }
59 return shouldRender;
60 }
61
62
63
64
65
66 @Override
67 public boolean determineEditPermissionOnLine(AccountingDocument accountingDocument, AccountingLine accountingLine, String accountingLineCollectionProperty, boolean currentUserIsDocumentInitiator, boolean pageIsEditable) {
68 final boolean hasEditPermOnLine = super.determineEditPermissionOnLine(accountingDocument, accountingLine, accountingLineCollectionProperty, currentUserIsDocumentInitiator, pageIsEditable);
69 if (hasEditPermOnLine && accountingLineCollectionProperty.contains("source")) {
70 return !hasElectronicPaymentClaims(accountingDocument);
71 }
72 return hasEditPermOnLine;
73 }
74
75
76
77
78
79
80 protected boolean hasElectronicPaymentClaims(AccountingDocument accountingDocument) {
81 DistributionOfIncomeAndExpenseDocument diDoc = (DistributionOfIncomeAndExpenseDocument) accountingDocument;
82
83 List<ElectronicPaymentClaim> epcs = diDoc.getElectronicPaymentClaims();
84
85 if (epcs == null) {
86 diDoc.refreshReferenceObject(OLEPropertyConstants.ELECTRONIC_PAYMENT_CLAIMS);
87 epcs = diDoc.getElectronicPaymentClaims();
88 }
89
90 return (!ObjectUtils.isNull(epcs) && epcs.size() > 0);
91 }
92
93 }