Java Code Examples for java.sql.Date#before()
The following examples show how to use
java.sql.Date#before() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CustomerRule.java From kfs with GNU Affero General Public License v3.0 | 6 votes |
/** * This method checks if customer end date is valid: 1. if a new address is being added, customer end date must be a future date * 2. if inactivating an address, customer end date must be current or future date * * @param endDate * @param canBeTodaysDateFlag * @return True if endDate is valid. */ public boolean checkEndDateIsValid(Date endDate, boolean canBeTodaysDateFlag) { boolean isValid = true; if (ObjectUtils.isNull(endDate)) { return isValid; } Timestamp today = dateTimeService.getCurrentTimestamp(); today.setTime(DateUtils.truncate(today, Calendar.DAY_OF_MONTH).getTime()); // end date must be todays date or future date if (canBeTodaysDateFlag) { if (endDate.before(today)) { isValid = false; } } // end date must be a future date else { if (!endDate.after(today)) { isValid = false; } } return isValid; }
Example 2
Source File: PerDiemExpense.java From kfs with GNU Affero General Public License v3.0 | 5 votes |
/** * Determines if the mileage date for this per diem expense matches the range for the given mileage rate * @param mileageRate the mileage rate to check the mileage date against * @return true if the mileage date matches, false otherwise */ protected boolean isMileageDateWithinMileageRateRange(MileageRate mileageRate) { final Date fromDate = mileageRate.getActiveFromDate(); final Date toDate = mileageRate.getActiveToDate(); return (KfsDateUtils.isSameDay(fromDate, getMileageDate()) || fromDate.before(getMileageDate())) && (KfsDateUtils.isSameDay(toDate, getMileageDate()) || toDate.after(getMileageDate())); }
Example 3
Source File: MileageRateServiceImpl.java From kfs with GNU Affero General Public License v3.0 | 5 votes |
@Override public MileageRate findMileageRateByExpenseTypeCodeAndDate(String expenseTypeCode, Date effectiveDate) { for (MileageRate mileageRate : cachingMileageRateService.findAllMileageRates()) { if ((KfsDateUtils.isSameDay(effectiveDate, mileageRate.getActiveFromDate()) || effectiveDate.after(mileageRate.getActiveFromDate())) && (KfsDateUtils.isSameDay(effectiveDate, mileageRate.getActiveToDate()) || effectiveDate.before(mileageRate.getActiveToDate())) && mileageRate.getExpenseTypeCode().equals(expenseTypeCode)) { return mileageRate; } } return null; }
Example 4
Source File: AccountingDocumentRuleHelperServiceImpl.java From kfs with GNU Affero General Public License v3.0 | 5 votes |
/** * @see org.kuali.kfs.sys.document.service.AccountingDocumentRuleHelperService#isValidReversalDate(java.sql.Date, * java.lang.String) */ public boolean isValidReversalDate(Date reversalDate, String errorPropertyName) { java.sql.Date today = SpringContext.getBean(DateTimeService.class).getCurrentSqlDateMidnight(); if (null != reversalDate && reversalDate.before(today)) { GlobalVariables.getMessageMap().putError(errorPropertyName, KFSKeyConstants.ERROR_DOCUMENT_INCORRECT_REVERSAL_DATE); return false; } else { return true; } }
Example 5
Source File: AwardPreRules.java From kfs with GNU Affero General Public License v3.0 | 5 votes |
/** * 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. * * @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, KFSPropertyConstants.AWARD_ENTRY_DATE); String beginDateLabel = dataDictionaryService.getAttributeErrorLabel(Award.class, KFSPropertyConstants.AWARD_BEGINNING_DATE); proceed = askOrAnalyzeYesNoQuestion("entryDateBeforeStartDate", buildConfirmationQuestion(KFSKeyConstants.WARNING_AWARD_ENTRY_BEFORE_START_DATE, entryDateLabel, beginDateLabel)); } return proceed; }
Example 6
Source File: EquipmentLoanOrReturnDocumentRule.java From kfs with GNU Affero General Public License v3.0 | 5 votes |
/** * Implementation of the rule that if a document has a valid expect loan date and loan return date, the both dates should come * before the 2 years limit. * * @param equipmentLoanOrReturnDocument the equipmentLoanOrReturn document to be validated * @return boolean false if the expect loan date or loan return date is not before the 2 years limit. */ protected boolean validateLoanDate(EquipmentLoanOrReturnDocument equipmentLoanOrReturnDocument) { boolean valid = true; Date loanDate = KfsDateUtils.clearTimeFields(equipmentLoanOrReturnDocument.getLoanDate()); Calendar cal = GregorianCalendar.getInstance(); cal.setTime(loanDate); cal.add(Calendar.YEAR, 2); Date maxDate = new Date(cal.getTime().getTime()); // Loan can not be before today Date loanReturnDate = equipmentLoanOrReturnDocument.getLoanReturnDate(); if (equipmentLoanOrReturnDocument.isNewLoan() && loanDate.before(KfsDateUtils.clearTimeFields(new java.util.Date()))) { GlobalVariables.getMessageMap().putError(KFSConstants.DOCUMENT_PROPERTY_NAME + "." + CamsPropertyConstants.EquipmentLoanOrReturnDocument.LOAN_DATE, CamsKeyConstants.EquipmentLoanOrReturn.ERROR_INVALID_LOAN_DATE); } // expect return date must be >= loan date and within 2 years limit Date expectReturnDate = equipmentLoanOrReturnDocument.getExpectedReturnDate(); if (expectReturnDate != null) { KfsDateUtils.clearTimeFields(expectReturnDate); if (expectReturnDate.before(loanDate)) { valid &= false; GlobalVariables.getMessageMap().putError(KFSConstants.DOCUMENT_PROPERTY_NAME + "." + CamsPropertyConstants.EquipmentLoanOrReturnDocument.EXPECTED_RETURN_DATE, CamsKeyConstants.EquipmentLoanOrReturn.ERROR_INVALID_EXPECTED_RETURN_DATE); } if (maxDate.before(expectReturnDate)) { valid &= false; GlobalVariables.getMessageMap().putError(KFSConstants.DOCUMENT_PROPERTY_NAME + "." + CamsPropertyConstants.EquipmentLoanOrReturnDocument.EXPECTED_RETURN_DATE, CamsKeyConstants.EquipmentLoanOrReturn.ERROR_INVALID_EXPECTED_MAX_DATE); } } // loan return date must be >= loan date and within 2 years limit if (loanReturnDate != null) { KfsDateUtils.clearTimeFields(loanReturnDate); if (loanDate.after(loanReturnDate) || maxDate.before(loanReturnDate)) { valid &= false; GlobalVariables.getMessageMap().putError(KFSConstants.DOCUMENT_PROPERTY_NAME + "." + CamsPropertyConstants.EquipmentLoanOrReturnDocument.LOAN_RETURN_DATE, CamsKeyConstants.EquipmentLoanOrReturn.ERROR_INVALID_LOAN_RETURN_DATE); } } return valid; }
Example 7
Source File: CustomerInvoiceBothEndDateAndTotalRecurrenceNumberValidation.java From kfs with GNU Affero General Public License v3.0 | 4 votes |
public boolean validate(AttributedDocumentEvent event) { // short circuit if no recurrence object at all if (ObjectUtils.isNull(customerInvoiceDocument.getCustomerInvoiceRecurrenceDetails())) { return true; } if (ObjectUtils.isNull(customerInvoiceDocument.getCustomerInvoiceRecurrenceDetails().getDocumentRecurrenceBeginDate()) || ObjectUtils.isNull(customerInvoiceDocument.getCustomerInvoiceRecurrenceDetails().getDocumentRecurrenceIntervalCode()) || ObjectUtils.isNull(customerInvoiceDocument.getCustomerInvoiceRecurrenceDetails().getDocumentRecurrenceEndDate()) || ObjectUtils.isNull(customerInvoiceDocument.getCustomerInvoiceRecurrenceDetails().getDocumentTotalRecurrenceNumber())) { return true; } Calendar beginCalendar = Calendar.getInstance(); beginCalendar.setTime(customerInvoiceDocument.getCustomerInvoiceRecurrenceDetails().getDocumentRecurrenceBeginDate()); Date beginDate = customerInvoiceDocument.getCustomerInvoiceRecurrenceDetails().getDocumentRecurrenceBeginDate(); Calendar endCalendar = Calendar.getInstance(); endCalendar.setTime(customerInvoiceDocument.getCustomerInvoiceRecurrenceDetails().getDocumentRecurrenceEndDate()); Date endDate = customerInvoiceDocument.getCustomerInvoiceRecurrenceDetails().getDocumentRecurrenceEndDate(); Calendar nextCalendar = Calendar.getInstance(); Date nextDate = beginDate; int totalRecurrences = 0; int addCounter = 0; String intervalCode = customerInvoiceDocument.getCustomerInvoiceRecurrenceDetails().getDocumentRecurrenceIntervalCode(); if (intervalCode.equals("M")) { addCounter = 1; } if (intervalCode.equals("Q")) { addCounter = 3; } /* perform this loop while begin_date is less than or equal to end_date */ while (!(beginDate.after(endDate))){ beginCalendar.setTime(beginDate); beginCalendar.add(Calendar.MONTH, addCounter); beginDate = KfsDateUtils.convertToSqlDate(beginCalendar.getTime()); totalRecurrences++; nextDate = beginDate; nextCalendar.setTime(nextDate); nextCalendar.add(Calendar.MONTH, addCounter); nextDate = KfsDateUtils.convertToSqlDate(nextCalendar.getTime()); if (endDate.after(beginDate) && endDate.before(nextDate)) { totalRecurrences++; break; } } if (totalRecurrences != customerInvoiceDocument.getCustomerInvoiceRecurrenceDetails().getDocumentTotalRecurrenceNumber().intValue()) { GlobalVariables.getMessageMap().putError(DOCUMENT_ERROR_PREFIX + ArPropertyConstants.CustomerInvoiceDocumentFields.INVOICE_DOCUMENT_RECURRENCE_END_DATE, ArKeyConstants.ERROR_END_DATE_AND_TOTAL_NUMBER_OF_RECURRENCES_NOT_VALID); return false; } return true; }
Example 8
Source File: InvoiceRecurrencePreRules.java From kfs with GNU Affero General Public License v3.0 | 4 votes |
/** * This method calculates the total number of recurrences when a begin date and end date is entered. * * @param document the maintenance document * @return */ protected boolean setTotalRecurrenceNumberIfEndDateIsEntered(Document document) { MaintenanceDocument maintenanceDocument = (MaintenanceDocument) document; InvoiceRecurrence newInvoiceRecurrence = (InvoiceRecurrence) maintenanceDocument.getNewMaintainableObject().getBusinessObject(); if (ObjectUtils.isNull(newInvoiceRecurrence.getDocumentRecurrenceEndDate())) { return true; } if (ObjectUtils.isNotNull(newInvoiceRecurrence.getDocumentRecurrenceEndDate()) && ObjectUtils.isNotNull(newInvoiceRecurrence.getDocumentTotalRecurrenceNumber())) { return true; } Calendar beginCalendar = Calendar.getInstance(); /* * beginCalendar.setTime(new Timestamp(newInvoiceRecurrence.getDocumentRecurrenceBeginDate().getTime())); */ beginCalendar.setTime(newInvoiceRecurrence.getDocumentRecurrenceBeginDate()); Date beginDate = newInvoiceRecurrence.getDocumentRecurrenceBeginDate(); Calendar endCalendar = Calendar.getInstance(); /* * endCalendar.setTime(new Timestamp(newInvoiceRecurrence.getDocumentRecurrenceEndDate().getTime())); */ endCalendar.setTime(newInvoiceRecurrence.getDocumentRecurrenceEndDate()); Date endDate = newInvoiceRecurrence.getDocumentRecurrenceEndDate(); Calendar nextCalendar = Calendar.getInstance(); Date nextDate = beginDate; int totalRecurrences = 0; int addCounter = 0; String intervalCode = newInvoiceRecurrence.getDocumentRecurrenceIntervalCode(); if (intervalCode.equals("M")) { addCounter = 1; } if (intervalCode.equals("Q")) { addCounter = 3; } /* perform this loop while begin_date is less than or equal to end_date */ while (!(beginDate.after(endDate))){ beginCalendar.setTime(beginDate); beginCalendar.add(Calendar.MONTH, addCounter); beginDate = KfsDateUtils.convertToSqlDate(beginCalendar.getTime()); totalRecurrences++; nextDate = beginDate; nextCalendar.setTime(nextDate); nextCalendar.add(Calendar.MONTH, addCounter); nextDate = KfsDateUtils.convertToSqlDate(nextCalendar.getTime()); if (endDate.after(beginDate) && endDate.before(nextDate)) { totalRecurrences++; break; } } if (totalRecurrences > 0) { newInvoiceRecurrence.setDocumentTotalRecurrenceNumber(totalRecurrences); } return true; }
Example 9
Source File: InvoiceRecurrenceRule.java From kfs with GNU Affero General Public License v3.0 | 4 votes |
/** * This method checks that End Date and Total Recurrence Number are valid when both are entered. * * @param document the maintenance document * @return */ protected boolean validateIfBothEndDateAndTotalRecurrenceNumberAreEntered(Date recurrenceBeginDate, Date recurrenceEndDate, Integer totalRecurrenceNumber, String recurrenceIntervalCode) { if (ObjectUtils.isNull(recurrenceBeginDate) || ObjectUtils.isNull(recurrenceIntervalCode) || ObjectUtils.isNull(recurrenceEndDate) || ObjectUtils.isNull(totalRecurrenceNumber)) { return true; } Calendar beginCalendar = Calendar.getInstance(); beginCalendar.setTime(recurrenceBeginDate); Date beginDate = recurrenceBeginDate; Calendar endCalendar = Calendar.getInstance(); endCalendar.setTime(recurrenceEndDate); Date endDate = recurrenceEndDate; Calendar nextCalendar = Calendar.getInstance(); Date nextDate = beginDate; int totalRecurrences = 0; int addCounter = 0; String intervalCode = recurrenceIntervalCode; if (intervalCode.equals("M")) { addCounter = 1; } if (intervalCode.equals("Q")) { addCounter = 3; } /* perform this loop while begin_date is less than or equal to end_date */ while (!(beginDate.after(endDate))){ beginCalendar.setTime(beginDate); beginCalendar.add(Calendar.MONTH, addCounter); beginDate = KfsDateUtils.convertToSqlDate(beginCalendar.getTime()); totalRecurrences++; nextDate = beginDate; nextCalendar.setTime(nextDate); nextCalendar.add(Calendar.MONTH, addCounter); nextDate = KfsDateUtils.convertToSqlDate(nextCalendar.getTime()); if (endDate.after(beginDate) && endDate.before(nextDate)) { totalRecurrences++; break; } } if (totalRecurrences != totalRecurrenceNumber.intValue()) { putFieldError(ArPropertyConstants.InvoiceRecurrenceFields.INVOICE_RECURRENCE_END_DATE, ArKeyConstants.ERROR_END_DATE_AND_TOTAL_NUMBER_OF_RECURRENCES_NOT_VALID); return false; } return true; }
Example 10
Source File: InvoiceRecurrenceDocumentServiceImpl.java From kfs with GNU Affero General Public License v3.0 | 4 votes |
/** * @see org.kuali.kfs.module.ar.document.service.InvoiceRecurrenceService#isValidEndDateAndTotalRecurrenceNumber(Date,Date,int,String) */ @Override public boolean isValidEndDateAndTotalRecurrenceNumber( Date recurrenceBeginDate, Date recurrenceEndDate, Integer totalRecurrenceNumber, String recurrenceIntervalCode ) { if (ObjectUtils.isNull(recurrenceBeginDate) || ObjectUtils.isNull(recurrenceIntervalCode) || ObjectUtils.isNull(recurrenceEndDate) || ObjectUtils.isNull(totalRecurrenceNumber)) { return true; } Calendar beginCalendar = Calendar.getInstance(); beginCalendar.setTime(recurrenceBeginDate); Date beginDate = recurrenceBeginDate; Calendar endCalendar = Calendar.getInstance(); endCalendar.setTime(recurrenceEndDate); Date endDate = recurrenceEndDate; Calendar nextCalendar = Calendar.getInstance(); Date nextDate = beginDate; int totalRecurrences = 0; int addCounter = 0; String intervalCode = recurrenceIntervalCode; if (intervalCode.equals("M")) { addCounter = 1; } if (intervalCode.equals("Q")) { addCounter = 3; } /* perform this loop while begin_date is less than or equal to end_date */ while (!(beginDate.after(endDate))){ beginCalendar.setTime(beginDate); beginCalendar.add(Calendar.MONTH, addCounter); beginDate = KfsDateUtils.convertToSqlDate(beginCalendar.getTime()); totalRecurrences++; nextDate = beginDate; nextCalendar.setTime(nextDate); nextCalendar.add(Calendar.MONTH, addCounter); nextDate = KfsDateUtils.convertToSqlDate(nextCalendar.getTime()); if (endDate.after(beginDate) && endDate.before(nextDate)) { totalRecurrences++; break; } } if (totalRecurrences != totalRecurrenceNumber.intValue()) { return false; } return true; }
Example 11
Source File: AccountGlobalRule.java From kfs with GNU Affero General Public License v3.0 | 4 votes |
/** * This method checks to see if any expiration date field rules were violated in relation to the given detail record * * @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(); Date prevExpDate = null; // get previous expiration date for possible check later if (maintenanceDocument.getDocumentHeader().getWorkflowDocument().isApprovalRequested()) { try { MaintenanceDocument oldMaintDoc = (MaintenanceDocument) SpringContext.getBean(DocumentService.class).getByDocumentHeaderId(maintenanceDocument.getDocumentNumber()); AccountGlobal oldAccountGlobal = (AccountGlobal)oldMaintDoc.getDocumentBusinessObject(); if (ObjectUtils.isNotNull(oldAccountGlobal)) { prevExpDate = oldAccountGlobal.getAccountExpirationDate(); } } catch (WorkflowException ex) { LOG.warn( "Error retrieving maintenance doc for doc #" + maintenanceDocument.getDocumentNumber()+ ". This shouldn't happen.", ex ); } } // load the object by keys 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)) { // if the date was valid upon submission, and this is an approval, // we're not interested unless the approver changed the value if (ObjectUtils.isNull(prevExpDate) || !prevExpDate.equals(newExpDate)) { putFieldError("accountExpirationDate", KFSKeyConstants.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 // unless the date was valid upon submission, this is an approval action // and the approver hasn't changed the value if (maintenanceDocument.isNew() && ObjectUtils.isNotNull(newExpDate)) { if (ObjectUtils.isNull(prevExpDate) || !prevExpDate.equals(newExpDate)) { if (ObjectUtils.isNotNull(newExpDate) && ObjectUtils.isNull(newAccountGlobal.getSubFundGroup())) { if (ObjectUtils.isNotNull(account.getSubFundGroup())) { if (!account.isForContractsAndGrants()) { if (!newExpDate.after(today) && !newExpDate.equals(today)) { putGlobalError(KFSKeyConstants.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(KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_EXP_DATE_CANNOT_BE_BEFORE_EFFECTIVE_DATE); success &= false; } } } return success; }
Example 12
Source File: DisbursementVoucherDocument.java From kfs with GNU Affero General Public License v3.0 | 4 votes |
/** * Convenience method to set dv payee detail fields based on a given vendor. * * @param vendor */ public void templateVendor(VendorDetail vendor, VendorAddress vendorAddress) { if (vendor == null) { return; } this.getDvPayeeDetail().setDisbursementVoucherPayeeTypeCode(KFSConstants.PaymentPayeeTypes.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); } }
Example 13
Source File: LiquidityEntryDao.java From projectforge-webapp with GNU General Public License v3.0 | 4 votes |
@Override public List<LiquidityEntryDO> getList(final BaseSearchFilter filter) { final LiquidityFilter myFilter; if (filter instanceof LiquidityFilter) { myFilter = (LiquidityFilter) filter; } else { myFilter = new LiquidityFilter(filter); } final QueryFilter queryFilter = new QueryFilter(myFilter); final List<LiquidityEntryDO> list = getList(queryFilter); if (myFilter.getPaymentStatus() == PaymentStatus.ALL && myFilter.getAmountType() == AmountType.ALL && myFilter.getNextDays() <= 0 || myFilter.isDeleted() == true) { return list; } final List<LiquidityEntryDO> result = new ArrayList<LiquidityEntryDO>(); final DayHolder today = new DayHolder(); for (final LiquidityEntryDO entry : list) { if (myFilter.getPaymentStatus() == PaymentStatus.PAID && entry.isPaid() == false) { continue; } if (myFilter.getPaymentStatus() == PaymentStatus.UNPAID && entry.isPaid() == true) { continue; } if (entry.getAmount() != null) { if (myFilter.getAmountType() == AmountType.CREDIT && entry.getAmount().compareTo(BigDecimal.ZERO) >= 0) { continue; } if (myFilter.getAmountType() == AmountType.DEBIT && entry.getAmount().compareTo(BigDecimal.ZERO) <= 0) { continue; } } if (myFilter.getNextDays() > 0) { Date dateOfPayment = entry.getDateOfPayment(); if (dateOfPayment == null) { dateOfPayment = today.getSQLDate(); } if (dateOfPayment.before(today.getDate()) == true) { // Entry is before today: if (myFilter.getPaymentStatus() == PaymentStatus.PAID || entry.isPaid() == true) { // Ignore entries of the past if they were paid. Also ignore unpaid entries of the past if the user wants to filter only paid // entries. continue; } } else { if (today.daysBetween(entry.getDateOfPayment()) > myFilter.getNextDays()) { continue; } } } result.add(entry); } return result; }