Skip to content
Extraits de code Groupes Projets
Valider d6b28947 rédigé par mohammed echahbouni's avatar mohammed echahbouni
Parcourir les fichiers

Removing the debug log and change the name from saved to savedContract and...

Removing the debug log and change the name from saved to savedContract and Replacing the exception message with an error code
parent 1f1923c6
Branches
Étiquettes
1 requête de fusion!5MLC-260/add cancellationReason and creationdate and update contractController
...@@ -77,7 +77,6 @@ public class ContractController { ...@@ -77,7 +77,6 @@ public class ContractController {
@PostMapping @PostMapping
public ResponseEntity<ContractDTO> createContract(@RequestBody ContractDTO contractDTO) throws FunctionalException { public ResponseEntity<ContractDTO> createContract(@RequestBody ContractDTO contractDTO) throws FunctionalException {
System.out.println("Reçu: " + contractDTO);
ContractDTO saved = contractService.createContract(contractDTO); ContractDTO saved = contractService.createContract(contractDTO);
return ResponseEntity.ok(saved); return ResponseEntity.ok(saved);
} }
......
...@@ -212,18 +212,18 @@ public class ContractServiceImpl implements ContractService { ...@@ -212,18 +212,18 @@ public class ContractServiceImpl implements ContractService {
@Transactional @Transactional
public ContractDTO updateDepositAndActivate(Long id, double depositAmount) throws FunctionalException { public ContractDTO updateDepositAndActivate(Long id, double depositAmount) throws FunctionalException {
Contract contract = contractRepository.findById(id) Contract contract = contractRepository.findById(id)
.orElseThrow(() -> new FunctionalException("Contrat non trouvé avec l'ID: " + id)); .orElseThrow(() -> new FunctionalException("CONTRACT_NOT_FOUND"));
contract.setDepositAmount(depositAmount); contract.setDepositAmount(depositAmount);
contract.setStatus(ContractStatus.ACTIVE); contract.setStatus(ContractStatus.ACTIVE);
Contract saved = contractRepository.save(contract); Contract savedContract = contractRepository.save(contract);
ContractDTO dto = contractMapper.toDto(saved); ContractDTO dto = contractMapper.toDto(savedContract);
dto.setDepositAmount(saved.getDepositAmount()); dto.setDepositAmount(savedContract.getDepositAmount());
if (saved.getSingleReservation() != null) { if (savedContract.getSingleReservation() != null) {
var reservation = saved.getSingleReservation(); var reservation = savedContract.getSingleReservation();
if (reservation.getGlobalReservation() != null) { if (reservation.getGlobalReservation() != null) {
dto.setTotalAmount(reservation.getGlobalReservation().getTotalAmount()); dto.setTotalAmount(reservation.getGlobalReservation().getTotalAmount());
Long clientId = reservation.getGlobalReservation().getClientId(); Long clientId = reservation.getGlobalReservation().getClientId();
......
0% ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter