1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.sys.document.authorization;
17
18 import java.util.Map;
19
20 import org.apache.commons.logging.Log;
21 import org.apache.commons.logging.LogFactory;
22 import org.kuali.ole.coa.businessobject.Account;
23 import org.kuali.ole.coa.service.AccountService;
24 import org.kuali.ole.sys.businessobject.AccountingLine;
25 import org.kuali.ole.sys.businessobject.FinancialSystemDocumentHeader;
26 import org.kuali.ole.sys.document.AccountingDocument;
27 import org.kuali.ole.sys.identity.OleKimAttributes;
28 import org.kuali.rice.kim.api.identity.Person;
29 import org.kuali.rice.krad.document.Document;
30
31
32
33
34 public class AccountingDocumentAuthorizerBase extends FinancialSystemTransactionalDocumentAuthorizerBase {
35 private static final Log LOG = LogFactory.getLog(AccountingDocumentAuthorizerBase.class);
36
37
38
39
40
41
42
43
44 protected boolean determineLineEditability(AccountingLine line, Person currentUser, AccountService accountService) {
45 Account acct = accountService.getByPrimaryId(line.getChartOfAccountsCode(), line.getAccountNumber());
46 if (acct == null) return true;
47 return accountService.hasResponsibilityOnAccount(currentUser, acct);
48 }
49
50 @Override
51 protected void addRoleQualification(Object dataObject, Map<String,String> attributes) {
52 super.addRoleQualification(dataObject, attributes);
53 Document document = (Document)dataObject;
54
55 if ( ((AccountingDocument)document).getSourceTotal() != null && ((FinancialSystemDocumentHeader)document.getDocumentHeader()).getFinancialDocumentTotalAmount() != null ) {
56 attributes.put(OleKimAttributes.FINANCIAL_DOCUMENT_TOTAL_AMOUNT, ((FinancialSystemDocumentHeader)document.getDocumentHeader()).getFinancialDocumentTotalAmount().toString());
57 } else {
58 attributes.put(OleKimAttributes.FINANCIAL_DOCUMENT_TOTAL_AMOUNT, "0" );
59 }
60 }
61 }
62