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.PurapConstants;
19 import org.kuali.ole.module.purap.PurapParameterConstants;
20 import org.kuali.ole.module.purap.document.AccountsPayableDocument;
21 import org.kuali.ole.module.purap.document.PurchasingAccountsPayableDocument;
22 import org.kuali.ole.module.purap.document.VendorCreditMemoDocument;
23 import org.kuali.ole.sys.context.SpringContext;
24 import org.kuali.ole.sys.service.impl.OleParameterConstants;
25 import org.kuali.rice.core.web.format.CurrencyFormatter;
26 import org.kuali.rice.coreservice.framework.parameter.ParameterService;
27 import org.kuali.rice.krad.document.Document;
28
29
30
31
32 public class CreditMemoDocumentPreRules extends AccountsPayableDocumentPreRulesBase {
33
34
35
36
37 public CreditMemoDocumentPreRules() {
38 super();
39 }
40
41
42
43
44 @Override
45 public boolean doPrompts(Document document) {
46 return super.doPrompts(document);
47 }
48
49
50
51
52 @Override
53 public String getDocumentName() {
54 return "Credit Memo";
55 }
56
57
58
59
60 @Override
61 public String createInvoiceNoMatchQuestionText(AccountsPayableDocument accountsPayableDocument) {
62
63 String questionText = super.createInvoiceNoMatchQuestionText(accountsPayableDocument);
64
65 CurrencyFormatter cf = new CurrencyFormatter();
66 VendorCreditMemoDocument cm = (VendorCreditMemoDocument) accountsPayableDocument;
67 StringBuffer questionTextBuffer = new StringBuffer("");
68 questionTextBuffer.append(questionText);
69
70 questionTextBuffer.append("[br][br][b]Summary Detail Below[/b][br][br][table questionTable]");
71 questionTextBuffer.append("[tr][td leftTd]Credit Memo Amount entered on start screen:[/td][td rightTd]").append((String) cf.format(cm.getInitialAmount())).append("[/td][/tr]");
72 questionTextBuffer.append("[tr][td leftTd]Total credit processed prior to restocking fee:[/td][td rightTd]").append((String) cf.format(cm.getLineItemTotal())).append("[/td][/tr]");
73
74
75 boolean salesTaxInd = SpringContext.getBean(ParameterService.class).getParameterValueAsBoolean(OleParameterConstants.PURCHASING_DOCUMENT.class, PurapParameterConstants.ENABLE_SALES_TAX_IND);
76 if (salesTaxInd) {
77 questionTextBuffer.append("[tr][td leftTd]Grand Total Prior to Tax:[/td][td rightTd]").append((String) cf.format(cm.getGrandPreTaxTotal())).append("[/td][/tr]");
78 questionTextBuffer.append("[tr][td leftTd]Grand Total Tax:[/td][td rightTd]").append((String) cf.format(cm.getGrandTaxAmount())).append("[/td][/tr]");
79 }
80
81 questionTextBuffer.append("[tr][td leftTd]Grand Total:[/td][td rightTd]").append((String) cf.format(cm.getGrandTotal())).append("[/td][/tr][/table]");
82
83 return questionTextBuffer.toString();
84
85 }
86
87 @Override
88 protected boolean checkCAMSWarningStatus(PurchasingAccountsPayableDocument purapDocument) {
89 return PurapConstants.CAMSWarningStatuses.CREDIT_MEMO_STATUS_WARNING_NO_CAMS_DATA.contains(purapDocument.getApplicationDocumentStatus());
90 }
91
92
93
94
95
96
97
98 @Override
99 protected boolean validateInvoiceTotalsAreMismatched(AccountsPayableDocument accountsPayableDocument) {
100 boolean mismatched = false;
101 String[] excludeArray = {PurapConstants.ItemTypeCodes.ITEM_TYPE_PMT_TERMS_DISCOUNT_CODE};
102
103
104
105 if (accountsPayableDocument.isUseTaxIndicator()) {
106 if (accountsPayableDocument.getTotalPreTaxDollarAmountAllItems(excludeArray).compareTo(accountsPayableDocument.getInitialAmount()) != 0 && !accountsPayableDocument.isUnmatchedOverride()) {
107 mismatched = true;
108 }
109 }
110
111
112 else {
113 if (accountsPayableDocument.getTotalDollarAmountAllItems(excludeArray).compareTo(accountsPayableDocument.getInitialAmount()) != 0 && !accountsPayableDocument.isUnmatchedOverride()) {
114 mismatched = true;
115 }
116 }
117 return mismatched;
118 }
119 }