0

Good afternoon, I have the following code, in which, when executing the findOne of the repository, it sets the current value of the object, not the one in the database, I am doing it to compare the current value, against the historical one, but for some reason it always brings me the current one, as if it were in a cache:

CuentaDetalle detOld = findOne(cuentaDetalle.getId());
        ////// Tengo qeu validar que si antes estab en dolares o pesos y se cambio ese tilde, descontar de uno y pasar al otro
        if (cuentaDetalle.getPedido().isDolar() != detOld.getPedido().isDolar()) {
            if (cuentaDetalle.getPedido().isDolar()) {
                cuentaDetalle.getCuenta().setDebeDolar(cuentaDetalle.getCuenta().getDebeDolar() + cuentaDetalle.getMonto());
                cuentaDetalle.getCuenta().setHaberDolar(cuentaDetalle.getCuenta().getHaberDolar() + cuentaDetalle.getMontoPago());
                cuentaDetalle.getCuenta().setDebe(cuentaDetalle.getCuenta().getDebe() - detOld.getMonto());
                cuentaDetalle.getCuenta().setHaber(cuentaDetalle.getCuenta().getHaber() - detOld.getMontoPago());
            } else {
                cuentaDetalle.getCuenta().setDebe(cuentaDetalle.getCuenta().getDebe() + cuentaDetalle.getMonto());
                cuentaDetalle.getCuenta().setHaber(cuentaDetalle.getCuenta().getHaber() + cuentaDetalle.getMontoPago());
                cuentaDetalle.getCuenta().setDebeDolar(cuentaDetalle.getCuenta().getDebeDolar() - detOld.getMonto());
                cuentaDetalle.getCuenta().setHaberDolar(cuentaDetalle.getCuenta().getHaberDolar() - detOld.getMontoPago());
            }
        } else {
            if (cuentaDetalle.getPedido().isDolar()) {
                cuentaDetalle.getCuenta().setDebeDolar(cuentaDetalle.getCuenta().getDebeDolar() + (cuentaDetalle.getMonto() - detOld.getMonto()));
                cuentaDetalle.getCuenta().setHaberDolar(cuentaDetalle.getCuenta().getHaberDolar() + (cuentaDetalle.getMontoPago() - detOld.getMontoPago()));
            } else {
                cuentaDetalle.getCuenta().setDebe(cuentaDetalle.getCuenta().getDebe() + (cuentaDetalle.getMonto() - detOld.getMonto()));
                cuentaDetalle.getCuenta().setHaber(cuentaDetalle.getCuenta().getHaber() + (cuentaDetalle.getMontoPago() - detOld.getMontoPago()));
            }
        }
NicoGuevaraAtuq
  • 502
  • 2
  • 5
  • 17

0 Answers0