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 java.util.ArrayList; 019 import java.util.Collection; 020 import java.util.LinkedHashMap; 021 import java.util.List; 022 023 import org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader; 024 import org.kuali.rice.kns.bo.PersistableBusinessObjectBase; 025 import org.kuali.rice.kns.util.KualiDecimal; 026 027 /** 028 * @author Kuali Nervous System Team (kualidev@oncourse.iu.edu) 029 */ 030 public class NonAppliedHolding extends PersistableBusinessObjectBase { 031 032 private String referenceFinancialDocumentNumber; 033 private KualiDecimal financialDocumentLineAmount = KualiDecimal.ZERO; 034 private String customerNumber; 035 private Customer customer; 036 private KualiDecimal availableUnappliedAmount = KualiDecimal.ZERO; 037 private KualiDecimal appliedUnappliedAmount = KualiDecimal.ZERO; 038 private Collection<NonInvoicedDistribution> nonInvoicedDistributions; 039 private Collection<NonAppliedDistribution> nonAppliedDistributions; 040 private FinancialSystemDocumentHeader documentHeader; 041 042 /** 043 * Default constructor. 044 */ 045 public NonAppliedHolding() { 046 nonAppliedDistributions = new ArrayList<NonAppliedDistribution>(); 047 } 048 049 /** 050 * Gets the referenceFinancialDocumentNumber attribute. 051 * 052 * @return Returns the referenceFinancialDocumentNumber 053 * 054 */ 055 public String getReferenceFinancialDocumentNumber() { 056 return referenceFinancialDocumentNumber; 057 } 058 059 /** 060 * Sets the referenceFinancialDocumentNumber attribute. 061 * 062 * @param referenceFinancialDocumentNumber The referenceFinancialDocumentNumber to set. 063 * 064 */ 065 public void setReferenceFinancialDocumentNumber(String referenceFinancialDocumentNumber) { 066 this.referenceFinancialDocumentNumber = referenceFinancialDocumentNumber; 067 } 068 069 070 /** 071 * Gets the financialDocumentLineAmount attribute. 072 * 073 * @return Returns the financialDocumentLineAmount 074 * 075 */ 076 public KualiDecimal getFinancialDocumentLineAmount() { 077 return financialDocumentLineAmount; 078 } 079 080 /** 081 * Sets the financialDocumentLineAmount attribute. 082 * 083 * @param financialDocumentLineAmount The financialDocumentLineAmount to set. 084 * 085 */ 086 public void setFinancialDocumentLineAmount(KualiDecimal financialDocumentLineAmount) { 087 this.financialDocumentLineAmount = financialDocumentLineAmount; 088 } 089 090 091 /** 092 * Gets the customerNumber attribute. 093 * 094 * @return Returns the customerNumber 095 * 096 */ 097 public String getCustomerNumber() { 098 return customerNumber; 099 } 100 101 /** 102 * Sets the customerNumber attribute. 103 * 104 * @param customerNumber The customerNumber to set. 105 * 106 */ 107 public void setCustomerNumber(String customerNumber) { 108 this.customerNumber = customerNumber; 109 } 110 111 112 /** 113 * Gets the customer attribute. 114 * 115 * @return Returns the customer 116 * 117 */ 118 public Customer getCustomer() { 119 return customer; 120 } 121 122 /** 123 * Sets the customer attribute. 124 * 125 * @param customer The customer to set. 126 * @deprecated 127 */ 128 public void setCustomer(Customer customer) { 129 this.customer = customer; 130 } 131 132 /** 133 * Gets the nonInvoicedDistributions attribute. 134 * @return Returns the nonInvoicedDistributions. 135 */ 136 public Collection<NonInvoicedDistribution> getNonInvoicedDistributions() { 137 return nonInvoicedDistributions; 138 } 139 140 /** 141 * Sets the nonInvoicedDistributions attribute value. 142 * @param nonInvoicedDistributions The nonInvoicedDistributions to set. 143 */ 144 public void setNonInvoicedDistributions(Collection<NonInvoicedDistribution> nonInvoicedDistributions) { 145 this.nonInvoicedDistributions = nonInvoicedDistributions; 146 } 147 148 /** 149 * Gets the nonAppliedDistributions attribute. 150 * @return Returns the nonAppliedDistributions. 151 */ 152 public Collection<NonAppliedDistribution> getNonAppliedDistributions() { 153 return nonAppliedDistributions; 154 } 155 156 /** 157 * Sets the nonAppliedDistributions attribute value. 158 * @param nonAppliedDistributions The nonAppliedDistributions to set. 159 */ 160 public void setNonAppliedDistributions(List<NonAppliedDistribution> nonAppliedDistributions) { 161 this.nonAppliedDistributions = nonAppliedDistributions; 162 } 163 164 /** 165 * @see org.kuali.rice.kns.bo.BusinessObjectBase#toStringMapper() 166 */ 167 protected LinkedHashMap toStringMapper() { 168 LinkedHashMap m = new LinkedHashMap(); 169 m.put("referenceFinancialDocumentNumber", this.referenceFinancialDocumentNumber); 170 return m; 171 } 172 173 /** 174 * Gets the availableUnappliedAmount attribute. 175 * @return Returns the availableUnappliedAmount. 176 */ 177 public KualiDecimal getAvailableUnappliedAmount() { 178 // start with the original unapplied amount 179 KualiDecimal amount = financialDocumentLineAmount; 180 181 // subtract any non-invoiced distributions made against it 182 for (NonInvoicedDistribution nonInvoicedDistribution : nonInvoicedDistributions) { 183 amount = amount.subtract(nonInvoicedDistribution.getFinancialDocumentLineAmount()); 184 } 185 186 // subtract any non-applied distributions made against it 187 for (NonAppliedDistribution nonAppliedDistribution : nonAppliedDistributions) { 188 amount = amount.subtract(nonAppliedDistribution.getFinancialDocumentLineAmount()); 189 } 190 return amount; 191 } 192 193 /** 194 * Gets the appliedUnappliedAmount attribute. 195 * @return Returns the appliedUnappliedAmount. 196 */ 197 public KualiDecimal getAppliedUnappliedAmount() { 198 // start with zero 199 KualiDecimal amount = KualiDecimal.ZERO; 200 201 // add any non-invoiced distributions made against it 202 for (NonInvoicedDistribution nonInvoicedDistribution : nonInvoicedDistributions) { 203 amount = amount.add(nonInvoicedDistribution.getFinancialDocumentLineAmount()); 204 } 205 206 // add any non-applied distributions made against it 207 for (NonAppliedDistribution nonAppliedDistribution : nonAppliedDistributions) { 208 amount = amount.add(nonAppliedDistribution.getFinancialDocumentLineAmount()); 209 } 210 return amount; 211 } 212 213 /** 214 * Sets the documentHeader attribute value. 215 * @param documentHeader. 216 */ 217 public FinancialSystemDocumentHeader getDocumentHeader() { 218 return documentHeader; 219 } 220 221 /** 222 * Sets the documentHeader attribute value. 223 * @param documentHeader. 224 */ 225 public void setDocumentHeader(FinancialSystemDocumentHeader documentHeader) { 226 this.documentHeader = documentHeader; 227 } 228 229 }