1 /*
2 * Copyright 2008 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.kuali.ole.select.document.validation.impl;
17
18 import org.kuali.ole.sys.OLEConstants;
19 import org.kuali.ole.sys.businessobject.AccountingLine;
20 import org.kuali.ole.sys.document.validation.GenericValidation;
21 import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
22 import org.kuali.rice.krad.util.GlobalVariables;
23
24 import static org.kuali.ole.sys.OLEConstants.AMOUNT_PROPERTY_NAME;
25
26 /**
27 * A validation that checks that the credits and debits of GLPEs generated by a document are balanced.
28 */
29 public class OleAccountingLineAmountValidation extends GenericValidation {
30 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OleAccountingLineAmountValidation.class);
31
32 private AccountingLine accountingLineForValidation;
33
34 /**
35 * Generates the GLPEs for a given accounting document and checks that the debits total equals
36 * the credits total.
37 * <strong>Expects the document to be sent in as a property.</strong>
38 *
39 * @see org.kuali.ole.sys.document.validation.GenericValidation#validate(java.lang.Object[])
40 */
41 @Override
42 public boolean validate(AttributedDocumentEvent event) {
43 LOG.debug("Validation started");
44 boolean isValid = true;
45 if (accountingLineForValidation.getAmount() == null) {
46 GlobalVariables.getMessageMap().putError(AMOUNT_PROPERTY_NAME, OLEConstants.ERROR_AMOUNT, "");
47 isValid = false;
48 }
49 return isValid;
50 }
51
52 /**
53 * Gets the accountingLineForValidation attribute.
54 *
55 * @return Returns the accountingLineForValidation.
56 */
57 public AccountingLine getAccountingLineForValidation() {
58 return accountingLineForValidation;
59 }
60
61 /**
62 * Sets the accountingLineForValidation attribute value.
63 *
64 * @param accountingLineForValidation The accountingLineForValidation to set.
65 */
66 public void setAccountingLineForValidation(AccountingLine accountingLineForValidation) {
67 this.accountingLineForValidation = accountingLineForValidation;
68 }
69 }