1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| @Override
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
public int louerPaiementDirect(int idAdherent, int idJeu, String dateSortie, String dateRetourPrevue, String commentaireSortie) throws ExceptionMetier, ExceptionTechnique {
Adherent adherent = null;
try {
adherent = adherentDao.getAdherent(idAdherent);
} catch (ExceptionTechnique e) {
// TODO: handle exception
}
Jeu jeu = jeuDao.getJeu(idJeu);
Pret pret = new Pret();
pret.setAdherent(adherent);
pret.setJeu(jeu);
pret.setDateSortie(DateUtils.getDateFromDatePicker(dateSortie));
pret.setDateRetourPrevue(DateUtils.getDateFromDatePicker(dateRetourPrevue));
pret.setCommentaireSortie(commentaireSortie);
int idPret = pretDao.creerPret(pret);
//throw new RuntimeException();
//TODO créer une opération
Operation operation = new Operation();
operation.setAdherent(adherent);
operation.setDateOperation(DateUtils.getDateFromDatePicker(dateSortie));
operation.setDateReglement(DateUtils.getDateFromDatePicker(dateSortie));
operation.setModeReglement(paramLudoDao.getParamLudo(ModeReglement.class, "mode_reglement", ModeReglement.TIRELIRE));
operation.setPrestation(jeu.getCategorie().getPrestation());
operation.setMontant(operation.getPrestation().getCout());
operation.setCredit(false);
operationDao.creerOperation(operation);
adherent.setTirelire(adherent.getTirelire() - jeu.getCategorie().getPrestation().getCout());
return idPret;
} |
Partager