| @@ -135,6 +135,10 @@ public class TBCodeResource { | |||
| throw new BadRequestAlertException("1047", ENTITY_NAME, "1047"); | |||
| } | |||
| if (tBCodeCreationDTO.getExpiredDate() == null) { | |||
| throw new BadRequestAlertException("1047", ENTITY_NAME, "1047"); | |||
| } | |||
| Optional<TBCropDTO> tbCropDTO = tBCropService.findOne(tBCodeCreationDTO.gettBCropId()); | |||
| if (!tbCropDTO.isPresent()) { | |||
| throw new BadRequestAlertException("1019", ENTITY_NAME, "1019"); | |||
| @@ -151,6 +155,7 @@ public class TBCodeResource { | |||
| tBCodeDTO.setCreatedDate(Instant.now()); | |||
| tBCodeDTO.setCreatedById(currentUser.getUserId()); | |||
| tBCodeDTO.setStatus(TBCodeStatusEnum.NEW); | |||
| tBCodeDTO.setExpiredDate(tBCodeCreationDTO.getExpiredDate()); | |||
| if (tBCodeCreationDTO.getTbExampleStampId() != null) { | |||
| tBCodeDTO.setTbExampleStampId(tBCodeCreationDTO.getTbExampleStampId()); | |||
| } | |||
| @@ -271,11 +276,11 @@ public class TBCodeResource { | |||
| Optional<TBCode> tbCode = tBCodeService.findByCode(activityCodeCreationDTO.getCode()); | |||
| if(!tbCode.isPresent()) { | |||
| if (!tbCode.isPresent()) { | |||
| throw new BadRequestAlertException("1047", ENTITY_NAME, "1047"); | |||
| } else { | |||
| if(tbCode.get().getStatus().equals(TBCodeStatusEnum.EXPIRED) | |||
| || tbCode.get().getStatus().equals(TBCodeStatusEnum.CANCELED)) { | |||
| if (tbCode.get().getStatus().equals(TBCodeStatusEnum.EXPIRED) | |||
| || tbCode.get().getStatus().equals(TBCodeStatusEnum.CANCELED)) { | |||
| throw new BadRequestAlertException("1047", "TB Code is not active", "1047"); | |||
| } | |||
| } | |||