/* * The Kuali Financial System, a comprehensive financial management system for higher education. * * Copyright 2005-2014 The Kuali Foundation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.kuali.kfs.fp.document.validation.impl; import org.kuali.kfs.fp.businessobject.BudgetAdjustmentAccountingLine; import org.kuali.kfs.sys.KFSKeyConstants; import org.kuali.kfs.sys.KFSPropertyConstants; import org.kuali.kfs.sys.document.validation.GenericValidation; import org.kuali.kfs.sys.document.validation.event.AttributedDocumentEvent; import org.kuali.rice.core.api.util.type.KualiDecimal; import org.kuali.rice.krad.util.GlobalVariables; /** * Validation for a budget adjustment accounting line that validates the information in the monthly lines */ public class BudgetAdjustmentAccountingLineMonthlyLinesValidation extends GenericValidation { private BudgetAdjustmentAccountingLine accountingLineForValidation; /** * Validates the total of the monthly amount fields (if not 0) equals the current budget amount. If current budget is 0, then * total of monthly fields must be 0. * * @see org.kuali.kfs.sys.document.validation.Validation#validate(org.kuali.kfs.sys.document.validation.event.AttributedDocumentEvent) */ public boolean validate(AttributedDocumentEvent event) { boolean validMonthlyLines = true; KualiDecimal monthlyTotal = getAccountingLineForValidation().getMonthlyLinesTotal(); if (monthlyTotal.isNonZero() && monthlyTotal.compareTo(getAccountingLineForValidation().getCurrentBudgetAdjustmentAmount()) != 0) { GlobalVariables.getMessageMap().putError(KFSPropertyConstants.CURRENT_BUDGET_ADJUSTMENT_AMOUNT, KFSKeyConstants.ERROR_DOCUMENT_BA_MONTH_TOTAL_NOT_EQUAL_CURRENT); validMonthlyLines = false; } return validMonthlyLines; } /** * Gets the accountingLineForValidation attribute. * @return Returns the accountingLineForValidation. */ public BudgetAdjustmentAccountingLine getAccountingLineForValidation() { return accountingLineForValidation; } /** * Sets the accountingLineForValidation attribute value. * @param accountingLineForValidation The accountingLineForValidation to set. */ public void setAccountingLineForValidation(BudgetAdjustmentAccountingLine accountingLineForValidation) { this.accountingLineForValidation = accountingLineForValidation; } }