1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.module.purap.businessobject;
17
18 import org.kuali.ole.module.purap.document.service.PurapService;
19 import org.kuali.ole.module.purap.identity.PurapKimAttributes;
20 import org.kuali.ole.select.businessobject.OleInvoiceItem;
21 import org.kuali.ole.sys.OLEConstants;
22 import org.kuali.ole.sys.OLEPropertyConstants;
23 import org.kuali.ole.sys.businessobject.FinancialSystemDocumentHeader;
24 import org.kuali.ole.sys.context.SpringContext;
25 import org.kuali.rice.core.web.format.CurrencyFormatter;
26 import org.kuali.rice.core.web.format.DateFormatter;
27 import org.kuali.rice.krad.bo.Note;
28 import org.kuali.rice.krad.service.BusinessObjectService;
29
30 import java.sql.Date;
31 import java.sql.Timestamp;
32 import java.util.ArrayList;
33 import java.util.HashMap;
34 import java.util.List;
35 import java.util.Map;
36
37
38
39
40 public class InvoiceView extends AbstractRelatedView {
41
42 private String invoiceNumber;
43 private Integer purchaseOrderIdentifier;
44 private boolean paymentHoldIndicator;
45 private boolean invoiceCancelIndicator;
46 private String vendorName;
47 private String vendorCustomerNumber;
48 private Date invoicePayDate;
49 private Timestamp paymentExtractedTimestamp;
50 private Timestamp paymentPaidTimestamp;
51 private Integer accountsPayablePurchasingDocumentLinkIdentifier;
52 private Integer invoiceIdentifier;
53 protected Date invoiceDate;
54 private List<PaymentRequestView> paymentRequestViews = new ArrayList<PaymentRequestView>();
55
56
57 private FinancialSystemDocumentHeader documentHeader;
58
59 public Integer getAccountsPayablePurchasingDocumentLinkIdentifier() {
60 return accountsPayablePurchasingDocumentLinkIdentifier;
61 }
62
63 public void setAccountsPayablePurchasingDocumentLinkIdentifier(Integer accountsPayablePurchasingDocumentLinkIdentifier) {
64 this.accountsPayablePurchasingDocumentLinkIdentifier = accountsPayablePurchasingDocumentLinkIdentifier;
65 }
66
67 public Integer getInvoiceIdentifier() {
68 return invoiceIdentifier;
69 }
70
71 public void setInvoiceIdentifier(Integer invoiceIdentifier) {
72 this.invoiceIdentifier = invoiceIdentifier;
73 }
74
75
76 public Object getTotalAmount() {
77 return (new CurrencyFormatter()).format(documentHeader.getFinancialDocumentTotalAmount());
78 }
79
80 public String getInvoiceNumber() {
81 return invoiceNumber;
82 }
83
84 public void setInvoiceNumber(String invoiceNumber) {
85 this.invoiceNumber = invoiceNumber;
86 }
87
88 public Timestamp getPaymentExtractedTimestamp() {
89 return paymentExtractedTimestamp;
90 }
91
92 public void setPaymentExtractedTimestamp(Timestamp paymentExtractedTimestamp) {
93 this.paymentExtractedTimestamp = paymentExtractedTimestamp;
94 }
95
96 public boolean isPaymentHoldIndicator() {
97 return paymentHoldIndicator;
98 }
99
100 public void setPaymentHoldIndicator(boolean paymentHoldIndicator) {
101 this.paymentHoldIndicator = paymentHoldIndicator;
102 }
103
104 public Timestamp getPaymentPaidTimestamp() {
105 return paymentPaidTimestamp;
106 }
107
108 public void setPaymentPaidTimestamp(Timestamp paymentPaidTimestamp) {
109 this.paymentPaidTimestamp = paymentPaidTimestamp;
110 }
111
112 public boolean isInvoiceCancelIndicator() {
113 return invoiceCancelIndicator;
114 }
115
116 public void setInvoiceCancelIndicator(boolean invoiceCancelIndicator) {
117 this.invoiceCancelIndicator = invoiceCancelIndicator;
118 }
119
120 public Object getInvoicePayDate() {
121 return new DateFormatter().format(invoicePayDate);
122 }
123
124 public void setInvoicePayDate(Date invoicePayDate) {
125 this.invoicePayDate = invoicePayDate;
126 }
127
128 public Integer getPurchaseOrderIdentifier() {
129 return purchaseOrderIdentifier;
130 }
131
132 public void setPurchaseOrderIdentifier(Integer purchaseOrderIdentifier) {
133 this.purchaseOrderIdentifier = purchaseOrderIdentifier;
134 }
135
136 public String getVendorCustomerNumber() {
137 return vendorCustomerNumber;
138 }
139
140 public void setVendorCustomerNumber(String vendorCustomerNumber) {
141 this.vendorCustomerNumber = vendorCustomerNumber;
142 }
143
144 public String getVendorName() {
145 return vendorName;
146 }
147
148 public void setVendorName(String vendorName) {
149 this.vendorName = vendorName;
150 }
151
152
153
154
155 public String getDocumentType() {
156 return OLEConstants.FinancialDocumentTypeCodes.INVOICE;
157 }
158
159
160
161
162
163 @Override
164 public Integer getPurapDocumentIdentifier() {
165 return super.getPurapDocumentIdentifier();
166 }
167
168 @Override
169 public String getDocumentIdentifierString() {
170
171 if(getInvoiceNumber() != null && getInvoiceNumber().trim().length() > 0) {
172 return getInvoiceNumber();
173 }
174 else {
175 return getDocumentNumber();
176 }
177
178
179
180 }
181
182
183
184
185 @Override
186 public List<Note> getNotes() {
187 return super.getNotes();
188 }
189
190
191
192
193 @Override
194 public String getUrl() {
195 return super.getUrl();
196 }
197
198
199
200
201 @Override
202 public String getDocumentTypeName() {
203 return OLEConstants.FinancialDocumentTypeCodes.INVOICE;
204 }
205
206 public Date getInvoiceDate() {
207 return invoiceDate;
208 }
209
210 public void setInvoiceDate(Date invoiceDate) {
211 this.invoiceDate = invoiceDate;
212 }
213
214 public List<PaymentRequestView> getPaymentRequestViews() {
215 if (this.getAccountsPayablePurchasingDocumentLinkIdentifier() != null) {
216 Map criteria = new HashMap();
217 criteria.put(OLEConstants.PUR_DOC_IDENTIFIER,this.getPurapDocumentIdentifier());
218 List<OleInvoiceItem> invoiceItems = (List<OleInvoiceItem>)SpringContext.getBean(BusinessObjectService.class).findMatching(OleInvoiceItem.class,criteria);
219 List<PaymentRequestView> relatedList = new ArrayList<PaymentRequestView>();
220 if (invoiceItems.size() > 0) {
221 for (OleInvoiceItem item : invoiceItems) {
222 Map paymentCriteria = new HashMap();
223 paymentCriteria.put(PurapKimAttributes.ACCOUNTS_PAYABLE_PURCHASING_DOCUMENT_LINK_IDENTIFIER, item.getAccountsPayablePurchasingDocumentLinkIdentifier());
224 paymentCriteria.put(OLEConstants.InvoiceDocument.INVOICE_IDENTIFIER,this.getInvoiceIdentifier());
225 List<PaymentRequestView> paymentViewList = (List<PaymentRequestView>)SpringContext.getBean(BusinessObjectService.class).findMatching(PaymentRequestView.class,paymentCriteria);
226 relatedList.addAll(paymentViewList);
227 }
228 }
229 this.setPaymentRequestViews(relatedList);
230 }
231 return paymentRequestViews;
232 }
233
234 public void setPaymentRequestViews(List<PaymentRequestView> paymentRequestViews) {
235 this.paymentRequestViews = paymentRequestViews;
236 }
237 }