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
19 import org.apache.commons.lang.StringUtils;
20 import org.kuali.ole.module.purap.PurapConstants;
21 import org.kuali.ole.module.purap.businessobject.PurApItem;
22 import org.kuali.ole.module.purap.businessobject.PurchasingItemBase;
23 import org.kuali.ole.module.purap.document.PurchasingAccountsPayableDocument;
24 import org.kuali.ole.module.purap.document.PurchasingDocumentBase;
25 import org.kuali.ole.module.purap.document.web.struts.PurchasingFormBase;
26 import org.kuali.ole.sys.OLEConstants;
27 import org.kuali.rice.krad.document.Document;
28
29 public abstract class PurchasingDocumentPreRulesBase extends PurapDocumentPreRulesBase {
30
31 @Override
32 public boolean doPrompts(Document document) {
33 PurchasingAccountsPayableDocument purapDocument = (PurchasingAccountsPayableDocument) document;
34
35 boolean preRulesValid = super.doPrompts(document);
36
37 if (StringUtils.isBlank(event.getQuestionContext()) || StringUtils.equals(question, PurapConstants.FIX_CAPITAL_ASSET_WARNINGS)) {
38 preRulesValid &= confirmFixCapitalAssetWarningConditions(purapDocument);
39 }
40
41 return preRulesValid;
42 }
43
44 protected boolean checkForTaxRecalculation(PurchasingAccountsPayableDocument purapDocument) {
45
46 String initialZipCode = ((PurchasingFormBase) form).getInitialZipCode();
47 if (StringUtils.isNotEmpty(initialZipCode) && !StringUtils.equals(initialZipCode, ((PurchasingDocumentBase) purapDocument).getDeliveryPostalCode())) {
48 for (PurApItem purApItem : purapDocument.getItems()) {
49 PurchasingItemBase item = (PurchasingItemBase) purApItem;
50 if (item.getItemTaxAmount() != null) {
51
52 StringBuffer questionTextBuffer = new StringBuffer("");
53 questionTextBuffer.append(PurapConstants.TAX_RECALCULATION_QUESTION);
54
55 Boolean proceed = super.askOrAnalyzeYesNoQuestion(PurapConstants.TAX_RECALCULATION_INFO, questionTextBuffer.toString());
56
57
58 if (proceed && StringUtils.isBlank(event.getQuestionContext())) {
59 event.setQuestionContext(PurapConstants.TAX_RECALCULATION_INFO);
60 }
61
62 if (!proceed) {
63 event.setActionForwardName(OLEConstants.MAPPING_BASIC);
64 return false;
65 }
66 }
67 }
68 }
69
70 return true;
71 }
72
73
74 }