List of usage examples for org.joda.time LocalDate isAfter
public boolean isAfter(ReadablePartial partial)
From source file:Reporte.ReporteCajaList.java
/** * Processes requests for both HTTP//from w w w . j a v a 2s. co m * <code>GET</code> and * <code>POST</code> methods. * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("application/json;charset=UTF-8"); PrintWriter out = response.getWriter(); JsonRespuesta jr = new JsonRespuesta(); try { Integer id_caja = Parser.parseInt(request.getParameter("id_caja")); Integer id_estado = Parser.parseInt(request.getParameter("id_estado")); Integer id_forma = Parser.parseInt(request.getParameter("id_forma")); Integer id_usuario = Parser.parseInt(request.getParameter("id_usuario")); String fecha_desde = TFecha.formatearFechaVistaBd(request.getParameter("fecha_desde")); String fecha_hasta = TFecha.formatearFechaVistaBd(request.getParameter("fecha_hasta")); HttpSession session = request.getSession(); Integer id_usuario_actual = (Integer) session.getAttribute("id_usuario"); Integer id_tipo_usuario_actual = (Integer) session.getAttribute("id_tipo_usuario"); //Si es un usuario distinto de Administrador, solo se muestran las cajas del usuario actual if (!id_tipo_usuario_actual.equals(OptionsCfg.USUARIO_ADMINISTRADOR)) id_usuario = id_usuario_actual; mapFormaPago = OptionsCfg.getMap(OptionsCfg.getFormaPago()); mapMovimiento = OptionsCfg.getMap(OptionsCfg.getTipoMovimiento()); mapEstadosCaja = OptionsCfg.getMap(OptionsCfg.getEstadosCaja()); TCaja tc = new TCaja(); TCaja_detalle tcd = new TCaja_detalle(); HashMap<String, String> mapFiltro = new HashMap<String, String>(); HashMap<String, String> mapFiltroCaja = new HashMap<String, String>(); tc.setOrderBy(" fecha desc "); if (id_estado != 0) mapFiltroCaja.put("id_estado", id_estado.toString()); if (id_usuario != 0) mapFiltroCaja.put("id_usuario", id_usuario.toString()); List<Caja> lstCajas = tc.getListFiltro(mapFiltroCaja); ArrayList<CajaDet> listaDet = new ArrayList<CajaDet>(); LocalDate desde = null; LocalDate hasta = null; if (fecha_desde != null && !fecha_desde.equals("")) desde = new LocalDate(fecha_desde); if (fecha_hasta != null && !fecha_hasta.equals("")) hasta = new LocalDate(fecha_hasta); for (Caja caja : lstCajas) { CajaDet cd = new CajaDet(caja); LocalDate fecha = new LocalDate(caja.getFecha().getFecha()); if (desde != null && fecha.isBefore(desde)) continue; if (hasta != null && fecha.isAfter(hasta)) continue; mapFiltro.put("id_caja", caja.getId().toString()); if (id_forma != 0) mapFiltro.put("id_forma", id_forma.toString()); List<Caja_detalle> listFiltro = tcd.getListFiltro(mapFiltro); if (listFiltro == null) throw new BaseException("ERROR", "Ocurrió un error al listar los movimientos de caja"); ArrayList<CajaDetalleDet> listaCajaDet = new ArrayList<CajaDetalleDet>(); Float saldo = 0f; Float saldo_efectivo = 0f; Float saldo_cheque = 0f; Float saldo_transf = 0f; for (Caja_detalle detalle : listFiltro) { if (detalle.getConcepto().startsWith("Apertura ")) continue; if (detalle.getConcepto().startsWith("Diferencia ")) continue; float importe = detalle.getId_tipo() == OptionsCfg.TIPO_INGRESO ? detalle.getImporte() : -1 * detalle.getImporte(); saldo += importe; switch (detalle.getId_forma()) { case OptionsCfg.FORMA_EFECTIVO: saldo_efectivo += importe; case OptionsCfg.FORMA_CHEQUE: saldo_cheque += importe; case OptionsCfg.FORMA_TRANSFERENCIA: saldo_transf += importe; } detalle.setSaldo(saldo); listaCajaDet.add(new CajaDetalleDet(detalle)); } cd.setEfectivo_cierre(saldo_efectivo); cd.setCheque_cierre(saldo_cheque); cd.setTransferencia_cierre(saldo_transf); //if(listaCajaDet.size()>0) { cd.detalle = listaCajaDet; listaDet.add(cd); //} } jr.setResult("OK"); jr.setRecordCount(listaDet.size()); jr.setRecords(listaDet); } catch (BaseException ex) { jr.setResult(ex.getResult()); jr.setMessage(ex.getMessage()); } finally { out.print(new Gson().toJson(jr)); out.close(); } }
From source file:Reporte.ReporteComisionVendedorList.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./* w ww . ja va2 s . c om*/ * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("application/json;charset=UTF-8"); PrintWriter out = response.getWriter(); String pagNro = request.getParameter("pagNro"); String codigo = request.getParameter("codigo"); Integer id_cliente = Parser.parseInt(request.getParameter("id_cliente")); Integer id_propiedad = Parser.parseInt(request.getParameter("id_propiedad")); Integer id_tipo = Parser.parseInt(request.getParameter("id_tipo")); String fecha_desde = TFecha.formatearFechaVistaBd(request.getParameter("fecha_desde")); String fecha_hasta = TFecha.formatearFechaVistaBd(request.getParameter("fecha_hasta")); Integer page = Parser.parseInt(pagNro); LocalDate desde = null; LocalDate hasta = null; try { JsonRespuesta jr = new JsonRespuesta(); List<Contrato> lista; mapPropietarios = new TPropietario().getMap(); mapInquilinos = new TInquilino().getMap(); mapPropiedades = new TPropiedad().getMap(); mapVendedor = new TVendedor().getMap(); mapEstados = OptionsCfg.getMap(OptionsCfg.getEstadosContrato()); TContrato tp = new TContrato(); HashMap<String, String> mapFiltro = new HashMap<String, String>(); if (id_cliente != 0) { if (id_tipo.equals(OptionsCfg.CLIENTE_TIPO_PROPIETARIO)) mapFiltro.put("id_propietario", id_cliente.toString()); else if (id_tipo.equals(OptionsCfg.CLIENTE_TIPO_INQUILINO)) mapFiltro.put("id_inquilino", id_cliente.toString()); } if (id_propiedad != 0) mapFiltro.put("id_propiedad", id_propiedad.toString()); lista = tp.getListFiltro(mapFiltro); //lista = tp.getList(); if (fecha_desde != null && !fecha_desde.equals("")) desde = new LocalDate(fecha_desde); if (fecha_hasta != null && !fecha_hasta.equals("")) hasta = new LocalDate(fecha_hasta); if (lista != null) { List<Contrato> listaDet = new ArrayList<Contrato>(); for (Contrato c : lista) { LocalDate fecha = new LocalDate(c.getFecha_inicio()); if (desde != null && fecha.isBefore(desde)) continue; if (hasta != null && fecha.isAfter(hasta)) continue; listaDet.add(new ContratoDet(c)); } jr.setTotalRecordCount(listaDet.size()); jr.setResult("OK"); jr.setRecords(listaDet); } else { jr.setResult("ERROR"); jr.setTotalRecordCount(0); } String jsonResult = new Gson().toJson(jr); out.print(jsonResult); } finally { out.close(); } }
From source file:ru.codemine.ccms.dao.SalesDAOImpl.java
License:Open Source License
@Override public boolean updatePlanAll(Double plan, LocalDate startDate, LocalDate endDate) { if (plan == null || startDate == null || endDate == null || startDate.isAfter(endDate)) return false; Query updateQuery = getSession().createQuery("UPDATE SalesMeta Sm " + "SET Sm.plan = :plan " + "WHERE Sm.startDate = :startdate " + "AND Sm.endDate = :enddate"); updateQuery.setDate("startdate", startDate.toDate()); updateQuery.setDate("enddate", endDate.toDate()); updateQuery.setDouble("plan", plan); return updateQuery.executeUpdate() > 0; }