List of usage examples for java.sql Date after
public boolean after(Date when)
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. * // w w w.jav a 2s. c o 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./*from w w w.ja v a 2s.co m*/ */ protected boolean inspectAndCaptureObligationExpirationDateChanges(TimeAndMoneyForm timeAndMoneyForm, Boolean isNoCostExtension, AwardAmountInfo aai, Integer index, Award award, TimeAndMoneyDocument timeAndMoneyDocument, Entry<String, AwardHierarchyNode> awardHierarchyNode, List<TransactionDetail> dateChangeTransactionDetailItems) { boolean needToSave = false; Date previousObligationExpirationDate = aai.getObligationExpirationDate(); Date currentObligationExpirationDate = timeAndMoneyForm.getAwardHierarchyNodeItems().get(index) .getObligationExpirationDate(); if (timeAndMoneyForm.getAwardHierarchyNodeItems().get(index).isPopulatedFromClient() && currentObligationExpirationDate != null && !currentObligationExpirationDate.equals(previousObligationExpirationDate)) { // previousObligationExpirationDate is null if (isNoCostExtension && (previousObligationExpirationDate == null || currentObligationExpirationDate.after(previousObligationExpirationDate))) { aai = getNewAwardAmountInfoForDateChangeTransaction(aai, award, timeAndMoneyDocument.getDocumentNumber()); aai.setObligationExpirationDate(currentObligationExpirationDate); awardHierarchyNode.getValue().setObligationExpirationDate(currentObligationExpirationDate); award.getAwardAmountInfos().add(aai); TransactionDetail transactionDetail = createTransDetailForDateChanges(aai.getAwardNumber(), aai.getAwardNumber(), aai.getSequenceNumber(), timeAndMoneyDocument.getAwardNumber(), timeAndMoneyDocument.getDocumentNumber(), OBLIGATED_END_COMMENT); aai.setTransactionId(transactionDetail.getTransactionId()); dateChangeTransactionDetailItems.add(transactionDetail); } else { aai = getNewAwardAmountInfoForDateChangeTransaction(aai, award, timeAndMoneyDocument.getDocumentNumber()); aai.setObligationExpirationDate(currentObligationExpirationDate); awardHierarchyNode.getValue().setObligationExpirationDate(currentObligationExpirationDate); award.getAwardAmountInfos().add(aai); } needToSave = true; } else if (timeAndMoneyForm.getAwardHierarchyNodeItems().get(index).isPopulatedFromClient() && currentObligationExpirationDate == null) { //FYI, this will show an error to the user, we are doing this such they can see the error, and that they had put in a null value awardHierarchyNode.getValue().setObligationExpirationDate(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 && currentObligationExpirationDate != null && currentObligationExpirationDate.equals(previousObligationExpirationDate) && !currentObligationExpirationDate .equals(awardHierarchyNode.getValue().getObligationExpirationDate())) { awardHierarchyNode.getValue().setObligationExpirationDate(currentObligationExpirationDate); } 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 Loops through each detail object and calls * {@link AccountGlobalRule#checkExpirationDate(MaintenanceDocument, AccountGlobalDetail)} * //from w w w . java 2s . co m * @param maintenanceDocument * @return false on rules violation */ protected boolean checkExpirationDate(MaintenanceDocument maintenanceDocument) { LOG.info("checkExpirationDate called"); boolean success = true; Date newExpDate = newAccountGlobal.getAccountExpirationDate(); // 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)) { if (ObjectUtils.isNotNull(newAccountGlobal.getSubFundGroup())) { if (!SpringContext.getBean(SubFundGroupService.class) .isForContractsAndGrants(newAccountGlobal.getSubFundGroup())) { if (!newExpDate.after(today) && !newExpDate.equals(today)) { putGlobalError(OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_EXP_DATE_TODAY_LATER); success &= false; } } } } // a continuation account is required if the expiration date is completed. success &= checkContinuationAccount(maintenanceDocument, newExpDate); for (AccountGlobalDetail detail : newAccountGlobal.getAccountGlobalDetails()) { success &= checkExpirationDate(maintenanceDocument, detail); } return success; }
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 * /* w w w . j a v a 2 s .com*/ * @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.AccountGlobalRule.java
/** * This method checks to see if the updated expiration is not a valid one Only gets checked for specific {@link SubFundGroup}s * /*from ww w .ja v a2 s . co m*/ * @param oldAccount * @param newAccountGlobal * @return true if date has changed and is invalid */ protected boolean isUpdatedExpirationDateInvalid(Account oldAccount, AccountGlobal newAccountGlobal) { Date oldExpDate = oldAccount.getAccountExpirationDate(); Date newExpDate = newAccountGlobal.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 boolean expDateHasChanged = false; // if the old version of the account had no expiration date, and the new // one has a date if (ObjectUtils.isNull(oldExpDate) && ObjectUtils.isNotNull(newExpDate)) { expDateHasChanged = true; } // if there was an old and a new expDate, but they're different else if (ObjectUtils.isNotNull(oldExpDate) && ObjectUtils.isNotNull(newExpDate)) { if (!oldExpDate.equals(newExpDate)) { expDateHasChanged = true; } } // if the expiration date hasnt changed, we're not interested if (!expDateHasChanged) { return false; } // if a subFundGroup isnt present, we cannot continue the testing SubFundGroup subFundGroup = newAccountGlobal.getSubFundGroup(); if (ObjectUtils.isNull(subFundGroup)) { return false; } // get the fundGroup code String fundGroupCode = newAccountGlobal.getSubFundGroup().getFundGroupCode().trim(); // if the account is part of the CG fund group, then this rule does not // apply, so we're done if (SpringContext.getBean(SubFundGroupService.class) .isForContractsAndGrants(newAccountGlobal.getSubFundGroup())) { return false; } // at this point, we know its not a CG fund group, so we must apply the rule // expirationDate must be today or later than today (cannot be before today) if (newExpDate.equals(today) || newExpDate.after(today)) { return false; } else return true; }
From source file:org.kuali.ole.coa.document.validation.impl.AccountRule.java
/** * This method checks to see if the account expiration date is today's date or earlier * * @param newAccount//www .jav a 2 s. co m * @return fails if the expiration date is null or after today's date */ protected boolean checkAccountExpirationDateValidTodayOrEarlier(Account newAccount) { // get today's date, with no time component Date todaysDate = new Date(getDateTimeService().getCurrentDate().getTime()); todaysDate.setTime(DateUtils.truncate(todaysDate, Calendar.DAY_OF_MONTH).getTime()); // TODO: convert this to using Wes' Kuali KfsDateUtils once we're using Date's instead of Timestamp // get the expiration date, if any Date expirationDate = newAccount.getAccountExpirationDate(); if (ObjectUtils.isNull(expirationDate)) { putFieldError("accountExpirationDate", OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_ACCT_CANNOT_BE_CLOSED_EXP_DATE_INVALID); return false; } // when closing an account, the account expiration date must be the current date or earlier expirationDate.setTime(DateUtils.truncate(expirationDate, Calendar.DAY_OF_MONTH).getTime()); if (expirationDate.after(todaysDate)) { putFieldError("accountExpirationDate", OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_ACCT_CANNOT_BE_CLOSED_EXP_DATE_INVALID); return false; } return true; }
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 w w . j a v a2s . 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.AccountRule.java
/** * This method checks to see if the new expiration date is different from the old expiration and if it has if it is invalid * * @param maintDoc/* w w w. ja v a 2s .c o m*/ * @return true if expiration date has changed and is invalid */ protected boolean isUpdatedExpirationDateInvalid(MaintenanceDocument maintDoc) { // if this isn't an Edit document, we're not interested if (!maintDoc.isEdit()) { return false; } Date oldExpDate = oldAccount.getAccountExpirationDate(); Date newExpDate = newAccount.getAccountExpirationDate(); Date today = new Date(getDateTimeService().getCurrentDate().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 boolean expDateHasChanged = false; // if the old version of the account had no expiration date, and the new // one has a date if (ObjectUtils.isNull(oldExpDate) && ObjectUtils.isNotNull(newExpDate)) { expDateHasChanged = true; } // if there was an old and a new expDate, but they're different else if (ObjectUtils.isNotNull(oldExpDate) && ObjectUtils.isNotNull(newExpDate)) { if (!oldExpDate.equals(newExpDate)) { expDateHasChanged = true; } } // if the expiration date hasn't changed, we're not interested if (!expDateHasChanged) { return false; } // make a shortcut to the newAccount Account newAccount = (Account) maintDoc.getNewMaintainableObject().getBusinessObject(); // expirationDate must be today or later than today (cannot be before today) if (newExpDate.equals(today) || newExpDate.after(today)) { return false; } else { return true; } }
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 w w w . j ava2 s . c o 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.CGMaintenanceDocumentRuleBase.java
/** * Checks to see if the end date is after the begin date * * @param begin// w w w . j a va 2s . c o m * @param end * @param propertyName * @return true if end is after begin, false otherwise */ protected boolean checkEndAfterBegin(Date begin, Date end, String propertyName) { boolean success = true; if (ObjectUtils.isNotNull(begin) && ObjectUtils.isNotNull(end) && !end.after(begin)) { putFieldError(propertyName, OLEKeyConstants.ERROR_ENDING_DATE_NOT_AFTER_BEGIN); success = false; } return success; }