use of org.kuali.kfs.module.purap.document.PaymentRequestDocument in project cu-kfs by CU-CommunityApps.
the class CuAccountsPayableBankCodeValidation method validate.
@Override
public boolean validate(AttributedDocumentEvent event) {
AccountsPayableDocumentBase apDocument = (AccountsPayableDocumentBase) getAccountingDocumentForValidation();
// check if one of the extended UA documents, if so, take the payment method into account, otherwise, revert to baseline behavior
boolean isValid = true;
if (apDocument instanceof PaymentRequestDocument) {
if (StringUtils.isNotBlank(apDocument.getBankCode())) {
// PREQ bank code is not required
isValid = CuBankCodeValidation.validate(apDocument.getBankCode(), "document." + PurapPropertyConstants.BANK_CODE, ((CuPaymentRequestDocument) apDocument).getPaymentMethodCode(), false, true);
if (isValid) {
if (!(event instanceof AttributedRouteDocumentEvent) && StringUtils.isNotBlank(apDocument.getBankCode()) && !CuBankCodeValidation.doesBankCodeNeedToBePopulated(((CuPaymentRequestDocument) apDocument).getPaymentMethodCode())) {
apDocument.setBank(null);
apDocument.setBankCode(null);
}
}
}
} else if (apDocument instanceof VendorCreditMemoDocument) {
if (StringUtils.isNotBlank(apDocument.getBankCode())) {
isValid = CuBankCodeValidation.validate(apDocument.getBankCode(), "document." + PurapPropertyConstants.BANK_CODE, ((CuVendorCreditMemoDocument) apDocument).getPaymentMethodCode(), false, true);
if (isValid) {
// clear out the bank code on the document if not needed (per the message set by the call above)
if (StringUtils.isNotBlank(apDocument.getBankCode()) && !CuBankCodeValidation.doesBankCodeNeedToBePopulated(((CuVendorCreditMemoDocument) apDocument).getPaymentMethodCode())) {
apDocument.setBank(null);
apDocument.setBankCode(null);
}
}
}
} else {
isValid = CuBankCodeValidation.validate(apDocument.getBankCode(), "document." + PurapPropertyConstants.BANK_CODE, false, true);
}
return isValid;
}
use of org.kuali.kfs.module.purap.document.PaymentRequestDocument in project cu-kfs by CU-CommunityApps.
the class CuLineItemQuantityNotZero method validate.
public boolean validate(AttributedDocumentEvent event) {
boolean valid = true;
PaymentRequestDocument document = (PaymentRequestDocument) event.getDocument();
GlobalVariables.getMessageMap().clearErrorPath();
GlobalVariables.getMessageMap().addToErrorPath(KFSPropertyConstants.DOCUMENT);
int i = 0;
for (PurApItem item : (List<PurApItem>) document.getItems()) {
KualiDecimal itemQuantity = item.getItemQuantity();
if (!((PaymentRequestItem) item).isNoQtyItem() && itemQuantity != null) {
if (!itemQuantity.isNonZero()) {
GlobalVariables.getMessageMap().putError("item[" + i + "].itemQuantity", PurapKeyConstants.ERROR_PAYMENT_REQUEST_LINE_ITEM_QUANTITY_ZERO);
GlobalVariables.getMessageMap().clearErrorPath();
valid = false;
break;
}
i++;
}
}
return valid;
}
use of org.kuali.kfs.module.purap.document.PaymentRequestDocument in project cu-kfs by CU-CommunityApps.
the class CuPaymentRequestAction method approve.
@Override
public ActionForward approve(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
PaymentRequestDocument preq = ((PaymentRequestForm) form).getPaymentRequestDocument();
SpringContext.getBean(PurapService.class).prorateForTradeInAndFullOrderDiscount(preq);
// if tax is required but not yet calculated, return and prompt user to calculate
if (requiresCalculateTax((PaymentRequestForm) form)) {
GlobalVariables.getMessageMap().putError(KFSConstants.DOCUMENT_ERRORS, PurapKeyConstants.ERROR_APPROVE_REQUIRES_CALCULATE);
return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
// and thus system wouldn't know it's not re-calculated after tax data are changed
if (SpringContext.getBean(KualiRuleService.class).applyRules(new AttributedPreCalculateAccountsPayableEvent(preq))) {
ActionForward forward = super.approve(mapping, form, request, response);
// TODO : this preqacctrevision is new. need to validate with existing system to see if '0' is normal ?
if (StringUtils.equals(preq.getApplicationDocumentStatus(), PaymentRequestStatuses.APPDOC_PAYMENT_METHOD_REVIEW) || StringUtils.equals(preq.getApplicationDocumentStatus(), PaymentRequestStatuses.APPDOC_AWAITING_TAX_REVIEW)) {
SpringContext.getBean(PurapAccountRevisionService.class).savePaymentRequestAccountRevisions(preq.getItems(), preq.getPostingYearFromPendingGLEntries(), preq.getPostingPeriodCodeFromPendingGLEntries());
}
return forward;
} else {
// pre-calculation rules fail, go back to same page with error messages
return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
}
use of org.kuali.kfs.module.purap.document.PaymentRequestDocument in project cu-kfs by CU-CommunityApps.
the class CuPaymentRequestForm method getExtraButtons.
@Override
public List<ExtraButton> getExtraButtons() {
super.getExtraButtons();
PaymentRequestDocument paymentRequestDocument = this.getPaymentRequestDocument();
if (StringUtils.equalsIgnoreCase(paymentRequestDocument.getFinancialSystemDocumentHeader().getApplicationDocumentStatus(), PaymentRequestStatuses.APPDOC_DEPARTMENT_APPROVED) && paymentRequestDocument.getFinancialSystemDocumentHeader().getWorkflowDocument().isFinal() && !SpringContext.getBean(CUPaymentMethodGeneralLedgerPendingEntryService.class).isPaymentMethodProcessedUsingPdp(((CuPaymentRequestDocument) paymentRequestDocument).getPaymentMethodCode())) {
ExtraButton cancelButton = null;
for (ExtraButton extraButton : extraButtons) {
if (StringUtils.equals("methodToCall.cancel", extraButton.getExtraButtonProperty())) {
cancelButton = extraButton;
}
}
if (ObjectUtils.isNotNull(cancelButton)) {
extraButtons.remove(cancelButton);
}
}
return extraButtons;
}
use of org.kuali.kfs.module.purap.document.PaymentRequestDocument in project cu-kfs by CU-CommunityApps.
the class CuPurchasingAccountsPayableObjectCodeOverrideBranchingValidation method determineBranch.
@Override
protected String determineBranch(AttributedDocumentEvent event) {
if (!StringUtils.isBlank(propertyPath)) {
refreshByPath(accountingLineForValidation);
}
boolean isTaxApproval = false;
// KFSPTS-1891 : treasury manager also skip this object type allowed check
boolean isTreasuryApproval = false;
// or if this accounting line is from a Tax Charge line.
if (accountingDocumentForValidation instanceof PaymentRequestDocument) {
PaymentRequestDocument preq = (PaymentRequestDocument) accountingDocumentForValidation;
PurApAccountingLine purapAccountingLine = (PurApAccountingLine) accountingLineForValidation;
PurApItem item = purapAccountingLine.getPurapItem();
if (StringUtils.equals(PaymentRequestStatuses.APPDOC_AWAITING_TAX_REVIEW, preq.getApplicationDocumentStatus())) {
isTaxApproval = true;
} else if (StringUtils.equals(PaymentRequestStatuses.APPDOC_PAYMENT_METHOD_REVIEW, preq.getApplicationDocumentStatus())) {
isTreasuryApproval = true;
} else if (StringUtils.equals(PaymentRequestStatuses.APPDOC_DEPARTMENT_APPROVED, preq.getApplicationDocumentStatus()) && (ObjectUtils.isNotNull(item) && item.getItemType().getIsTaxCharge())) {
isTaxApproval = true;
}
}
if (isTaxApproval || isTreasuryApproval) {
return null;
} else if (isAccountingLineValueAllowed(accountingDocumentForValidation.getClass(), accountingLineForValidation, parameterToCheckAgainst, propertyPath, (responsibleProperty != null ? responsibleProperty : propertyPath))) {
return OBJECT_CODE_OVERRIDEN;
} else {
return OBJECT_CODE_NOT_OVERRIDEN;
}
}
Aggregations