1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.module.purap.document.web.struts;
17
18 import org.kuali.ole.module.purap.PurapAuthorizationConstants.PaymentRequestEditMode;
19 import org.kuali.ole.module.purap.PurapConstants;
20 import org.kuali.ole.module.purap.PurapConstants.PaymentRequestStatuses;
21 import org.kuali.ole.module.purap.businessobject.PurApItem;
22 import org.kuali.ole.module.purap.document.PaymentRequestDocument;
23 import org.kuali.ole.module.purap.document.service.PurapService;
24 import org.kuali.ole.select.businessobject.OlePurchaseOrderItem;
25 import org.kuali.ole.sys.OLEConstants;
26 import org.kuali.ole.sys.context.SpringContext;
27 import org.kuali.rice.core.api.config.property.ConfigurationService;
28 import org.kuali.rice.kew.api.WorkflowDocument;
29 import org.kuali.rice.kns.document.authorization.DocumentAuthorizer;
30 import org.kuali.rice.kns.service.DocumentHelperService;
31 import org.kuali.rice.kns.web.ui.ExtraButton;
32 import org.kuali.rice.kns.web.ui.HeaderField;
33 import org.kuali.rice.krad.util.GlobalVariables;
34 import org.kuali.rice.krad.util.KRADConstants;
35 import org.kuali.rice.krad.util.ObjectUtils;
36
37 import javax.servlet.http.HttpServletRequest;
38 import java.util.List;
39
40
41
42
43 public class PaymentRequestForm extends AccountsPayableFormBase {
44
45
46
47
48
49 protected boolean calculatedTax;
50
51
52
53
54 public PaymentRequestForm() {
55 super();
56 this.setNewPurchasingItemLine(setupNewPurchasingItemLine());
57
58 setReadOnlyAccountDistributionMethod(true);
59 }
60
61 @Override
62 protected String getDefaultDocumentTypeName() {
63 return "OLE_PREQ";
64 }
65
66 public boolean isCalculatedTax() {
67 return calculatedTax;
68 }
69
70 public void setCalculatedTax(boolean calculatedTax) {
71 this.calculatedTax = calculatedTax;
72 }
73
74 public PaymentRequestDocument getPaymentRequestDocument() {
75 return (PaymentRequestDocument) getDocument();
76 }
77
78 public void setPaymentRequestDocument(PaymentRequestDocument purchaseOrderDocument) {
79 setDocument(purchaseOrderDocument);
80 }
81
82 @Override
83 public void populateHeaderFields(WorkflowDocument workflowDocument) {
84 super.populateHeaderFields(workflowDocument);
85
86 if (ObjectUtils.isNotNull(this.getPaymentRequestDocument().getPurapDocumentIdentifier())) {
87 getDocInfo().add(new HeaderField("DataDictionary.PaymentRequestDocument.attributes.purapDocumentIdentifier", ((PaymentRequestDocument) this.getDocument()).getPurapDocumentIdentifier().toString()));
88 } else {
89 getDocInfo().add(new HeaderField("DataDictionary.PaymentRequestDocument.attributes.purapDocumentIdentifier", "Not Available"));
90 }
91
92 String applicationDocumentStatus = "Not Available";
93
94 if (ObjectUtils.isNotNull(this.getPaymentRequestDocument().getApplicationDocumentStatus())) {
95 applicationDocumentStatus = workflowDocument.getApplicationDocumentStatus();
96 }
97
98 getDocInfo().add(new HeaderField("DataDictionary.PaymentRequestDocument.attributes.applicationDocumentStatus", applicationDocumentStatus));
99 }
100
101
102
103
104 @Override
105 public PurApItem setupNewPurchasingItemLine() {
106 return new OlePurchaseOrderItem();
107 }
108
109
110
111
112
113
114
115
116
117
118 @Override
119 public List<ExtraButton> getExtraButtons() {
120 extraButtons.clear();
121 PaymentRequestDocument paymentRequestDocument = this.getPaymentRequestDocument();
122 String externalImageURL = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(OLEConstants.RICE_EXTERNALIZABLE_IMAGES_URL_KEY);
123 String appExternalImageURL = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(OLEConstants.EXTERNALIZABLE_IMAGES_URL_KEY);
124
125 if (canContinue()) {
126 addExtraButton("methodToCall.continuePREQ", externalImageURL + "buttonsmall_continue.gif", "Continue");
127 addExtraButton("methodToCall.clearInitFields", externalImageURL + "buttonsmall_clear.gif", "Clear");
128 } else {
129 if (getEditingMode().containsKey(PaymentRequestEditMode.HOLD)) {
130 addExtraButton("methodToCall.addHoldOnPayment", appExternalImageURL + "buttonsmall_hold.gif", "Hold");
131 }
132
133 if (getEditingMode().containsKey(PaymentRequestEditMode.REMOVE_HOLD) && paymentRequestDocument.isHoldIndicator()) {
134 addExtraButton("methodToCall.removeHoldFromPayment", appExternalImageURL + "buttonsmall_removehold.gif", "Remove");
135 }
136
137 if (getEditingMode().containsKey(PaymentRequestEditMode.REQUEST_CANCEL)) {
138 addExtraButton("methodToCall.requestCancelOnPayment", appExternalImageURL + "buttonsmall_requestcancel.gif", "Cancel");
139 }
140
141 if (getEditingMode().containsKey(PaymentRequestEditMode.REMOVE_REQUEST_CANCEL) && paymentRequestDocument.isPaymentRequestedCancelIndicator()) {
142 addExtraButton("methodToCall.removeCancelRequestFromPayment", appExternalImageURL + "buttonsmall_remreqcanc.gif", "Remove");
143 }
144
145 if (canCalculate()) {
146 addExtraButton("methodToCall.calculate", appExternalImageURL + "buttonsmall_calculate.gif", "Calculate");
147 }
148
149 if (getEditingMode().containsKey(PaymentRequestEditMode.ACCOUNTS_PAYABLE_PROCESSOR_CANCEL) ||
150 getEditingMode().containsKey(PaymentRequestEditMode.ACCOUNTS_PAYABLE_MANAGER_CANCEL)) {
151 if (PurapConstants.PurchaseOrderStatuses.APPDOC_CLOSED.equals(paymentRequestDocument.getPurchaseOrderDocument().getApplicationDocumentStatus())) {
152
153 if (!paymentRequestDocument.getPurchaseOrderDocument().isPendingActionIndicator()) {
154 addExtraButton("methodToCall.reopenPo", appExternalImageURL + "buttonsmall_openorder.gif", "Reopen PO");
155 }
156 } else {
157 if (!paymentRequestDocument.getFinancialSystemDocumentHeader().getWorkflowDocument().isDisapproved()) {
158 addExtraButton("methodToCall.cancel", externalImageURL + "buttonsmall_cancel.gif", "Cancel");
159 }
160 }
161 }
162 }
163
164 return extraButtons;
165 }
166
167
168
169
170
171
172
173
174 public boolean canContinue() {
175
176 boolean can = PaymentRequestStatuses.APPDOC_INITIATE.equals(getPaymentRequestDocument().getApplicationDocumentStatus());
177
178
179 if (can) {
180 DocumentAuthorizer documentAuthorizer = SpringContext.getBean(DocumentHelperService.class).getDocumentAuthorizer(getPaymentRequestDocument());
181 can = documentAuthorizer.canInitiate(OLEConstants.FinancialDocumentTypeCodes.PAYMENT_REQUEST, GlobalVariables.getUserSession().getPerson());
182 }
183
184 return can;
185 }
186
187
188
189
190
191
192
193
194 public boolean canCalculate() {
195
196 boolean can = !SpringContext.getBean(PurapService.class).isFullDocumentEntryCompleted(getPaymentRequestDocument());
197
198
199 can = can && documentActions.containsKey(KRADConstants.KUALI_ACTION_CAN_EDIT);
200
201
202 can = can || editingMode.containsKey(PaymentRequestEditMode.TAX_AREA_EDITABLE);
203
204 return can;
205 }
206
207
208
209
210 @Override
211 public boolean shouldMethodToCallParameterBeUsed(String methodToCallParameterName, String methodToCallParameterValue, HttpServletRequest request) {
212 if (KRADConstants.DISPATCH_REQUEST_PARAMETER.equals(methodToCallParameterName) &&
213 ("changeUseTaxIndicator".equals(methodToCallParameterValue))) {
214 return true;
215 }
216 return super.shouldMethodToCallParameterBeUsed(methodToCallParameterName, methodToCallParameterValue, request);
217 }
218
219 }
220