Search in sources :

Example 1 with DisbursementVoucherDocument

use of org.kuali.kfs.fp.document.DisbursementVoucherDocument in project cu-kfs by CU-CommunityApps.

the class PaymentSourceExtractionServiceImpl method getListByDocumentStatusCodeCampus.

/**
 * This method retrieves a list of disbursement voucher documents that are in the status provided for the campus code given.
 *
 * @param statusCode The status of the disbursement vouchers to be retrieved.
 * @param campusCode The campus code that the disbursement vouchers will be associated with.
 * @param immediatesOnly only retrieve Disbursement Vouchers marked for immediate payment
 * @return A collection of disbursement voucher objects that meet the search criteria given.
 */
protected Collection<DisbursementVoucherDocument> getListByDocumentStatusCodeCampus(String statusCode, String campusCode, boolean immediatesOnly) {
    LOG.info("getListByDocumentStatusCodeCampus(statusCode=" + statusCode + ", campusCode=" + campusCode + ", immediatesOnly=" + immediatesOnly + ") started");
    Collection<DisbursementVoucherDocument> list = new ArrayList<DisbursementVoucherDocument>();
    try {
        Collection<DisbursementVoucherDocument> docs = SpringContext.getBean(FinancialSystemDocumentService.class).findByDocumentHeaderStatusCode(DisbursementVoucherDocument.class, statusCode);
        for (DisbursementVoucherDocument element : docs) {
            String dvdCampusCode = element.getCampusCode();
            if (dvdCampusCode.equals(campusCode) && KFSConstants.PaymentSourceConstants.PAYMENT_METHOD_CHECK.equals(element.getDisbVchrPaymentMethodCode())) {
                if ((immediatesOnly && element.isImmediatePaymentIndicator()) || !immediatesOnly) {
                    list.add(element);
                }
            }
        }
    } catch (WorkflowException we) {
        LOG.error("Could not load Disbursement Voucher Documents with status code = " + statusCode + ": " + we);
        throw new RuntimeException(we);
    }
    return list;
}
Also used : WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) ArrayList(java.util.ArrayList) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument) FinancialSystemDocumentService(org.kuali.kfs.sys.document.service.FinancialSystemDocumentService)

Example 2 with DisbursementVoucherDocument

use of org.kuali.kfs.fp.document.DisbursementVoucherDocument in project cu-kfs by CU-CommunityApps.

the class KualiAccountingDocumentActionBase method insertSourceLine.

/**
 * This action executes an insert of a SourceAccountingLine into a document only after validating the accounting line and
 * checking any appropriate business rules.
 *
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return ActionForward
 * @throws Exception
 */
public ActionForward insertSourceLine(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    KualiAccountingDocumentFormBase financialDocumentForm = (KualiAccountingDocumentFormBase) form;
    SourceAccountingLine line = financialDocumentForm.getNewSourceLine();
    // populate chartOfAccountsCode from account number if accounts cant cross chart and Javascript is turned off
    // SpringContext.getBean(AccountService.class).populateAccountingLineChartIfNeeded(line);
    boolean rulePassed = true;
    // DV acct line amount got error during form populate; should not insert this line.  KFSUPGRADE-847
    MessageMap msgMap = GlobalVariables.getMessageMap();
    if (msgMap.hasErrors() && msgMap.getErrorMessages().keySet().contains("newSourceLine.amount") && financialDocumentForm.getDocument() instanceof DisbursementVoucherDocument) {
        rulePassed = false;
    }
    // before we check the regular rules we need to check the sales tax rules
    // TODO: Refactor rules so we no longer have to call this before a copy of the
    // accountingLine
    rulePassed &= checkSalesTax((AccountingDocument) financialDocumentForm.getDocument(), line, true, true, 0);
    // check any business rules
    rulePassed &= SpringContext.getBean(KualiRuleService.class).applyRules(new AddAccountingLineEvent(KFSConstants.NEW_SOURCE_ACCT_LINE_PROPERTY_NAME, financialDocumentForm.getDocument(), line));
    if (rulePassed) {
        // add accountingLine
        SpringContext.getBean(PersistenceService.class).refreshAllNonUpdatingReferences(line);
        insertAccountingLine(true, financialDocumentForm, line);
        // clear the used newTargetLine
        financialDocumentForm.setNewSourceLine(null);
    }
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : PersistenceService(org.kuali.kfs.krad.service.PersistenceService) AddAccountingLineEvent(org.kuali.kfs.sys.document.validation.event.AddAccountingLineEvent) SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) AccountingDocument(org.kuali.kfs.sys.document.AccountingDocument) MessageMap(org.kuali.kfs.krad.util.MessageMap) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument)

Example 3 with DisbursementVoucherDocument

use of org.kuali.kfs.fp.document.DisbursementVoucherDocument in project cu-kfs by CU-CommunityApps.

the class CuDisbursementVoucherExtractionHelperServiceImpl method getCampusListByDocumentStatusCode.

// KFSPTS-1891 : calling PaymentMethodGeneralLedgerPendingEntryService().isPaymentMethodProcessedUsingPdp
// TODO :  this method does not seem to be referenced.
// @Override
protected Set<String> getCampusListByDocumentStatusCode(String statusCode) {
    LOG.debug("getCampusListByDocumentStatusCode() started");
    Set<String> campusSet = new HashSet<String>();
    Collection<DisbursementVoucherDocument> docs = disbursementVoucherDao.getDocumentsByHeaderStatus(statusCode, false);
    for (DisbursementVoucherDocument doc : docs) {
        if (getPaymentMethodGeneralLedgerPendingEntryService().isPaymentMethodProcessedUsingPdp(doc.getDisbVchrPaymentMethodCode())) {
            campusSet.add(doc.getCampusCode());
        }
    }
    return campusSet;
}
Also used : RecurringDisbursementVoucherDocument(edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument) CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument) HashSet(java.util.HashSet)

Example 4 with DisbursementVoucherDocument

use of org.kuali.kfs.fp.document.DisbursementVoucherDocument in project cu-kfs by CU-CommunityApps.

the class CuDisbursementVoucherAccountingLineTotalsValidation method validate.

@Override
public boolean validate(AttributedDocumentEvent event) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("validate start");
    }
    DisbursementVoucherDocument dvDocument = (DisbursementVoucherDocument) event.getDocument();
    Person financialSystemUser = GlobalVariables.getUserSession().getPerson();
    final Set<String> currentEditModes = getEditModesFromDocument(dvDocument, financialSystemUser);
    // amounts can only decrease
    List<String> candidateEditModes = this.getCandidateEditModes();
    if (this.hasRequiredEditMode(currentEditModes, candidateEditModes)) {
        // users in foreign or wire workgroup can increase or decrease amounts because of currency conversion
        List<String> foreignDraftAndWireTransferEditModes = this.getForeignDraftAndWireTransferEditModes(dvDocument);
        if (!this.hasRequiredEditMode(currentEditModes, foreignDraftAndWireTransferEditModes)) {
            DisbursementVoucherDocument persistedDocument = (DisbursementVoucherDocument) retrievePersistedDocument(dvDocument);
            if (persistedDocument == null) {
                handleNonExistentDocumentWhenApproving(dvDocument);
                return true;
            }
            // KFSMI- 5183
            if (persistedDocument.getDocumentHeader().getWorkflowDocument().isSaved() && persistedDocument.getDisbVchrCheckTotalAmount().isZero()) {
                return true;
            }
            // check total cannot decrease
            if (!persistedDocument.getDocumentHeader().getWorkflowDocument().isCompletionRequested() && (!persistedDocument.getDisbVchrCheckTotalAmount().equals(dvDocument.getDisbVchrCheckTotalAmount()))) {
                GlobalVariables.getMessageMap().putError(KFSPropertyConstants.DOCUMENT + "." + KFSPropertyConstants.DISB_VCHR_CHECK_TOTAL_AMOUNT, CUKFSKeyConstants.ERROR_DV_CHECK_TOTAL_NO_CHANGE);
                return false;
            }
        }
        return true;
    }
    // KFSUPGRADE-848 : skip total check here for FO
    final WorkflowDocument workflowDocument = dvDocument.getDocumentHeader().getWorkflowDocument();
    final Set<String> currentRouteLevels = workflowDocument.getCurrentNodeNames();
    if (CollectionUtils.isNotEmpty(currentRouteLevels)) {
        if (currentRouteLevels.contains(DisbursementVoucherConstants.RouteLevelNames.ACCOUNT)) {
            return true;
        }
    }
    if (dvDocument instanceof RecurringDisbursementVoucherDocument) {
        RecurringDisbursementVoucherDocument recurringDV = (RecurringDisbursementVoucherDocument) dvDocument;
        if (!doesAccountingLineTotalEqualDVTotalDollarAmount(recurringDV)) {
            String propertyName = KFSPropertyConstants.DOCUMENT + "." + KFSPropertyConstants.DISB_VCHR_CHECK_TOTAL_AMOUNT;
            GlobalVariables.getMessageMap().putError(propertyName, CUKFSKeyConstants.ERROR_DV_CHECK_TOTAL_MUST_EQUAL_ACCOUNTING_LINE_TOTAL);
            return false;
        }
        if (StringUtils.isEmpty(recurringDV.getDisbVchrCheckStubText()) && !recurringDV.getSourceAccountingLines().isEmpty()) {
            String propertyName = KFSPropertyConstants.DOCUMENT + "." + KFSPropertyConstants.DISB_VCHR_CHECK_STUB_TEXT;
            GlobalVariables.getMessageMap().putError(propertyName, CUKFSKeyConstants.ERROR_DV_CHECK_STUB_REQUIRED);
            return false;
        }
        if (!isAccountingLineEndDateValid(recurringDV)) {
            return false;
        }
    }
    return super.validate(event);
}
Also used : WorkflowDocument(org.kuali.rice.kew.api.WorkflowDocument) RecurringDisbursementVoucherDocument(edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument) Person(org.kuali.rice.kim.api.identity.Person) RecurringDisbursementVoucherDocument(edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument)

Example 5 with DisbursementVoucherDocument

use of org.kuali.kfs.fp.document.DisbursementVoucherDocument in project cu-kfs by CU-CommunityApps.

the class CuDisbursementVoucherDocumentPreRules method setIncomeClassNonReportableForForeignVendorWithNoTaxReviewRequired.

private void setIncomeClassNonReportableForForeignVendorWithNoTaxReviewRequired(Document document) {
    DisbursementVoucherDocument dvDoc = (DisbursementVoucherDocument) document;
    DisbursementVoucherPayeeDetail dvPayeeDetail = dvDoc.getDvPayeeDetail();
    String payeeTypeCode = dvPayeeDetail.getDisbursementVoucherPayeeTypeCode();
    String paymentReasonCode = dvPayeeDetail.getDisbVchrPaymentReasonCode();
    Integer vendorHeaderId = dvPayeeDetail.getDisbVchrVendorHeaderIdNumberAsInteger();
    if (getCuDisbursementVoucherTaxService().isForeignVendorAndTaxReviewNotRequired(payeeTypeCode, paymentReasonCode, vendorHeaderId)) {
        dvDoc.getDvNonResidentAlienTax().setIncomeClassCode(DisbursementVoucherConstants.NRA_TAX_INCOME_CLASS_NON_REPORTABLE);
    }
}
Also used : DisbursementVoucherPayeeDetail(org.kuali.kfs.fp.businessobject.DisbursementVoucherPayeeDetail) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument)

Aggregations

DisbursementVoucherDocument (org.kuali.kfs.fp.document.DisbursementVoucherDocument)44 RecurringDisbursementVoucherDocument (edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument)10 CuDisbursementVoucherDocument (edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)8 WorkflowException (org.kuali.rice.kew.api.exception.WorkflowException)7 ArrayList (java.util.ArrayList)6 List (java.util.List)4 DisbursementVoucherNonEmployeeTravel (org.kuali.kfs.fp.businessobject.DisbursementVoucherNonEmployeeTravel)4 DisbursementVoucherPayeeDetail (org.kuali.kfs.fp.businessobject.DisbursementVoucherPayeeDetail)4 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)4 Date (java.sql.Date)3 DisbursementVoucherNonEmployeeExpense (org.kuali.kfs.fp.businessobject.DisbursementVoucherNonEmployeeExpense)3 DisbursementVoucherTaxService (org.kuali.kfs.fp.document.service.DisbursementVoucherTaxService)3 SourceAccountingLine (org.kuali.kfs.sys.businessobject.SourceAccountingLine)3 VendorDetail (org.kuali.kfs.vnd.businessobject.VendorDetail)3 BatchDisbursementVoucherDocument (com.rsmart.kuali.kfs.fp.document.BatchDisbursementVoucherDocument)2 CuDisbursementVoucherPayeeDetail (edu.cornell.kfs.fp.businessobject.CuDisbursementVoucherPayeeDetail)2 RecurringDisbursementVoucherDetail (edu.cornell.kfs.fp.businessobject.RecurringDisbursementVoucherDetail)2 HashMap (java.util.HashMap)2 DisbursementVoucherPreConferenceRegistrant (org.kuali.kfs.fp.businessobject.DisbursementVoucherPreConferenceRegistrant)2 DisbursementVoucherTravelService (org.kuali.kfs.fp.document.service.DisbursementVoucherTravelService)2