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.coa.service.ObjectCodeService;
021 import org.kuali.kfs.module.ar.ArConstants;
022 import org.kuali.kfs.module.ar.document.CustomerInvoiceWriteoffDocument;
023 import org.kuali.kfs.sys.context.SpringContext;
024 import org.kuali.kfs.sys.document.validation.impl.AccountingDocumentRuleBaseConstants.GENERAL_LEDGER_PENDING_ENTRY_CODE;
025 import org.kuali.rice.kns.service.ParameterService;
026 import org.kuali.rice.kns.util.KualiDecimal;
027
028
029 public class WriteoffTaxCustomerInvoiceDetail extends CustomerInvoiceDetail {
030
031 private CustomerInvoiceDetail postable;
032 private CustomerInvoiceWriteoffDocument poster;
033 private boolean isUsingTaxLiabilityAdjustmentIndNo;
034
035 public WriteoffTaxCustomerInvoiceDetail(CustomerInvoiceDetail postable, CustomerInvoiceWriteoffDocument poster){
036 this.postable = postable;
037 this.poster = poster;
038
039 String writeoffTaxGenerationOption = SpringContext.getBean(ParameterService.class).getParameterValue(CustomerInvoiceWriteoffDocument.class, ArConstants.ALLOW_SALES_TAX_LIABILITY_ADJUSTMENT_IND);
040 isUsingTaxLiabilityAdjustmentIndNo = ArConstants.ALLOW_SALES_TAX_LIABILITY_ADJUSTMENT_IND_NO.equals( writeoffTaxGenerationOption );
041
042 if( isUsingTaxLiabilityAdjustmentIndNo ){
043 //if is using org account default, I already set the writeoff FAU on
044 //the document, so that is needed to do is refresh the FAU objects
045 this.poster.refreshReferenceObject("account");
046 this.poster.refreshReferenceObject("chartOfAccounts");
047 this.poster.refreshReferenceObject("subAccount");
048 this.poster.refreshReferenceObject("financialObject");
049 this.poster.refreshReferenceObject("financialSubObject");
050 this.poster.refreshReferenceObject("project");
051 } else {
052 this.postable.refreshNonUpdateableReferences();
053 }
054 }
055
056 @Override
057 public Account getAccount() {
058 if ( isUsingTaxLiabilityAdjustmentIndNo ){
059 return poster.getAccount();
060 } else {
061 return postable.getAccount();
062 }
063 }
064
065 @Override
066 public String getAccountNumber() {
067 if ( isUsingTaxLiabilityAdjustmentIndNo ){
068 return poster.getAccountNumber();
069 } else {
070 return postable.getAccountNumber();
071 }
072 }
073
074 @Override
075 public KualiDecimal getAmount() {
076 return postable.getAmountOpen();
077 }
078
079 @Override
080 public String getChartOfAccountsCode() {
081 if ( isUsingTaxLiabilityAdjustmentIndNo ){
082 return poster.getChartOfAccountsCode();
083 } else {
084 return postable.getChartOfAccountsCode();
085 }
086 }
087
088 @Override
089 public String getDocumentNumber() {
090 return postable.getDocumentNumber();
091 }
092
093 @Override
094 public String getFinancialDocumentLineDescription() {
095 return postable.getFinancialDocumentLineDescription();
096 }
097
098 @Override
099 public String getFinancialObjectCode() {
100 if ( isUsingTaxLiabilityAdjustmentIndNo ){
101 return poster.getFinancialObjectCode();
102 } else {
103 return postable.getAccountsReceivableObjectCode();
104 }
105 }
106
107 @Override
108 public ObjectCode getObjectCode() {
109 if ( isUsingTaxLiabilityAdjustmentIndNo ){
110 return poster.getFinancialObject();
111 } else {
112 return postable.getAccountsReceivableObject();
113 }
114 }
115
116 @Override
117 public String getFinancialSubObjectCode() {
118 return GENERAL_LEDGER_PENDING_ENTRY_CODE.getBlankFinancialSubObjectCode();
119 }
120
121 @Override
122 public String getOrganizationReferenceId() {
123 if ( isUsingTaxLiabilityAdjustmentIndNo ){
124 return poster.getOrganizationReferenceIdentifier();
125 } else {
126 return postable.getOrganizationReferenceId();
127 }
128 }
129
130 @Override
131 public String getProjectCode() {
132 if ( isUsingTaxLiabilityAdjustmentIndNo ){
133 return poster.getProjectCode();
134 } else {
135 return postable.getProjectCode();
136 }
137 }
138
139 @Override
140 public String getSubAccountNumber() {
141 if ( isUsingTaxLiabilityAdjustmentIndNo ){
142 return poster.getSubAccountNumber();
143 } else {
144 return postable.getSubAccountNumber();
145 }
146 }
147 }