Changes between Initial Version and Version 1 of UseCase0003


Ignore:
Timestamp:
06/18/26 20:26:04 (2 days ago)
Author:
223091
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • UseCase0003

    v1 v1  
     1= Use-case 0003 - Approve or reject reservation =
     2
     3'''Initiating actor:'''
     4
     5Reservation Approver
     6
     7'''Other actors:'''
     8
     9Room Requester
     10
     11'''Description of the use-case goals:'''
     12
     13The goal of this use case is to allow a reservation approver to review pending reservation requests and record an approval or rejection decision. The system displays pending reservations together with requester, room, and equipment details. The approver then chooses a decision. The database is modified by updating the reservation status and inserting a corresponding approval record in the approvals table.
     14
     15'''Scenario:'''
     16
     17The Reservation Approver opens the list of pending reservations.
     18The system loads pending reservation requests from the database.
     19The system displays reservation details, including requester, room, date, time, requested equipment, and requested quantities.
     20The Reservation Approver selects one reservation.
     21The Reservation Approver chooses whether to approve or reject the reservation and enters an optional note.
     22The system updates the reservation status.
     23The system inserts the approval decision in the approvals table.
     24The system displays the final decision for the selected reservation.
     25
     26'''SQL commands used by the system:'''
     27
     28List all pending reservations:
     29
     30{{{
     31SELECT
     32res.reservation_id,
     33res.reservation_date,
     34res.start_time,
     35res.end_time,
     36res.status,
     37u.full_name AS requester_name,
     38r.room_code,
     39e.name AS requested_equipment,
     40req.requested_quantity
     41FROM project.reservations res
     42JOIN project.users u
     43ON u.user_id = res.user_id
     44LEFT JOIN project.rooms r
     45ON r.room_id = res.room_id
     46LEFT JOIN project.reservation_equipment req
     47ON req.reservation_id = res.reservation_id
     48LEFT JOIN project.equipment e
     49ON e.equipment_id = req.equipment_id
     50WHERE res.status = 'pending'
     51ORDER BY res.reservation_date, res.start_time, res.reservation_id;
     52}}}
     53
     54Approve a pending reservation and create an approval record:
     55
     56{{{
     57BEGIN;
     58
     59UPDATE project.reservations
     60SET status = 'approved'
     61WHERE reservation_id = 1
     62AND status = 'pending';
     63
     64INSERT INTO project.approvals (
     65reservation_id,
     66approver_id,
     67decision,
     68decision_time,
     69note
     70)
     71SELECT
     721,
     73u.user_id,
     74'approved',
     75CURRENT_TIMESTAMP,
     76'Approved after checking room and equipment availability.'
     77FROM project.users u
     78WHERE u.username = 'approver1'
     79AND NOT EXISTS (
     80SELECT 1
     81FROM project.approvals a
     82WHERE a.reservation_id = 1
     83);
     84
     85COMMIT;
     86}}}
     87
     88Show the final approval decision:
     89
     90{{{
     91SELECT
     92res.reservation_id,
     93res.status,
     94a.decision,
     95a.decision_time,
     96a.note,
     97approver.full_name AS approver_name
     98FROM project.reservations res
     99JOIN project.approvals a
     100ON a.reservation_id = res.reservation_id
     101JOIN project.users approver
     102ON approver.user_id = a.approver_id
     103WHERE res.reservation_id = 1;
     104}}}