View Javadoc
1   /*
2    * Copyright 2009 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.module.purap.businessobject.PurApAccountingLine;
19  import org.kuali.ole.module.purap.businessobject.PurApItem;
20  import org.kuali.ole.module.purap.document.validation.impl.PurchasingAccountsPayableAccountTotalValidation;
21  import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
22  
23  import java.math.BigDecimal;
24  
25  public class OlePurchasingAccountsPayableAccountTotalValidation extends PurchasingAccountsPayableAccountTotalValidation {
26  
27      private PurApItem itemForValidation;
28  
29      /**
30       * Verifies account percent. If the total percent does not equal 100, the validation fails.
31       */
32      @Override
33      public boolean validate(AttributedDocumentEvent event) {
34          boolean valid = true;
35  
36          // validate that the amount total
37          BigDecimal totalAmount = BigDecimal.ZERO;
38          BigDecimal desiredAmount =
39                  (itemForValidation.getTotalAmount() == null) ? new BigDecimal(0) : itemForValidation.getTotalAmount().bigDecimalValue();
40          for (PurApAccountingLine account : itemForValidation.getSourceAccountingLines()) {
41              if (account.getAmount() != null) {
42                  totalAmount = totalAmount.add(account.getAmount().bigDecimalValue());
43              } else {
44                  totalAmount = totalAmount.add(BigDecimal.ZERO);
45              }
46          }
47  
48          /*
49           * if (desiredAmount.compareTo(totalAmount) != 0) {
50           * GlobalVariables.getMessageMap().putError(PurapConstants.ITEM_TAB_ERROR_PROPERTY,
51           * PurapKeyConstants.ERROR_ITEM_ACCOUNTING_TOTAL_AMOUNT, itemForValidation.getItemIdentifierString(),
52           * desiredAmount.toString()); valid = false; }
53           */
54  
55  
56          return valid;
57      }
58  
59      public PurApItem getItemForValidation() {
60          return itemForValidation;
61      }
62  
63      public void setItemForValidation(PurApItem itemForValidation) {
64          this.itemForValidation = itemForValidation;
65      }
66  
67  }