Search in sources :

Example 1 with DisbursementVoucherPayeeDetail

use of org.kuali.kfs.fp.businessobject.DisbursementVoucherPayeeDetail in project cu-kfs by CU-CommunityApps.

the class DisbursementVoucherDocumentBatchServiceImpl method populateBatchSummaryLine.

/**
 * Creates and populates a batch summary line for the disbursement voucher document
 *
 * @param disbursementVoucherDocument batch disbursement voucher document
 * @param MessageMap MessageMap containing errors encountered while populating document
 * @return PurchaseOrderBatchSummaryLine
 */
protected DisbursementVoucherBatchSummaryLine populateBatchSummaryLine(DisbursementVoucherDocument disbursementVoucherDocument, MessageMap MessageMap) {
    DisbursementVoucherBatchSummaryLine batchSummaryLine = new DisbursementVoucherBatchSummaryLine();
    DisbursementVoucherPayeeDetail dvPayeeDetail = disbursementVoucherDocument.getDvPayeeDetail();
    // dvPayeeDetail.refresh();
    Date currentDate = dateTimeService.getCurrentDate();
    batchSummaryLine.setDisbVchrCreateDate(dateTimeService.toDateString(currentDate));
    batchSummaryLine.setDisbVchrPayeeId(dvPayeeDetail.getDisbVchrPayeeIdNumber() + " (" + dvPayeeDetail.getDisbVchrPayeePersonName() + " )");
    if (disbursementVoucherDocument.getDisbVchrCheckTotalAmount() != null) {
        String totalDollarAmount = (String) (new CurrencyFormatter()).formatForPresentation(disbursementVoucherDocument.getDisbVchrCheckTotalAmount());
        batchSummaryLine.setDisbVchrAmount(totalDollarAmount);
    }
    if (disbursementVoucherDocument.getDisbursementVoucherDueDate() != null) {
        batchSummaryLine.setDisbursementVoucherDueDate(disbursementVoucherDocument.getDisbursementVoucherDueDate().toString());
    }
    if (ObjectUtils.isNotNull(dvPayeeDetail.getDisbVchrPaymentReason())) {
        String paymentReasonDescription = dvPayeeDetail.getDisbVchrPaymentReason().getDescription();
        if (paymentReasonDescription.length() >= 50) {
            paymentReasonDescription = paymentReasonDescription.substring(0, 49);
        }
        batchSummaryLine.setDisbVchrPaymentReason(dvPayeeDetail.getDisbVchrPaymentReasonCode() + "-" + paymentReasonDescription);
    }
    batchSummaryLine.setAuditMessage(batchFeedHelperService.getAuditMessage(FPKeyConstants.MESSAGE_AUDIT_DV_SUCCESSFULLY_GENERATED, disbursementVoucherDocument.getDocumentNumber(), MessageMap));
    return batchSummaryLine;
}
Also used : DisbursementVoucherPayeeDetail(org.kuali.kfs.fp.businessobject.DisbursementVoucherPayeeDetail) CurrencyFormatter(org.kuali.rice.core.web.format.CurrencyFormatter) DisbursementVoucherBatchSummaryLine(com.rsmart.kuali.kfs.fp.businessobject.DisbursementVoucherBatchSummaryLine) Date(java.util.Date)

Example 2 with DisbursementVoucherPayeeDetail

use of org.kuali.kfs.fp.businessobject.DisbursementVoucherPayeeDetail 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)

Example 3 with DisbursementVoucherPayeeDetail

use of org.kuali.kfs.fp.businessobject.DisbursementVoucherPayeeDetail in project cu-kfs by CU-CommunityApps.

the class CuDisbursementVoucherNonResidentAlienInformationValidation method validate.

@Override
public boolean validate(AttributedDocumentEvent event) {
    LOG.debug("validate start");
    boolean isValid = true;
    DisbursementVoucherDocument document = (DisbursementVoucherDocument) accountingDocumentForValidation;
    DisbursementVoucherNonResidentAlienTax nonResidentAlienTax = document.getDvNonResidentAlienTax();
    DisbursementVoucherPayeeDetail payeeDetail = document.getDvPayeeDetail();
    Person financialSystemUser = GlobalVariables.getUserSession().getPerson();
    List<String> taxEditMode = this.getTaxEditMode();
    if (!payeeDetail.isDisbVchrAlienPaymentCode() || !this.hasRequiredEditMode(document, financialSystemUser, taxEditMode)) {
        return true;
    }
    MessageMap errors = GlobalVariables.getMessageMap();
    errors.addToErrorPath(KFSPropertyConstants.DOCUMENT);
    errors.addToErrorPath(KFSPropertyConstants.DV_NON_RESIDENT_ALIEN_TAX);
    /* income class code required */
    if (StringUtils.isBlank(nonResidentAlienTax.getIncomeClassCode())) {
        errors.putErrorWithoutFullErrorPath("DVNRATaxErrors", KFSKeyConstants.ERROR_REQUIRED, "Income class code");
        return false;
    }
    /* country code required, unless income type is nonreportable */
    if (StringUtils.isBlank(nonResidentAlienTax.getPostalCountryCode()) && !NRA_TAX_INCOME_CLASS_NON_REPORTABLE.equals(nonResidentAlienTax.getIncomeClassCode())) {
        errors.putErrorWithoutFullErrorPath("DVNRATaxErrors", KFSKeyConstants.ERROR_REQUIRED, "Country code");
        return false;
    }
    // income class is FELLOWSHIP
    if (nonResidentAlienTax.getIncomeClassCode().equals(NRA_TAX_INCOME_CLASS_FELLOWSHIP)) {
    // Place holder for logic related to the ICC
    }
    // income class is INDEPENDENT CONTRACTOR
    if (nonResidentAlienTax.getIncomeClassCode().equals(NRA_TAX_INCOME_CLASS_INDEPENDENT_CONTRACTOR)) {
    // Place holder for logic related to the ICC
    }
    // income class is ROYALTIES
    if (nonResidentAlienTax.getIncomeClassCode().equals(NRA_TAX_INCOME_CLASS_ROYALTIES)) {
    // Place holder for logic related to the ICC
    }
    // income class is NON_REPORTABLE
    if (nonResidentAlienTax.getIncomeClassCode().equals(NRA_TAX_INCOME_CLASS_NON_REPORTABLE)) {
        if ((nonResidentAlienTax.isForeignSourceIncomeCode()) || (nonResidentAlienTax.isIncomeTaxTreatyExemptCode()) || (nonResidentAlienTax.isTaxOtherExemptIndicator()) || (nonResidentAlienTax.isIncomeTaxGrossUpCode()) || (nonResidentAlienTax.isTaxUSAIDPerDiemIndicator()) || (nonResidentAlienTax.getTaxSpecialW4Amount() != null) || (nonResidentAlienTax.getReferenceFinancialDocumentNumber() != null) || (nonResidentAlienTax.getTaxNQIId() != null) || (nonResidentAlienTax.getPostalCountryCode() != null)) {
            String boxCode = "";
            if (nonResidentAlienTax.isForeignSourceIncomeCode()) {
                boxCode = "Foreign Source";
            }
            if (nonResidentAlienTax.isIncomeTaxTreatyExemptCode()) {
                boxCode = "Treaty Exempt";
            }
            if (nonResidentAlienTax.isTaxOtherExemptIndicator()) {
                boxCode = "Exempt Under Other Code";
            }
            if (nonResidentAlienTax.isIncomeTaxGrossUpCode()) {
                boxCode = "Gross Up Payment";
            }
            if (nonResidentAlienTax.isTaxUSAIDPerDiemIndicator()) {
                boxCode = "USAID Per Diem";
            }
            if (nonResidentAlienTax.getTaxSpecialW4Amount() != null) {
                boxCode = "Special W-4 Amount";
            }
            if (nonResidentAlienTax.getReferenceFinancialDocumentNumber() != null) {
                boxCode = "Reference Doc";
            }
            if (nonResidentAlienTax.getTaxNQIId() != null) {
                boxCode = "NQI Id";
            }
            if (nonResidentAlienTax.getPostalCountryCode() != null) {
                boxCode = "Country Code";
            }
            errors.putErrorWithoutFullErrorPath("DVNRATaxErrors", KFSKeyConstants.ERROR_DV_NON_REPORTABLE_ONLY, boxCode);
            return false;
        }
    }
    /* check tax rates */
    if (((nonResidentAlienTax.getFederalIncomeTaxPercent() == null) || (nonResidentAlienTax.getFederalIncomeTaxPercent().equals(KualiDecimal.ZERO))) && (nonResidentAlienTax.getIncomeClassCode().equals(NRA_TAX_INCOME_CLASS_NON_REPORTABLE))) {
        nonResidentAlienTax.setFederalIncomeTaxPercent(KualiDecimal.ZERO);
    } else {
        if (nonResidentAlienTax.getFederalIncomeTaxPercent() == null) {
            errors.putErrorWithoutFullErrorPath("DVNRATaxErrors", KFSKeyConstants.ERROR_REQUIRED, "Federal tax percent");
            return false;
        } else {
            // check Federal tax percent is in non-resident alien tax percent table for income class code
            NonResidentAlienTaxPercent taxPercent = new NonResidentAlienTaxPercent();
            taxPercent.setIncomeClassCode(nonResidentAlienTax.getIncomeClassCode());
            taxPercent.setIncomeTaxTypeCode(FEDERAL_TAX_TYPE_CODE);
            taxPercent.setIncomeTaxPercent(nonResidentAlienTax.getFederalIncomeTaxPercent());
            NonResidentAlienTaxPercent retrievedPercent = (NonResidentAlienTaxPercent) SpringContext.getBean(BusinessObjectService.class).retrieve(taxPercent);
            if (retrievedPercent == null) {
                errors.putErrorWithoutFullErrorPath("DVNRATaxErrors", KFSKeyConstants.ERROR_DV_INVALID_FED_TAX_PERCENT, new String[] { nonResidentAlienTax.getFederalIncomeTaxPercent().toString(), nonResidentAlienTax.getIncomeClassCode() });
                return false;
            }
        }
    }
    if (((nonResidentAlienTax.getStateIncomeTaxPercent() == null) || (nonResidentAlienTax.getStateIncomeTaxPercent().equals(KualiDecimal.ZERO))) && (nonResidentAlienTax.getIncomeClassCode().equals(NRA_TAX_INCOME_CLASS_NON_REPORTABLE))) {
        nonResidentAlienTax.setStateIncomeTaxPercent(KualiDecimal.ZERO);
    } else {
        if (nonResidentAlienTax.getStateIncomeTaxPercent() == null) {
            errors.putErrorWithoutFullErrorPath("DVNRATaxErrors", KFSKeyConstants.ERROR_REQUIRED, "State tax percent");
            return false;
        } else {
            // check State tax percent is in non-resident alien tax percent table for income class code
            NonResidentAlienTaxPercent taxPercent = new NonResidentAlienTaxPercent();
            taxPercent.setIncomeClassCode(nonResidentAlienTax.getIncomeClassCode());
            taxPercent.setIncomeTaxTypeCode(STATE_TAX_TYPE_CODE);
            taxPercent.setIncomeTaxPercent(nonResidentAlienTax.getStateIncomeTaxPercent());
            PersistableBusinessObject retrievedPercent = SpringContext.getBean(BusinessObjectService.class).retrieve(taxPercent);
            if (retrievedPercent == null) {
                errors.putErrorWithoutFullErrorPath("DVNRATaxErrors", KFSKeyConstants.ERROR_DV_INVALID_STATE_TAX_PERCENT, nonResidentAlienTax.getStateIncomeTaxPercent().toString(), nonResidentAlienTax.getIncomeClassCode());
                return false;
            } else {
                if ((!document.getDvNonResidentAlienTax().getIncomeClassCode().equals(NRA_TAX_INCOME_CLASS_ROYALTIES)) && (!document.getDvNonResidentAlienTax().getIncomeClassCode().equals(NRA_TAX_INCOME_CLASS_INDEPENDENT_CONTRACTOR))) {
                    // If fed tax rate is zero, the state tax rate should be zero.
                    if ((document.getDvNonResidentAlienTax().getFederalIncomeTaxPercent().equals(KualiDecimal.ZERO)) && (!document.getDvNonResidentAlienTax().getStateIncomeTaxPercent().isZero())) {
                        errors.putErrorWithoutFullErrorPath("DVNRATaxErrors", KFSKeyConstants.ERROR_DV_STATE_TAX_SHOULD_BE_ZERO);
                        return false;
                    }
                }
            }
        }
    }
    // the 4 check boxes (Foreign Source, Treaty Exempt, Gross Up Payment, Exempt Under Other Code) shall be mutual exclusive
    if (OneOrLessBoxesChecked(document)) {
        // if Foreign Source is checked
        if (nonResidentAlienTax.isForeignSourceIncomeCode()) {
            // Federal and State tax rate should be zero.
            if ((!nonResidentAlienTax.getFederalIncomeTaxPercent().equals(KualiDecimal.ZERO)) || (!nonResidentAlienTax.getStateIncomeTaxPercent().equals(KualiDecimal.ZERO))) {
                errors.putErrorWithoutFullErrorPath("DVNRATaxErrors", KFSKeyConstants.ERROR_DV_NRA_TAX_WHEN_CHECKED_FEDERAL_AND_STATE_TAXES_SHOULD_BE_ZERO, "Foreign Source");
                return false;
            }
            // No other items (mutual exclusiveness checking on USAID Per Diem and Special W-4 Amount are optional here since these are also ensured by their validation later)
            if ((nonResidentAlienTax.isTaxUSAIDPerDiemIndicator()) || (nonResidentAlienTax.getTaxSpecialW4Amount() != null) || (nonResidentAlienTax.getReferenceFinancialDocumentNumber() != null) || (nonResidentAlienTax.getTaxNQIId() != null)) {
                errors.putErrorWithoutFullErrorPath("DVNRATaxErrors", KFSKeyConstants.ERROR_DV_NRA_TAX_WHEN_CHECKED_CANNOT_HAVE_VALUE, "Foreign Source", "NQI Id, Reference Doc, USAID Per Diem, or Special W-4 Amount");
                return false;
            }
        }
        // if Treaty Exempt is checked
        if (nonResidentAlienTax.isIncomeTaxTreatyExemptCode()) {
            // No other items (mutual exclusiveness checking on USAID Per Diem and Special W-4 Amount are optional here since these are also ensured by their validation later)
            if ((nonResidentAlienTax.isTaxUSAIDPerDiemIndicator()) || (nonResidentAlienTax.getTaxSpecialW4Amount() != null) || (nonResidentAlienTax.getReferenceFinancialDocumentNumber() != null) || (nonResidentAlienTax.getTaxNQIId() != null)) {
                errors.putErrorWithoutFullErrorPath("DVNRATaxErrors", KFSKeyConstants.ERROR_DV_NRA_TAX_WHEN_CHECKED_CANNOT_HAVE_VALUE, "Treaty Exempt", "NQI Id, Reference Doc, USAID Per Diem, or Special W-4 Amount");
                return false;
            }
        }
        // if Gross Up Payment is checked
        if (nonResidentAlienTax.isIncomeTaxGrossUpCode()) {
            // NOTE: Also, state tax not allowed to be zero for income classes "R" and "I", however, this rule is already checked in the tax rate section, so no need to re-check
            if ((nonResidentAlienTax.getFederalIncomeTaxPercent().equals(KualiDecimal.ZERO))) {
                errors.putErrorWithoutFullErrorPath("DVNRATaxErrors", KFSKeyConstants.ERROR_DV_NRA_TAX_WHEN_CHECKED_FEDERAL_TAX_CANNOT_BE_ZERO, "Gross Up Payment");
                return false;
            }
            // No other items (mutual exclusiveness checking on USAID Per Diem and Special W-4 Amount are optional here since these are also ensured by their validation later)
            if ((nonResidentAlienTax.isTaxUSAIDPerDiemIndicator()) || (nonResidentAlienTax.getTaxSpecialW4Amount() != null) || (nonResidentAlienTax.getReferenceFinancialDocumentNumber() != null) || (nonResidentAlienTax.getTaxNQIId() != null)) {
                errors.putErrorWithoutFullErrorPath("DVNRATaxErrors", KFSKeyConstants.ERROR_DV_NRA_TAX_WHEN_CHECKED_CANNOT_HAVE_VALUE, "Gross Up Payment", "NQI Id, Reference Doc, USAID Per Diem, or Special W-4 Amount");
                return false;
            }
        }
        // if Exempt Under Other Code is checked
        if (nonResidentAlienTax.isTaxOtherExemptIndicator()) {
            // Federal and State tax rate should be zero.
            if (!(nonResidentAlienTax.getStateIncomeTaxPercent().equals(KualiDecimal.ZERO)) || !(nonResidentAlienTax.getFederalIncomeTaxPercent().equals(KualiDecimal.ZERO))) {
                errors.putErrorWithoutFullErrorPath("DVNRATaxErrors", KFSKeyConstants.ERROR_DV_NRA_TAX_WHEN_CHECKED_FEDERAL_AND_STATE_TAXES_SHOULD_BE_ZERO, "Exempt Under Other Code");
                return false;
            }
        }
        // if USAID Per Diem is checked
        if (nonResidentAlienTax.isTaxUSAIDPerDiemIndicator()) {
            // income class code should be fellowship
            if (!nonResidentAlienTax.getIncomeClassCode().equals(NRA_TAX_INCOME_CLASS_FELLOWSHIP)) {
                errors.putErrorWithoutFullErrorPath("DVNRATaxErrors", KFSKeyConstants.ERROR_DV_NRA_TAX_WHEN_CHECKED_SHOULD_BE_SELECTED, "USAID Per Diem", "Income Class Code : Fellowship");
                return false;
            }
            // Federal and State tax rate should be zero.
            if (!(nonResidentAlienTax.getStateIncomeTaxPercent().equals(KualiDecimal.ZERO)) || !(nonResidentAlienTax.getFederalIncomeTaxPercent().equals(KualiDecimal.ZERO))) {
                errors.putErrorWithoutFullErrorPath("DVNRATaxErrors", KFSKeyConstants.ERROR_DV_NRA_TAX_WHEN_CHECKED_FEDERAL_AND_STATE_TAXES_SHOULD_BE_ZERO, "USAID Per Diem");
                return false;
            }
            // Exempt Under Other Code should be checked; this will ensure the other 3 check boxes not checked due to mutual exclusiveness
            if (!nonResidentAlienTax.isTaxOtherExemptIndicator()) {
                errors.putErrorWithoutFullErrorPath("DVNRATaxErrors", KFSKeyConstants.ERROR_DV_NRA_TAX_WHEN_CHECKED_SHOULD_BE_SELECTED, "USAID Per Diem", "Exempt Under Other Code");
                return false;
            }
            // Special W-4 Amount shall have no value
            if (nonResidentAlienTax.getTaxSpecialW4Amount() != null) {
                errors.putErrorWithoutFullErrorPath("DVNRATaxErrors", KFSKeyConstants.ERROR_DV_NRA_TAX_WHEN_CHECKED_CANNOT_HAVE_VALUE, "USAID Per Diem", "Special W-4 Amount");
                return false;
            }
        }
        // if Special W-4 Amount is entered
        if (nonResidentAlienTax.getTaxSpecialW4Amount() != null) {
            // income class code should be fellowship
            if (!nonResidentAlienTax.getIncomeClassCode().equals(NRA_TAX_INCOME_CLASS_FELLOWSHIP)) {
                errors.putErrorWithoutFullErrorPath("DVNRATaxErrors", KFSKeyConstants.ERROR_DV_NRA_TAX_WHEN_CHECKED_SHOULD_BE_SELECTED, "Special W-4 Amount", "Income Class Code : Fellowship");
                return false;
            }
            // Federal and State tax rate should be zero.
            if (!(nonResidentAlienTax.getStateIncomeTaxPercent().equals(KualiDecimal.ZERO)) || !(nonResidentAlienTax.getFederalIncomeTaxPercent().equals(KualiDecimal.ZERO))) {
                errors.putErrorWithoutFullErrorPath("DVNRATaxErrors", KFSKeyConstants.ERROR_DV_NRA_TAX_WHEN_CHECKED_FEDERAL_AND_STATE_TAXES_SHOULD_BE_ZERO, "Special W-4 Amount");
                return false;
            }
            // Exempt Under Other Code should be checked; this will ensure the other 3 check boxes not checked due to mutual exclusiveness
            if (!nonResidentAlienTax.isTaxOtherExemptIndicator()) {
                errors.putErrorWithoutFullErrorPath("DVNRATaxErrors", KFSKeyConstants.ERROR_DV_NRA_TAX_WHEN_CHECKED_SHOULD_BE_SELECTED, "Special W-4 Amount", "Exempt Under Other Code");
                return false;
            }
            // USAID Per Diem should not be checked (mutual exclusive checking on USAID Per Diem here is optional since this is also ensured by validation on Special W-4 Amount above
            if ((nonResidentAlienTax.isTaxUSAIDPerDiemIndicator())) {
                errors.putErrorWithoutFullErrorPath("DVNRATaxErrors", KFSKeyConstants.ERROR_DV_NRA_TAX_WHEN_CHECKED_CANNOT_BE_SELECTED, "Special W-4 Amount", "USAID Per Diem");
                return false;
            }
        }
        // if NQI Id is entered
        if (nonResidentAlienTax.getTaxNQIId() != null) {
        }
        // if Reference Doc is entered
        if (nonResidentAlienTax.getReferenceFinancialDocumentNumber() != null) {
        }
    }
    if (validationType != "GENERATE") {
        // verify tax lines have been generated
        if ((nonResidentAlienTax.getFederalIncomeTaxPercent().isNonZero() || nonResidentAlienTax.getStateIncomeTaxPercent().isNonZero())) {
            if (StringUtils.isBlank(nonResidentAlienTax.getFinancialDocumentAccountingLineText())) {
                errors.putErrorWithoutFullErrorPath(KFSConstants.GENERAL_NRATAX_TAB_ERRORS, KFSKeyConstants.ERROR_DV_NRA_NO_TAXLINES_GENERATED);
                return false;
            }
        }
    }
    errors.removeFromErrorPath(KFSPropertyConstants.DV_NON_RESIDENT_ALIEN_TAX);
    errors.removeFromErrorPath(KFSPropertyConstants.DOCUMENT);
    return isValid;
}
Also used : PersistableBusinessObject(org.kuali.kfs.krad.bo.PersistableBusinessObject) DisbursementVoucherNonResidentAlienTax(org.kuali.kfs.fp.businessobject.DisbursementVoucherNonResidentAlienTax) DisbursementVoucherPayeeDetail(org.kuali.kfs.fp.businessobject.DisbursementVoucherPayeeDetail) NonResidentAlienTaxPercent(org.kuali.kfs.fp.businessobject.NonResidentAlienTaxPercent) Person(org.kuali.rice.kim.api.identity.Person) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument) MessageMap(org.kuali.kfs.krad.util.MessageMap) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService)

Example 4 with DisbursementVoucherPayeeDetail

use of org.kuali.kfs.fp.businessobject.DisbursementVoucherPayeeDetail in project cu-kfs by CU-CommunityApps.

the class CuDisbursementVoucherExtractionHelperServiceImpl method buildPaymentDetail.

protected PaymentDetail buildPaymentDetail(DisbursementVoucherDocument document, Date processRunDate) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("buildPaymentDetail() started");
    }
    final String maxNoteLinesParam = getParameterService().getParameterValueAsString(KfsParameterConstants.PRE_DISBURSEMENT_ALL.class, PdpParameterConstants.MAX_NOTE_LINES);
    int maxNoteLines;
    try {
        maxNoteLines = Integer.parseInt(maxNoteLinesParam);
    } catch (NumberFormatException nfe) {
        throw new IllegalArgumentException("Invalid Max Notes Lines parameter, value: " + maxNoteLinesParam + " cannot be converted to an integer");
    }
    PaymentDetail pd = new PaymentDetail();
    if (StringUtils.isNotEmpty(document.getDocumentHeader().getOrganizationDocumentNumber())) {
        pd.setOrganizationDocNbr(document.getDocumentHeader().getOrganizationDocumentNumber());
    }
    pd.setCustPaymentDocNbr(document.getDocumentNumber());
    pd.setInvoiceDate(new java.sql.Date(processRunDate.getTime()));
    pd.setOrigInvoiceAmount(document.getDisbVchrCheckTotalAmount());
    pd.setInvTotDiscountAmount(KualiDecimal.ZERO);
    pd.setInvTotOtherCreditAmount(KualiDecimal.ZERO);
    pd.setInvTotOtherDebitAmount(KualiDecimal.ZERO);
    pd.setInvTotShipAmount(KualiDecimal.ZERO);
    pd.setNetPaymentAmount(document.getDisbVchrCheckTotalAmount());
    pd.setPrimaryCancelledPayment(Boolean.FALSE);
    pd.setFinancialDocumentTypeCode(DisbursementVoucherConstants.DOCUMENT_TYPE_CHECKACH);
    pd.setFinancialSystemOriginCode(KFSConstants.ORIGIN_CODE_KUALI);
    // Handle accounts
    for (SourceAccountingLine sal : (List<? extends SourceAccountingLine>) document.getSourceAccountingLines()) {
        PaymentAccountDetail pad = new PaymentAccountDetail();
        pad.setFinChartCode(sal.getChartOfAccountsCode());
        pad.setAccountNbr(sal.getAccountNumber());
        if (StringUtils.isNotEmpty(sal.getSubAccountNumber())) {
            pad.setSubAccountNbr(sal.getSubAccountNumber());
        } else {
            pad.setSubAccountNbr(KFSConstants.getDashSubAccountNumber());
        }
        pad.setFinObjectCode(sal.getFinancialObjectCode());
        if (StringUtils.isNotEmpty(sal.getFinancialSubObjectCode())) {
            pad.setFinSubObjectCode(sal.getFinancialSubObjectCode());
        } else {
            pad.setFinSubObjectCode(KFSConstants.getDashFinancialSubObjectCode());
        }
        if (StringUtils.isNotEmpty(sal.getOrganizationReferenceId())) {
            pad.setOrgReferenceId(sal.getOrganizationReferenceId());
        }
        if (StringUtils.isNotEmpty(sal.getProjectCode())) {
            pad.setProjectCode(sal.getProjectCode());
        } else {
            pad.setProjectCode(KFSConstants.getDashProjectCode());
        }
        pad.setAccountNetAmount(sal.getAmount());
        pd.addAccountDetail(pad);
    }
    // Handle notes
    DisbursementVoucherPayeeDetail dvpd = document.getDvPayeeDetail();
    int line = 0;
    PaymentNoteText pnt = new PaymentNoteText();
    pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
    pnt.setCustomerNoteText(CuDisbursementVoucherConstants.DV_EXTRACT_NOTE_PREFIX_PREPARER + document.getDisbVchrContactPersonName() + " " + document.getDisbVchrContactPhoneNumber());
    pd.addNote(pnt);
    String dvSpecialHandlingPersonName = null;
    String dvSpecialHandlingLine1Address = null;
    String dvSpecialHandlingLine2Address = null;
    String dvSpecialHandlingCity = null;
    String dvSpecialHandlingState = null;
    String dvSpecialHandlingZip = null;
    dvSpecialHandlingPersonName = dvpd.getDisbVchrSpecialHandlingPersonName();
    dvSpecialHandlingLine1Address = dvpd.getDisbVchrSpecialHandlingLine1Addr();
    dvSpecialHandlingLine2Address = dvpd.getDisbVchrSpecialHandlingLine2Addr();
    dvSpecialHandlingCity = dvpd.getDisbVchrSpecialHandlingCityName();
    dvSpecialHandlingState = dvpd.getDisbVchrSpecialHandlingStateCode();
    dvSpecialHandlingZip = dvpd.getDisbVchrSpecialHandlingZipCode();
    if (StringUtils.isNotEmpty(dvSpecialHandlingPersonName)) {
        pnt = new PaymentNoteText();
        pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
        pnt.setCustomerNoteText("Send Check To: " + dvSpecialHandlingPersonName);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Creating special handling person name note: " + pnt.getCustomerNoteText());
        }
        pd.addNote(pnt);
    }
    if (StringUtils.isNotEmpty(dvSpecialHandlingLine1Address)) {
        pnt = new PaymentNoteText();
        pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
        pnt.setCustomerNoteText(CuDisbursementVoucherConstants.DV_EXTRACT_NOTE_PREFIX_SPECIAL_HANDLING_ADDRESS1 + dvSpecialHandlingLine1Address);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Creating special handling address 1 note: " + pnt.getCustomerNoteText());
        }
        pd.addNote(pnt);
    }
    if (StringUtils.isNotEmpty(dvSpecialHandlingLine2Address)) {
        pnt = new PaymentNoteText();
        pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
        pnt.setCustomerNoteText(CuDisbursementVoucherConstants.DV_EXTRACT_NOTE_PREFIX_SPECIAL_HANDLING_ADDRESS2 + dvSpecialHandlingLine2Address);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Creating special handling address 2 note: " + pnt.getCustomerNoteText());
        }
        pd.addNote(pnt);
    }
    if (StringUtils.isNotEmpty(dvSpecialHandlingCity)) {
        pnt = new PaymentNoteText();
        pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
        pnt.setCustomerNoteText(CuDisbursementVoucherConstants.DV_EXTRACT_NOTE_PREFIX_SPECIAL_HANDLING_ADDRESS3 + dvSpecialHandlingCity + ", " + dvSpecialHandlingState + " " + dvSpecialHandlingZip);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Creating special handling city note: " + pnt.getCustomerNoteText());
        }
        pd.addNote(pnt);
    }
    if (document.isDisbVchrAttachmentCode()) {
        pnt = new PaymentNoteText();
        pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
        pnt.setCustomerNoteText("Attachment Included");
        if (LOG.isDebugEnabled()) {
            LOG.debug("create attachment note: " + pnt.getCustomerNoteText());
        }
        pd.addNote(pnt);
    }
    String paymentReasonCode = dvpd.getDisbVchrPaymentReasonCode();
    if (/*REFACTORME*/
    getParameterEvaluatorService().getParameterEvaluator(DisbursementVoucherDocument.class, DisbursementVoucherConstants.NONEMPLOYEE_TRAVEL_PAY_REASONS_PARM_NM, paymentReasonCode).evaluationSucceeds()) {
        DisbursementVoucherNonEmployeeTravel dvnet = document.getDvNonEmployeeTravel();
        pnt = new PaymentNoteText();
        pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
        pnt.setCustomerNoteText("Reimbursement associated with " + dvnet.getDisbVchrServicePerformedDesc());
        if (LOG.isDebugEnabled()) {
            LOG.debug("Creating non employee travel notes: " + pnt.getCustomerNoteText());
        }
        pd.addNote(pnt);
        pnt = new PaymentNoteText();
        pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
        pnt.setCustomerNoteText("The total per diem amount for your daily expenses is " + dvnet.getDisbVchrPerdiemActualAmount());
        if (LOG.isDebugEnabled()) {
            LOG.debug("Creating non employee travel notes: " + pnt.getCustomerNoteText());
        }
        pd.addNote(pnt);
        if (dvnet.getDisbVchrPersonalCarAmount() != null && dvnet.getDisbVchrPersonalCarAmount().compareTo(KualiDecimal.ZERO) != 0) {
            pnt = new PaymentNoteText();
            pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
            pnt.setCustomerNoteText("The total dollar amount for your vehicle mileage is " + dvnet.getDisbVchrPersonalCarAmount());
            if (LOG.isDebugEnabled()) {
                LOG.debug("Creating non employee travel vehicle note: " + pnt.getCustomerNoteText());
            }
            pd.addNote(pnt);
            for (DisbursementVoucherNonEmployeeExpense exp : (List<DisbursementVoucherNonEmployeeExpense>) dvnet.getDvNonEmployeeExpenses()) {
                if (line < (maxNoteLines - 8)) {
                    pnt = new PaymentNoteText();
                    pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
                    pnt.setCustomerNoteText(exp.getDisbVchrExpenseCompanyName() + " " + exp.getDisbVchrExpenseAmount());
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("Creating non employee travel expense note: " + pnt.getCustomerNoteText());
                    }
                    pd.addNote(pnt);
                }
            }
        }
    } else if (/*REFACTORME*/
    getParameterEvaluatorService().getParameterEvaluator(DisbursementVoucherDocument.class, DisbursementVoucherConstants.PREPAID_TRAVEL_PAYMENT_REASONS_PARM_NM, paymentReasonCode).evaluationSucceeds()) {
        pnt = new PaymentNoteText();
        pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
        pnt.setCustomerNoteText("Payment is for the following individuals/charges:");
        pd.addNote(pnt);
        if (LOG.isDebugEnabled()) {
            LOG.info("Creating prepaid travel note note: " + pnt.getCustomerNoteText());
        }
        DisbursementVoucherPreConferenceDetail dvpcd = document.getDvPreConferenceDetail();
        for (DisbursementVoucherPreConferenceRegistrant dvpcr : (List<DisbursementVoucherPreConferenceRegistrant>) dvpcd.getDvPreConferenceRegistrants()) {
            if (line < (maxNoteLines - 8)) {
                pnt = new PaymentNoteText();
                pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
                pnt.setCustomerNoteText(dvpcr.getDvConferenceRegistrantName() + " " + dvpcr.getDisbVchrExpenseAmount());
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Creating pre-paid conference registrants note: " + pnt.getCustomerNoteText());
                }
                pd.addNote(pnt);
            }
        }
    }
    // Get the original, raw form, note text from the DV document.
    final String text = document.getDisbVchrCheckStubText();
    if (!StringUtils.isBlank(text)) {
        pd.addNotes(getPaymentSourceHelperService().buildNotesForCheckStubText(text, line));
    }
    return pd;
}
Also used : DisbursementVoucherNonEmployeeTravel(org.kuali.kfs.fp.businessobject.DisbursementVoucherNonEmployeeTravel) DisbursementVoucherPreConferenceDetail(org.kuali.kfs.fp.businessobject.DisbursementVoucherPreConferenceDetail) KualiInteger(org.kuali.rice.core.api.util.type.KualiInteger) KfsParameterConstants(org.kuali.kfs.sys.service.impl.KfsParameterConstants) DisbursementVoucherNonEmployeeExpense(org.kuali.kfs.fp.businessobject.DisbursementVoucherNonEmployeeExpense) DisbursementVoucherPayeeDetail(org.kuali.kfs.fp.businessobject.DisbursementVoucherPayeeDetail) CuDisbursementVoucherPayeeDetail(edu.cornell.kfs.fp.businessobject.CuDisbursementVoucherPayeeDetail) SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) DisbursementVoucherPreConferenceRegistrant(org.kuali.kfs.fp.businessobject.DisbursementVoucherPreConferenceRegistrant) Date(java.sql.Date) PaymentDetail(org.kuali.kfs.pdp.businessobject.PaymentDetail) PaymentNoteText(org.kuali.kfs.pdp.businessobject.PaymentNoteText) ArrayList(java.util.ArrayList) List(java.util.List) RecurringDisbursementVoucherDocument(edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument) CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument) PaymentAccountDetail(org.kuali.kfs.pdp.businessobject.PaymentAccountDetail)

Example 5 with DisbursementVoucherPayeeDetail

use of org.kuali.kfs.fp.businessobject.DisbursementVoucherPayeeDetail in project cu-kfs by CU-CommunityApps.

the class CuDisbursementVoucherEmployeeInformationValidation method validate.

public boolean validate(AttributedDocumentEvent event) {
    LOG.debug("validate start");
    boolean isValid = true;
    CuDisbursementVoucherDocument document = (CuDisbursementVoucherDocument) getAccountingDocumentForValidation();
    DisbursementVoucherPayeeDetail payeeDetail = document.getDvPayeeDetail();
    if (!payeeDetail.isEmployee() || payeeDetail.isVendor() || !(document.getDocumentHeader().getWorkflowDocument().isInitiated() || document.getDocumentHeader().getWorkflowDocument().isSaved())) {
        return true;
    }
    String employeeId = payeeDetail.getDisbVchrPayeeIdNumber();
    Person employee = SpringContext.getBean(PersonService.class).getPersonByEmployeeId(employeeId);
    MessageMap errors = GlobalVariables.getMessageMap();
    errors.addToErrorPath(KFSPropertyConstants.DOCUMENT);
    WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
    boolean stateIsInitiated = workflowDocument.isInitiated() || workflowDocument.isSaved();
    if (ObjectUtils.isNull(employee)) {
        employee = SpringContext.getBean(PersonService.class).getPerson(employeeId);
    } else {
        if (!KFSConstants.EMPLOYEE_ACTIVE_STATUS.equals(employee.getEmployeeStatusCode()) && !CUKFSConstants.EMPLOYEE_RETIRED_STATUS.equals(employee.getEmployeeStatusCode())) {
            // If employee is found, then check that employee is active or retired if the doc has not already been routed.
            if (stateIsInitiated) {
                String label = SpringContext.getBean(DataDictionaryService.class).getAttributeLabel(DisbursementVoucherPayeeDetail.class, KFSPropertyConstants.DISB_VCHR_PAYEE_ID_NUMBER);
                errors.putError(DV_PAYEE_ID_NUMBER_PROPERTY_PATH, KFSKeyConstants.ERROR_INACTIVE, label);
                isValid = false;
            }
        }
    }
    // check existence of employee
    if (employee == null) {
        // If employee is not found, report existence error
        String label = SpringContext.getBean(DataDictionaryService.class).getAttributeLabel(DisbursementVoucherPayeeDetail.class, KFSPropertyConstants.DISB_VCHR_PAYEE_ID_NUMBER);
        errors.putError(DV_PAYEE_ID_NUMBER_PROPERTY_PATH, KFSKeyConstants.ERROR_EXISTENCE, label);
        isValid = false;
    }
    errors.removeFromErrorPath(KFSPropertyConstants.DOCUMENT);
    return isValid;
}
Also used : CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument) WorkflowDocument(org.kuali.rice.kew.api.WorkflowDocument) PersonService(org.kuali.rice.kim.api.identity.PersonService) DisbursementVoucherPayeeDetail(org.kuali.kfs.fp.businessobject.DisbursementVoucherPayeeDetail) Person(org.kuali.rice.kim.api.identity.Person) MessageMap(org.kuali.kfs.krad.util.MessageMap) DataDictionaryService(org.kuali.kfs.kns.service.DataDictionaryService)

Aggregations

DisbursementVoucherPayeeDetail (org.kuali.kfs.fp.businessobject.DisbursementVoucherPayeeDetail)7 DisbursementVoucherDocument (org.kuali.kfs.fp.document.DisbursementVoucherDocument)4 CuDisbursementVoucherDocument (edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)2 RecurringDisbursementVoucherDocument (edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument)2 MessageMap (org.kuali.kfs.krad.util.MessageMap)2 Person (org.kuali.rice.kim.api.identity.Person)2 DisbursementVoucherBatchSummaryLine (com.rsmart.kuali.kfs.fp.businessobject.DisbursementVoucherBatchSummaryLine)1 CuDisbursementVoucherPayeeDetail (edu.cornell.kfs.fp.businessobject.CuDisbursementVoucherPayeeDetail)1 Date (java.sql.Date)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 List (java.util.List)1 DisbursementVoucherNonEmployeeExpense (org.kuali.kfs.fp.businessobject.DisbursementVoucherNonEmployeeExpense)1 DisbursementVoucherNonEmployeeTravel (org.kuali.kfs.fp.businessobject.DisbursementVoucherNonEmployeeTravel)1 DisbursementVoucherNonResidentAlienTax (org.kuali.kfs.fp.businessobject.DisbursementVoucherNonResidentAlienTax)1 DisbursementVoucherPreConferenceDetail (org.kuali.kfs.fp.businessobject.DisbursementVoucherPreConferenceDetail)1 DisbursementVoucherPreConferenceRegistrant (org.kuali.kfs.fp.businessobject.DisbursementVoucherPreConferenceRegistrant)1 NonResidentAlienTaxPercent (org.kuali.kfs.fp.businessobject.NonResidentAlienTaxPercent)1 DataDictionaryService (org.kuali.kfs.kns.service.DataDictionaryService)1 PersistableBusinessObject (org.kuali.kfs.krad.bo.PersistableBusinessObject)1