Example usage for java.sql Date before

List of usage examples for java.sql Date before

Introduction

In this page you can find the example usage for java.sql Date before.

Prototype

public boolean before(Date when) 

Source Link

Document

Tests if this date is before the specified date.

Usage

From source file:org.kuali.kra.budget.summary.BudgetSummaryServiceImpl.java

public boolean isLeapDaysInPeriod(Date sDate, Date eDate) {
    Date leapDate;//from  w w w.  j av  a2s .co m
    int sYear = getYear(sDate);
    int eYear = getYear(eDate);
    if (isLeapYear(sDate)) {
        Calendar c1 = Calendar.getInstance();
        c1.clear();
        c1.set(sYear, 1, 29);
        leapDate = new java.sql.Date(c1.getTime().getTime());
        // start date is before 2/29 & enddate >= 2/29
        if (sDate.before(leapDate)) {
            if (eDate.compareTo(leapDate) >= 0) {
                return true;
            }
        } else if (sDate.equals(leapDate)) {
            return true;
        }
    } else if (isLeapYear(eDate)) {
        Calendar c1 = Calendar.getInstance();
        c1.set(eYear, 1, 29);
        leapDate = new java.sql.Date(c1.getTime().getTime());
        if (eDate.compareTo(leapDate) >= 0) {
            return true;
        }
    } else {
        sYear++;
        while (eYear > sYear) {
            if (isLeapYear(sYear)) {
                return true;
            }
            sYear++;
        }
    }
    return false;
}

From source file:org.kuali.kra.committee.bo.Committee.java

private boolean isChairPerson(CommitteeMembership committeeMembership) {

    boolean isChairRoleFound = false;
    Date currentDate = DateUtils.clearTimeFields(new Date(System.currentTimeMillis()));

    for (CommitteeMembershipRole committeeMembershipRole : committeeMembership.getMembershipRoles()) {
        if (committeeMembershipRole.getMembershipRoleCode().equals(CHAIR_MEMBERSHIP_ROLE_CODE)
                && !currentDate.before(committeeMembershipRole.getStartDate())
                && !currentDate.after(committeeMembershipRole.getEndDate())) {
            isChairRoleFound = true;/*from w ww.j  a va2  s.c  o m*/
            break;
        }
    }
    return isChairRoleFound;
}

From source file:org.kuali.kra.committee.rules.CommitteeDocumentRule.java

/**
 * Check if the date is outside the committee membership term.
 * If any of the date are null the method returns false.
 * /*from   w ww. j  a  v  a2s  .co m*/
 * @param committeeMembership - the committeeMembership whose term we are comparing against
 * @param date - the date to be checked
 * @return <code>true</code> if the date is outside the committee membership term, <code>false</code> otherwise
 */
private boolean hasDateOutsideCommitteeMembershipTerm(CommitteeMembership committeeMembership, Date date) {
    boolean isOutside = false;
    if ((committeeMembership.getTermStartDate() != null) && (committeeMembership.getTermEndDate() != null)
            && (date != null)) {
        if (date.before(committeeMembership.getTermStartDate())
                || date.after(committeeMembership.getTermEndDate())) {
            isOutside = true;
        }
    }
    return isOutside;
}

From source file:org.kuali.kra.timeandmoney.web.struts.action.TimeAndMoneyAction.java

/**
 * Date changes in hierarchy view are captured here.  If the transaction is a No Cost Extension, we report the transaction
 * details for display in history tab./*w  w  w. j av a2  s  .c  o m*/
 */
protected boolean inspectAndCaptureCurrentFundEffectiveDateChanges(TimeAndMoneyForm timeAndMoneyForm,
        Boolean isNoCostExtension, AwardAmountInfo aai, Integer index, Award award,
        TimeAndMoneyDocument timeAndMoneyDocument, Entry<String, AwardHierarchyNode> awardHierarchyNode,
        List<TransactionDetail> dateChangeTransactionDetailItems) {

    Date currentEffectiveDate = timeAndMoneyForm.getAwardHierarchyNodeItems().get(index)
            .getCurrentFundEffectiveDate();
    Date previousEffectiveDate = aai.getCurrentFundEffectiveDate();
    boolean needToSave = false;
    if (timeAndMoneyForm.getAwardHierarchyNodeItems().get(index).isPopulatedFromClient()
            && currentEffectiveDate != null && !currentEffectiveDate.equals(previousEffectiveDate)) {

        //aai.getCurrentFundEffectiveDate == null and this throws a stack trace only when doign a before
        // if current transaction currentFEDate is < previosu trans currentFEDate
        if (isNoCostExtension && previousEffectiveDate != null
                && currentEffectiveDate.before(previousEffectiveDate)) {
            AwardAmountInfo tempAai = getNewAwardAmountInfoForDateChangeTransaction(aai, award,
                    timeAndMoneyDocument.getDocumentNumber());
            needToSave = true;
            aai = tempAai;
            aai.setCurrentFundEffectiveDate(currentEffectiveDate);
            awardHierarchyNode.getValue().setCurrentFundEffectiveDate(currentEffectiveDate);
            award.getAwardAmountInfos().add(aai);
            TransactionDetail transactionDetail = createTransDetailForDateChanges(aai.getAwardNumber(),
                    aai.getAwardNumber(), aai.getSequenceNumber(), timeAndMoneyDocument.getAwardNumber(),
                    timeAndMoneyDocument.getDocumentNumber(), OBLIGATED_START_COMMENT);
            aai.setTransactionId(transactionDetail.getTransactionId());
            dateChangeTransactionDetailItems.add(transactionDetail);
        } else {
            AwardAmountInfo tempAai = getNewAwardAmountInfoForDateChangeTransaction(aai, award,
                    timeAndMoneyDocument.getDocumentNumber());
            needToSave = true;
            aai = tempAai;
            aai.setCurrentFundEffectiveDate(currentEffectiveDate);
            awardHierarchyNode.getValue().setCurrentFundEffectiveDate(currentEffectiveDate);
            award.getAwardAmountInfos().add(aai);
        }
    } else if (timeAndMoneyForm.getAwardHierarchyNodeItems().get(index).isPopulatedFromClient()
            && currentEffectiveDate == null) {
        //FYI, this will show an erorr to the user, we are doing this such they can see the error, and that they had put in a null value
        awardHierarchyNode.getValue().setCurrentFundEffectiveDate(null);
    }
    //special case where a user can enter an invalid date that will throw a hard error.  If the user tries to change that date back
    //to the original date, we need to capture that and change the value on the document which is the date value that gets validated
    //in save rules.
    if (timeAndMoneyForm.getAwardHierarchyNodeItems().get(index).getCurrentFundEffectiveDate() != null
            && timeAndMoneyForm.getAwardHierarchyNodeItems().get(index).getCurrentFundEffectiveDate() != null
            && timeAndMoneyForm.getAwardHierarchyNodeItems().get(index).getCurrentFundEffectiveDate()
                    .equals(aai.getCurrentFundEffectiveDate())
            && !timeAndMoneyForm.getAwardHierarchyNodeItems().get(index).getCurrentFundEffectiveDate()
                    .equals(awardHierarchyNode.getValue().getCurrentFundEffectiveDate())) {
        awardHierarchyNode.getValue().setCurrentFundEffectiveDate(
                timeAndMoneyForm.getAwardHierarchyNodeItems().get(index).getCurrentFundEffectiveDate());
    }
    return needToSave;
}

From source file:org.kuali.ole.coa.document.validation.impl.AccountGlobalRule.java

/**
 * This method checks to see if any expiration date field rules were violated in relation to the given detail record
 * /*from   w w  w  .jav a2s. c  o  m*/
 * @param maintenanceDocument
 * @param detail - the account detail we are investigating
 * @return false on rules violation
 */
protected boolean checkExpirationDate(MaintenanceDocument maintenanceDocument, AccountGlobalDetail detail) {
    boolean success = true;
    Date newExpDate = newAccountGlobal.getAccountExpirationDate();

    // load the object by keys
    Account account = (Account) SpringContext.getBean(BusinessObjectService.class)
            .findByPrimaryKey(Account.class, detail.getPrimaryKeys());
    if (ObjectUtils.isNotNull(account)) {
        Date oldExpDate = account.getAccountExpirationDate();

        // When updating an account expiration date, the date must be today or later
        // (except for C&G accounts). Only run this test if this maint doc
        // is an edit doc
        if (isUpdatedExpirationDateInvalid(account, newAccountGlobal)) {
            putFieldError("accountExpirationDate",
                    OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_EXP_DATE_TODAY_LATER);
            success &= false;
        }

        // If creating a new account if acct_expiration_dt is set and the fund_group is not "CG" then
        // the acct_expiration_dt must be changed to a date that is today or later
        if (ObjectUtils.isNotNull(newExpDate) && ObjectUtils.isNull(newAccountGlobal.getSubFundGroup())) {
            if (ObjectUtils.isNotNull(account.getSubFundGroup())) {
                if (!account.isForContractsAndGrants()) {
                    if (!newExpDate.after(today) && !newExpDate.equals(today)) {
                        putGlobalError(OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_EXP_DATE_TODAY_LATER);
                        success &= false;
                    }
                }
            }
        }
        // acct_expiration_dt can not be before acct_effect_dt
        Date effectiveDate = account.getAccountEffectiveDate();
        if (ObjectUtils.isNotNull(effectiveDate) && ObjectUtils.isNotNull(newExpDate)) {
            if (newExpDate.before(effectiveDate)) {
                putGlobalError(
                        OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_EXP_DATE_CANNOT_BE_BEFORE_EFFECTIVE_DATE);
                success &= false;
            }
        }
    }

    return success;
}

From source file:org.kuali.ole.coa.document.validation.impl.AccountRule.java

/**
 * This method checks to see if any expiration date field rules were violated
 *
 * @param maintenanceDocument/*from w  ww. j av a  2s .c  o m*/
 * @return false on rules violation
 */
protected boolean checkExpirationDate(MaintenanceDocument maintenanceDocument) {

    LOG.debug("checkExpirationDate called");

    boolean success = true;

    Date oldExpDate = oldAccount.getAccountExpirationDate();
    Date newExpDate = newAccount.getAccountExpirationDate();
    Date today = new Date(getDateTimeService().getCurrentTimestamp().getTime());
    today.setTime(DateUtils.truncate(today, Calendar.DAY_OF_MONTH).getTime()); // remove any time components

    // When updating an account expiration date, the date must be today or later
    // Only run this test if this maintenance doc
    // is an edit doc

    //MSU Contribution OLEMI-8567 DTT-565 OLECNTRB-972
    if (isUpdatedExpirationDateInvalid(maintenanceDocument)) {
        Account newAccount = (Account) maintenanceDocument.getNewMaintainableObject().getBusinessObject();
        if (newAccount.isClosed()) {
            /*If the Account is being closed and the date is before today's date, the EXP date can only be today*/
            putFieldError("accountExpirationDate",
                    OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_ACCT_CANNOT_BE_CLOSED_EXP_DATE_INVALID);
        } else {
            /*If the Account is not being closed and the date is before today's date, the EXP date can only be today or at a later date*/
            putFieldError("accountExpirationDate",
                    OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_EXP_DATE_TODAY_LATER);
        }
        success &= false;
    }

    // a continuation account is required if the expiration date is completed.
    if (ObjectUtils.isNotNull(newExpDate)) {
        if (StringUtils.isBlank(newAccount.getContinuationAccountNumber())) {
            putFieldError("continuationAccountNumber",
                    OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_CONTINUATION_ACCT_REQD_IF_EXP_DATE_COMPLETED);
        }
        if (StringUtils.isBlank(newAccount.getContinuationFinChrtOfAcctCd())) {
            putFieldError("continuationFinChrtOfAcctCd",
                    OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_CONTINUATION_FINCODE_REQD_IF_EXP_DATE_COMPLETED);
            // putGlobalError(OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_CONTINUATION_ACCT_REQD_IF_EXP_DATE_COMPLETED);
            success &= false;
        }
    }

    // If creating a new account if acct_expiration_dt is set then
    // the acct_expiration_dt must be changed to a date that is today or later
    if (maintenanceDocument.isNew() && ObjectUtils.isNotNull(newExpDate)) {
        if (!newExpDate.after(today) && !newExpDate.equals(today)) {
            putFieldError("accountExpirationDate",
                    OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_EXP_DATE_TODAY_LATER);
            // putGlobalError(OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_EXP_DATE_TODAY_LATER);
            success &= false;
        }
    }

    // acct_expiration_dt can not be before acct_effect_dt
    Date effectiveDate = newAccount.getAccountEffectiveDate();
    if (ObjectUtils.isNotNull(effectiveDate) && ObjectUtils.isNotNull(newExpDate)) {
        if (newExpDate.before(effectiveDate)) {
            putFieldError("accountExpirationDate",
                    OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_EXP_DATE_CANNOT_BE_BEFORE_EFFECTIVE_DATE);
            // putGlobalError(OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_EXP_DATE_CANNOT_BE_BEFORE_EFFECTIVE_DATE);
            success &= false;
        }
    }

    return success;
}

From source file:org.kuali.ole.coa.document.validation.impl.OrgRule.java

/**
 * This checks the following conditions:
 * <ul>/*from   ww w .  ja v a 2  s  .  co m*/
 * <li>begin date must be greater than or equal to end date</li>
 * <li>start date must be greater than or equal to today if new Document</li>
 * <li>Reports To Chart/Org should not be same as this Chart/Org</li>
 * </ul>
 *
 * @param document
 * @return true if it passes all the rules, false otherwise
 */
protected boolean checkSimpleRules(MaintenanceDocument document) {

    boolean success = true;
    String lastReportsToChartOfAccountsCode;
    String lastReportsToOrganizationCode;
    boolean continueSearch;
    Organization tempOrg;
    Integer loopCount;
    Integer maxLoopCount = 40;

    // begin date must be greater than or equal to end date
    if ((ObjectUtils.isNotNull(newOrg.getOrganizationBeginDate())
            && (ObjectUtils.isNotNull(newOrg.getOrganizationEndDate())))) {

        Date beginDate = newOrg.getOrganizationBeginDate();
        Date endDate = newOrg.getOrganizationEndDate();

        if (endDate.before(beginDate)) {
            putFieldError("organizationEndDate",
                    OLEKeyConstants.ERROR_DOCUMENT_ORGMAINT_END_DATE_GREATER_THAN_BEGIN_DATE);
            success &= false;
        }
    }

    // start date must be greater than or equal to today if new Document
    if ((ObjectUtils.isNotNull(newOrg.getOrganizationBeginDate()) && (document.isNew()))) {
        Timestamp today = getDateTimeService().getCurrentTimestamp();
        today.setTime(DateUtils.truncate(today, Calendar.DAY_OF_MONTH).getTime());
        if (newOrg.getOrganizationBeginDate().before(today)) {
            putFieldError("organizationBeginDate", OLEKeyConstants.ERROR_DOCUMENT_ORGMAINT_STARTDATE_IN_PAST);
            success &= false;
        }
    }

    // Reports To Chart/Org should not be same as this Chart/Org
    // However, allow special case where organization type is listed in the business rules
    if (ObjectUtils.isNotNull(newOrg.getReportsToChartOfAccountsCode())
            && ObjectUtils.isNotNull(newOrg.getReportsToOrganizationCode())
            && ObjectUtils.isNotNull(newOrg.getChartOfAccountsCode())
            && ObjectUtils.isNotNull(newOrg.getOrganizationCode())) {
        if (!getOrgMustReportToSelf(newOrg)) {

            if ((newOrg.getReportsToChartOfAccountsCode().equals(newOrg.getChartOfAccountsCode()))
                    && (newOrg.getReportsToOrganizationCode().equals(newOrg.getOrganizationCode()))) {
                putFieldError("reportsToOrganizationCode",
                        OLEKeyConstants.ERROR_DOCUMENT_ORGMAINT_REPORTING_ORG_CANNOT_BE_SAME_ORG);
                success = false;
            } else {
                // Don't allow a circular reference on Reports to Chart/Org
                // terminate the search when a top-level org is found
                lastReportsToChartOfAccountsCode = newOrg.getReportsToChartOfAccountsCode();
                lastReportsToOrganizationCode = newOrg.getReportsToOrganizationCode();
                continueSearch = true;
                loopCount = 0;
                do {
                    tempOrg = orgService.getByPrimaryId(lastReportsToChartOfAccountsCode,
                            lastReportsToOrganizationCode);
                    loopCount++;
                    ;
                    if (ObjectUtils.isNull(tempOrg)) {
                        continueSearch = false;
                        // if a null is returned on the first iteration, then the reports-to org does not exist
                        // fail the validation
                        if (loopCount == 1) {
                            putFieldError("reportsToOrganizationCode",
                                    OLEKeyConstants.ERROR_DOCUMENT_ORGMAINT_REPORTING_ORG_MUST_EXIST);
                            success = false;
                        }
                    } else {
                        // on the first iteration, check whether the reports-to organization is active
                        if (loopCount == 1 && !tempOrg.isActive()) {
                            putFieldError("reportsToOrganizationCode",
                                    OLEKeyConstants.ERROR_DOCUMENT_ORGMAINT_REPORTING_ORG_MUST_EXIST);
                            success = false;
                            continueSearch = false;
                        } else {
                            // LOG.info("Found Org = " + lastReportsToChartOfAccountsCode + "/" +
                            // lastReportsToOrganizationCode);
                            lastReportsToChartOfAccountsCode = tempOrg.getReportsToChartOfAccountsCode();
                            lastReportsToOrganizationCode = tempOrg.getReportsToOrganizationCode();

                            if ((tempOrg.getReportsToChartOfAccountsCode()
                                    .equals(newOrg.getChartOfAccountsCode()))
                                    && (tempOrg.getReportsToOrganizationCode()
                                            .equals(newOrg.getOrganizationCode()))) {
                                putFieldError("reportsToOrganizationCode",
                                        OLEKeyConstants.ERROR_DOCUMENT_ORGMAINT_REPORTING_ORG_CANNOT_BE_CIRCULAR_REF_TO_SAME_ORG);
                                success = false;
                                continueSearch = false;
                            }
                        }
                    }
                    if (loopCount > maxLoopCount) {
                        continueSearch = false;
                    }
                    // stop the search if we reach an org that must report to itself
                    if (continueSearch && /*REFACTORME*/SpringContext.getBean(ParameterEvaluatorService.class)
                            .getParameterEvaluator(Organization.class,
                                    OLEConstants.ChartApcParms.ORG_MUST_REPORT_TO_SELF_ORG_TYPES,
                                    tempOrg.getOrganizationTypeCode())
                            .evaluationSucceeds()) {
                        continueSearch = false;
                    }

                } while (continueSearch == true);
            } // end else (checking for circular ref)
        } else { // org must report to self (university level organization)
            if (!(newOrg.getReportsToChartOfAccountsCode().equals(newOrg.getChartOfAccountsCode())
                    && newOrg.getReportsToOrganizationCode().equals(newOrg.getOrganizationCode()))) {
                putFieldError("reportsToOrganizationCode",
                        OLEKeyConstants.ERROR_DOCUMENT_ORGMAINT_REPORTING_ORG_MUST_BE_SAME_ORG);
                success = false;
            }
            // org must be the only one of that type
            String topLevelOrgTypeCode = SpringContext.getBean(ParameterService.class)
                    .getParameterValueAsString(Organization.class,
                            OLEConstants.ChartApcParms.ORG_MUST_REPORT_TO_SELF_ORG_TYPES);
            List<Organization> topLevelOrgs = orgService.getActiveOrgsByType(topLevelOrgTypeCode);
            if (!topLevelOrgs.isEmpty()) {
                // is the new org in the topLevelOrgs list? If not, then there's an error; if so, we're editing the top level
                // org
                if (!topLevelOrgs.contains(newOrg)) {
                    putFieldError("organizationTypeCode",
                            OLEKeyConstants.ERROR_DOCUMENT_ORGMAINT_ONLY_ONE_TOP_LEVEL_ORG,
                            topLevelOrgs.get(0).getChartOfAccountsCode() + "-"
                                    + topLevelOrgs.get(0).getOrganizationCode());
                    success = false;
                }
            }
        }
    }

    return success;
}

From source file:org.kuali.ole.fp.document.DisbursementVoucherDocument.java

/**
 * Convenience method to set dv payee detail fields based on a given vendor.
 *
 * @param vendor//from   ww w .j  av a  2  s.  co  m
 */
public void templateVendor(VendorDetail vendor, VendorAddress vendorAddress) {
    if (vendor == null) {
        return;
    }
    this.setPaymentMethodId(vendor.getPaymentMethodId());
    this.getDvPayeeDetail()
            .setDisbursementVoucherPayeeTypeCode(DisbursementVoucherConstants.DV_PAYEE_TYPE_VENDOR);
    this.getDvPayeeDetail().setDisbVchrPayeeIdNumber(vendor.getVendorNumber());
    this.getDvPayeeDetail().setDisbVchrPayeePersonName(vendor.getVendorName());

    this.getDvPayeeDetail().setDisbVchrAlienPaymentCode(vendor.getVendorHeader().getVendorForeignIndicator());

    if (ObjectUtils.isNotNull(vendorAddress)
            && ObjectUtils.isNotNull(vendorAddress.getVendorAddressGeneratedIdentifier())) {
        this.getDvPayeeDetail().setDisbVchrVendorAddressIdNumber(
                vendorAddress.getVendorAddressGeneratedIdentifier().toString());
        this.getDvPayeeDetail().setDisbVchrPayeeLine1Addr(vendorAddress.getVendorLine1Address());
        this.getDvPayeeDetail().setDisbVchrPayeeLine2Addr(vendorAddress.getVendorLine2Address());
        this.getDvPayeeDetail().setDisbVchrPayeeCityName(vendorAddress.getVendorCityName());
        this.getDvPayeeDetail().setDisbVchrPayeeStateCode(vendorAddress.getVendorStateCode());
        this.getDvPayeeDetail().setDisbVchrPayeeZipCode(vendorAddress.getVendorZipCode());
        this.getDvPayeeDetail().setDisbVchrPayeeCountryCode(vendorAddress.getVendorCountryCode());
    } else {
        this.getDvPayeeDetail().setDisbVchrVendorAddressIdNumber(StringUtils.EMPTY);
        this.getDvPayeeDetail().setDisbVchrPayeeLine1Addr(StringUtils.EMPTY);
        this.getDvPayeeDetail().setDisbVchrPayeeLine2Addr(StringUtils.EMPTY);
        this.getDvPayeeDetail().setDisbVchrPayeeCityName(StringUtils.EMPTY);
        this.getDvPayeeDetail().setDisbVchrPayeeStateCode(StringUtils.EMPTY);
        this.getDvPayeeDetail().setDisbVchrPayeeZipCode(StringUtils.EMPTY);
        this.getDvPayeeDetail().setDisbVchrPayeeCountryCode(StringUtils.EMPTY);
    }

    this.getDvPayeeDetail().setDisbVchrAlienPaymentCode(vendor.getVendorHeader().getVendorForeignIndicator());
    this.getDvPayeeDetail().setDvPayeeSubjectPaymentCode(
            VendorConstants.VendorTypes.SUBJECT_PAYMENT.equals(vendor.getVendorHeader().getVendorTypeCode()));
    this.getDvPayeeDetail().setDisbVchrEmployeePaidOutsidePayrollCode(
            getVendorService().isVendorInstitutionEmployee(vendor.getVendorHeaderGeneratedIdentifier()));

    this.getDvPayeeDetail().setHasMultipleVendorAddresses(1 < vendor.getVendorAddresses().size());

    boolean w9AndW8Checked = false;
    if ((ObjectUtils.isNotNull(vendor.getVendorHeader().getVendorW9ReceivedIndicator())
            && vendor.getVendorHeader().getVendorW9ReceivedIndicator() == true)
            || (ObjectUtils.isNotNull(vendor.getVendorHeader().getVendorW8BenReceivedIndicator())
                    && vendor.getVendorHeader().getVendorW8BenReceivedIndicator() == true)) {

        w9AndW8Checked = true;
    }

    //    this.disbVchrPayeeW9CompleteCode = vendor.getVendorHeader().getVendorW8BenReceivedIndicator()  == null ? false : vendor.getVendorHeader().getVendorW8BenReceivedIndicator();
    this.disbVchrPayeeW9CompleteCode = w9AndW8Checked;

    Date vendorFederalWithholdingTaxBeginDate = vendor.getVendorHeader()
            .getVendorFederalWithholdingTaxBeginningDate();
    Date vendorFederalWithholdingTaxEndDate = vendor.getVendorHeader().getVendorFederalWithholdingTaxEndDate();
    java.util.Date today = getDateTimeService().getCurrentDate();
    if ((vendorFederalWithholdingTaxBeginDate != null && vendorFederalWithholdingTaxBeginDate.before(today))
            && (vendorFederalWithholdingTaxEndDate == null
                    || vendorFederalWithholdingTaxEndDate.after(today))) {
        this.disbVchrPayeeTaxControlCode = DisbursementVoucherConstants.TAX_CONTROL_CODE_BEGIN_WITHHOLDING;
    }

    // if vendor is foreign, default alien payment code to true
    if (getVendorService().isVendorForeign(vendor.getVendorHeaderGeneratedIdentifier())) {
        getDvPayeeDetail().setDisbVchrAlienPaymentCode(true);
    }
}

From source file:org.kuali.ole.module.cg.document.validation.impl.AwardPreRules.java

/**
 * Checks if the entry date is before the begin date. if so asks the user if they want to continue validation. if no is selected
 * further validation is aborted and the user is returned to the award document.
 * /*from   ww  w  .  j  a  va  2  s.c om*/
 * @return true if the user selects yes, false otherwise
 */
protected boolean continueIfEntryDateBeforeBeginDate() {
    boolean proceed = true;
    Date entryDate = newAward.getAwardEntryDate();
    Date beginDate = newAward.getAwardBeginningDate();

    if (ObjectUtils.isNotNull(entryDate) && ObjectUtils.isNotNull(beginDate) && entryDate.before(beginDate)) {
        String entryDateLabel = dataDictionaryService.getAttributeErrorLabel(Award.class,
                OLEPropertyConstants.AWARD_ENTRY_DATE);
        String beginDateLabel = dataDictionaryService.getAttributeErrorLabel(Award.class,
                OLEPropertyConstants.AWARD_BEGINNING_DATE);
        proceed = askOrAnalyzeYesNoQuestion("entryDateBeforeStartDate", buildConfirmationQuestion(
                OLEKeyConstants.WARNING_AWARD_ENTRY_BEFORE_START_DATE, entryDateLabel, beginDateLabel));
    }
    return proceed;
}

From source file:org.kuali.ole.select.document.OleDisbursementVoucherDocument.java

/**
 * Convenience method to set dv payee detail fields based on a given vendor.
 *
 * @param vendor//from   w w  w . j  a  v  a  2s .co m
 */
@Override
public void templateVendor(VendorDetail vendor, VendorAddress vendorAddress) {
    if (vendor == null) {
        return;
    }
    if (this.getDocumentHeader().getDocumentTemplateNumber() == null) {
        this.setPaymentMethodId(vendor.getPaymentMethodId());
    }
    this.getDvPayeeDetail()
            .setDisbursementVoucherPayeeTypeCode(DisbursementVoucherConstants.DV_PAYEE_TYPE_VENDOR);
    this.getDvPayeeDetail().setDisbVchrPayeeIdNumber(vendor.getVendorNumber());
    this.getDvPayeeDetail().setDisbVchrPayeePersonName(vendor.getVendorName());

    this.getDvPayeeDetail().setDisbVchrAlienPaymentCode(vendor.getVendorHeader().getVendorForeignIndicator());

    if (ObjectUtils.isNull(vendorAddress)
            || ObjectUtils.isNull(vendorAddress.getVendorAddressGeneratedIdentifier())) {
        for (VendorAddress addr : vendor.getVendorAddresses()) {
            if (addr.isVendorDefaultAddressIndicator()) {
                vendorAddress = addr;
                break;
            }
        }
    }

    if (ObjectUtils.isNotNull(vendorAddress)
            && ObjectUtils.isNotNull(vendorAddress.getVendorAddressGeneratedIdentifier())) {
        this.getDvPayeeDetail().setDisbVchrVendorAddressIdNumber(
                vendorAddress.getVendorAddressGeneratedIdentifier().toString());
        this.getDvPayeeDetail().setDisbVchrPayeeLine1Addr(vendorAddress.getVendorLine1Address());
        this.getDvPayeeDetail().setDisbVchrPayeeLine2Addr(vendorAddress.getVendorLine2Address());
        this.getDvPayeeDetail().setDisbVchrPayeeCityName(vendorAddress.getVendorCityName());
        this.getDvPayeeDetail().setDisbVchrPayeeStateCode(vendorAddress.getVendorStateCode());
        this.getDvPayeeDetail().setDisbVchrPayeeZipCode(vendorAddress.getVendorZipCode());
        this.getDvPayeeDetail().setDisbVchrPayeeCountryCode(vendorAddress.getVendorCountryCode());
    } else {
        this.getDvPayeeDetail().setDisbVchrVendorAddressIdNumber("");
        this.getDvPayeeDetail().setDisbVchrPayeeLine1Addr("");
        this.getDvPayeeDetail().setDisbVchrPayeeLine2Addr("");
        this.getDvPayeeDetail().setDisbVchrPayeeCityName("");
        this.getDvPayeeDetail().setDisbVchrPayeeStateCode("");
        this.getDvPayeeDetail().setDisbVchrPayeeZipCode("");
        this.getDvPayeeDetail().setDisbVchrPayeeCountryCode("");
    }

    //        this.getDvPayeeDetail().setDisbVchrAlienPaymentCode(vendor.getVendorHeader().getVendorForeignIndicator());
    this.getDvPayeeDetail().setDvPayeeSubjectPaymentCode(
            VendorConstants.VendorTypes.SUBJECT_PAYMENT.equals(vendor.getVendorHeader().getVendorTypeCode()));
    this.getDvPayeeDetail().setDisbVchrEmployeePaidOutsidePayrollCode(
            getVendorService().isVendorInstitutionEmployee(vendor.getVendorHeaderGeneratedIdentifier()));

    this.getDvPayeeDetail().setHasMultipleVendorAddresses(1 < vendor.getVendorAddresses().size());

    boolean w9AndW8Checked = false;
    if ((ObjectUtils.isNotNull(vendor.getVendorHeader().getVendorW9ReceivedIndicator())
            && vendor.getVendorHeader().getVendorW9ReceivedIndicator() == true)
            || (ObjectUtils.isNotNull(vendor.getVendorHeader().getVendorW8BenReceivedIndicator())
                    && vendor.getVendorHeader().getVendorW8BenReceivedIndicator() == true)) {

        w9AndW8Checked = true;
    }

    //    this.disbVchrPayeeW9CompleteCode = vendor.getVendorHeader().getVendorW8BenReceivedIndicator()  == null ? false : vendor.getVendorHeader().getVendorW8BenReceivedIndicator();
    this.disbVchrPayeeW9CompleteCode = w9AndW8Checked;

    Date vendorFederalWithholdingTaxBeginDate = vendor.getVendorHeader()
            .getVendorFederalWithholdingTaxBeginningDate();
    Date vendorFederalWithholdingTaxEndDate = vendor.getVendorHeader().getVendorFederalWithholdingTaxEndDate();
    java.util.Date today = getDateTimeService().getCurrentDate();
    if ((vendorFederalWithholdingTaxBeginDate != null && vendorFederalWithholdingTaxBeginDate.before(today))
            && (vendorFederalWithholdingTaxEndDate == null
                    || vendorFederalWithholdingTaxEndDate.after(today))) {
        this.disbVchrPayeeTaxControlCode = DisbursementVoucherConstants.TAX_CONTROL_CODE_BEGIN_WITHHOLDING;
    }

    // if vendor is foreign, default alien payment code to true
    if (getVendorService().isVendorForeign(vendor.getVendorHeaderGeneratedIdentifier())) {
        getDvPayeeDetail().setDisbVchrAlienPaymentCode(true);
    }
}