1 /*
2 * Copyright 2005-2006 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.kuali.ole.fp.document;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.ole.sys.businessobject.AccountingLine;
20 import org.kuali.ole.sys.businessobject.GeneralLedgerPendingEntry;
21 import org.kuali.ole.sys.businessobject.GeneralLedgerPendingEntrySourceDetail;
22 import org.kuali.ole.sys.context.SpringContext;
23 import org.kuali.ole.sys.document.service.DebitDeterminerService;
24
25 /**
26 * This is the business object that represents the ServiceBillingDocument in Kuali. See
27 * {@link org.kuali.ole.fp.document.validation.impl.ServiceBillingDocumentRule} for details on how it differs from
28 * {@link InternalBillingDocument}.
29 */
30 public class ServiceBillingDocument extends InternalBillingDocument implements CapitalAssetEditable {
31
32 /**
33 * This method further restricts the valid accounting line types exclusively to those with income or expense object type codes
34 * only. This is done by calling isIncome() and isExpense() passing the accounting line.
35 *
36 * @param financialDocument The document used to determine if the accounting line is a debit line.
37 * @param accountingLine The accounting line to be analyzed.
38 * @return True if the accounting line passed in is an expense or income accounting line and meets the rules defined by
39 * super.isDebit() method.
40 * @see org.kuali.ole.fp.document.validation.impl.InternalBillingDocumentRule#isDebit(org.kuali.rice.krad.document.FinancialDocument,
41 * org.kuali.rice.krad.bo.AccountingLine)
42 */
43 @Override
44 public boolean isDebit(GeneralLedgerPendingEntrySourceDetail postable) {
45 AccountingLine accountingLine = (AccountingLine) postable;
46 DebitDeterminerService isDebitUtils = SpringContext.getBean(DebitDeterminerService.class);
47 if (!isDebitUtils.isIncome(accountingLine) && !isDebitUtils.isExpense(accountingLine)) {
48 throw new IllegalStateException(isDebitUtils.getDebitCalculationIllegalStateExceptionMessage());
49 }
50
51 return super.isDebit(postable);
52 }
53
54 /**
55 * This method sets extra accounting line fields in explicit general ledger pending entries. Internal billing transactions don't
56 * have this field.
57 *
58 * @param financialDocument The accounting document containing the general ledger pending entries being customized.
59 * @param accountingLine The accounting line the explicit general ledger pending entry was generated from.
60 * @param explicitEntry The explicit general ledger pending entry to be customized.
61 * @see FinancialDocumentRuleBase#customizeExplicitGeneralLedgerPendingEntry(FinancialDocument, AccountingLine,
62 * GeneralLedgerPendingEntry)
63 */
64 @Override
65 public void customizeExplicitGeneralLedgerPendingEntry(GeneralLedgerPendingEntrySourceDetail postable, GeneralLedgerPendingEntry explicitEntry) {
66 String description = postable.getFinancialDocumentLineDescription();
67 if (StringUtils.isNotBlank(description)) {
68 explicitEntry.setTransactionLedgerEntryDescription(description);
69 }
70 }
71 }