/** * Returns whether the origin entry represents a credit * * @param oe origin entry * @return true if origin entry represents a credit */ public static boolean isCredit(OriginEntryFull oe) { return KFSConstants.GL_CREDIT_CODE.equals(oe.getTransactionDebitCreditCode()); }
public void setFromFileForCollectorDetail( String detailLine, Map<String, String> accountRecordBalanceTypeMap, Date curDate, UniversityDate universityDate, int lineNumber, MessageMap messageMap) { try { final Map<String, Integer> pMap = getCollectorDetailFieldUtil().getFieldBeginningPositionMap(); detailLine = org.apache.commons.lang.StringUtils.rightPad( detailLine, GeneralLedgerConstants.getSpaceAllCollectorDetailFields().length(), ' '); setCreateDate(curDate); if (!GeneralLedgerConstants.getSpaceUniversityFiscalYear() .equals( detailLine.substring( pMap.get(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR), pMap.get(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE)))) { try { setUniversityFiscalYear( new Integer( getValue( detailLine, pMap.get(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR), pMap.get(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE)))); } catch (NumberFormatException e) { messageMap.putError( KFSConstants.GLOBAL_ERRORS, KFSKeyConstants.ERROR_CUSTOM, "Collector detail university fiscal year " + lineNumber + " string " + detailLine.substring( pMap.get(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR), pMap.get(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE))); setUniversityFiscalYear(null); } } else { setUniversityFiscalYear(null); } if (!GeneralLedgerConstants.getSpaceChartOfAccountsCode() .equals( detailLine.substring( pMap.get(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR), pMap.get(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE)))) setChartOfAccountsCode( getValue( detailLine, pMap.get(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE), pMap.get(KFSPropertyConstants.ACCOUNT_NUMBER))); else setChartOfAccountsCode(GeneralLedgerConstants.getSpaceChartOfAccountsCode()); setAccountNumber( getValue( detailLine, pMap.get(KFSPropertyConstants.ACCOUNT_NUMBER), pMap.get(KFSPropertyConstants.SUB_ACCOUNT_NUMBER))); // if chart code is empty while accounts cannot cross charts, then derive chart code from // account number AccountService acctserv = SpringContext.getBean(AccountService.class); if (StringUtils.isEmpty(getChartOfAccountsCode()) && StringUtils.isNotEmpty(getAccountNumber()) && !acctserv.accountsCanCrossCharts()) { Account account = acctserv.getUniqueAccountForAccountNumber(getAccountNumber()); if (account != null) { setChartOfAccountsCode(account.getChartOfAccountsCode()); } } setSubAccountNumber( getValue( detailLine, pMap.get(KFSPropertyConstants.SUB_ACCOUNT_NUMBER), pMap.get(KFSPropertyConstants.FINANCIAL_OBJECT_CODE))); setFinancialObjectCode( getValue( detailLine, pMap.get(KFSPropertyConstants.FINANCIAL_OBJECT_CODE), pMap.get(KFSPropertyConstants.FINANCIAL_SUB_OBJECT_CODE))); setFinancialSubObjectCode( getValue( detailLine, pMap.get(KFSPropertyConstants.FINANCIAL_SUB_OBJECT_CODE), pMap.get(KFSPropertyConstants.FINANCIAL_BALANCE_TYPE_CODE))); // We are in Collector Detail for ID Billing Details because the value from file positions 26, // 27 = DT. We don not want to set Financial Balance Type Code to detail type code (DT) // Generate the account record key to retrieve the balance type from the map which contains // the balance type from the accounting record/origin entry String accountRecordKey = generateAccountRecordBalanceTypeKey(); String financialBalanceTypeCode = accountRecordBalanceTypeMap.get(accountRecordKey); // Default to "AC" if we do not find account record key record from the map setFinancialBalanceTypeCode( StringUtils.defaultIfEmpty( financialBalanceTypeCode, GeneralLedgerConstants.FINALNCIAL_BALANCE_TYPE_FOR_COLLECTOR_DETAIL_RECORD)); setFinancialObjectTypeCode( getValue( detailLine, pMap.get(KFSPropertyConstants.FINANCIAL_OBJECT_TYPE_CODE), pMap.get(KFSPropertyConstants.COLLECTOR_DETAIL_SEQUENCE_NUMBER))); setUniversityFiscalPeriodCode(universityDate.getUniversityFiscalAccountingPeriod()); setCollectorDetailSequenceNumber( getValue( detailLine, pMap.get(KFSPropertyConstants.COLLECTOR_DETAIL_SEQUENCE_NUMBER), pMap.get(KFSPropertyConstants.FINANCIAL_DOCUMENT_TYPE_CODE))); setFinancialDocumentTypeCode( getValue( detailLine, pMap.get(KFSPropertyConstants.FINANCIAL_DOCUMENT_TYPE_CODE), pMap.get(KFSPropertyConstants.FINANCIAL_SYSTEM_ORIGINATION_CODE))); setFinancialSystemOriginationCode( getValue( detailLine, pMap.get(KFSPropertyConstants.FINANCIAL_SYSTEM_ORIGINATION_CODE), pMap.get(KFSPropertyConstants.DOCUMENT_NUMBER))); setDocumentNumber( getValue( detailLine, pMap.get(KFSPropertyConstants.DOCUMENT_NUMBER), pMap.get(KFSPropertyConstants.COLLECTOR_DETAIL_AMOUNT))); try { setCollectorDetailItemAmount( getValue( detailLine, pMap.get(KFSPropertyConstants.COLLECTOR_DETAIL_AMOUNT), pMap.get(KFSPropertyConstants.COLLECTOR_DETAIL_GL_CREDIT_CODE))); } catch (NumberFormatException e) { setCollectorDetailItemAmount(KualiDecimal.ZERO); messageMap.putError( KFSConstants.GLOBAL_ERRORS, KFSKeyConstants.ERROR_CUSTOM, "Collector detail amount cannot be parsed on line " + lineNumber + " amount string " + detailLine.substring( pMap.get(KFSPropertyConstants.COLLECTOR_DETAIL_AMOUNT), pMap.get(KFSPropertyConstants.GL_CREDIT_CODE))); } if (KFSConstants.GL_CREDIT_CODE.equalsIgnoreCase( getValue( detailLine, pMap.get(KFSPropertyConstants.COLLECTOR_DETAIL_GL_CREDIT_CODE), pMap.get(KFSPropertyConstants.COLLECTOR_DETAIL_NOTE_TEXT)))) { setCollectorDetailItemAmount(getCollectorDetailItemAmount().negated()); } setCollectorDetailNoteText( getValue( detailLine, pMap.get(KFSPropertyConstants.COLLECTOR_DETAIL_NOTE_TEXT), GeneralLedgerConstants.getSpaceAllCollectorDetailFields().length())); if (org.apache.commons.lang.StringUtils.isEmpty(getSubAccountNumber())) { setSubAccountNumber(KFSConstants.getDashSubAccountNumber()); } if (org.apache.commons.lang.StringUtils.isEmpty(getFinancialSubObjectCode())) { setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode()); } if (org.apache.commons.lang.StringUtils.isEmpty(getCollectorDetailSequenceNumber())) { setCollectorDetailSequenceNumber(" "); } } catch (Exception e) { throw new RuntimeException( e + " occurred in CollectorDetail.setFromFileForCollectorDetail()"); } }