001 /*
002 * Copyright 2011 The Kuali Foundation.
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.kfs.module.endow.document.service.impl;
017
018 import java.util.HashMap;
019 import java.util.Map;
020
021 import org.apache.commons.lang.StringUtils;
022 import org.kuali.kfs.module.endow.EndowConstants;
023 import org.kuali.kfs.module.endow.EndowPropertyConstants;
024 import org.kuali.kfs.module.endow.businessobject.KEMID;
025 import org.kuali.kfs.module.endow.businessobject.EndowmentTransactionCode;
026 import org.kuali.kfs.module.endow.document.service.EndowmentTransactionLinesDocumentService;
027 import org.kuali.kfs.module.endow.document.service.KEMIDService;
028 import org.kuali.kfs.module.endow.document.service.EndowmentTransactionCodeService;
029 import org.kuali.rice.kns.service.BusinessObjectService;
030
031 public class EndowmentTransactionLinesDocumentServiceImpl extends EndowmentTransactionDocumentServiceImpl implements EndowmentTransactionLinesDocumentService {
032
033 private KEMIDService kemidService;
034 private EndowmentTransactionCodeService endowmentTransactionCodeService;
035
036 /**
037 * @see org.kuali.kfs.module.endow.document.service.EndowmentTransactionLinesDocumentService#getCorpusIndicatorValueforAnEndowmentTransactionLine(java.lang.String, java.lang.String, java.lang.String)
038 *
039 * Get the value of CorpusIndicator based on the following rule:
040 * If the KEMID is a true endowment (the END_KEMID_T: TYP_CD has an END_TYP_T: PRIN_RESTR_CD where the END_TYP_RESTR_CD_T: PERM is equal to Yes,)
041 * AND if the ETRAN code record has the END_ETRAN_CD_T: CORPUS_IND set to Yes,
042 * then transaction lines where the END_TRAN_LN_T: TRAN_IP_IND_CD is equal to P will affect the corpus value for the KEMID.
043 * Upon adding the transaction line, the END_TRAN_LN_T: CORPUS_IND for the transaction line will be set to Yes.
044 */
045 public boolean getCorpusIndicatorValueforAnEndowmentTransactionLine(String kemid, String etranCode, String ipIndicator) {
046 boolean corpusIndicator = false;
047 EndowmentTransactionCode theEtranCodeObj = null;
048 if (ipIndicator.equalsIgnoreCase(EndowConstants.IncomePrincipalIndicator.PRINCIPAL)){
049 if (kemidService.isTrueEndowment(kemid)){
050 theEtranCodeObj = endowmentTransactionCodeService.getByPrimaryKey(etranCode);
051 if (theEtranCodeObj.isCorpusIndicator()){
052 corpusIndicator = true;
053 }
054 }
055 }
056 return corpusIndicator;
057 }
058
059 /**
060 * @see org.kuali.kfs.module.endow.document.service.EndowmentTransactionLinesDocumentService#canKEMIDHaveAPrincipalActivity(java.lang.String, java.lang.String)
061 *
062 * IF the END _TRAN_LN_T: TRAN_IP_IND_CD for the transaction line is equal to P, then the KEMID must have a type code (END_KEMID_T: TYP_CD)
063 * that does not have the END_TYPE_T: TYP_PRIN_RESTR_CD equal to NA which implies that the KEMID cannot have any activity in Principal.
064 * This would guarantee that the KEMID has an active general ledger account with the Income/Principal indicator equal to "P".
065 */
066 public boolean canKEMIDHaveAPrincipalActivity (String kemid, String ipIndicator){
067 boolean canHaveAPrincipalActivity = true;
068 KEMID theKemidObj = null;
069 if (ipIndicator.equalsIgnoreCase(EndowConstants.IncomePrincipalIndicator.PRINCIPAL)){
070 theKemidObj = kemidService.getByPrimaryKey(kemid);
071 if (theKemidObj.getPrincipalRestrictionCode().equalsIgnoreCase(EndowConstants.TypeRestrictionPresetValueCodes.NOT_APPLICABLE_TYPE_RESTRICTION_CODE)){
072 canHaveAPrincipalActivity = false;
073 }
074 }
075 return canHaveAPrincipalActivity;
076 }
077
078
079 /**
080 * Gets the kemidService.
081 *
082 * @return kemidService
083 */
084 public KEMIDService getKemidService(){
085 return kemidService;
086 }
087
088 /**
089 * Sets the kemidService.
090 *
091 * @param kemidService
092 */
093 public void setKemidService (KEMIDService kemidService){
094 this.kemidService = kemidService;
095 }
096
097 /**
098 * Gets the endowmentTransactionCodeService.
099 *
100 * @return endowmentTransactionCodeService
101 */
102 public EndowmentTransactionCodeService getEndowmentTransactionCodeService(){
103 return endowmentTransactionCodeService;
104 }
105
106 /**
107 * Sets the endowmentTransactionCodeService.
108 *
109 * @param endowmentTransactionCodeService
110 */
111 public void setEndowmentTransactionCodeService (EndowmentTransactionCodeService endowmentTransactionCodeService){
112 this.endowmentTransactionCodeService = endowmentTransactionCodeService;
113 }
114
115
116
117
118 }