(Labor labor)
| 35 | private final LicenseService licenseService; |
| 36 | |
| 37 | @Transactional |
| 38 | public Labor create(Labor labor) { |
| 39 | if (!licenseService.hasEntitlement(LicenseEntitlement.TIME_TRACKING)) |
| 40 | throw new CustomException("You need a license to create a labor", HttpStatus.FORBIDDEN); |
| 41 | updateHourlyRateIfNeeded(labor); |
| 42 | Labor savedLabor = laborRepository.saveAndFlush(labor); |
| 43 | em.refresh(savedLabor); |
| 44 | return savedLabor; |
| 45 | } |
| 46 | |
| 47 | private void updateHourlyRateIfNeeded(Labor labor) { |
| 48 | if (labor.getHourlyRate() <= 0L && labor.getAssignedTo() != null) { |
nothing calls this directly
no test coverage detected