1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.module.purap.document.validation.impl;
17
18 import org.kuali.ole.module.purap.businessobject.PaymentRequestItem;
19 import org.kuali.ole.module.purap.document.PaymentRequestDocument;
20 import org.kuali.ole.sys.document.validation.GenericValidation;
21 import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
22
23 import java.math.BigDecimal;
24
25 public class PaymentRequestReviewValidation extends GenericValidation {
26 protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(PaymentRequestReviewValidation.class);
27
28 private PaymentRequestItem itemForValidation;
29
30 public boolean validate(AttributedDocumentEvent event) {
31 boolean valid = true;
32 PaymentRequestDocument paymentRequest = (PaymentRequestDocument) event.getDocument();
33
34
35 boolean containsAccounts = false;
36 int accountLineNbr = 0;
37
38 String identifier = itemForValidation.getItemIdentifierString();
39 BigDecimal total = BigDecimal.ZERO;
40 if (LOG.isDebugEnabled()) {
41 LOG.debug("validatePaymentRequestReview() The " + identifier + " is getting the total percent field set to " + BigDecimal.ZERO);
42 }
43
44 if ((itemForValidation.getTotalAmount() != null && itemForValidation.getTotalAmount().isNonZero() && itemForValidation.getItemType().isLineItemIndicator() && ((itemForValidation.getItemType().isAmountBasedGeneralLedgerIndicator() && (itemForValidation.getPoOutstandingAmount() == null || itemForValidation.getPoOutstandingAmount().isZero())) || (itemForValidation.getItemType().isQuantityBasedGeneralLedgerIndicator() && (itemForValidation.getPoOutstandingQuantity() == null || itemForValidation.getPoOutstandingQuantity().isZero()))))) {
45
46
47 if (itemForValidation.getItemType().isAmountBasedGeneralLedgerIndicator()) {
48 String error = "Payment Request " + paymentRequest.getPurapDocumentIdentifier() + ", " + identifier + " has total amount '" + itemForValidation.getTotalAmount() + "' but outstanding encumbered amount " + itemForValidation.getPoOutstandingAmount();
49 LOG.error("validatePaymentRequestReview() " + error);
50 } else {
51 String error = "Payment Request " + paymentRequest.getPurapDocumentIdentifier() + ", " + identifier + " has quantity '" + itemForValidation.getItemQuantity() + "' but outstanding encumbered quantity " + itemForValidation.getPoOutstandingQuantity();
52 LOG.error("validatePaymentRequestReview() " + error);
53 }
54 } else {
55
56 String error = "Payment Request " + paymentRequest.getPurapDocumentIdentifier() + ", " + identifier + " has total amount '" + itemForValidation.getTotalAmount() + "'";
57 if (itemForValidation.getItemType().isLineItemIndicator()) {
58 if (itemForValidation.getItemType().isAmountBasedGeneralLedgerIndicator()) {
59 error = error + " with outstanding encumbered amount " + itemForValidation.getPoOutstandingAmount();
60 } else {
61 error = error + " with outstanding encumbered quantity " + itemForValidation.getPoOutstandingQuantity();
62 }
63 }
64 LOG.info("validatePaymentRequestReview() " + error);
65 }
66
67 return valid;
68 }
69
70
71 public PaymentRequestItem getItemForValidation() {
72 return itemForValidation;
73 }
74
75 public void setItemForValidation(PaymentRequestItem itemForValidation) {
76 this.itemForValidation = itemForValidation;
77 }
78
79
80 }