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.ar.businessobject;
017
018 import org.kuali.kfs.coa.businessobject.Account;
019 import org.kuali.kfs.coa.businessobject.ObjectCode;
020 import org.kuali.kfs.module.ar.ArConstants;
021 import org.kuali.kfs.module.ar.document.CustomerInvoiceDocument;
022 import org.kuali.kfs.sys.context.SpringContext;
023 import org.kuali.kfs.sys.document.validation.impl.AccountingDocumentRuleBaseConstants.GENERAL_LEDGER_PENDING_ENTRY_CODE;
024 import org.kuali.rice.kns.service.ParameterService;
025 import org.kuali.rice.kns.util.KualiDecimal;
026
027 public class ReceivableCustomerInvoiceDetail extends CustomerInvoiceDetail {
028
029 private CustomerInvoiceDetail postable;
030 private CustomerInvoiceDocument poster;
031 private boolean isUsingReceivableFAU;
032
033 public ReceivableCustomerInvoiceDetail(CustomerInvoiceDetail postable, CustomerInvoiceDocument poster){
034
035 this.poster = poster;
036 this.postable = postable;
037
038 String receivableOffsetOption = SpringContext.getBean(ParameterService.class).getParameterValue(CustomerInvoiceDocument.class, ArConstants.GLPE_RECEIVABLE_OFFSET_GENERATION_METHOD);
039 isUsingReceivableFAU = ArConstants.GLPE_RECEIVABLE_OFFSET_GENERATION_METHOD_FAU.equals( receivableOffsetOption );
040 if( isUsingReceivableFAU ){
041 this.poster.refreshReferenceObject("paymentAccount");
042 this.poster.refreshReferenceObject("paymentChartOfAccounts");
043 this.poster.refreshReferenceObject("paymentSubAccount");
044 this.poster.refreshReferenceObject("paymentFinancialObject");
045 this.poster.refreshReferenceObject("paymentFinancialSubObject");
046 this.poster.refreshReferenceObject("paymentProject");
047 } else {
048 this.postable.refreshNonUpdateableReferences();
049 }
050
051 }
052
053 @Override
054 public Account getAccount() {
055 if ( isUsingReceivableFAU ){
056 return poster.getPaymentAccount();
057 } else {
058 return postable.getAccount();
059 }
060 }
061
062 @Override
063 public String getAccountNumber() {
064 if ( isUsingReceivableFAU ){
065 return poster.getPaymentAccountNumber();
066 } else {
067 return postable.getAccountNumber();
068 }
069 }
070
071 @Override
072 public KualiDecimal getAmount() {
073 return postable.getInvoiceItemPreTaxAmount();
074 }
075
076 @Override
077 public String getChartOfAccountsCode() {
078 if ( isUsingReceivableFAU ){
079 return poster.getPaymentChartOfAccountsCode();
080 } else {
081 return postable.getChartOfAccountsCode();
082 }
083 }
084
085 @Override
086 public String getDocumentNumber() {
087 return postable.getDocumentNumber();
088 }
089
090 @Override
091 public String getFinancialDocumentLineDescription() {
092 return postable.getFinancialDocumentLineDescription();
093 }
094
095 @Override
096 public String getFinancialObjectCode() {
097 if ( isUsingReceivableFAU ){
098 return poster.getPaymentFinancialObjectCode();
099 } else {
100 return postable.getAccountsReceivableObjectCode();
101 }
102 }
103
104 @Override
105 public ObjectCode getObjectCode() {
106 if ( isUsingReceivableFAU ){
107 return poster.getPaymentFinancialObject();
108 } else {
109 return postable.getAccountsReceivableObject();
110 }
111 }
112
113 @Override
114 public String getFinancialSubObjectCode() {
115 return GENERAL_LEDGER_PENDING_ENTRY_CODE.getBlankFinancialSubObjectCode();
116 }
117
118 @Override
119 public String getOrganizationReferenceId() {
120 if ( isUsingReceivableFAU ){
121 return poster.getPaymentOrganizationReferenceIdentifier();
122 } else {
123 return postable.getOrganizationReferenceId();
124 }
125 }
126
127 @Override
128 public String getProjectCode() {
129 if ( isUsingReceivableFAU ){
130 return poster.getPaymentProjectCode();
131 } else {
132 return postable.getProjectCode();
133 }
134 }
135
136 @Override
137 public String getSubAccountNumber() {
138 if ( isUsingReceivableFAU ){
139 return poster.getPaymentSubAccountNumber();
140 } else {
141 return postable.getSubAccountNumber();
142 }
143 }
144
145 }