Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * PRE: numeroDeFactura y fechaDeSolicitud deben ser distintos de null
- * El formato de la fecha ya esta validado
- * Numero de factura es > 0
- * <p>
- * POST: El metodo retorna un importe adicional a la factura emitida, dependiendo del total facturado, de la fecha de solicitud, de la fecha de facturación, de la lista de insumos
- *
- * @param numeroDeFactura
- * @param fechaDeSolicitud
- * @param listaDeInsumos
- * @return
- */
- public double calculoImporteAdicionales(int numeroDeFactura, GregorianCalendar fechaDeSolicitud, ArrayList<Double> listaDeInsumos) {
- Factura factura = null;
- double importeParcial = 0;
- double importeTotal = 0;
- double respuesta = 0;
- int aleatorio = Util.createRandom();
- System.out.println(aleatorio);
- //busco la factura
- for (Factura facturaact : this.facturas) {
- if (facturaact.getNroFactura() == numeroDeFactura) {
- factura = facturaact;
- }
- }
- if (factura != null) {
- if (Math.abs(factura.getFecha().get(Calendar.DAY_OF_YEAR) - fechaDeSolicitud.get(Calendar.DAY_OF_YEAR)) < 10) {
- importeParcial = factura.getImporteTotal() - (factura.getSubTotalImpar() * 0.7);
- } else
- importeParcial = factura.getImporteTotal() * 0.3;
- if (factura.getPaciente().getRangoEtario().equalsIgnoreCase("mayor")) {
- importeTotal = importeParcial * 1.4;
- } else
- importeTotal = importeParcial * 0.85;
- if (aleatorio == factura.getFecha().get(Calendar.DAY_OF_MONTH)) {
- respuesta = importeTotal;
- } else {
- double sumavalores = 0;
- if (listaDeInsumos!=null) {
- for (Double valor : listaDeInsumos)
- sumavalores += valor;
- }
- respuesta = importeTotal + sumavalores;
- }
- }
- return respuesta;
- }
- //En la clase Utils:
- public static int createRandom(){
- Random r = new Random();
- return r.nextInt(31)+1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement