Add Missed status

This commit is contained in:
2026-04-06 00:39:37 -06:00
parent 6d4c9a5e65
commit d8e2c8c95d
3 changed files with 13 additions and 3 deletions

View File

@@ -18,7 +18,7 @@ public interface AppointmentRepository extends JpaRepository<Appointment, Long>
@Query("SELECT a FROM Appointment a WHERE a.appointmentDate = :date AND a.appointmentTime = :time") @Query("SELECT a FROM Appointment a WHERE a.appointmentDate = :date AND a.appointmentTime = :time")
List<Appointment> findByDateAndTime(@Param("date") LocalDate date, @Param("time") LocalTime time); List<Appointment> findByDateAndTime(@Param("date") LocalDate date, @Param("time") LocalTime time);
@Query("SELECT a FROM Appointment a JOIN FETCH a.service WHERE a.store.storeId = :storeId AND a.appointmentDate = :date AND LOWER(a.appointmentStatus) <> 'cancelled'") @Query("SELECT a FROM Appointment a JOIN FETCH a.service WHERE a.store.storeId = :storeId AND a.appointmentDate = :date AND LOWER(a.appointmentStatus) NOT IN ('cancelled', 'missed')")
List<Appointment> findByStoreAndDate(@Param("storeId") Long storeId, @Param("date") LocalDate date); List<Appointment> findByStoreAndDate(@Param("storeId") Long storeId, @Param("date") LocalDate date);
@Query("SELECT DISTINCT a FROM Appointment a LEFT JOIN a.pets p WHERE " + @Query("SELECT DISTINCT a FROM Appointment a LEFT JOIN a.pets p WHERE " +
@@ -37,6 +37,6 @@ public interface AppointmentRepository extends JpaRepository<Appointment, Long>
"LOWER(p.petName) LIKE LOWER(CONCAT('%', :q, '%')))") "LOWER(p.petName) LIKE LOWER(CONCAT('%', :q, '%')))")
Page<Appointment> searchAppointmentsByCustomer(@Param("customerId") Long customerId, @Param("q") String query, Pageable pageable); Page<Appointment> searchAppointmentsByCustomer(@Param("customerId") Long customerId, @Param("q") String query, Pageable pageable);
@Query("SELECT a FROM Appointment a JOIN FETCH a.service WHERE a.employee.employeeId = :employeeId AND a.appointmentDate = :date AND LOWER(a.appointmentStatus) <> 'cancelled'") @Query("SELECT a FROM Appointment a JOIN FETCH a.service WHERE a.employee.employeeId = :employeeId AND a.appointmentDate = :date AND LOWER(a.appointmentStatus) NOT IN ('cancelled', 'missed')")
List<Appointment> findByEmployeeEmployeeIdAndAppointmentDate(@Param("employeeId") Long employeeId, @Param("date") LocalDate date); List<Appointment> findByEmployeeEmployeeIdAndAppointmentDate(@Param("employeeId") Long employeeId, @Param("date") LocalDate date);
} }

View File

@@ -0,0 +1,10 @@
-- V18: Normalize past appointments.
-- Any appointment that is still 'Booked' but the date/time has passed should be marked as 'Missed'.
UPDATE appointment
SET appointmentStatus = 'Missed'
WHERE LOWER(appointmentStatus) = 'booked'
AND (
appointmentDate < CURRENT_DATE
OR (appointmentDate = CURRENT_DATE AND appointmentTime < CURRENT_TIME)
);

View File

@@ -57,7 +57,7 @@ public class AppointmentDialogController {
private ObservableList<String> statusList = private ObservableList<String> statusList =
FXCollections.observableArrayList( FXCollections.observableArrayList(
"Booked", "Completed", "Cancelled" "Booked", "Completed", "Cancelled", "Missed"
); );
// //