001/* 002 * Copyright 2009 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 */ 016package org.kuali.ole.module.purap.document.validation.impl; 017 018import org.kuali.ole.module.purap.businessobject.PaymentRequestItem; 019import org.kuali.ole.module.purap.businessobject.PurApAccountingLine; 020import org.kuali.ole.sys.document.validation.GenericValidation; 021import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent; 022import org.kuali.rice.krad.util.ObjectUtils; 023 024public class PaymentRequestProcessAccountValidation extends GenericValidation { 025 026 private PurchasingAccountsPayableHasAccountsValidation hasAccountsValidation; 027 private PurchasingAccountsPayableAccountPercentValidation accountPercentValidation; 028 private PaymentRequestAccountTotalValidation accountTotalValidation; 029 private PurchasingAccountsPayableUniqueAccountingStringsValidation accountingStringsValidation; 030 private PaymentRequestItem itemForValidation; 031 private PurchasingAccountsPayableAccountAtleastOneLineHasPercentValidation accountHasAtleastOnePercentValidation; 032 private PurchasingAccountingLineAmountValidation accountLineAmountValidation; 033 034 @Override 035 public boolean validate(AttributedDocumentEvent event) { 036 boolean valid = true; 037 038 if (ObjectUtils.isNull(itemForValidation)) { 039 return valid; 040 } 041 042 hasAccountsValidation.setItemForValidation(itemForValidation); 043 valid &= hasAccountsValidation.validate(event); 044 045 if (valid) { 046 accountPercentValidation.setItemForValidation(itemForValidation); 047 valid &= accountPercentValidation.validate(event); 048 } 049 050 if (valid) { 051 accountTotalValidation.setItemForValidation(itemForValidation); 052 valid &= accountTotalValidation.validate(event); 053 } 054 055 accountingStringsValidation.setItemForValidation(itemForValidation); 056 valid &= accountingStringsValidation.validate(event); 057 058 if (valid) { 059 getAccountHasAtlestOnePercentValidation().setItemForValidation(itemForValidation); 060 valid &= getAccountHasAtlestOnePercentValidation().validate(event); 061 } 062 063 if (valid) { 064 for (PurApAccountingLine account : itemForValidation.getSourceAccountingLines()) { 065 getAccountLineAmountValidation().setUpdatedAccountingLine(account); 066 valid &= getAccountLineAmountValidation().validate(event); 067 if (!valid) { 068 break; 069 } 070 } 071 } 072 073 return valid; 074 } 075 076 public PurchasingAccountsPayableHasAccountsValidation getHasAccountsValidation() { 077 return hasAccountsValidation; 078 } 079 080 public void setHasAccountsValidation(PurchasingAccountsPayableHasAccountsValidation hasAccountsValidation) { 081 this.hasAccountsValidation = hasAccountsValidation; 082 } 083 084 085 public PaymentRequestAccountTotalValidation getAccountTotalValidation() { 086 return accountTotalValidation; 087 } 088 089 public void setAccountTotalValidation(PaymentRequestAccountTotalValidation accountTotalValidation) { 090 this.accountTotalValidation = accountTotalValidation; 091 } 092 093 094 public PurchasingAccountsPayableUniqueAccountingStringsValidation getAccountingStringsValidation() { 095 return accountingStringsValidation; 096 } 097 098 public void setAccountingStringsValidation(PurchasingAccountsPayableUniqueAccountingStringsValidation accountingStringsValidation) { 099 this.accountingStringsValidation = accountingStringsValidation; 100 } 101 102 public PaymentRequestItem getItemForValidation() { 103 return itemForValidation; 104 } 105 106 public void setItemForValidation(PaymentRequestItem itemForValidation) { 107 this.itemForValidation = itemForValidation; 108 } 109 110 /** 111 * @return Returns the accountHasAtleastOnePercentValidation 112 */ 113 114 public PurchasingAccountsPayableAccountAtleastOneLineHasPercentValidation getAccountHasAtlestOnePercentValidation() { 115 return accountHasAtleastOnePercentValidation; 116 } 117 118 /** 119 * Sets the accountHasAtleastOnePercentValidation attribute. 120 * 121 * @param accountHasAtleastOnePercentValidation 122 * The accountHasAtleastOnePercentValidation to set. 123 */ 124 public void setAccountHasAtleastOnePercentValidation(PurchasingAccountsPayableAccountAtleastOneLineHasPercentValidation accountHasAtleastOnePercentValidation) { 125 this.accountHasAtleastOnePercentValidation = accountHasAtleastOnePercentValidation; 126 } 127 128 /** 129 * Gets the accountLineAmountValidation attribute. 130 * 131 * @return Returns the accountLineAmountValidation 132 */ 133 134 public PurchasingAccountingLineAmountValidation getAccountLineAmountValidation() { 135 return accountLineAmountValidation; 136 } 137 138 /** 139 * Sets the accountLineAmountValidation attribute. 140 * 141 * @param accountLineAmountValidation The accountLineAmountValidation to set. 142 */ 143 public void setAccountLineAmountValidation(PurchasingAccountingLineAmountValidation accountLineAmountValidation) { 144 this.accountLineAmountValidation = accountLineAmountValidation; 145 } 146 147 public PurchasingAccountsPayableAccountPercentValidation getAccountPercentValidation() { 148 return accountPercentValidation; 149 } 150 151 public void setAccountPercentValidation(PurchasingAccountsPayableAccountPercentValidation accountPercentValidation) { 152 this.accountPercentValidation = accountPercentValidation; 153 } 154 155}