List of usage examples for java.util Date compareTo
public int compareTo(Date anotherDate)
From source file:com.openbravo.pos.sales.restaurant.JRetailTicketsBagRestaurantMap.java
public void newTicket() { if (m_PlaceCurrent != null) { try {/*w w w. j a va 2 s . c om*/ // if there is no kot items logger.info("exit Table Action Table name: " + m_panelticket.getActiveTicket().getTableName()); String currentUpdated = m_dateformat.format(m_panelticket.getActiveTicket().getObjectUpdateDate()) + " " + m_dateformattime.format(m_panelticket.getActiveTicket().getObjectUpdateDate()); String dbUpdated = ""; dbUpdated = dlReceipts.getUpdatedTime(m_panelticket.getActiveTicket().getPlaceId(), m_panelticket.getActiveTicket().getSplitSharedId()); Date currentUpdatedDate = DateFormats.StringToDateTime(currentUpdated); Date dbUpdatedDate = DateFormats.StringToDateTime(dbUpdated); if (dbUpdated.equals(null) || dbUpdated.equals("")) { showMessage(this, "This Bill is no longer exist"); logger.info("This Bill is no longer exist"); activate(); } else if (dbUpdatedDate.compareTo(currentUpdatedDate) > 0) { showMessage(this, "The Table is being accessed by another User!Cannot update the bill"); logger.info("The Table is being accessed by another User!Cannot update the bill"); int iskds = dlReceipts.getKdsUpdateStatus(m_PlaceCurrent.getId(), m_panelticket.getActiveTicket().getSplitSharedId()); if (iskds == 1) { RetailTicketInfo ticket = dlReceipts.getRetailSharedTicketSplit(m_PlaceCurrent.getId(), m_panelticket.getActiveTicket().getSplitSharedId()); if (ticket != null) { ticket.setTicketOpen(false); dlReceipts.updateSharedTicket(m_PlaceCurrent.getId(), ticket); } } // activate(); } else { if (m_panelticket.getActiveTicket().getOrderId() == 0) { try { logger.info("Order No." + m_panelticket.getActiveTicket().getOrderId() + " deleting 0 order no. Bill in newticket method of " + m_panelticket.getActiveTicket().getTableName() + " id is " + m_PlaceCurrent.getId()); dlReceipts.deleteSharedTicket(m_PlaceCurrent.getId()); deleteTicket(); } catch (BasicException ex) { Logger.getLogger(JRetailTicketsBagRestaurantMap.class.getName()).log(Level.SEVERE, null, ex); } } //if kot done but cancelled all lines then save the bill as cancel ticket and remove from shared tickets else if (m_panelticket.getActiveTicket().getOrderId() != 0 && m_panelticket.getActiveTicket().getLinesCount() == 0) { m_panelticket.getActiveTicket().setUser(m_App.getAppUserView().getUser().getUserInfo()); // El usuario que lo cobra m_panelticket.getActiveTicket().setActiveCash(m_App.getActiveCashIndex()); m_panelticket.getActiveTicket().setActiveDay(m_App.getActiveDayIndex()); m_panelticket.getActiveTicket().setDate(new Date()); // String ticketDocument; ticketDocument = m_App.getProperties().getStoreName() + "-" + m_App.getProperties().getPosNo() + "-" + m_panelticket.getActiveTicket().getTicketId(); String reason = "Splitted with zero lines/cancelled all kot lines"; try { dlSales.saveRetailCancelTicket(m_panelticket.getActiveTicket(), m_App.getProperties().getStoreName(), ticketDocument, "Y", m_App.getInventoryLocation(), reason, "", m_App.getProperties().getPosNo(), "N"); } catch (BasicException ex) { logger.info("newTicket saveRetailCancelTicket exception " + ex.getMessage()); Logger.getLogger(JRetailPanelTicket.class.getName()).log(Level.SEVERE, null, ex); } if (m_panelticket.getActiveTicket().getSplitValue().equals("")) { deleteTicket(); } // else { // try { // dlReceipts.deleteSharedSplitTicket(m_panelticket.getActiveTicket().getPlaceId(), m_panelticket.getActiveTicket().getSplitSharedId()); // } catch (BasicException ex) { // logger.info("newTicket deleteSharedSplitTicket exception " + ex.getMessage()); // maybe other guy deleted it // } // } } //if partially kot and partially non kot items present else { int i = 0; //Removing non kot items while (i < m_panelticket.getActiveTicket().getLinesCount()) { if (m_panelticket.getActiveTicket().getLine(i).getIsKot() == 0) { m_panelticket.getActiveTicket().removeLine(i); i = 0; } else { i++; } } m_panelticket.getActiveTicket().refreshTxtFields(0); m_panelticket.getActiveTicket().setTicketOpen(false); if (m_panelticket.getActiveTicket().getLinesCount() == 0) { logger.info("Order No." + m_panelticket.getActiveTicket().getOrderId() + "deleting partially kot and partially non kot items Bill in newticket method of " + m_panelticket.getActiveTicket().getTableName()); if (m_panelticket.getActiveTicket().getOrderId() != 0) { m_panelticket.getActiveTicket() .setUser(m_App.getAppUserView().getUser().getUserInfo()); // El usuario que lo cobra m_panelticket.getActiveTicket().setActiveCash(m_App.getActiveCashIndex()); m_panelticket.getActiveTicket().setActiveDay(m_App.getActiveDayIndex()); m_panelticket.getActiveTicket().setDate(new Date()); // String ticketDocument; ticketDocument = m_App.getProperties().getStoreName() + "-" + m_App.getProperties().getPosNo() + "-" + m_panelticket.getActiveTicket().getTicketId(); String reason = "cancelled all kot lines"; try { dlSales.saveRetailCancelTicket(m_panelticket.getActiveTicket(), m_App.getProperties().getStoreName(), ticketDocument, "Y", m_App.getInventoryLocation(), reason, "", m_App.getProperties().getPosNo(), "N"); } catch (BasicException ex) { logger.info( "newTicket saveRetailCancelTicket exception 2" + ex.getMessage() + ";"); Logger.getLogger(JRetailPanelTicket.class.getName()).log(Level.SEVERE, null, ex); } } if (m_panelticket.getActiveTicket().getSplitValue().equals("")) { deleteTicket(); } } else { try { dlReceipts.updateSharedTicket(m_PlaceCurrent.getId(), m_panelticket.getActiveTicket()); } catch (BasicException e) { logger.info("newTicket updateSharedTicket exception " + e.getMessage()); new MessageInf(e).show(this); // maybe other guy deleted it } m_PlaceCurrent = null; } } printState(); m_panelticket.setRetailActiveTicket(null, null); } } //Method is used for holding the bill catch (BasicException ex) { Logger.getLogger(JRetailTicketsBagRestaurantMap.class.getName()).log(Level.SEVERE, null, ex); } } //Method is used for holding the bill }
From source file:org.kuali.kfs.module.cam.batch.service.impl.AssetDepreciationServiceImpl.java
protected boolean hasBlankOutPeriodStarted(Date beginDate, Date endDate, List<String> errorMessages) throws ParseException { Date currentDate = convertToDate(dateTimeService.toDateString(dateTimeService.getCurrentDate())); String blankOutBegin = parameterService.getParameterValueAsString(AssetDepreciationStep.class, CamsConstants.Parameters.BLANK_OUT_BEGIN_MMDD); String blankOutEnd = parameterService.getParameterValueAsString(AssetDepreciationStep.class, CamsConstants.Parameters.BLANK_OUT_END_MMDD); if (ObjectUtils.isNotNull(beginDate) && ObjectUtils.isNotNull(endDate)) { if (currentDate.compareTo(beginDate) >= 0 && currentDate.compareTo(endDate) <= 0) { return true; }//from w ww.j av a2s . c o m } else { String message = "Unable to determine blank out period for a given " + blankOutBegin + " - " + blankOutEnd + " range ."; errorMessages.add(message); LOG.info(message); } return false; }
From source file:com.zimbra.cs.mailbox.calendar.ZRecur.java
public List<Date> expandRecurrenceOverRange(ParsedDateTime dtStart, long rangeStart, long rangeEnd) throws ServiceException { List<Date> toRet = new LinkedList<Date>(); Date rangeStartDate = new Date(rangeStart); // subtract 1000ms (1sec) because the code in the method treats // end time as inclusive while the rangeEnd input argument is // exclusive value Date rangeEndDate = new Date(rangeEnd - 1000); Date dtStartDate = new Date(dtStart.getUtcTime()); Date earliestDate;//www . ja va2 s. co m if (dtStartDate.after(rangeStartDate)) earliestDate = dtStartDate; else earliestDate = rangeStartDate; if (mUntil != null) { Date until = mUntil.getDateForRecurUntil(dtStart.getTimeZone()); if (until.before(rangeEndDate)) rangeEndDate = until; } // Set limit of expansion count. int maxInstancesFromConfig = sExpansionLimits.maxInstances; int maxInstancesExpanded; if (maxInstancesFromConfig <= 0) maxInstancesExpanded = mCount; else if (mCount <= 0) maxInstancesExpanded = maxInstancesFromConfig; else maxInstancesExpanded = Math.min(mCount, maxInstancesFromConfig); int numInstancesExpanded = 1; // initially 1 rather than 0 because DTSTART is always included // Set hard limit of expansion time range. (bug 21989) ParsedDateTime earliestDateTime = ParsedDateTime.fromUTCTime(earliestDate.getTime()); Date hardEndDate = getEstimatedEndTime(earliestDateTime); if (hardEndDate.before(rangeEndDate)) rangeEndDate = hardEndDate; if (rangeEndDate.before(earliestDate)) { ZimbraLog.calendar.debug( "Expanding recurrence over range where range end %s is before earliest date %s", DateUtil.formatDate(rangeEndDate), DateUtil.formatDate(earliestDate)); return toRet; } GregorianCalendar cur = dtStart.getCalendarCopy(); int baseMonthDay = cur.get(Calendar.DAY_OF_MONTH); boolean baseIsLeapDay = ((baseMonthDay == 29) && (cur.get(Calendar.MONTH) == Calendar.FEBRUARY)); // until we hit rangeEnd, or we've SAVED count entries: // // gather each set { // // // // curDate forward one INTERVAL // // } // check Set against BYSETPOS & ranges & count // int interval = mInterval; if (interval <= 0) interval = 1; // DTSTART is always part of the expansion, as long as it falls within // the range. if (!dtStartDate.before(earliestDate) && !dtStartDate.after(rangeEndDate)) toRet.add(dtStartDate); int numConsecutiveIterationsWithoutMatchingInstance = 0; boolean pastHardEndTime = false; long numIterations = 0; // track how many times we looped while (!pastHardEndTime && (maxInstancesExpanded <= 0 || numInstancesExpanded < maxInstancesExpanded)) { numIterations++; boolean curIsAtOrAfterEarliestDate = !cur.getTime().before(earliestDate); boolean curIsAfterEndDate = cur.getTime().after(rangeEndDate); List<Calendar> addList = new LinkedList<Calendar>(); switch (mFreq) { case HOURLY: /* * BYSECOND - for each listed second * BYMINUTE - for each listed minute in hour * BYHOUR - match iff in hour list * BYDAY - for each day listed * BYMONTHDAY - only those monthdays * BYYEARDAY - only those yeardays * BYMONTH - only those months */ if (!checkMonthList(cur)) continue; if (!checkYearDayList(cur)) continue; if (!checkMonthDayList(cur)) continue; if (!checkDayList(cur)) continue; if (!checkHourList(cur)) continue; addList.add((Calendar) (cur.clone())); cur.add(Calendar.HOUR_OF_DAY, interval); addList = expandHourList(addList); addList = expandMinuteList(addList); addList = expandSecondList(addList); break; case DAILY: /* * BYSECOND - for each listed second in day * BYMINUTE - for each listed minute in day * BYHOUR - for each listed hour in day * BYDAY - no ordinal allowed, match iff in day list * BYMONTHDAY - only that day * BYYEARDAY - only that day * BYWEEKNO -- YEARLY ONLY * BYMONTH - only that month * * while (count check & until check & rangeEnd check) { * if (byMonth && !month matches) * curDay = set MONTH to matching month * * if (byYearDay && !yearday matches) * curDay = set DAY to next matching yearday * * if (byMonthday && !monthday matches) * curDay = skip to next matching monthday * * if (byDay && !day in list) * curDay = skip to next mathcing byDay * * if (!byHour or FOR EACH HOUR IN HOURLIST) * if (!byMinute or FOR EACH MINUTE IN MINLIST) * if (!bySecond or FOR EACH SECOND IN LIST) * ----add to list--- * * check against BYSETPOS * * curDay+=1 day * } * */ if (!checkMonthList(cur)) continue; if (!checkYearDayList(cur)) continue; if (!checkMonthDayList(cur)) continue; if (!checkDayList(cur)) continue; addList.add((Calendar) (cur.clone())); cur.add(Calendar.DAY_OF_YEAR, interval); addList = expandHourList(addList); addList = expandMinuteList(addList); addList = expandSecondList(addList); break; case WEEKLY: /* * BYSECOND - for every listed second * BYMINUTE - for every listed minute * BYHOUR - for every listed hour * BYDAY - for every listed day * BYMONTHDAY - MAYBE once a month * BYYEARDAY - MAYBE once a year * BYMONTH - iff month matches * * for each (INTERVAL)WEEK{ * if (byMonth && !month matches) * curDay = set MONTH to DtStart in next matching month * * if (byYearDay && !yearday matches) * curDay = set date to next matching yearday * * if (byMonthDay && !monthday matches) * curDay = skip to next matching monthday * * if (!byDay or FOREACH day in list) * if (!byHour or FOREACH hour in list) * if (!byMinute or FOREACH minute in list) * if (!bySecond or FOREACH second in list) * ----add to list---- * * check against BYSETPOS * * curDay += 1 week * } while (count check & until check & rangeEnd check) * */ if (!checkMonthList(cur)) continue; if (!checkYearDayList(cur)) continue; if (!checkMonthDayList(cur)) continue; addList.add((Calendar) (cur.clone())); cur.add(Calendar.WEEK_OF_YEAR, interval); addList = expandDayListForWeekly(addList); addList = expandHourList(addList); addList = expandMinuteList(addList); addList = expandSecondList(addList); break; case MONTHLY: if (!checkMonthList(cur)) continue; if (!checkYearDayList(cur)) continue; addList.add((Calendar) (cur.clone())); cur.set(Calendar.DAY_OF_MONTH, 1); cur.add(Calendar.MONTH, interval); int daysInMonth = cur.getActualMaximum(Calendar.DAY_OF_MONTH); cur.set(Calendar.DAY_OF_MONTH, Math.min(baseMonthDay, daysInMonth)); addList = expandMonthDayList(addList); addList = expandDayListForMonthlyYearly(addList); addList = expandHourList(addList); addList = expandMinuteList(addList); addList = expandSecondList(addList); break; case YEARLY: /* * BYSECOND * BYMINUTE * BYHOUR * BYDAY * BYMONTHDAY * BYYEARDAY * BYWEEKNO - specified week * BYMONTH - once */ if (baseIsLeapDay) { // previously adding a year to a leap day will have rounded down to the 28th. // If this happened, we need to be sure that if we are back in a leap // year, it is back at 29th cur.set(Calendar.DAY_OF_MONTH, cur.getActualMaximum(Calendar.DAY_OF_MONTH)); } if (ignoreYearForRecurrenceExpansion(cur, baseIsLeapDay)) { cur.add(Calendar.YEAR, interval); break; } addList.add((Calendar) (cur.clone())); cur.add(Calendar.YEAR, interval); addList = expandMonthList(addList); addList = expandYearDayList(addList); addList = expandMonthDayList(addList); addList = expandDayListForMonthlyYearly(addList); addList = expandHourList(addList); addList = expandMinuteList(addList); addList = expandSecondList(addList); break; default: // MINUTELY and SECONDLY are intentionally not supported for performance reasons. return toRet; } addList = handleSetPos(addList); boolean noInstanceFound = true; boolean foundInstancePastEndDate = false; // add all the ones that match! for (Calendar addCal : addList) { Date toAdd = addCal.getTime(); // We already counted DTSTART before the main loop, so don't // count it twice. if (toAdd.compareTo(dtStartDate) == 0) { noInstanceFound = false; continue; } // we still have expanded this instance, even if it isn't in our // current date window if (toAdd.after(dtStartDate)) numInstancesExpanded++; if (!toAdd.after(rangeEndDate)) { if (!toAdd.before(earliestDate)) { toRet.add(toAdd); noInstanceFound = false; } } else { foundInstancePastEndDate = true; break; } if (maxInstancesExpanded > 0 && numInstancesExpanded >= maxInstancesExpanded) break; } // Detect invalid rule. If the rule was invalid the current iteration, which is for the current // frequency interval, would have found no matching instance. The next iteration will also find // no matching instance, and there is no need to keep iterating until we go past the hard end // time or COUNT/UNTIL limit. // // However, we have to make an exception for leap year. An yearly rule looking for February 29th // will find no instance in up to 3 consecutive years before finding Feb 29th in the fourth year. // // So the invalid rule detection must look for at least 4 consecutive failed iterations. if (curIsAtOrAfterEarliestDate) { if (noInstanceFound) numConsecutiveIterationsWithoutMatchingInstance++; else numConsecutiveIterationsWithoutMatchingInstance = 0; if (numConsecutiveIterationsWithoutMatchingInstance >= 4) { ZimbraLog.calendar.warn("Invalid recurrence rule: " + toString()); return toRet; } } pastHardEndTime = foundInstancePastEndDate || (noInstanceFound && curIsAfterEndDate); } return toRet; }
From source file:org.kuali.rice.kew.actionlist.web.ActionListAction.java
private boolean refreshList(HttpServletRequest request, String principalId) { List<Object> maxActionItemDateAssignedAndCount = KEWServiceLocator.getActionListService() .getMaxActionItemDateAssignedAndCountForUser(principalId); long count = (Long) maxActionItemDateAssignedAndCount.get(1); int previousCount = 0; Object actionItemCountFromSession = request.getSession().getAttribute(ACTION_ITEM_COUNT_FOR_USER_KEY); if (actionItemCountFromSession != null) { previousCount = Integer.parseInt(actionItemCountFromSession.toString()); }// ww w . ja v a 2 s. c om SimpleDateFormat dFormatter = new SimpleDateFormat(MAX_ACTION_ITEM_DATE_FORMAT); Date maxActionItemDateAssigned = (Date) maxActionItemDateAssignedAndCount.get(0); if (maxActionItemDateAssigned == null) { maxActionItemDateAssigned = new Date(0); } Date previousMaxActionItemDateAssigned = null; try { Object dateAttributeFromSession = request.getSession() .getAttribute(MAX_ACTION_ITEM_DATE_ASSIGNED_FOR_USER_KEY); if (dateAttributeFromSession != null) { previousMaxActionItemDateAssigned = dFormatter.parse(dateAttributeFromSession.toString()); } } catch (ParseException e) { LOG.warn(MAX_ACTION_ITEM_DATE_ASSIGNED_FOR_USER_KEY + " in session did not have expected date format. " + "Was: " + request.getSession().getAttribute(MAX_ACTION_ITEM_DATE_ASSIGNED_FOR_USER_KEY), e); } if (previousCount != count) { request.getSession().setAttribute(MAX_ACTION_ITEM_DATE_ASSIGNED_FOR_USER_KEY, dFormatter.format(maxActionItemDateAssigned)); request.getSession().setAttribute(ACTION_ITEM_COUNT_FOR_USER_KEY, count); return true; } else if (previousMaxActionItemDateAssigned == null || previousMaxActionItemDateAssigned.compareTo(maxActionItemDateAssigned) != 0) { request.getSession().setAttribute(MAX_ACTION_ITEM_DATE_ASSIGNED_FOR_USER_KEY, dFormatter.format(maxActionItemDateAssigned)); request.getSession().setAttribute(ACTION_ITEM_COUNT_FOR_USER_KEY, count); return true; } else { return false; } }
From source file:com.turborep.turbotracker.banking.controller.BankingController.java
@RequestMapping(value = "/saveTransactionDetails", method = RequestMethod.POST) public @ResponseBody Integer saveTransactionDetails( @RequestParam(value = "transactionDetails[]", required = false) ArrayList<?> theTransactionDetails, @RequestParam(value = "editamount", required = false) BigDecimal editamount, @RequestParam(value = "oldamount", required = false) BigDecimal oldamount, @RequestParam(value = "currentbalance", required = false) BigDecimal currentbalance, @RequestParam(value = "resultingbalance", required = false) BigDecimal resultingbalance, @RequestParam(value = "NewMoTypeId", required = false) String NewMoTypeId, @RequestParam(value = "coFiscalPeriodId", required = false) Integer periodID, @RequestParam(value = "coFiscalYearId", required = false) Integer yearID, @RequestParam(value = "gridData", required = false) String gridData, HttpSession session, HttpServletResponse theResponse, HttpServletRequest request) throws IOException, ParseException, BankingException, CompanyException, MessagingException { Motransaction aMotransaction = new Motransaction(); Byte aBigDecimal = 0;// w w w . ja v a 2 s . c o m boolean accountStatus = false; Byte printed = 0; Byte void_ = 0; Byte tempRec = 0; String aTypeID = ""; Date transdate = null; Date currdate = null; boolean futureornot = true; int motransiid = 0; String DepositType = "Single"; UserBean aUserBean; aUserBean = (UserBean) session.getAttribute(SessionConstants.USER); try { if (theTransactionDetails.get(0) != "" && theTransactionDetails.get(0) != null) { aMotransaction.setTransactionDate( DateUtils.parseDate((String) theTransactionDetails.get(0), new String[] { "MM/dd/yyyy" })); //transdate=DateUtils.parseDate( (String) theTransactionDetails.get(0), new String[]{"yyyy-MM-dd"}); Date myDate = new Date(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); String dateAsString_format = simpleDateFormat.format(myDate); if (myDate.compareTo(aMotransaction.getTransactionDate()) < 0 || myDate.compareTo(aMotransaction.getTransactionDate()) == 0) { //System.out.println("transdate date is greater than todate"); futureornot = false; } else { futureornot = true; //System.out.println("transdate date is lesser than todate"); } } if (theTransactionDetails.get(1) != "" && theTransactionDetails.get(1) != null) { aTypeID = theTransactionDetails.get(1).toString(); aMotransaction.setMoTransactionTypeId(Short.parseShort(aTypeID)); } if (theTransactionDetails.get(2) != "" && theTransactionDetails.get(2) != null) { aMotransaction.setReference((String) theTransactionDetails.get(2)); } if (theTransactionDetails.get(3) != "" && theTransactionDetails.get(3) != null) { String aDescription = theTransactionDetails.get(3).toString().replaceAll("\n", "").replaceAll("\t", ""); aMotransaction.setDescription(aDescription); } if (theTransactionDetails.get(4) != "" && theTransactionDetails.get(4) != null) { String aCoAccountID = theTransactionDetails.get(4).toString(); aMotransaction.setCoAccountId(Integer.parseInt(aCoAccountID)); System.out.println("===========>>=" + aCoAccountID); if (!aCoAccountID.equals("-1")) accountStatus = true; } if (theTransactionDetails.get(5) != "" && theTransactionDetails.get(5) != null) { String aReconcil = theTransactionDetails.get(5).toString(); aMotransaction.setReconciled(Byte.valueOf(aReconcil)); } if (theTransactionDetails.get(6) != "" && theTransactionDetails.get(6) != null) { String aAmount = ""; String theAmount = ""; if (theTransactionDetails.get(6).equals("0")) { aAmount = "0"; } else { if (aTypeID.equalsIgnoreCase("0")) { aAmount = theTransactionDetails.get(6).toString(); } else { aAmount = "-" + theTransactionDetails.get(6).toString(); } } BigDecimal aPrice = new BigDecimal(aAmount); aMotransaction.setAmount(aPrice); } if (theTransactionDetails.get(9) != "" && theTransactionDetails.get(9) != null) { String aMoAccountID = theTransactionDetails.get(9).toString(); aMotransaction.setMoAccountId(Integer.valueOf(aMoAccountID)); } String aOperation = theTransactionDetails.get(7).toString(); Motransaction mts = bankingAccountsService.getResultingBalance(aMotransaction.getMoAccountId()); currentbalance = mts.getCurrentbalance(); String aMemo = theTransactionDetails.get(11).toString(); String aRxMasterID = theTransactionDetails.get(12).toString(); String aRxAddressID = theTransactionDetails.get(13).toString(); aMotransaction.setDirectDeposit(aBigDecimal); aMotransaction.setPrinted(printed); aMotransaction.setVoid_(void_); aMotransaction.setTempRec(tempRec); System.out.println("aOperation---" + aMotransaction.getMoAccountId() + "--->" + aOperation); //aMotransaction.setBalance(currentbalance); MoAccount moAccount = new MoAccount(); moAccount.setMoAccountId(aMotransaction.getMoAccountId()); moAccount.setOper(aOperation); /** * Created By :Leo Description:New Check Creation * * Date:28-10-2014 * * */ /*---------------------------New Check----------------------*/ if (aOperation.equalsIgnoreCase("new")) { moAccount.setMoTransactionTypeId(aMotransaction.getMoTransactionTypeId()); BigDecimal balance = new BigDecimal("0.00"); if (aMotransaction.getMoTransactionTypeId() == 0) { moAccount.setAdditions(aMotransaction.getAmount()); //Commented by: Leo purpose:BID#1326 /*if(futureornot){ balance=currentbalance.add(aMotransaction.getAmount()); }else{ balance=currentbalance; }*/ balance = currentbalance.add(aMotransaction.getAmount()); } else { moAccount.setSubtractions(aMotransaction.getAmount()); /*if(futureornot){ balance=currentbalance.add(aMotransaction.getAmount()); }else{ balance=currentbalance; }*/ balance = currentbalance.add(aMotransaction.getAmount()); } aMotransaction.setMemo(aMemo); aMotransaction.setRxMasterId(Integer.parseInt(aRxMasterID)); if (aRxAddressID != "" && aRxAddressID != null) aMotransaction.setRxAddressId( bankingAccountsService.getRxAddressIDfmRxmasterID(Integer.parseInt(aRxMasterID))); motransiid = bankingAccountsService.createtransactionBanknewCheck(moAccount, aMotransaction, DepositType, yearID, periodID, aUserBean.getFullName(), balance, accountStatus, motransiid, aOperation, "", false, null, null, "", null, "", ""); } /*---------------------------New Transaction----------------------*/ else if (aOperation.equalsIgnoreCase("add")) { moAccount.setMoTransactionTypeId(aMotransaction.getMoTransactionTypeId()); BigDecimal balance = new BigDecimal("0.00"); if (aMotransaction.getMoTransactionTypeId() == 0) { moAccount.setAdditions(aMotransaction.getAmount()); /*if(futureornot){ balance=currentbalance.add(aMotransaction.getAmount()); }else{ balance=currentbalance; }*/ balance = currentbalance.add(aMotransaction.getAmount()); } else { moAccount.setSubtractions(aMotransaction.getAmount()); /*if(futureornot){ balance=currentbalance.add(aMotransaction.getAmount()); }else{ balance=currentbalance; }*/ balance = currentbalance.add(aMotransaction.getAmount()); } motransiid = bankingAccountsService.createtransactionBanknewCheck(moAccount, aMotransaction, DepositType, yearID, periodID, aUserBean.getFullName(), balance, accountStatus, motransiid, aOperation, gridData, false, null, null, "", null, "", ""); } /*---------------------------Edit Transaction----------------------*/ else if (aOperation.equalsIgnoreCase("edit")) { Motransaction M1 = new Motransaction(); M1 = aMotransaction; boolean motransaceditStatus = false; BigDecimal balance = new BigDecimal("0.00"); short transtypid = M1.getMoTransactionTypeId(); BigDecimal amt = M1.getAmount(); moAccount.setMoTransactionTypeId(M1.getMoTransactionTypeId()); if (theTransactionDetails.get(8) != "" && theTransactionDetails.get(8) != null) { String aTransID = theTransactionDetails.get(8).toString(); M1.setMoTransactionId(Integer.valueOf(aTransID)); } M1.setStatus(true); Motransaction checkforTestMotrans = new Motransaction(); checkforTestMotrans = bankingAccountsService .getMOtransactionDetails(aMotransaction.getMoTransactionId()); if (checkforTestMotrans != null) { if (!(M1.getMoTransactionTypeId().equals(checkforTestMotrans.getMoTransactionTypeId()))) { motransaceditStatus = true; } else if (!M1.getTransactionDate().equals(checkforTestMotrans.getTransactionDate())) { motransaceditStatus = true; } else if (!(M1.getReference() == null ? "" : M1.getReference()) .equals(checkforTestMotrans.getReference())) { motransaceditStatus = true; } else if (!(M1.getDescription() == null ? "" : M1.getDescription()) .equals(checkforTestMotrans.getDescription())) { motransaceditStatus = true; } else if (!M1.getReconciled().equals(checkforTestMotrans.getReconciled())) { motransaceditStatus = true; } else if (!M1.getAmount().equals(checkforTestMotrans.getAmount())) { motransaceditStatus = true; } else if (!M1.getCoAccountId().equals(checkforTestMotrans.getCoAccountId())) { motransaceditStatus = true; } } motransiid = bankingAccountsService.createtransactionBanknewCheck(moAccount, M1, DepositType, yearID, periodID, aUserBean.getFullName(), balance, accountStatus, motransiid, aOperation, gridData, futureornot, currentbalance, oldamount, NewMoTypeId, amt, aMemo, aRxMasterID); } /*---------------------------Delete Transaction----------------------*/ else if (aOperation.equalsIgnoreCase("delete")) { Motransaction dM1 = new Motransaction(); dM1 = aMotransaction; if (theTransactionDetails.get(8) != "" && theTransactionDetails.get(8) != null) { String aTransID = theTransactionDetails.get(8).toString(); dM1.setMoTransactionId(Integer.valueOf(aTransID)); } if (aRxMasterID != "" && aRxMasterID != null) dM1.setRxMasterId(Integer.parseInt(aRxMasterID)); if (aRxAddressID != "" && aRxAddressID != null) dM1.setRxAddressId(Integer.parseInt(aRxAddressID)); moAccount.setMoAccountId(dM1.getMoAccountId()); moAccount.setMoTransactionTypeId(dM1.getMoTransactionTypeId()); dM1.setStatus(true); bankingAccountsService.createtransactionBanknewCheck(moAccount, dM1, DepositType, yearID, periodID, aUserBean.getFullName(), BigDecimal.ZERO, accountStatus, motransiid, aOperation, "", futureornot, currentbalance, null, "", null, "", ""); } else if (aOperation.equalsIgnoreCase("void")) { Motransaction vM1 = new Motransaction(); vM1 = aMotransaction; if (theTransactionDetails.get(8) != "" && theTransactionDetails.get(8) != null) { String aTransID = theTransactionDetails.get(8).toString(); vM1.setMoTransactionId(Integer.valueOf(aTransID)); } if (theTransactionDetails.get(10) != "" && theTransactionDetails.get(10) != null) { String aVoid = theTransactionDetails.get(10).toString(); vM1.setVoid_(Byte.valueOf(aVoid)); } if (aRxMasterID != "" && aRxMasterID != null) vM1.setRxMasterId(Integer.parseInt(aRxMasterID)); if (aRxAddressID != "" && aRxAddressID != null) vM1.setRxAddressId(Integer.parseInt(aRxAddressID)); vM1.setStatus(true); moAccount.setMoAccountId(vM1.getMoAccountId()); moAccount.setMoTransactionTypeId(vM1.getMoTransactionTypeId()); bankingAccountsService.createtransactionBanknewCheck(moAccount, vM1, DepositType, yearID, periodID, aUserBean.getFullName(), BigDecimal.ZERO, accountStatus, motransiid, aOperation, "", futureornot, currentbalance, null, "", null, "", ""); } } catch (BankingException e) { logger.error(e.getMessage(), e); theResponse.sendError(e.getItsErrorStatusCode(), e.getMessage()); sendTransactionException("<b>MoTransactionID:</b>" + aMotransaction.getMoTransactionId() + "<br><b>RxMasterID:</b>" + aMotransaction.getRxMasterId(), "Banking.", e, session, request); } return motransiid; }
From source file:oscar.dms.actions.DmsInboxManageAction.java
public ActionForward prepareForContentPage(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {//from ww w . j a v a2s.c o m HttpSession session = request.getSession(); try { if (session.getAttribute("userrole") == null) response.sendRedirect("../logout.jsp"); } catch (Exception e) { logger.error("Error", e); } // can't use userrole from session, because it changes if provider A search for provider B's documents // oscar.oscarMDS.data.MDSResultsData mDSData = new oscar.oscarMDS.data.MDSResultsData(); CommonLabResultData comLab = new CommonLabResultData(); // String providerNo = request.getParameter("providerNo"); String providerNo = (String) session.getAttribute("user"); String searchProviderNo = request.getParameter("searchProviderNo"); String ackStatus = request.getParameter("status"); String demographicNo = request.getParameter("demographicNo"); // used when searching for labs by patient instead of provider String scannedDocStatus = request.getParameter("scannedDocument"); Integer page = 0; try { page = Integer.parseInt(request.getParameter("page")); if (page > 0) { page--; } } catch (NumberFormatException nfe) { page = 0; } Integer pageSize = 20; try { String tmp = request.getParameter("pageSize"); pageSize = Integer.parseInt(tmp); } catch (NumberFormatException nfe) { pageSize = 20; } scannedDocStatus = "I"; String startDateStr = request.getParameter("startDate"); String endDateStr = request.getParameter("endDate"); String view = request.getParameter("view"); if (view == null || "".equals(view)) { view = "all"; } boolean mixLabsAndDocs = "normal".equals(view) || "all".equals(view); Date startDate = null; Date endDate = null; try { if (startDateStr != null && startDateStr.length() > 0) { startDateStr = startDateStr.trim(); startDate = UtilDateUtilities.StringToDate(startDateStr); } if (endDateStr != null && endDateStr.length() > 0) { endDateStr = endDateStr.trim(); endDate = UtilDateUtilities.StringToDate(endDateStr); } } catch (Exception e) { startDate = null; endDate = null; } Boolean isAbnormal = null; if ("abnormal".equals(view)) isAbnormal = new Boolean(true); if ("normal".equals(view)) isAbnormal = new Boolean(false); if (ackStatus == null) { ackStatus = "N"; } // default to new labs only if (providerNo == null) { providerNo = ""; } if (searchProviderNo == null) { searchProviderNo = providerNo; } String roleName = ""; List<SecUserRole> roles = secUserRoleDao.getUserRoles(searchProviderNo); for (SecUserRole r : roles) { if (r != null) { if (roleName.length() == 0) { roleName = r.getRoleName(); } else { roleName += "," + r.getRoleName(); } } } roleName += "," + searchProviderNo; // mDSData.populateMDSResultsData2(searchProviderNo, demographicNo, request.getParameter("fname"), request.getParameter("lname"), request.getParameter("hnum"), ackStatus); // HashMap<String,String> docQueue=comLab.getDocumentQueueLinks(); List<QueueDocumentLink> qd = queueDocumentLinkDAO.getQueueDocLinks(); HashMap<String, String> docQueue = new HashMap(); for (QueueDocumentLink qdl : qd) { Integer i = qdl.getDocId(); Integer n = qdl.getQueueId(); docQueue.put(i.toString(), n.toString()); } InboxResultsDao inboxResultsDao = (InboxResultsDao) SpringUtils.getBean("inboxResultsDao"); String patientFirstName = request.getParameter("fname"); String patientLastName = request.getParameter("lname"); String patientHealthNumber = request.getParameter("hnum"); ArrayList<LabResultData> labdocs = new ArrayList<LabResultData>(); if (!"labs".equals(view) && !"abnormal".equals(view)) { labdocs = inboxResultsDao.populateDocumentResultsData(searchProviderNo, demographicNo, patientFirstName, patientLastName, patientHealthNumber, ackStatus, true, page, pageSize, mixLabsAndDocs, isAbnormal); } if (!"documents".equals(view)) { labdocs.addAll(comLab.populateLabResultsData(searchProviderNo, demographicNo, patientFirstName, patientLastName, patientHealthNumber, ackStatus, scannedDocStatus, true, page, pageSize, mixLabsAndDocs, isAbnormal)); } labdocs = (ArrayList<LabResultData>) filterLabDocsForSuperSite(labdocs, providerNo); ArrayList<LabResultData> validlabdocs = new ArrayList<LabResultData>(); DocumentResultsDao documentResultsDao = (DocumentResultsDao) SpringUtils.getBean("documentResultsDao"); // check privilege for documents only for (LabResultData data : labdocs) { if (data.isDocument()) { String docid = data.getSegmentID(); String queueid = docQueue.get(docid); if (queueid != null) { queueid = queueid.trim(); int queueIdInt = Integer.parseInt(queueid); // if doc sent to default queue and no valid provider, do NOT include it if (queueIdInt == Queue.DEFAULT_QUEUE_ID && !documentResultsDao.isSentToValidProvider(docid) && isSegmentIDUnique(validlabdocs, data)) { // validlabdocs.add(data); } // if doc sent to default queue && valid provider, check if it's sent to this provider, if yes include it else if (queueIdInt == Queue.DEFAULT_QUEUE_ID && documentResultsDao.isSentToValidProvider(docid) && documentResultsDao.isSentToProvider(docid, searchProviderNo) && isSegmentIDUnique(validlabdocs, data)) { validlabdocs.add(data); } // if doc setn to non-default queue and valid provider, check if provider is in the queue or equal to the provider else if (queueIdInt != Queue.DEFAULT_QUEUE_ID && documentResultsDao.isSentToValidProvider(docid)) { Vector vec = OscarRoleObjectPrivilege.getPrivilegeProp("_queue." + queueid); if (OscarRoleObjectPrivilege.checkPrivilege(roleName, (Properties) vec.get(0), (Vector) vec.get(1)) || documentResultsDao.isSentToProvider(docid, searchProviderNo)) { // labs is in provider's queue,do nothing if (isSegmentIDUnique(validlabdocs, data)) { validlabdocs.add(data); } } } // if doc sent to non default queue and no valid provider, check if provider is in the non default queue else if (!queueid.equals(Queue.DEFAULT_QUEUE_ID) && !documentResultsDao.isSentToValidProvider(docid)) { Vector vec = OscarRoleObjectPrivilege.getPrivilegeProp("_queue." + queueid); if (OscarRoleObjectPrivilege.checkPrivilege(roleName, (Properties) vec.get(0), (Vector) vec.get(1))) { // labs is in provider's queue,do nothing if (isSegmentIDUnique(validlabdocs, data)) { validlabdocs.add(data); } } } } } else {// add lab if (isSegmentIDUnique(validlabdocs, data)) { validlabdocs.add(data); } } } // Find the oldest lab returned in labdocs, use that as the limit date for the HRM query Date oldestLab = null; Date newestLab = null; if (request.getParameter("newestDate") != null) { try { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); newestLab = formatter.parse(request.getParameter("newestDate")); } catch (Exception e) { logger.error("Couldn't parse date + " + request.getParameter("newestDate"), e); } } for (LabResultData result : labdocs) { if (result != null && result.getDateObj() != null) { if (oldestLab == null || oldestLab.compareTo(result.getDateObj()) > 0) oldestLab = result.getDateObj(); if (request.getParameter("newestDate") != null && (newestLab == null || newestLab.compareTo(result.getDateObj()) < 0)) newestLab = result.getDateObj(); } } HRMResultsData hrmResult = new HRMResultsData(); Collection<LabResultData> hrmDocuments = hrmResult.populateHRMdocumentsResultsData(searchProviderNo, ackStatus, newestLab, oldestLab); if (oldestLab == null) { for (LabResultData hrmDocument : hrmDocuments) { if (oldestLab == null || (hrmDocument.getDateObj() != null && oldestLab.compareTo(hrmDocument.getDateObj()) > 0)) oldestLab = hrmDocument.getDateObj(); } } //labdocs is already filtered for super site access.. not just filter hrmDocuments hrmDocuments = filterLabDocsForSuperSite(hrmDocuments, providerNo); labdocs.addAll(hrmDocuments); Collections.sort(labdocs); HashMap<String, LabResultData> labMap = new HashMap<String, LabResultData>(); LinkedHashMap<String, ArrayList<String>> accessionMap = new LinkedHashMap<String, ArrayList<String>>(); int accessionNumCount = 0; for (LabResultData result : labdocs) { if (startDate != null && startDate.after(result.getDateObj())) { continue; } if (endDate != null && endDate.before(result.getDateObj())) { continue; } String segmentId = result.getSegmentID(); if (result.isDocument()) segmentId += "d"; else if (result.isHRM()) segmentId += "h"; labMap.put(segmentId, result); ArrayList<String> labNums = new ArrayList<String>(); if (result.accessionNumber == null || result.accessionNumber.equals("")) { labNums.add(segmentId); accessionNumCount++; accessionMap.put("noAccessionNum" + accessionNumCount + result.labType, labNums); } else if (!accessionMap.containsKey(result.accessionNumber + result.labType)) { labNums.add(segmentId); accessionMap.put(result.accessionNumber + result.labType, labNums); // Different MDS Labs may have the same accession Number if they are seperated // by two years. So accession numbers are limited to matching only if their // labs are within one year of eachother } else { labNums = accessionMap.get(result.accessionNumber + result.labType); boolean matchFlag = false; for (int j = 0; j < labNums.size(); j++) { LabResultData matchingResult = labMap.get(labNums.get(j)); Date dateA = result.getDateObj(); Date dateB = matchingResult.getDateObj(); int monthsBetween = 0; if (dateA == null || dateB == null) { monthsBetween = 5; } else if (dateA.before(dateB)) { monthsBetween = UtilDateUtilities.getNumMonths(dateA, dateB); } else { monthsBetween = UtilDateUtilities.getNumMonths(dateB, dateA); } if (monthsBetween < 4) { matchFlag = true; break; } } if (!matchFlag) { labNums.add(segmentId); accessionMap.put(result.accessionNumber + result.labType, labNums); } } } labdocs.clear(); for (ArrayList<String> labNums : accessionMap.values()) { // must sort through in reverse to keep the labs in the correct order for (int j = labNums.size() - 1; j >= 0; j--) { labdocs.add(labMap.get(labNums.get(j))); } } logger.debug("labdocs.size()=" + labdocs.size()); /* find all data for the index.jsp page */ Hashtable patientDocs = new Hashtable(); Hashtable patientIdNames = new Hashtable(); String patientIdNamesStr = ""; Hashtable docStatus = new Hashtable(); Hashtable docType = new Hashtable(); Hashtable<String, List<String>> ab_NormalDoc = new Hashtable(); for (int i = 0; i < labdocs.size(); i++) { LabResultData data = labdocs.get(i); List<String> segIDs = new ArrayList<String>(); String labPatientId = data.getLabPatientId(); if (labPatientId == null || labPatientId.equals("-1")) labPatientId = "-1"; if (data.isAbnormal()) { List<String> abns = ab_NormalDoc.get("abnormal"); if (abns == null) { abns = new ArrayList<String>(); abns.add(data.getSegmentID()); } else { abns.add(data.getSegmentID()); } ab_NormalDoc.put("abnormal", abns); } else { List<String> ns = ab_NormalDoc.get("normal"); if (ns == null) { ns = new ArrayList<String>(); ns.add(data.getSegmentID()); } else { ns.add(data.getSegmentID()); } ab_NormalDoc.put("normal", ns); } if (patientDocs.containsKey(labPatientId)) { segIDs = (List) patientDocs.get(labPatientId); segIDs.add(data.getSegmentID()); patientDocs.put(labPatientId, segIDs); } else { segIDs.add(data.getSegmentID()); patientDocs.put(labPatientId, segIDs); patientIdNames.put(labPatientId, data.patientName); patientIdNamesStr += ";" + labPatientId + "=" + data.patientName; } docStatus.put(data.getSegmentID(), data.getAcknowledgedStatus()); docType.put(data.getSegmentID(), data.labType); } Integer totalDocs = 0; Integer totalHL7 = 0; Hashtable<String, List<String>> typeDocLab = new Hashtable(); Enumeration keys = docType.keys(); while (keys.hasMoreElements()) { String keyDocLabId = ((String) keys.nextElement()); String valType = (String) docType.get(keyDocLabId); if (valType.equalsIgnoreCase("DOC")) { if (typeDocLab.containsKey("DOC")) { List<String> docids = typeDocLab.get("DOC"); docids.add(keyDocLabId);// add doc id to list typeDocLab.put("DOC", docids); } else { List<String> docids = new ArrayList<String>(); docids.add(keyDocLabId); typeDocLab.put("DOC", docids); } totalDocs++; } else if (valType.equalsIgnoreCase("HL7")) { if (typeDocLab.containsKey("HL7")) { List<String> hl7ids = typeDocLab.get("HL7"); hl7ids.add(keyDocLabId); typeDocLab.put("HL7", hl7ids); } else { List<String> hl7ids = new ArrayList<String>(); hl7ids.add(keyDocLabId); typeDocLab.put("HL7", hl7ids); } totalHL7++; } } Hashtable patientNumDoc = new Hashtable(); Enumeration patientIds = patientDocs.keys(); String patientIdStr = ""; Integer totalNumDocs = 0; while (patientIds.hasMoreElements()) { String key = (String) patientIds.nextElement(); patientIdStr += key; patientIdStr += ","; List<String> val = (List<String>) patientDocs.get(key); Integer numDoc = val.size(); patientNumDoc.put(key, numDoc); totalNumDocs += numDoc; } List<String> normals = ab_NormalDoc.get("normal"); List<String> abnormals = ab_NormalDoc.get("abnormal"); logger.debug("labdocs.size()=" + labdocs.size()); // set attributes request.setAttribute("pageNum", page); request.setAttribute("docType", docType); request.setAttribute("patientDocs", patientDocs); request.setAttribute("providerNo", providerNo); request.setAttribute("searchProviderNo", searchProviderNo); request.setAttribute("patientIdNames", patientIdNames); request.setAttribute("docStatus", docStatus); request.setAttribute("patientIdStr", patientIdStr); request.setAttribute("typeDocLab", typeDocLab); request.setAttribute("demographicNo", demographicNo); request.setAttribute("ackStatus", ackStatus); request.setAttribute("labdocs", labdocs); request.setAttribute("patientNumDoc", patientNumDoc); request.setAttribute("totalDocs", totalDocs); request.setAttribute("totalHL7", totalHL7); request.setAttribute("normals", normals); request.setAttribute("abnormals", abnormals); request.setAttribute("totalNumDocs", totalNumDocs); request.setAttribute("patientIdNamesStr", patientIdNamesStr); request.setAttribute("oldestLab", oldestLab != null ? DateUtils.formatDate(oldestLab, "yyyy-MM-dd HH:mm:ss") : null); return mapping.findForward("dms_page"); }
From source file:org.kuali.student.enrollment.class2.acal.service.impl.AcademicCalendarViewHelperServiceImpl.java
protected boolean doDatesOverlap(Date periodStartDate, Date periodEndDate, Date subStart, Date subEnd) { boolean bRet = false; int compStart = subStart.compareTo(periodEndDate); int compEnd = subEnd.compareTo(periodStartDate); if (compStart <= 0 && compEnd >= 0) { bRet = true;// ww w . ja va2 s . co m } return bRet; }
From source file:org.kuali.ole.select.document.OleReceivingQueueSearchDocument.java
public void valueSearch() throws Exception { String[] purchaseOrderNumbers = {}; Collection results = new ArrayList<OlePurchaseOrderItem>(); Map purapDocumentIdentifierMap = new HashMap(); if (this.purchaseOrderNumber != null) { purchaseOrderNumbers = (this.purchaseOrderNumber.toString()).split(","); for (int i = 0; i < purchaseOrderNumbers.length; i++) { // TODO Auto-generated method stub List<String> poDocNumbers = new ArrayList<String>(); LOG.debug(" OleReceivingQueueSearchDocument.valueSearch method starts "); purapDocumentIdentifierMap = new HashMap(); if (purchaseOrderNumbers[i] != null) { purapDocumentIdentifierMap.put("purchaseOrder.purapDocumentIdentifier", purchaseOrderNumbers[i]); }// w w w . j a v a 2 s . co m if (this.vendorName != null) { purapDocumentIdentifierMap.put("purchaseOrder.vendorName", this.vendorName); } if (this.title != null) { purapDocumentIdentifierMap.put("docData.title", this.title); } if (this.standardNumber != null) { purapDocumentIdentifierMap.put("docData.isbn", this.standardNumber); } results.addAll(SpringContext.getBean(OleDocStoreLookupService.class) .findCollectionBySearch(OlePurchaseOrderItem.class, purapDocumentIdentifierMap)); } } else { purapDocumentIdentifierMap = new HashMap(); if (this.purchaseOrderNumber != null) { purapDocumentIdentifierMap.put("purchaseOrder.purapDocumentIdentifier", this.purchaseOrderNumber); } if (this.vendorName != null) { purapDocumentIdentifierMap.put("purchaseOrder.vendorName", this.vendorName); } if (this.title != null) { purapDocumentIdentifierMap.put("docData.title", this.title); } if (this.standardNumber != null) { purapDocumentIdentifierMap.put("docData.isbn", this.standardNumber); } results.addAll(SpringContext.getBean(OleDocStoreLookupService.class) .findCollectionBySearch(OlePurchaseOrderItem.class, purapDocumentIdentifierMap)); } //results from docstore // Collection results = SpringContext.getBean(OleDocStoreLookupService.class).findCollectionBySearch(OlePurchaseOrderItem.class, purapDocumentIdentifierMap); boolean isbeginEndDateExsist = false; boolean isEndDateSmallerThanBeginDate = false; List<OlePurchaseOrderItem> tempResult = (List<OlePurchaseOrderItem>) results; List<String> docNumberList = new ArrayList<String>(); //This code executes if begin date and end date is not null and checks whether enddate is greatter than begin date if (this.beginDate != null && this.endDate != null) { DateFormat formatter = new SimpleDateFormat("MM/dd/yyyy"); Date startDate = formatter.parse(this.beginDate); Date endDate = formatter.parse(this.endDate); if (startDate.compareTo(endDate) > 0) { isEndDateSmallerThanBeginDate = true; GlobalVariables.getMessageMap().putError(OleSelectConstant.RECEIVING_QUEUE_SEARCH, OLEKeyConstants.PUR_ORD_DATE_TO_NOT_LESSER_THAN_PUR_ORD_DATE_FROM, new String[] {}); } } //if enddate is greater than begin date this code will not execute /*if((this.beginDate!=null || this.endDate!=null) && !isEndDateSmallerThanBeginDate) { docNumberList= filterOtherSearchCriteria(); isbeginEndDateExsist = true; }*/ if (!isEndDateSmallerThanBeginDate) { if ((this.beginDate != null || this.endDate != null)) { docNumberList = filterOtherSearchCriteria(); isbeginEndDateExsist = true; } for (int i = 0; i < tempResult.size(); i++) { int purAppNum = tempResult.get(i).getPurchaseOrder().getPurapDocumentIdentifier(); String docNumber = tempResult.get(i).getPurchaseOrder().getDocumentNumber(); // int itemLineNumber = tempResult.get(i).getItemLineNumber(); boolean isValidRecord = validateRecords(purAppNum, docNumber); boolean isSpecHandlingNotesExist = false; /* * if(isValidRecord) { isValidRecord = checkForReceivingLineItem(purAppNum,itemLineNumber); } */ if (isValidRecord) { isValidRecord = validateCopiesAndParts(tempResult.get(i)); } if (tempResult.get(i).getNotes() != null) { isSpecHandlingNotesExist = checkSpecialHandlingNotesExsist(tempResult.get(i)); } if (this.purchaseOrderType != null && isValidRecord) { isValidRecord = validatePurchaseOrderStatus(this.purchaseOrderType, purAppNum); } if (isbeginEndDateExsist) { if (!docNumberList.contains(docNumber)) { isValidRecord = false; } } boolean isRetiredVersionPo = !(validatePoByRetiredVersionStatus( (OlePurchaseOrderItem) tempResult.get(i))); OlePurchaseOrderItem olePurchaseOrderItem = tempResult.get(i); if (!isValidRecord || isRetiredVersionPo || isSpecHandlingNotesExist) { tempResult.remove(i); i--; } } if (tempResult.size() <= 0) { if (!GlobalVariables.getMessageMap().hasInfo()) { GlobalVariables.getMessageMap().putInfo(OleSelectConstant.RECEIVING_QUEUE_SEARCH, OLEKeyConstants.ERROR_NO_PURCHASEORDERS_FOUND); } } this.setPurchaseOrders(removeReceivedTitles(tempResult)); if (this.getPurchaseOrders().size() > 0) { GlobalVariables.clear(); } } LOG.debug(" OleReceivingQueueSearchDocument.valueSearch method ends "); }
From source file:org.kuali.kfs.vnd.document.validation.impl.VendorRule.java
protected boolean validateW8SignedDate(VendorDetail vDetail) { boolean valid = true; if (ObjectUtils.isNotNull(vDetail.getVendorHeader().getVendorW8BenReceivedIndicator()) && vDetail.getVendorHeader().getVendorW8BenReceivedIndicator()) { if (SpringContext.getBean(ParameterService.class).getParameterValueAsBoolean(VendorDetail.class, VendorParameterConstants.W8_DATA_REQUIRED_IND)) { DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class); Date today = dateTimeService.getCurrentDate(); if (ObjectUtils.isNotNull(vDetail.getVendorHeader().getVendorW8SignedDate())) { Date signedDate = vDetail.getVendorHeader().getVendorW8SignedDate(); if (today.compareTo(signedDate) <= 0) { putFieldError(VendorPropertyConstants.VENDOR_W8SIGNED_DATE, VendorKeyConstants.ERROR_VENDOR_W8ANDW9_SIGNED_AFTER_TODAY); valid &= false;//from ww w .j a v a 2 s . co m } } else { putFieldError(VendorPropertyConstants.VENDOR_W8SIGNED_DATE, VendorKeyConstants.ERROR_VENDOR_W8SINGED_DATE_REQUIRED); valid &= false; } } } return valid; }
From source file:org.kuali.kfs.vnd.document.validation.impl.VendorRule.java
protected boolean validateW9SignedDate(VendorDetail vDetail) { boolean valid = true; if (ObjectUtils.isNotNull(vDetail.getVendorHeader().getVendorW9ReceivedIndicator()) && vDetail.getVendorHeader().getVendorW9ReceivedIndicator()) { if (SpringContext.getBean(ParameterService.class).getParameterValueAsBoolean(VendorDetail.class, VendorParameterConstants.W9_SIGNED_DATE_REQUIRED) && ObjectUtils.isNotNull(vDetail.getVendorHeader().getVendorW9ReceivedIndicator())) { DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class); Date today = dateTimeService.getCurrentDate(); if (ObjectUtils.isNotNull(vDetail.getVendorHeader().getVendorW9SignedDate())) { Date signedDate = vDetail.getVendorHeader().getVendorW9SignedDate(); if (today.compareTo(signedDate) <= 0) { putFieldError(VendorPropertyConstants.VENDOR_W9SIGNED_DATE, VendorKeyConstants.ERROR_VENDOR_W8ANDW9_SIGNED_AFTER_TODAY); valid &= false;/*w ww. j a va2s . com*/ } } else { putFieldError(VendorPropertyConstants.VENDOR_W9SIGNED_DATE, VendorKeyConstants.ERROR_VENDOR_W9SINGED_DATE_REQUIRED); valid &= false; } } } return valid; }