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.PurapKeyConstants;
19 import org.kuali.ole.module.purap.PurapPropertyConstants;
20 import org.kuali.ole.module.purap.businessobject.PurApAccountingLine;
21 import org.kuali.ole.sys.businessobject.AccountingLine;
22 import org.kuali.ole.sys.document.validation.GenericValidation;
23 import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
24 import org.kuali.rice.krad.util.GlobalVariables;
25
26 public class PurchasingUpdateAccountingLineValidation extends GenericValidation {
27
28 private AccountingLine updatedAccountingLine;
29
30 public boolean validate(AttributedDocumentEvent event) {
31
32 if (updatedAccountingLine instanceof PurApAccountingLine) {
33 return verifyAccountingLinePercent((PurApAccountingLine) updatedAccountingLine);
34 }
35 return true;
36 }
37
38
39
40
41
42
43
44 protected boolean verifyAccountingLinePercent(PurApAccountingLine purapAccountingLine) {
45
46 if (purapAccountingLine.getAccountLinePercent().stripTrailingZeros().scale() > 0) {
47 GlobalVariables.getMessageMap().putError(PurapPropertyConstants.ACCOUNTS, PurapKeyConstants.ERROR_PURCHASING_PERCENT_NOT_WHOLE, purapAccountingLine.getAccountLinePercent().toPlainString());
48
49 return false;
50 }
51
52 return true;
53 }
54
55 public AccountingLine getUpdatedAccountingLine() {
56 return updatedAccountingLine;
57 }
58
59 public void setUpdatedAccountingLine(AccountingLine updatedAccountingLine) {
60 this.updatedAccountingLine = updatedAccountingLine;
61 }
62
63 }