Search in sources :

Example 1 with VendorCreditMemoForm

use of org.kuali.kfs.module.purap.document.web.struts.VendorCreditMemoForm in project cu-kfs by CU-CommunityApps.

the class CuVendorCreditMemoAction method calculate.

@Override
public ActionForward calculate(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    VendorCreditMemoForm cmForm = (VendorCreditMemoForm) form;
    CuVendorCreditMemoDocument creditMemoDocument = (CuVendorCreditMemoDocument) cmForm.getDocument();
    if (creditMemoDocument.getDocumentHeader().getWorkflowDocument().isInitiated() || creditMemoDocument.getDocumentHeader().getWorkflowDocument().isSaved()) {
        // need to check whether the user has the permission to edit the bank code
        // if so, don't synchronize since we can't tell whether the value coming in
        // was entered by the user or not.
        DocumentAuthorizer docAuth = SpringContext.getBean(DocumentHelperService.class).getDocumentAuthorizer(creditMemoDocument);
        if (!docAuth.isAuthorizedByTemplate(creditMemoDocument, KFSConstants.ParameterNamespaces.KFS, KFSConstants.PermissionTemplate.EDIT_BANK_CODE.name, GlobalVariables.getUserSession().getPrincipalId())) {
            creditMemoDocument.synchronizeBankCodeWithPaymentMethod();
        } else {
            // ensure that the name is updated properly
            creditMemoDocument.refreshReferenceObject("bank");
        }
    }
    return super.calculate(mapping, form, request, response);
}
Also used : CuVendorCreditMemoDocument(edu.cornell.kfs.module.purap.document.CuVendorCreditMemoDocument) DocumentAuthorizer(org.kuali.kfs.krad.document.DocumentAuthorizer) VendorCreditMemoForm(org.kuali.kfs.module.purap.document.web.struts.VendorCreditMemoForm) DocumentHelperService(org.kuali.kfs.kns.service.DocumentHelperService)

Aggregations

CuVendorCreditMemoDocument (edu.cornell.kfs.module.purap.document.CuVendorCreditMemoDocument)1 DocumentHelperService (org.kuali.kfs.kns.service.DocumentHelperService)1 DocumentAuthorizer (org.kuali.kfs.krad.document.DocumentAuthorizer)1 VendorCreditMemoForm (org.kuali.kfs.module.purap.document.web.struts.VendorCreditMemoForm)1