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.document.web.struts;
017
018 import java.io.Serializable;
019
020 import org.kuali.kfs.module.ar.businessobject.CustomerInvoiceDetail;
021 import org.kuali.kfs.module.ar.businessobject.InvoicePaidApplied;
022 import org.kuali.rice.kns.util.KualiDecimal;
023
024 public class PaymentApplicationInvoiceDetailApply implements Serializable {
025
026 private static final int DEFAULT_PAID_APPLIED_ITEM_NUMBER = 0;
027
028 private CustomerInvoiceDetail invoiceDetail;
029 private InvoicePaidApplied paidApplied;
030
031 private KualiDecimal amountApplied;
032 private KualiDecimal amountAppliedOldValue;
033 private boolean fullApply;
034 private boolean fullApplyOldValue;
035 private boolean invoiceQuickApplied;
036 private String payAppDocNumber;
037
038 public PaymentApplicationInvoiceDetailApply(String payAppDocNumber, CustomerInvoiceDetail invoiceDetail) {
039 this.invoiceDetail = invoiceDetail;
040 this.amountApplied = KualiDecimal.ZERO;
041 this.amountAppliedOldValue = KualiDecimal.ZERO;
042 this.fullApply = false;
043 this.fullApplyOldValue = false;
044 this.paidApplied = new InvoicePaidApplied();
045 this.payAppDocNumber = payAppDocNumber;
046 this.invoiceQuickApplied = false;
047 }
048
049 public InvoicePaidApplied generatePaidApplied() {
050 InvoicePaidApplied paidApplied = new InvoicePaidApplied(payAppDocNumber, invoiceDetail.getDocumentNumber(),
051 invoiceDetail.getSequenceNumber(), amountApplied, DEFAULT_PAID_APPLIED_ITEM_NUMBER);
052 return paidApplied;
053 }
054
055 public KualiDecimal getAmountOpen() {
056 return invoiceDetail.getAmountOpen();
057 }
058
059 public KualiDecimal getAmountApplied() {
060 return amountApplied;
061 }
062
063 public void setAmountApplied(KualiDecimal amountApplied) {
064 this.amountAppliedOldValue = this.amountApplied;
065 if (amountApplied == null) {
066 this.amountApplied = KualiDecimal.ZERO;
067 }
068 else {
069 this.amountApplied = amountApplied;
070 }
071 }
072
073 public boolean isAmountAppliedChanged() {
074 return !amountApplied.equals(amountAppliedOldValue);
075 }
076
077 public boolean isFullApply() {
078 return fullApply;
079 }
080
081 public void setFullApply(boolean fullApply) {
082 this.fullApplyOldValue = this.fullApply;
083 this.fullApply = fullApply;
084 }
085
086 public boolean isFullApplyChanged() {
087 return fullApply != fullApplyOldValue;
088 }
089
090 public CustomerInvoiceDetail getInvoiceDetail() {
091 return invoiceDetail;
092 }
093
094 public String getInvoiceDocumentNumber() {
095 return invoiceDetail.getDocumentNumber();
096 }
097
098 public Integer getSequenceNumber() {
099 return invoiceDetail.getSequenceNumber();
100 }
101
102 public String getChartOfAccountsCode() {
103 return invoiceDetail.getChartOfAccountsCode();
104 }
105
106 public String getAccountNumber() {
107 return invoiceDetail.getAccountNumber();
108 }
109
110 public String getInvoiceItemDescription() {
111 return invoiceDetail.getInvoiceItemDescription();
112 }
113
114 public KualiDecimal getAmount() {
115 return invoiceDetail.getAmount();
116 }
117
118 public boolean isInvoiceQuickApplied() {
119 return invoiceQuickApplied;
120 }
121
122 public void setInvoiceQuickApplied(boolean invoiceQuickApplied) {
123 this.invoiceQuickApplied = invoiceQuickApplied;
124 }
125
126 }