Esempio n. 1
0
  public void obtenerFacturasPendientes() {
    List<Factura> lista =
        facturaService.obtenerLista(
            "select distinct f from Factura f "
                + "inner join f.cliente c "
                + "where p.numeroDocumento=?1 "
                + "and f.fechaCierre is null and f.activo=true order by f.fechaInicio",
            new Object[] {criterioBusqueda},
            true,
            new Object[] {});

    if (lista.isEmpty()) {
      limpiar();
    } else {
      listaFacturasPendientes = new ArrayList<CobroReporte>();
      criterioBusqueda = new String();

      totalTotal = newBigDecimal();
      totalAbonos = newBigDecimal();
      totalSaldo = newBigDecimal();

      for (Factura factura : lista) {
        CobroReporte cobroReporte = new CobroReporte();

        cobroReporte.setId(factura.getId());
        cobroReporte.setNombre(factura.getCliente().getRazonSocial());
        cobroReporte.setCodigoDocumento(
            factura
                .getEstablecimiento()
                .concat("-")
                .concat(factura.getPuntoEmision())
                .concat("-")
                .concat(factura.getSecuencia()));
        cobroReporte.setFechaEmision(factura.getFechaInicio());
        cobroReporte.setEscogido(false);
        cobroReporte.setOrden(0);
        cobroReporte.setTotal(facturaService.calcularTotal(factura));
        cobroReporte.setAbono(facturaService.calcularEntradas(factura));
        cobroReporte.setSaldo(cobroReporte.getTotal().subtract(cobroReporte.getAbono()));

        listaFacturasPendientes.add(cobroReporte);
      }
    }
  }