Bank appointments system

December 8, 2022

In this project I built a system to manage appointments in a bank. The system has a login and registration section, and it allows users to create appointments, and to see the appointments they have created. The system also allows manager accounts to see the appointments created by other users and operate on them. Besides the expected CRUD operations available, managers can fulfil appointments, which means that they can mark them as completed, and leave a comment on them.

These managening accounts are assigned a department number, so they are restricted to see and operate on appointments created by users that belong to the same department only.

Admin accounts are in charge of creating both types of accounts, and can see all the appointments created by all users, but cannot operate on them.

Rubix bank app

The system has validations in place to ensure that the data entered by the users is valid, and that the appointments are created in the future, and not in the past. This validations are both applied on the client side as on the database side.

class Appointment < ApplicationRecord
    def past_date?
        if self.date < Date.today
            errors.add(:date, "The date entered cannot be in the past.")
        end
    end
    def valid_date?
        if !Schedule.exists?(branch_id: self.branch_id, day: self.date.wday)
            errors.add(:date, "The selected day is not available for this branch.")
        end
    end
    def valid_time?
        if !self.time.nil?
            schedule = Schedule.find_by(branch_id: self.branch_id, day: self.date.wday)
            if schedule && self.id && self.time < schedule.start_time || self.time > schedule.end_time
                errors.add(:time, "The selected time is not available for this branch.")
            end
        end
    end
    def check_done
        if !self.done
            errors.add(:base, "A completed appointment cannot be deleted.")
        end
    end
    def commentary_presence?
        if self.done && self.commentary.nil?
            errors.add(:commentary, "The commentary cannot be empty.")
        end
    end
    [...]

Projects by tags: