generator client {
  provider = "prisma-client-js"
}

datasource postgresql {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

enum RECURRING_TYPE {
  DAILY
  WEEKLY
  BIWEEKLY
  TRIWEEKLY
  MONTHLY
  YEARLY
}

enum SERVICE_TYPE {
  TRAINER
  TAILOR
  CLEANING
  MASSAGE
  DINER
  FLOWER
  DOG
  TICKET
  CAR_WASH
  SALE
  HANDYMAN
  GROCERY
  PHARMACY
  ELECTRICIAN
  JUICE
  CATERING
  MEALBOX
  DISINFECTION
  MEDICAL
  COFFEE
  LOCAL_GROCERY
  SELF_CARE
  INSURANCE 
  FOOD_AND_OTHERS 
  FURNITURE 
  AUTO_SERVICES 
  PET_SUPPLIES 
  OTHER 
  VETERINARY_SERVICES
}

enum EVENT_TYPE {
  PUBLIC
  PRIVATE
  COMMUNITY
  SERVICE_BOOK
  ASSEMBLY
}

enum TOOL_TYPE {
  NOTIFICATION
  CALENDAR
  CONTACT
  RULE
  AMENITY
  MAIL
  CHAT
  USER
  DELIVERY
  WORK_ORDER
  VALET
  DOOR_ACCESS
  SMART_SPEAKER
  FILE
  SALE
  CAMERA
}

enum ORDER_STATUS {
  ARRIVED
  ARRIVING
  IN_PROGRESS
  CONFIRMED
  PENDING
  COMPLETED
  CANCELED
  REFUNDED
}

enum ADDITIONAL_SERVICE_STATUS {
  CANCELED
  DECLINED
  PENDING
  CONFIRMED
}

enum AD_STATUS {
  PENDING_APPROVAL
  APPROVED
  SOLD
}

enum RESERVATION_STATUS {
  CANCELED
  PENDING
  CONFIRMED
  REJECTED
}

enum PACKAGE_STATUS {
  AT_RECEPTION
  DELIVERED
  DELIVERED_AT_YOUR_DOOR
}

enum SERVICE_REQUEST_STATUS {
  PENDING_APPROVAL
  APPROVED
  IN_PROCESS
  COMPLETED
}

enum USER_ROLE {
  TENANT
  RESIDENT
  EMPLOYEE
  MARKETER
  MANAGER
  PROVIDER
}

enum NOTIFICATION_TYPE {
  CHAT_NOTIFICATION_REMINDER
  NEW_RESIDENT
  NEW_RESIDENT_APPROVED
  NEW_CHAT_MESSAGE
  NEW_CHAT_PRIVATE_MENTIONED
  NEW_POST
  NEW_PROXY
  NEW_PROXY_COMPLETED
  NEW_EVENT
  UPDATE_EVENT
  EVENT_REMINDER
  NEW_AMENITY
  NEW_RULE
  NEW_CONTACT
  NEW_FILE
  NEW_FOLDER
  NEW_OFFENSE
  UPDATE_OFFENSE
  NEW_SERVICE_REQUEST
  UPDATE_SERVICE_REQUEST
  NEW_ORDER
  ORDER_CHANGE
  ORDER_NEED_ATTENTION
  ORDER_STATUS_CHANGED
  ORDER_UPDATE_ADDITIONAL_SERVICE
  ORDER_NEW_ADDITIONAL_SERVICE
  PACKAGE_AT_RECEPTION
  PACKAGE_DELIVERED
  PACKAGE_UPDATE
  NEW_RESERVATION
  UPDATE_RESERVATION
  NEW_AD
  UPDATE_AD
  NEW_SALE
  UPDATE_SALE
  SERVICE_REQUEST_ASSIGNED
  TASK_ASSIGNEE
  NEW_TASK
  NEW_COMMENT_SUBSCRIBED
  NEW_COMMENT_ON_ASSIGNEE_TASK
  NEW_COMMENT_WITH_MENTION
}

enum CONTACT_PERSON_TYPE {
  WEBMASTER
  MANAGER
  RESOURCE
}

enum NOTIFICATION_APP_TYPE {
  USER
  MANAGER
  PROVIDER
}

enum POST_TYPE {
  NORMAL
  POLL
  PROXY
}

enum OPERATING_SYSTEM {
  IOS
  ANDROID
}

enum RESERVATION_TYPE {
  SINGLE_DATE
  MULTIPLE_DATE
  SINGLE_DATE_TIME
  MULTIPLE_DATE_TIME
}

enum NOTIFICATION_DELIVERY_PLATFORM {
  EMAIL
  SMS
  APP
}

enum OFFENSE_STATUS {
  DRAFT
  SENT
  COMPLETED
}

enum PLATFORM {
  MOBILE
  WEB
}

enum CANT_DELIVER_EMAIL_REASON {
  BLOCKED
  SPAM
  BOUNCED
  INVALID_EMAIL
}

enum REPORT_SECTION {
  RESIDENTS
  UNITS
  LOCKERS
  PARKINGS
  TASKS
  ADS
  AMENITIES
}

enum PERMISSION_TYPE {
  MANAGING_COMPANY_INFO_READ
  MANAGING_COMPANY_INFO_WRITE
  ROLES_READ
  ROLES_WRITE
  ACCOUNTS_READ
  ACCOUNTS_WRITE
  NOTIFICATION_READ
  NOTIFICATION_WRITE
  CALENDAR_READ
  CALENDAR_WRITE
  CONTACT_READ
  CONTACT_WRITE
  RULE_READ
  RULE_WRITE
  AMENITY_READ
  AMENITY_WRITE
  MAIL_READ
  MAIL_WRITE
  CHAT_READ
  CHAT_WRITE
  USER_READ
  USER_WRITE
  DELIVERY_READ
  DELIVERY_WRITE
  WORK_ORDER_READ
  WORK_ORDER_WRITE
  VALET_READ
  VALET_WRITE
  DOOR_ACCESS_READ
  DOOR_ACCESS_WRITE
  SMART_SPEAKER_READ
  SMART_SPEAKER_WRITE
  FILE_READ
  FILE_WRITE
  SALE_READ
  SALE_WRITE
  INTERCHAT_READ
  INTERCHAT_WRITE
  NOTE_WRITE
  NOTE_READ
  SEGMENT_WRITE
  SEGMENT_READ
  MANAGING_COMPANY_WRITE
  MANAGING_COMPANY_READ
  PROJECT_WRITE
  PROJECT_READ
  OFFENSE_READ
  OFFENSE_WRITE
  CAMERA_READ
  CAMERA_WRITE
  TASK_WRITE
  TASK_READ
}

enum MODEL {
  USER
  PROPERTY
  PARKING
  LOCKER
}

enum COMPARISON_VALUE {
  IS_EMPTY
  IS_NOT_EMPTY
  EQUALS
  NOT_EQUALS
  CONTAINS
  NOT_CONTAINS
}

enum CONDITION_LOGICAL {
  AND
  OR
}

enum MEETING_PARTICIPANT_STATUS {
  LEFT_MEETING
  RECEIVED_INVITATION
  REGISTERED
  WAITING_FOR_APPROVAL
  IN_THE_MEETING
  CANCEL_REGISTRATION
}

enum MEETING_STATUS {
  NOT_STARTED
  WAITING_FOR_HOST
  IN_PROGRESS
  ENDED
}

enum PAYMENT_METHOD_TYPE {
  CASH
  CHEQUE
  CREDIT_CARD
}

enum PAYMENT_STATUS {
  RECEIVED
  PENDING
  COMPLETED
  PROCESSING
  FAILED
  CANCELLED
}

enum CURRENCY {
  US
  CAD
}

enum POLL_TYPE {
  SHORT
  SINGULAR
  MULTIPLE
}

enum NOTE_STATUS {
  PENDING
  IN_PROCESS
  DONE
}

enum PAYSAFE_PAYMENT_STATUS {
  RECEIVED
  PENDING
  COMPLETED
  PROCESSING
  FAILED
  CANCELLED
}

enum PAYSAFE_PAYMENT_TYPE {
  MONTHLY_CONDO_FEES
  MONTHLY_PARKING_FEES
}

enum THIRD_PARTY_SYNC_STATUS {
  UNSYNCED //can be used to prevent automatic updates if client wants to have partial sync
  SYNCED //any changes from walter can be pushed when this status
  CHANGED_ON_WALTER //this will trigger an exported file or API call when the third party sync module runs
  CONFLICTING_DATA //this will be used to signal that the person in control of the third party service needs to confirm which data is right
}

enum PRISMA_IMPORT_DATA_TYPE {
  INT
  STRING
  BOOLEAN
}

model AccessKey {
  id         String    @default(cuid()) @id
  createdAt  DateTime  @default(now())
  updatedAt  DateTime  @updatedAt
  number     String
  projectId  String?
  propertyId String?
  project    Project?  @relation(fields: [projectId], references: [id])
  property   Property? @relation(fields: [propertyId], references: [id])
  owners     User[]    @relation("AccessKeysOfUser")
}

model AccountStatement {
  id                String    @default(cuid()) @id
  createdAt         DateTime  @default(now())
  updatedAt         DateTime  @updatedAt
  transactionDate   DateTime?
  transactionNumber String?
  amount            Float?
  accountNumber     String?
  chequeNumber      String?
  receiptNumber     String?
  description       String?
  isDtCt            Boolean?
  isEndOfYear       Boolean?
  condoManagerId    String?
  propertyId        String?
  property          Property? @relation(fields: [propertyId], references: [id])
}

model Ad {
  id          String     @default(cuid()) @id
  status      AD_STATUS? @default(APPROVED)
  createdAt   DateTime   @default(now())
  updatedAt   DateTime   @updatedAt
  title       String?
  description String?
  price       Float?
  email       String?
  isSold      Boolean?
  projectId   String?
  phoneId     String?
  ownerId     String?
  owner       User?      @relation(fields: [ownerId], references: [id])
  phone       Phone?     @relation(fields: [phoneId], references: [id])
  project     Project?   @relation(fields: [projectId], references: [id])
  images      Picture[]
}

model AdditionalService {
  id          String                     @default(cuid()) @id
  status      ADDITIONAL_SERVICE_STATUS? @default(CONFIRMED) //unsure TO REVIEW
  createdAt   DateTime                   @default(now())
  updatedAt   DateTime                   @updatedAt
  subtotal    Float?
  totalTax    Float?
  total       Float?
  description String?
  isCharged   Boolean?
  isRecurrent Boolean?
  creatorId   String?
  creator     User?                      @relation(fields: [creatorId], references: [id])
  order       Order[]                    @relation("AdditionalServicesOfOrder")
}

model Addon {
  id                         String      @default(cuid()) @id
  createdAt                  DateTime    @default(now())
  updatedAt                  DateTime    @updatedAt
  title                      String
  titleFr                    String?
  isRequired                 Boolean?
  minimumNumberOfAddonsItems Int?
  maximumNumberOfAddonsItems Int?
  isDeleted                  Boolean?
  addonsItems                AddonItem[]
  options                    Option[]
}

model AddonItem {
  id        String   @default(cuid()) @id
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  title     String
  price     Float
  titleFr   String?
  isDeleted Boolean?
  owner     Addon[]
}

model Address {
  id                          String              @default(cuid()) @id
  createdAt                   DateTime            @default(now())
  updatedAt                   DateTime            @updatedAt
  address1                    String?
  apartmentNumber             String?
  zip                         String?
  city                        String?
  state                       String?
  country                     String?
  countryCode                 String?
  provinceCode                String?
  bookings                    Booking[] //unsure case 1: Booking has an Address and instrospect adds the other end as many relation no matter what. solution: keep Booking[] and rename with lowercase with plurial form
  buildings                   Building[]
  creditCards                 CreditCard[]
  events                      Event[]
  managerStoreOrders          ManagerStoreOrder[]
  managingCompanies           ManagingCompany[]
  orders                      Order[]
  paymentAccounts             PaymentAccount[]
  properties                  Property[]
  reservations                Reservation[]
  services                    Service[]
  users                       User[]
  address1SyncStatuses        SyncStatus[]        @relation("AddressSyncAddress1")
  apartmentNumberSyncStatuses SyncStatus[]        @relation("AddressSyncApartmentNumber")
  citySyncStatuses            SyncStatus[]        @relation("AddressSyncCity")
  countrySyncStatuses         SyncStatus[]        @relation("AddressSyncCountry")
  countryCodeSyncStatuses     SyncStatus[]        @relation("AddressSyncCountryCode")
  provinceCodeSyncStatuses    SyncStatus[]        @relation("AddressSyncProvinceCode")
  stateSyncStatuses           SyncStatus[]        @relation("AddressSyncState")
  zipSyncStatuses             SyncStatus[]        @relation("AddressSyncZip")
}

model Amenity {
  id                    String                  @default(cuid()) @id
  createdAt             DateTime                @default(now())
  updatedAt             DateTime                @updatedAt
  title                 String
  description           String?
  info                  String?
  hasReservation        Boolean?
  reservationType       String?
  position              Int?
  isDeleted             Boolean?
  imageId               String?
  projectId             String?
  termsFileId           String?
  price                 Float?
  usageDuration         Int?
  maximumUsageTime      Int?
  eventDate             DateTime?
  disclaimerFileId      String?
  bookingInAdvanceMaxMS Int?
  bookingInAdvanceMinMS Int?
  maximumUsageTime2     DateTime?
  disclaimerFile        File?                   @relation("Amenity_disclaimerFileToFile", fields: [disclaimerFileId], references: [id])
  image                 Picture?                @relation(fields: [imageId], references: [id])
  project               Project?                @relation(fields: [projectId], references: [id])
  termsFile             File?                   @relation("Amenity_termsFileToFile", fields: [termsFileId], references: [id])
  blockedDates          DateTime[] //unsure case 2: @scalarList creates intermediate table / model
  reservations          Reservation[]
  bookingOptions        AmenityBookingOption[] @relation("AmenityBookingOptions")
  seenBy                User[]
  images                Picture[]               @relation("ImagesOfAmenity")
  sharedWithProjects    Project[]               @relation("SharedProjectsOfAmenity")
}

model AmenityBookingOption {
  id                                    String                 @default(cuid()) @id
  createdAt                             DateTime               @default(now())
  updatedAt                             DateTime               @updatedAt
  maxUsageTimeMS                        Int?
  bookingInAdvanceMaxMS                 Int?
  bookingInAdvanceMinMS                 Int?
  timeRequiredBetweenEachBookingMS      Int?
  allowMultipleBookings                 Boolean?
  bookingRequiresStaffApproval          Boolean? @default(false)
  projectId                             String?
  maxUsageTimeSeconds                   Int?
  bookingInAdvanceMaxSeconds            Int?
  bookingInAdvanceMinSeconds            Int?
  timeRequiredBetweenEachBookingSeconds Int?
  bookingIntervalPerUserInSeconds       Int?
  maximumBookingsAtSameTime             Int?
  timeslotIncrementalInSeconds          Int?
  maximumOfResidentsInOneBooking        Int?
  project                               Project?               @relation(fields: [projectId], references: [id])
  usageDurationMS                       Int[]
  usageDurationSeconds                  Int[]
  bookingOptions                        Amenity[]              @relation("AmenityBookingOptions")
  businessHours                         BusinessHour[]        @relation("AmenityBookingOptionsBusinessHours")
  paymentOptions                        AmenityPaymentOption[] @relation("AmenityBookingOptionsPaymentOptions")
  segments                              Segment[]
}

model AmenityPaymentOption {
  id                                    String                  @default(cuid()) @id
  currency                              CURRENCY
  createdAt                             DateTime                @default(now())
  updatedAt                             DateTime                @updatedAt
  minUsageTimeBeforePaymentMS           Int?
  isDeposit                             Boolean?
  amount                                Float
  isTaxable                             Boolean?
  minUsageTimeBeforePaymentSeconds      Int?
  usageDurationForEveryPaymentInSeconds Int?
  acceptedPaymentMethods                PAYMENT_METHOD_TYPE[]
  amenityBookingOptions                 AmenityBookingOption[] @relation("AmenityBookingOptionsPaymentOptions")
}

model Booking {
  id        String    @default(cuid()) @id
  createdAt DateTime  @default(now())
  updatedAt DateTime  @updatedAt
  date      DateTime?
  addressId String?
  start     DateTime?
  end       DateTime?
  address   Address?  @relation(fields: [addressId], references: [id])
  orders    Order[]
}

model Building {
  id              String           @default(cuid()) @id
  createdAt       DateTime         @default(now())
  updatedAt       DateTime         @updatedAt
  addressId       String?
  address         Address?         @relation(fields: [addressId], references: [id])
  paysafeAccounts PaysafeAccount[]
  properties      Property[]
  project         Project?         @relation("BuildingOfProject")
  projects        Project[]        @relation("BuildingsOfProject")
}

model BusinessHour {
  id                             String                  @default(cuid()) @id
  createdAt                      DateTime                @default(now())
  updatedAt                      DateTime                @updatedAt
  dayOfWeek                      Int?
  openAtMS                       Int?
  closeAtMS                      Int?
  openAt                         DateTime?
  closeAt                        DateTime?
  isClosed                       Boolean?
  serviceProjectBusinessHoursId  String?
  serviceProjectSpecialDateId    String?
  serviceProjectBusinessHours    ServiceProject?         @relation("BusinessHours_serviceProjectBusinessHoursToServiceProject", fields: [serviceProjectBusinessHoursId], references: [id])
  serviceProjectSpecialDate      ServiceProject?         @relation("BusinessHours_serviceProjectSpecialDateToServiceProject", fields: [serviceProjectSpecialDateId], references: [id])
  amenityBookingOptions          AmenityBookingOption[] @relation("AmenityBookingOptionsBusinessHours")
  managingCompaniesBusinessHours ManagingCompany[]       @relation("BusinessHoursOfManagingCompany")
  servicesBusinessHours          Service[]               @relation("BusinessHoursOfService")
  servicesPickupHours            Service[]               @relation("PickupHoursOfService")
  managingCompaniesSpecialDates  ManagingCompany[]       @relation("SpecialDatesOfManagingCompany")
  servicesSpecialDates           Service[]               @relation("SpecialDatesOfService")
}

model Car {
  id                   String    @default(cuid()) @id
  createdAt            DateTime  @default(now())
  updatedAt            DateTime  @updatedAt
  model                String?
  registrationPlate    String?
  ownerId              String?
  associatedPropertyId String?
  description          String?
  associatedProperty   Property? @relation(fields: [associatedPropertyId], references: [id])
  owner                User?     @relation(fields: [ownerId], references: [id])
  usersCar             User[]    @relation("CarOfUser") //unsure
}

model ChosenModel {
  id         String     @default(cuid()) @id
  createdAt  DateTime   @default(now())
  updatedAt  DateTime   @updatedAt
  note       String?
  roomId     String?
  modelId    String?
  model      RoomModel? @relation(fields: [modelId], references: [id])
  room       UnitRoom?  @relation(fields: [roomId], references: [id])
  properties Property[]
}

model Comment {
  id                           String          @default(cuid()) @id
  createdAt                    DateTime        @default(now())
  updatedAt                    DateTime        @updatedAt
  message                      String?
  createdById                  String?
  serviceRequestAssociatedToId String?
  taskId                       String?
  createdBy                    User?           @relation(fields: [createdById], references: [id])
  serviceRequestAssociatedTo   ServiceRequest? @relation(fields: [serviceRequestAssociatedToId], references: [id])
  task                         Task?           @relation(fields: [taskId], references: [id])
  mentionedUsers               User[]          @relation("MentionedUsersInComments")
}

model Condition {
  id         String             @default(cuid()) @id
  model      MODEL
  comparison COMPARISON_VALUE
  logical    CONDITION_LOGICAL?
  createdAt  DateTime           @default(now())
  updatedAt  DateTime           @updatedAt
  path       String
  value      String
  order      Int
  segments   Segment[]
}

model CondoManagerCompte {
  id           String   @default(cuid()) @id
  createdAt    DateTime @default(now())
  updatedAt    DateTime @updatedAt
  nomCompte    String?
  noCompteReel String?
  userNumber   Int?
  projectId    String?
  project      Project? @relation(fields: [projectId], references: [id])
  users        User[]
}

model Contact {
  id        String    @default(cuid()) @id
  createdAt DateTime  @default(now())
  updatedAt DateTime  @updatedAt
  firstName String?
  lastName  String?
  fullname  String?
  title     String?
  email     String?
  phoneId   String?
  avatarId  String?
  projectId String?
  isPrivate Boolean?
  website   String?
  avatar    Picture?  @relation(fields: [avatarId], references: [id])
  phone     Phone?    @relation(fields: [phoneId], references: [id])
  project   Project?  @relation("ContactsOfProject", fields: [projectId], references: [id])
  projects  Project[] @relation("ContactsOfProjects")
  seenBy    User[]
}

model ContactPerson {
  id        String    @default(cuid()) @id
  createdAt DateTime  @default(now())
  updatedAt DateTime  @updatedAt
  type      String?
  firstName String?
  lastName  String?
  title     String?
  email     String?
  phoneId   String?
  phone     Phone?    @relation(fields: [phoneId], references: [id])
  projects  Project[] @relation("ContactPersonsOfProject")
  services  Service[]
}

model CreditCard {
  id            String          @default(cuid()) @id
  createdAt     DateTime        @default(now())
  updatedAt     DateTime        @updatedAt
  last4         String
  expiryMonth   Int
  expiryYear    Int
  type          String?
  name          String?
  cardId        String?
  addressId     String?
  address       Address?        @relation(fields: [addressId], references: [id])
  paymentMethod PaymentMethod[]
}

model CustomField {
  id          String   @default(cuid()) @id
  createdAt   DateTime @default(now())
  updatedAt   DateTime @updatedAt
  title       String
  type        String
  path        String
  description String?
  tasks       Task[]
}

model Event {
  id                           String         @default(cuid()) @id
  type                         EVENT_TYPE?
  createdAt                    DateTime       @default(now())
  updatedAt                    DateTime       @updatedAt
  title                        String?
  description                  String?
  repeat                       Int?
  location                     String?
  entryPrice                   Float? @default(0)
  hasAttendees                 Boolean?
  requiredNumberOfParticipants Int? @default(0)
  start                        DateTime?
  end                          DateTime?
  coverImageId                 String?
  projectId                    String?
  addressId                    String?
  isForManagingCompany         Boolean?
  hasAlertReminder             Boolean?
  firstReminderSentAt          DateTime?
  secondReminderSentAt         DateTime?
  assemblyDate                 DateTime?
  assemblyLocation             String?
  assemblyTime                 String?
  address                      Address?       @relation(fields: [addressId], references: [id])
  coverImage                   Picture?       @relation(fields: [coverImageId], references: [id])
  project                      Project?       @relation(fields: [projectId], references: [id])
  notifications                Notification[]
  seenBy                       User[]         @relation("EventsSeenByUser")
  //Event_A                      Event[]        @relation("EventToEvent") //unsure case 3: superfluous self-relation? --> Take notes and discuss with Thierry
  //Event_B                      Event[]        @relation("EventToEvent") //unsure case 3: superfluous self-relation?
  segments                     Segment[]
  cantGoUsers                  User[]         @relation("UsersCantGoToEvent")
  goingUsers                   User[]         @relation("UsersGoingToEvent")
  interestedUsers              User[]         @relation("UsersInterestedToEvent")
}

model FaqItem {
  id         String    @default(cuid()) @id
  createdAt  DateTime  @default(now())
  updatedAt  DateTime  @updatedAt
  question   String
  questionFr String?
  answer     String
  answerFr   String?
  services   Service[]
}

model File {
  id                            String               @default(cuid()) @id
  createdAt                     DateTime             @default(now())
  updatedAt                     DateTime             @updatedAt
  url                           String
  name                          String
  format                        String?
  cloudinaryId                  String?
  size                          Int?
  type                          String?
  amenitiesDisclaimerFileToFile Amenity[]            @relation("Amenity_disclaimerFileToFile")
  amenitiesTermsFileToFile      Amenity[]            @relation("Amenity_termsFileToFile")
  meetingParticipants           MeetingParticipant[]
  projects                      Project[]
  propertiesFileToProperty      Property[]
  proxies                       Proxy[]
  propertiesAnnexesOfProperty   Property[]           @relation("AnnexesOfProperty")
  folders                       Folder[]             @relation("FilesOfFolder")
  seenBy                        User[]               @relation("FilesSeenByUser")
  meetings                      Meeting[]
  posts                         Post[]
  rules                         Rule[]
  tasks                         Task[]
}

model Folder {
  id                  String    @default(cuid()) @id
  createdAt           DateTime  @default(now())
  updatedAt           DateTime  @updatedAt
  name                String
  description         String?
  folderParentId      String?
  projectId           String?
  hideFromTenants     Boolean?
  hiddenForTenants    Boolean?
  forOwnersOnly       Boolean?
  forBoardMembersOnly Boolean?
  sendNotification    Boolean?
  folderParent        Folder?   @relation("FolderToFolder_folderParent", fields: [folderParentId], references: [id])
  project             Project?  @relation(fields: [projectId], references: [id])
  other_Folder        Folder[]  @relation("FolderToFolder_folderParent")
  files               File[]    @relation("FilesOfFolder")
  segments            Segment[] @relation("SegmentsOfFolder")
}

model Invoice {
  id             String   @default(cuid()) @id
  createdAt      DateTime @default(now())
  updatedAt      DateTime @updatedAt
  url            String?
  number         String?
  month          Int?
  year           Int?
  numberOfOrders Int?
  serviceId      String?
  service        Service? @relation(fields: [serviceId], references: [id])
}

model Issue {
  id         String     @default(cuid()) @id
  createdAt  DateTime   @default(now())
  updatedAt  DateTime   @updatedAt
  endAt      DateTime
  category   String?
  assigneeId String?
  assignee   User?      @relation(fields: [assigneeId], references: [id])
  properties Property[]
}

model LineItem {
  id         String   @default(cuid()) @id
  createdAt  DateTime @default(now())
  updatedAt  DateTime @updatedAt
  optionJson Json?
  durationMS Int?
  quantity   Int?
  optionId   String?
  orderId    String?
  option     Option?  @relation(fields: [optionId], references: [id])
  order      Order?   @relation(fields: [orderId], references: [id])
}

model Locker {
  id             String     @default(cuid()) @id
  createdAt      DateTime   @default(now())
  updatedAt      DateTime   @updatedAt
  number         String
  projectId      String?
  cadastreNumber String?
  project        Project?   @relation(fields: [projectId], references: [id])
  properties     Property[] @relation("LockersOfProperties")
  owners         User[]     @relation("LockersOfUser")
  segments       Segment[]
}

model ManagerStoreItem {
  id                         String                      @default(cuid()) @id
  createdAt                  DateTime                    @default(now())
  updatedAt                  DateTime                    @updatedAt
  title                      String
  description                String?
  price                      Float?
  managerStoreOrderLineItems ManagerStoreOrderLineItem[]
  images                     Picture[]
  projects                   Project[]
}

model ManagerStoreOrder {
  id                String                      @default(cuid()) @id
  createdAt         DateTime                    @default(now())
  updatedAt         DateTime                    @updatedAt
  subtotal          Float?
  shipping          Float?
  discounts         Float?
  tax               Float?
  total             Float?
  isCharged         Boolean?
  chargedAt         DateTime?
  customerId        String?
  deliveryAddressId String?
  projectId         String?
  customer          User?                       @relation(fields: [customerId], references: [id])
  deliveryAddress   Address?                    @relation(fields: [deliveryAddressId], references: [id])
  project           Project?                    @relation(fields: [projectId], references: [id])
  lineItems         ManagerStoreOrderLineItem[]
}

model ManagerStoreOrderLineItem {
  id        String             @default(cuid()) @id
  createdAt DateTime           @default(now())
  updatedAt DateTime           @updatedAt
  quantity  Int?
  orderId   String?
  itemId    String?
  item      ManagerStoreItem?  @relation(fields: [itemId], references: [id])
  order     ManagerStoreOrder? @relation(fields: [orderId], references: [id])
}

model ManagingCompany {
  id                       String                   @default(cuid()) @id
  createdAt                DateTime                 @default(now())
  updatedAt                DateTime                 @updatedAt
  active                   Boolean? @default(true)
  shortName                String?
  longName                 String?
  condoManagerId           String?
  addressId                String?
  phoneId                  String?
  logoId                   String?
  email                    String?
  emailHeaderImageId       String?
  automaticChatMessage     String?
  automaticChatMessageFr   String?
  emergencyPhoneId         String?
  isUsingV2                Boolean? @default(true)
  logoAvatarId             String?
  stripeAccountAccessToken String?
  stripeAccountId          String?
  condoManagerApiKey       String?
  zoomAccessToken          String?
  zoomRefreshToken         String?
  zoomAccessTokenExpiresIn String?
  address                  Address?                 @relation(fields: [addressId], references: [id])
  emailHeaderImage         Picture?                 @relation("ManagingCompany_emailHeaderImageToPicture", fields: [emailHeaderImageId], references: [id])
  emergencyPhone           Phone?                   @relation("ManagingCompany_emergencyPhoneToPhone", fields: [emergencyPhoneId], references: [id])
  logo                     Picture?                 @relation("ManagingCompany_logoToPicture", fields: [logoId], references: [id])
  logoAvatar               Picture?                 @relation("ManagingCompany_logoAvatarToPicture", fields: [logoAvatarId], references: [id])
  phone                    Phone?                   @relation("ManagingCompany_phoneToPhone", fields: [phoneId], references: [id])
  roles                    ManagingCompanyRole[]
  serviceRequestCategories String[]
  tasksCategories          TaskCategory[]
  tasksStatuses            TaskStatus[]
  users                    User[]
  businessHours            BusinessHour[]          @relation("BusinessHoursOfManagingCompany")
  projects                 Project[]                @relation("ManagingCompanyOfProject")
  offenseCategories        OffenseCategory[]        @relation("OffenseCategoriesOfManagingCompany")
  serviceRequestPriorities ServiceRequestPriority[] @relation("ServiceRequestPrioritiesOfManagingCompany")
  specialDates             BusinessHour[]          @relation("SpecialDatesOfManagingCompany")
}

model ManagingCompanyRole {
  id                              String            @default(cuid()) @id
  permissions                     PERMISSION_TYPE[]
  createdAt                       DateTime          @default(now())
  updatedAt                       DateTime          @updatedAt
  title                           String
  description                     String?
  managingCompanyId               String?
  managingCompany                 ManagingCompany?  @relation(fields: [managingCompanyId], references: [id])
  managingCompanyRolesPermissions PERMISSION_TYPE[] // NEED TO REMOVE THIS?!
  users                           User[]
  projects                        Project[]
}

model MappedService {
  id                    String                  @default(cuid()) @id
  friendlyName          String
  mappedServiceSettings MappedServiceSetting[]
  mappings              Mapping[]
  projects              Project[]
}

model MappedServiceSetting {
  id              String         @default(cuid()) @id
  lastImport      DateTime?
  lastExport      DateTime?
  importEnabled   Boolean?
  exportEnabled   Boolean?
  importStatus    String?
  exportStatus    String?
  mappedServiceId String?
  mappedService   MappedService? @relation(fields: [mappedServiceId], references: [id])
  projects        Project[]
}

model Mapping {
  id                                               String                   @default(cuid()) @id
  prismaSourceDataType                             PRISMA_IMPORT_DATA_TYPE?
  prismaSyncStatusField                            String
  prismaSource                                     String
  prismaPrefixSuffix                               String?
  prismaSourceForeignKey                           String?
  prismaSecondForeignKey                           String?
  destinationKeyName                               String
  destinationPrimaryKey                            String?
  destinationSecondPrimaryKey                      String?
  destinationPrefixSuffix                          String?
  requiresConfirmationToOverwriteThirdPartyService Boolean
  requiresConfirmationToOverwriteWalter            Boolean
  excludeRecordIf                                  String?
  dontExport                                       Boolean @default(false)
  dontImport                                       Boolean @default(false)
  mappedServiceId                                  String?
  mappedService                                    MappedService?           @relation(fields: [mappedServiceId], references: [id])
  syncStatuses                                     SyncStatus[]
}

model Meeting {
  id                    String                   @default(cuid()) @id
  createdAt             DateTime                 @default(now())
  updatedAt             DateTime                 @updatedAt
  date                  DateTime?
  zoomWebinarPassword   String?
  topic                 String?
  agenda                String?
  start                 DateTime?
  password              String?
  durationMinutes       Int?
  contactName           String?
  contactEmail          String?
  status                MEETING_STATUS @default(NOT_STARTED)
  projectId             String?
  joinUrl               String?
  registrationUrl       String?
  startUrl              String?
  startedAt             DateTime?
  endedAt               DateTime?
  invitationSubject     String?
  invitationBody        String?
  zoomWebinarUuid       String?
  zoomWebinarId         String?
  project               Project?                 @relation(fields: [projectId], references: [id])
  participants          MeetingParticipant[]
  participantsUnits     MeetingParticipantUnit[]
  invitationAttachments File[]
  polls                 Poll[]
}

model MeetingActivity {
  id                  String               @default(cuid()) @id
  createdAt           DateTime             @default(now())
  updatedAt           DateTime             @updatedAt
  text                String?
  meetingParticipants MeetingParticipant[]
}

model MeetingParticipant {
  id                                String                      @default(cuid()) @id
  status                            MEETING_PARTICIPANT_STATUS?
  createdAt                         DateTime                    @default(now())
  updatedAt                         DateTime                    @updatedAt
  zoomUserId                        String?
  proportionateShare                Float?
  accessCode                        String?
  isRepresentedById                 String?
  propertyId                        String?
  userId                            String?
  isInTheMeeting                    Boolean? @default(false)
  isRegistered                      Boolean?
  isRepresentedByName               String?
  copropertyDueAmount               Float?
  firstName                         String?
  email                             String?
  joinUrl                           String?
  proxyId                           String?
  proxyFileId                       String?
  receivedInvitation                Boolean? @default(false)
  receivedInvitationAt              DateTime?
  isRepresentedByPropertyId         String?
  isRepresentedByEmail              String?
  canVote                           Boolean? @default(true)
  unitNumber                        String?
  meetingId                         String?
  joinedTheMeetingAt                DateTime?
  leftTheMeetingAt                  DateTime?
  isRepresentedByFirstName          String?
  isRepresentedByLastName           String?
  lastName                          String?
  representedByMeetingParticipantId String?
  zoomRegistrantId                  String?
  isARepresentee                    Boolean? @default(false)
  isRepresentedBy                   User?                       @relation("MeetingParticipant_isRepresentedByToUser", fields: [isRepresentedById], references: [id])
  property                          Property?                   @relation("MeetingParticipant_isRepresentedByPropertyToProperty", fields: [isRepresentedByPropertyId], references: [id])
  meeting                           Meeting?                    @relation(fields: [meetingId], references: [id])
  isRepresentedByProperty           Property?                   @relation("MeetingParticipant_propertyToProperty", fields: [propertyId], references: [id])
  proxy                             Proxy?                      @relation(fields: [proxyId], references: [id])
  proxyFile                         File?                       @relation(fields: [proxyFileId], references: [id])
  representedByMeetingParticipant   MeetingParticipant?         @relation("MeetingParticipantToMeetingParticipant_representedByMeetingParticipant", fields: [representedByMeetingParticipantId], references: [id])
  user                              User?                       @relation("MeetingParticipant_userToUser", fields: [userId], references: [id])
  meetingParticipantsRepresenting   MeetingParticipant[]        @relation("MeetingParticipantToMeetingParticipant_representedByMeetingParticipant")
  activities                        MeetingActivity[]
  properties                        Property[]                  @relation("MeetingParticipantProperties")
  meetingParticipantUnits           MeetingParticipantUnit[]
  polls                             Poll[]
  pollQuestionAnswers               PollQuestionAnswer[]
  users                             User[]                      @relation("MeetingParticipantUsers")
}

model MeetingParticipantUnit {
  id                  String               @default(cuid()) @id
  createdAt           DateTime             @default(now())
  updatedAt           DateTime             @updatedAt
  propertyId          String?
  meetingId           String?
  meeting             Meeting?             @relation(fields: [meetingId], references: [id])
  property            Property?            @relation(fields: [propertyId], references: [id])
  meetingParticipants MeetingParticipant[]
}

model Note {
  id          String        @default(cuid()) @id
  createdAt   DateTime      @default(now())
  updatedAt   DateTime      @updatedAt
  title       String?
  description String?
  status      String?
  projectId   String?
  project     Project?      @relation(fields: [projectId], references: [id])
  comments    NoteComment[] @relation("NoteCommentsOfNote")
  properties  Property[]    @relation("NotesOfProperty")
  users       User[]        @relation("NotesOfUser")
}

model NoteComment {
  id          String   @default(cuid()) @id
  createdAt   DateTime @default(now())
  updatedAt   DateTime @updatedAt
  text        String?
  createdById String?
  createdBy   User?    @relation(fields: [createdById], references: [id])
  notes       Note[]   @relation("NoteCommentsOfNote")
}

model Notification {
  id                         String             @default(cuid()) @id
  type                       NOTIFICATION_TYPE?
  createdAt                  DateTime           @default(now())
  updatedAt                  DateTime           @updatedAt
  appType                    String?
  title                      String?
  message                    String?
  hasBeenSeen                Boolean? @default(false)
  data                       Json?
  projectId                  String?
  serviceProjectId           String?
  userId                     String?
  subtitle                   String?
  hasBeenSeenAt              DateTime?
  hasBeenSeenByApp           Boolean?
  hasBeenSeenByAppAt         DateTime?
  hasBeenSeenBySMS           Boolean?
  hasBeenSeenBySMSAt         DateTime?
  hasBeenSeenByEmail         Boolean?
  hasBeenSeenByEmailAt       DateTime?
  twilioMessageSid           String?
  delivered                  Boolean?
  deliveredAt                DateTime?
  deliveredByApp             Boolean?
  deliveredByAppAt           DateTime?
  deliveredByEmail           Boolean?
  deliveredByEmailAt         DateTime?
  deliveredBySMS             Boolean?
  deliveredBySMSAt           DateTime?
  postId                     String?
  hasBeenSeenByWeb           Boolean?
  hasBeenSeenByWebAt         DateTime?
  sent                       Boolean?
  sentAt                     DateTime?
  sentByApp                  Boolean?
  sentByAppAt                DateTime?
  sentByEmail                Boolean?
  sentByEmailAt              DateTime?
  sentBySMS                  Boolean?
  sentBySMSAt                DateTime?
  eventId                    String?
  firstReminderSent          Boolean?
  firstReminderSentAt        DateTime?
  firstReminderSentByApp     Boolean?
  firstReminderSentByAppAt   DateTime?
  firstReminderSentByEmail   Boolean?
  firstReminderSentByEmailAt DateTime?
  firstReminderSentBySMS     Boolean?
  firstReminderSentBySMSAt   DateTime?
  hasBeenOpenedByApp         Boolean?
  hasBeenOpenedByAppAt       DateTime?
  deliveryErrorMessageApp    String?
  deliveryErrorMessageEmail  String?
  deliveryErrorMessageSMS    String?
  errorMessage               String?
  forceSend                  Boolean?
  noApp                      Boolean?
  noEmail                    Boolean?
  noSMS                      Boolean?
  forceEmail                 Boolean?
  forceApp                   Boolean?
  forceSMS                   Boolean?
  sentByAppErrorMessage      String?
  sentByEmailErrorMessage    String?
  sentBySMSErrorMessage      String?
  sentErrorMessage           String?
  forceSendMessage           String?
  event                      Event?             @relation(fields: [eventId], references: [id])
  post                       Post?              @relation(fields: [postId], references: [id])
  project                    Project?           @relation(fields: [projectId], references: [id])
  serviceProject             ServiceProject?    @relation(fields: [serviceProjectId], references: [id])
  user                       User?              @relation(fields: [userId], references: [id])
}

model NotificationPreference {
  id        String                          @default(cuid()) @id
  type      NOTIFICATION_TYPE?
  platform  NOTIFICATION_DELIVERY_PLATFORM?
  createdAt DateTime                        @default(now())
  updatedAt DateTime                        @updatedAt
  isEnable  Boolean?
  users     User[]
}

model Offense {
  id                        String          @default(cuid()) @id
  status                    OFFENSE_STATUS? @default(SENT)
  createdAt                 DateTime        @default(now())
  updatedAt                 DateTime        @updatedAt
  description               String?
  message                   String?
  isSent                    Boolean?
  propertyId                String?
  ruleId                    String?
  projectId                 String?
  pictureId                 String?
  createdById               String?
  sentAt                    DateTime?
  openAt                    Boolean?
  isDraft                   Boolean?
  createdBy                 User?           @relation(fields: [createdById], references: [id])
  picture                   Picture?        @relation(fields: [pictureId], references: [id])
  project                   Project?        @relation(fields: [projectId], references: [id])
  property                  Property?       @relation(fields: [propertyId], references: [id])
  rule                      Rule?           @relation(fields: [ruleId], references: [id])
  pictures                  Picture[]       @relation("PicturesOfOffense")
  usersUserReceivedOffenses User[]          @relation("UserReceivedOffenses")
}

model OffenseCategory {
  id                String            @default(cuid()) @id
  createdAt         DateTime          @default(now())
  updatedAt         DateTime          @updatedAt
  title             String
  description       String?
  actionToTake      String?
  managingCompanies ManagingCompany[] @relation("OffenseCategoriesOfManagingCompany")
}

model Option {
  id                        String           @default(cuid()) @id
  createdAt                 DateTime         @default(now())
  updatedAt                 DateTime         @updatedAt
  title                     String
  titleFr                   String?
  description               String?
  descriptionFr             String?
  price                     Float?
  durationMS                Int?
  recurring                 String?
  recurringType             String?
  isRecurring               Boolean?
  position                  Int?
  isDeleted                 Boolean?
  serviceProjectId          String?
  imageId                   String?
  serviceId                 String?
  timeRequiredAfterOptionMS Int?
  minimumQuantity           Int?
  maximumQuantity           Int?
  inventory                 Int?
  image                     Picture?         @relation(fields: [imageId], references: [id])
  service                   Service?         @relation(fields: [serviceId], references: [id])
  serviceProject            ServiceProject?  @relation(fields: [serviceProjectId], references: [id])
  lineItems                 LineItem[]
  addons                    Addon[]
  categories                OptionCategory[]
}

model OptionCategory {
  id        String   @default(cuid()) @id
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  title     String
  titleFr   String?
  serviceId String?
  isDeleted Boolean? @default(false)
  service   Service? @relation(fields: [serviceId], references: [id])
  options   Option[]
}

model Order {
  id                                   String              @default(cuid()) @id
  status                               ORDER_STATUS        @default(PENDING)
  createdAt                            DateTime            @default(now())
  updatedAt                            DateTime            @updatedAt
  number                               Int?                @unique
  paidAt                               DateTime?
  hasPaymentError                      Boolean?
  subtotalPrice                        Float?
  totalShipping                        Float?
  totalTax                             Float?
  totalPrice                           Float?
  totalDiscounts                       Float?
  isCharged                            Boolean?
  note                                 String?
  ratingComment                        String?
  rating                               Int?
  isAReorder                           Boolean?
  receivedRating                       Boolean? @default(false)
  showedRatingPopup                    Boolean? @default(false)
  sentToPartnerAt                      DateTime?
  lastSendToPartnerDate                DateTime?
  reminderSentToCustomer               Boolean?
  completedThankYouSentToCustomer      Boolean?
  deliveryAddressId                    String?
  serviceProjectId                     String?
  bookingId                            String?
  employeeName                         String?
  employeeEmail                        String?
  employeeMobilePhoneId                String?
  booking                              Booking?            @relation(fields: [bookingId], references: [id])
  deliveryAddress                      Address?            @relation(fields: [deliveryAddressId], references: [id])
  employeeMobilePhone                  Phone?              @relation(fields: [employeeMobilePhoneId], references: [id])
  serviceProject                       ServiceProject?     @relation(fields: [serviceProjectId], references: [id])
  lineItems                            LineItem[]
  additionalServices                   AdditionalService[] @relation("AdditionalServicesOfOrder")
  // subscriptionOrders Order[]             @relation("OrderSubscriptionRootOfOrder") //unsure TO REVIEW
  // Order_B_OrderSubscriptionRootOfOrder Order[]             @relation("OrderSubscriptionRootOfOrder") //unsure TO REVIEW
  // Order_A_OrderSubscriptionsOfOrder    Order[]             @relation("OrderSubscriptionsOfOrder") //unsure TO REVIEW
  // Order_B_OrderSubscriptionsOfOrder    Order[]             @relation("OrderSubscriptionsOfOrder") //unsure TO REVIEW
  subscription                         OrderSubscription[]
  review                               Review[]
  customerId                           String?
  customer                             User? @relation("OrdersOfUser", fields: [customerId], references: [id])
  promoCodes                           PromoCode[]         @relation("PromoCodesOfOrder")
}

model OrderSubscription {
  id        String         @default(cuid()) @id
  createdAt DateTime       @default(now())
  updatedAt DateTime       @updatedAt
  title     String?
  active    Boolean? @default(true)
  orders    Order[]
  type      RECURRING_TYPE
}

model Package {
  id                     String          @default(cuid()) @id
  status                 PACKAGE_STATUS? @default(AT_RECEPTION)
  createdAt              DateTime        @default(now())
  updatedAt              DateTime        @updatedAt
  title                  String?
  description            String?
  projectId              String?
  clientId               String?
  trackingNumber         String?
  isDraft                Boolean?
  deliveredAt            DateTime?
  client                 User?           @relation(fields: [clientId], references: [id])
  project                Project?        @relation(fields: [projectId], references: [id])
  picturesPackage        Picture[]
  imageId String?
  image Picture?       @relation("ImageOfPackage", fields: [imageId], references: [id])
  signatureImageId String?
  signatureImage Picture? @relation("SignatureImageOfPackage", fields: [signatureImageId], references: [id])
  seenBy                 User[]          @relation("UsersThatSeenPackage")
}

model Parking {
  id                 String     @default(cuid()) @id
  createdAt          DateTime   @default(now())
  updatedAt          DateTime   @updatedAt
  number             String
  projectId          String?
  cadastreNumber     String?
  proportionateShare Float?
  project            Project?   @relation(fields: [projectId], references: [id])
  properties         Property[] @relation("ParkingsOfProperties")
  owners             User[]     @relation("ParkingsOfUser")
  segments           Segment[]
}

model Payment {
  id              String          @default(cuid()) @id
  status          PAYMENT_STATUS? @default(PENDING)
  createdAt       DateTime        @default(now())
  updatedAt       DateTime        @updatedAt
  stripePaymentId String?
  amount          Float
  isDeposit       Boolean?
  customerId      String?
  createdById     String?
  currency        String
  taxes           Float?
  processingFee   Float?
  walterFee       Float?
  total           Float?
  paymentMethodId String?
  createdBy       User?           @relation("Payment_createdByToUser", fields: [createdById], references: [id])
  customer        User?           @relation("Payment_customerToUser", fields: [customerId], references: [id])
  paymentMethod   PaymentMethod?  @relation(fields: [paymentMethodId], references: [id])
  reservations    Reservation[]
}

model PaymentAccount {
  id                   String           @default(cuid()) @id
  paySafePaymentToken  String?
  EFTAccountNickname   String?
  paySafeBankAccountId String?
  paySafeAddressId     String?
  addressOnFileId      String?
  userId               String?
  addressOnFile        Address?         @relation(fields: [addressOnFileId], references: [id])
  user                 User?            @relation(fields: [userId], references: [id])
  paysafeAccounts      PaysafeAccount[]
}

model PaymentMethod {
  id           String               @default(cuid()) @id
  type         PAYMENT_METHOD_TYPE?
  createdAt    DateTime             @default(now())
  updatedAt    DateTime             @updatedAt
  isSelected   Boolean? @default(true)
  uniqueToken  String?
  stripeCardId String?
  ownerId      String?
  owner        User?                @relation(fields: [ownerId], references: [id])
  payments     Payment[]
  creditCard   CreditCard[]
}

model PaysafeAccount {
  id               String           @default(cuid()) @id
  paySafeProfileId String
  forBuildingId    String?
  forBuilding      Building?        @relation(fields: [forBuildingId], references: [id])
  paymentAccounts  PaymentAccount[]
  users            User[]
}

model PaySafePayment {
  id                String                  @default(cuid()) @id
  status            PAYSAFE_PAYMENT_STATUS?
  paymentForWhat    PAYSAFE_PAYMENT_TYPE[]
  merchantReference String
  paySafePaymentId  String?
  amount            Int
  currency          String
  properties        Property[]
}

model PaySafeRefund {
  id                String                  @default(cuid()) @id
  status            PAYSAFE_PAYMENT_STATUS?
  merchantReference String
  paySafePaymentId  String
  amount            Int
  paySafeRefundId   String?
  properties        Property[]
}

model Phone {
  id                                     String            @default(cuid()) @id
  createdAt                              DateTime          @default(now())
  updatedAt                              DateTime          @updatedAt
  number                                 String
  extension                              String?
  countryCode                            String?
  nationalFormat                         String?
  ads                                    Ad[]
  contacts                               Contact[]
  contactPersons                         ContactPerson[]
  managingCompaniesEmergencyPhoneToPhone ManagingCompany[] @relation("ManagingCompany_emergencyPhoneToPhone")
  managingCompaniesPhoneToPhone          ManagingCompany[] @relation("ManagingCompany_phoneToPhone")
  orders                                 Order[]
  services                               Service[]
  usersHomePhone                         User[]            @relation("PhoneToUser_homePhone")
  usersOfficePhone                       User[]            @relation("PhoneToUser_officePhone")
  usersPhone                             User[]            @relation("PhoneToUser_phone")
  countryCodeSyncStatuses                SyncStatus[]      @relation("CountryCodesSynced")
  extensionSyncStatuses                  SyncStatus[]      @relation("ExtensionsSynced")
  nationalFormatSyncStatuses             SyncStatus[]      @relation("NationalFormatsSynced")
  phoneSyncStatuses                      SyncStatus[]      @relation("NumbersSynced")
}

model Picture {
  id                                         String             @default(cuid()) @id
  createdAt                                  DateTime           @default(now())
  updatedAt                                  DateTime           @updatedAt
  name                                       String?
  url                                        String?
  cloudinaryId                               String?
  format                                     String?
  type                                       String?
  size                                       Int?
  roomModelId                                String?
  HeroImageOfServiceId                       String?
  iconOfServiceId                            String?
  heroImageOfService                         Service?           @relation("Picture_HeroImageOfServiceToService", fields: [HeroImageOfServiceId], references: [id])
  iconOfService                              Service?           @relation("Picture_iconOfServiceToService", fields: [iconOfServiceId], references: [id])
  packageOfSignatureImage                    Package?           @relation("SignatureImageOfPackage")
  roomModel                                  RoomModel?         @relation(fields: [roomModelId], references: [id])
  amenitiesToPicture                         Amenity[]
  contacts                                   Contact[]
  events                                     Event[]
  managingCompaniesEmailHeaderImageToPicture ManagingCompany[]  @relation("ManagingCompany_emailHeaderImageToPicture")
  managingCompaniesLogoToPicture             ManagingCompany[]  @relation("ManagingCompany_logoToPicture")
  managingCompaniesLogoAvatarToPicture       ManagingCompany[]  @relation("ManagingCompany_logoAvatarToPicture")
  offensesToPicture                          Offense[]
  options                                    Option[]
  posts                                      Post[]
  projectsLogo                               Project[]          @relation("PictureToProject_logo")
  projectsSquareLogo                         Project[]          @relation("PictureToProject_squareLogo")
  propertiesLease                            Property[]         @relation("PictureToProperty_lease")
  propertiesPlan                             Property[]         @relation("PictureToProperty_plan")
  servicesBannerLogo                         Service[]          @relation("PictureToService_bannerLogo")
  servicesSquareLogo                         Service[]          @relation("PictureToService_squareLogo")
  users                                      User[]
  ads                                        Ad[]
  projectAppInviteEmailHeader                Project[]          @relation("AppInviteEmailHeaderImageOfProject")
  packageOfImage                     Package?          @relation("ImageOfPackage")
  amenitiesImagesOfAmenity                   Amenity[]          @relation("ImagesOfAmenity")
  managerStoreItems                          ManagerStoreItem[]
  offenses_PicturesOfOffenses                Offense[]          @relation("PicturesOfOffense")
  serviceRequests                            ServiceRequest[]
  tasks                                      Task[]
}

model Poll {
  id                      String               @default(cuid()) @id
  createdAt               DateTime             @default(now())
  updatedAt               DateTime             @updatedAt
  expiryDate              DateTime?
  title                   String?
  question                String?
  zoomPollId              String?
  isLaunched              Boolean? @default(false)
  startedAt               DateTime?
  endedAt                 DateTime?
  posts                   Post[]
  completedByParticipants MeetingParticipant[]
  meetings                Meeting[]
  questions               PollQuestion[]
  completedByUsers        User[]
}

model PollQuestion {
  id              String               @default(cuid()) @id
  type            POLL_TYPE?
  createdAt       DateTime             @default(now())
  updatedAt       DateTime             @updatedAt
  question        String
  answers         PollQuestionAnswer[]  @relation("PollQuestionAnswersOfPollQuestion")
  winningAnswerId String?
  winningAnswer   PollQuestionAnswer? @relation("WinningPollQuestionAnswerOfPollQuestion", fields: [winningAnswerId], references: [id])
  polls           Poll[]
}

model PollQuestionAnswer {
  id                                String               @default(cuid()) @id
  createdAt                         DateTime             @default(now())
  updatedAt                         DateTime             @updatedAt
  hasWon                            Boolean?
  text                              String?
  numberOfVote                      Int? @default(0)
  isWinningAnswerForPollQuestion    PollQuestion? @relation("WinningPollQuestionAnswerOfPollQuestion")
  answeredByMeetingParticipants     MeetingParticipant[]
  associatedPollQuestionId          String?
  associatedPollQuestion            PollQuestion?       @relation("PollQuestionAnswersOfPollQuestion", fields: [associatedPollQuestionId], references: [id])
  answeredBy                        User[]
}

model Post {
  id                      String         @default(cuid()) @id
  createdAt               DateTime       @default(now())
  updatedAt               DateTime       @updatedAt
  title                   String?
  description             String?
  sendAsSMS               Boolean?
  sendAsEmailToNonAppUser Boolean?
  type                    POST_TYPE @default(NORMAL)
  coverImageId            String?
  pollId                  String?
  projectId               String?
  sendPostAt              DateTime?
  postSentAt              DateTime?
  assemblyDate            DateTime?
  assemblyLocation        String?
  assemblyTime            String?
  isDraft                 Boolean? @default(false)
  sendAsAPP               Boolean? @default(true)
  sendAsEmail             Boolean?
  coverImage              Picture?       @relation(fields: [coverImageId], references: [id])
  poll                    Poll?          @relation(fields: [pollId], references: [id])
  project                 Project?       @relation(fields: [projectId], references: [id])
  notifications           Notification[]
  audience                User[]         @relation("AudienceOfPost")
  attachments             File[]
  seenBy                  User[]         @relation("PostsSeenByUser")
  signedProxies           Proxy[]
  segments                Segment[]
}

model Project {
  id                                               String                  @default(cuid()) @id
  tools                                            TOOL_TYPE[]
  createdAt                                        DateTime                @default(now())
  updatedAt                                        DateTime                @updatedAt
  key                                              String?                 @unique
  isDeleted                                        Boolean?
  active                                           Boolean? @default(true)
  name                                             String
  colorHex                                         String? @default("#000000")
  additionalInfo                                   String?
  hasSecurityAgent                                 Boolean?
  hasGuessRegistration                             Boolean?
  hasFobAccess                                     Boolean?
  hasRestaurant                                    Boolean?
  hasGym                                           Boolean?
  hasShowerInGym                                   Boolean?
  hasLockerChangingRoom                            Boolean?
  hasGuessRoom                                     Boolean?
  hasPartyRoom                                     Boolean?
  allowDog                                         Boolean?
  needDogInArmInCommonArea                         Boolean?
  hasAccessForDog                                  Boolean?
  accessForDogInfo                                 String?
  hasParkingForWorker                              Boolean?
  parkingForWorkerInfo                             String?
  hasParkingForGuess                               Boolean?
  parkingForGuessInfo                              String?
  hasValet                                         Boolean?
  hasCarWash                                       Boolean?
  carWashInfo                                      String?
  hasResidentLockers                               Boolean?
  hasResidentParkings                              Boolean?
  residentCanEditUnits                             Boolean?
  residentCanEditLockers                           Boolean?
  residentCanEditParkings                          Boolean?
  residentCanEditAccessKeys                        Boolean?
  residentCanEditRemotes                           Boolean?
  remotePrice                                      Float?
  accessKeyPrice                                   Float?
  isInConstruction                                 Boolean?
  condoManagerId                                   String?
  needAdApproval                                   Boolean?
  coOwnershipDeclarationId                         String?
  logoId                                           String?
  numberOfProperties                               Int?
  hasSyncedWithCondoManager                        Boolean?
  hubspotCompanyId                                 Int?
  isLaunched                                       Boolean? @default(false)
  paySafeMerchantAccountId                         String?
  paySafeRefundPin                                 String?
  condoFeeEFTBillDay                               Int?
  lastDataSyncDate                                 DateTime?
  lastCondoManagerDataPushDate                     DateTime?
  privateColor                                     String?
  residentCanCreateUnits                           Boolean?
  residentCanCreateLockers                         Boolean?
  residentCanCreateParkings                        Boolean?
  residentCanCreateAccessKeys                      Boolean?
  residentCanCreateRemotes                         Boolean?
  isCondoProject                                   Boolean?
  isRentalProject                                  Boolean?
  squareLogoId                                     String?
  nameInitials                                     String?
  newTenantsNeedApproval                           Boolean?
  newFamilyMembersNeedApproval                     Boolean?
  newOwnersNeedApproval                            Boolean? @default(true)
  stripeAccountId                                  String?
  stripeAccountAccessToken                         String?
  automaticallyInviteResidentCreatedFromThirdParty Boolean?
  launchDate                                       DateTime?
  residentCanCreateTask                            Boolean?
  residentCanEditEmail                             Boolean?
  residentCanEditPhoneNumber                       Boolean?
  residentCanEditFirstName                         Boolean?
  residentCanEditLastName                          Boolean?
  newAdNeedApproval                                Boolean? @default(false)
  coOwnershipDeclaration                           File?                   @relation(fields: [coOwnershipDeclarationId], references: [id])
  logo                                             Picture?                @relation("PictureToProject_logo", fields: [logoId], references: [id])
  squareLogo                                       Picture?                @relation("PictureToProject_squareLogo", fields: [squareLogoId], references: [id])
  accessKeys                                       AccessKey[]
  ads                                              Ad[]
  amenities                                        Amenity[]
  amenityBookingOptions                            AmenityBookingOption[]
  condoManagerComptes                              CondoManagerCompte[]
  contactsLinked                                   Contact[] @relation("ContactsOfProjects")
  events                                           Event[]
  folders                                          Folder[]
  lockers                                          Locker[]
  managerStoreOrders                               ManagerStoreOrder[]
  meetings                                         Meeting[]
  notes                                            Note[]
  notifications                                    Notification[]
  offenses                                         Offense[]
  packages                                         Package[]
  parkings                                         Parking[]
  posts                                            Post[]
  servicesAvailable                                SERVICE_TYPE[]
  remotes                                          Remote[]
  reservations                                     Reservation[]
  rules2                                           Rule[] //unsure TO REVIEW
  segments                                         Segment[]
  serviceProjects                                  ServiceProject[]
  serviceRequests                                  ServiceRequest[]
  syncStatuses                                     SyncStatus[]
  tasks                                            Task[]
  unitRooms                                        UnitRoom[]
  currentUsers                                     User[]
  activeUsersForProject                            User[]                  @relation("ActiveUsersForProject")
  pictureId                                        String?
  appInviteEmailHeaderImage                        Picture?               @relation("AppInviteEmailHeaderImageOfProject", fields: [pictureId], references: [id])
  boardMembers                                     User[]                  @relation("BoardMembersOfProject")
  buildingId                                        String?
  building                                         Building?               @relation("BuildingOfProject", fields: [buildingId], references: [id])
  buildings                                         Building[]             @relation("BuildingsOfProject", fields: [buildingId], references: [id])
  contactPersons                                   ContactPerson[]         @relation("ContactPersonsOfProject")
  contacts                                         Contact[]               @relation("ContactsOfProject")
  managerStoreItems                                ManagerStoreItem[]
  managingCompanyId                                 String?
  managingCompany                                  ManagingCompany?       @relation("ManagingCompanyOfProject", fields: [managingCompanyId], references: [id])
  managingCompanyRoles                             ManagingCompanyRole[]
  thirdPartyServiceSettings                        MappedServiceSetting[]
  thirdPartyServices                               MappedService[]
  previousProjectsOfUser                           User[]                  @relation("PreviousProjectsOfUser")
  managers                                         User[]                  @relation("ProjectsThatUserManage")
  rules                                            Rule[]                  @relation("RulesOfProjects")
  amenityId                                       String?            
  sharedAmenities                                  Amenity[]               @relation("SharedProjectsOfAmenity", fields: [amenityId], references: [id])
  tenantUsersForProject                            User[]                  @relation("TenantUsersForProject")
  users                                            User[]                  @relation("UsersInProject")
}

model PromoCode {
  id                      String   @default(cuid()) @id
  createdAt               DateTime @default(now())
  updatedAt               DateTime @updatedAt
  title                   String   @unique
  description             String?
  value                   Float?
  isFromWalter            Boolean?
  isPercentage            Boolean?
  isOneTimeUsePerCustomer Boolean?
  isOneTimeUse            Boolean?
  canBeUse                Boolean? @default(true)
  order                   Order[]  @relation("PromoCodesOfOrder")
}

model Property {
  id                                                   String                   @default(cuid()) @id
  createdAt                                            DateTime                 @default(now())
  updatedAt                                            DateTime                 @updatedAt
  accessKey                                            String?
  intercomCode                                         String?
  parking                                              String?
  locker                                               String?
  remote                                               String?
  hasDog                                               Boolean?
  rentAmount                                           Float?
  rentStart                                            DateTime?
  rentEnd                                              DateTime?
  buzzCode                                             String?
  garageRemote                                         String?
  floor                                                String?
  squareFeet                                           Float?
  squareFeetBalcony                                    Float?
  type                                                 String?
  percentageSquareFootage                              Float?
  residentCanEditRoomsModels                           Boolean? @default(true)
  planId                                               String?
  addressId                                            String?
  buildingId                                           String?
  leaseId                                              String?
  rooms                                                String?
  wifiPassword                                         String?
  condoManagerNoCompteReel                             String?
  copropertyDueAmount                                  Float?
  hasAlarmSystem                                       Boolean?
  currentlyPaysCondoFeesViaEFT                         Boolean @default(false)
  condoFeeEFTPaymentsPausedDueToPriceChange            Boolean @default(false)
  usingPaymentAccountId                                String?
  monthlyCondoFeeAmount                                Float?
  note                                                 String?
  proportionateShare                                   Float?
  referencePropertyId                                  String?
  address                                              Address?                 @relation(fields: [addressId], references: [id])
  building                                             Building?                @relation(fields: [buildingId], references: [id])
  lease                                                Picture?                 @relation("PictureToProperty_lease", fields: [leaseId], references: [id])
  plan                                                 Picture?                 @relation("PictureToProperty_plan", fields: [planId], references: [id])
  referenceProperty                                    File?                    @relation(fields: [referencePropertyId], references: [id])
  accessKeys                                           AccessKey[]
  accountStatements                                    AccountStatement[]
  cars                                                 Car[]
  meetingParticipantsIsRepresentedByPropertyToProperty MeetingParticipant[]     @relation("MeetingParticipant_isRepresentedByPropertyToProperty")
  meetingParticipantsPropertyToProperty                MeetingParticipant[]     @relation("MeetingParticipant_propertyToProperty")
  meetingParticipantUnit                               MeetingParticipantUnit[]
  receivedOffenses                                     Offense[]
  proxies                                              Proxy[]
  remotes                                              Remote[]
  serviceRequests                                      ServiceRequest[]
  tasks                                                Task[]
  users                                                User[]
  annexes                                              File[]                   @relation("AnnexesOfProperty")
  chosenModels                                         ChosenModel[]
  issues                                               Issue[]
  lockers                                              Locker[]                 @relation("LockersOfProperties")
  meetingParticipantsProperties                        MeetingParticipant[]     @relation("MeetingParticipantProperties")
  notes                                                Note[]                   @relation("NotesOfProperty")
  owners                                               User[]                   @relation("OwnersOfProperty")
  parkings                                             Parking[]                @relation("ParkingsOfProperties")
  EFTPayments                                          PaySafePayment[]
  EFTRefunds                                           PaySafeRefund[]
  previousOwners                                       User[]                   @relation("PreviousOwnersOfProperty")
  previousUsers                                        User[]                   @relation("PreviousUsersOfProperty")
  segments                                             Segment[]
  tenants                                              User[]                   @relation("TenantsOfProperty")
}

model Proxy {
  id                  String               @default(cuid()) @id
  createdAt           DateTime             @default(now())
  updatedAt           DateTime             @updatedAt
  representativeName  String?
  pdfId               String?
  propertyId          String?
  signeeId            String?
  pdf                 File?                @relation(fields: [pdfId], references: [id])
  property            Property?            @relation(fields: [propertyId], references: [id])
  signee              User?                @relation(fields: [signeeId], references: [id])
  meetingParticipants MeetingParticipant[]
  posts               Post[]
}

model Reminder {
  id        String    @default(cuid()) @id
  createdAt DateTime  @default(now())
  updatedAt DateTime  @updatedAt
  title     String?
  subtitle  String?
  message   String?
  sendAt    DateTime?
}

model Remote {
  id         String    @default(cuid()) @id
  createdAt  DateTime  @default(now())
  updatedAt  DateTime  @updatedAt
  number     String
  projectId  String?
  propertyId String?
  project    Project?  @relation(fields: [projectId], references: [id])
  property   Property? @relation(fields: [propertyId], references: [id])
  owners     User[]    @relation("RemotesOfUser")
}

//unsure TO REVIEW
// model Report {
//   id           String         @default(cuid()) @id
//   section      REPORT_SECTION?
//   createdAt DateTime @default(now())
//   updatedAt DateTime @updatedAt
//   name         String
//   description  String?
//   section      String?
//   filters      ReportFilter[]
// }

// model ReportFilter {
//   id        String   @default(cuid()) @id
//   createdAt DateTime @default(now())
//   updatedAt DateTime @updatedAt
//   order     Int
//   path      String
//   value     String
//   reports   Report[]
// }

model Reservation {
  id                String             @default(cuid()) @id
  status            RESERVATION_STATUS @default(PENDING)
  createdAt         DateTime           @default(now())
  updatedAt         DateTime           @updatedAt
  start             DateTime
  end               DateTime?
  durationDays      Int?
  durationMS        Int?
  amenityId         String?
  customerId        String?
  addressId         String?
  projectId         String?
  note              String?
  numberOfResidents Int?
  address           Address?           @relation(fields: [addressId], references: [id])
  amenity           Amenity?           @relation(fields: [amenityId], references: [id])
  customer          User?              @relation(fields: [customerId], references: [id])
  project           Project?           @relation(fields: [projectId], references: [id])
  payments          Payment[]
}

model Review {
  id               String          @default(cuid()) @id
  createdAt        DateTime        @default(now())
  updatedAt        DateTime        @updatedAt
  numberOfStars    Int?
  comment          String?
  serviceProjectId String?
  serviceProject   ServiceProject? @relation(fields: [serviceProjectId], references: [id])
  orderId          String?
  order            Order? @relation(fields: [orderId], references: [id])
}

model RoomModel {
  id           String        @default(cuid()) @id
  createdAt    DateTime      @default(now())
  updatedAt    DateTime      @updatedAt
  title        String?
  description  String?
  price        Float?
  unitRoomId   String?
  unitRoom     UnitRoom?     @relation(fields: [unitRoomId], references: [id])
  chosenModels ChosenModel[]
  images       Picture[]
}

model Rule {
  id          String    @default(cuid()) @id
  createdAt   DateTime  @default(now())
  updatedAt   DateTime  @updatedAt
  title       String
  description String?
  category    String?
  projectId   String?
  isDeleted   Boolean? @default(false)
  project     Project?  @relation(fields: [projectId], references: [id])
  offenses    Offense[]
  attachments File[]
  projects    Project[] @relation("RulesOfProjects")
  seenBy      User[]
}

model Segment {
  id                    String                  @default(cuid()) @id
  createdAt             DateTime                @default(now())
  updatedAt             DateTime                @updatedAt
  title                 String?
  description           String?
  projectId             String?
  isDeleted             Boolean? @default(false)
  project               Project?                @relation(fields: [projectId], references: [id])
  folders               Folder[]                @relation("SegmentsOfFolder")
  amenityBookingOptions AmenityBookingOption[]
  conditions            Condition[]
  events                Event[]
  lockers               Locker[]
  parkings              Parking[]
  posts                 Post[]
  properties            Property[]
  segmentFields         SegmentField[]
  users                 User[]
}

model SegmentField {
  id         String           @default(cuid()) @id
  model      MODEL
  comparison COMPARISON_VALUE
  createdAt  DateTime         @default(now())
  updatedAt  DateTime         @updatedAt
  path       String
  value      String
  segments   Segment[]
}

model Service {
  id                                        String           @default(cuid()) @id
  type                                      SERVICE_TYPE
  createdAt                                 DateTime         @default(now())
  updatedAt                                 DateTime         @updatedAt
  businessName                              String?
  GST                                       String?
  PST                                       String?
  identificationNumber                      Int?
  walterPourcentage                         Float?
  homeScreenPosition                        Int?
  canAddMultipleOptions                     Boolean?
  durationMS                                Int?
  maxDateBookingDaysFromNow                 Int?
  isOffline                                 Boolean? @default(true)
  addressId                                 String?
  phoneId                                   String?
  maximumUsageTime                          Int?
  acceptedTermsAndConditions                Boolean?
  email                                     String?
  minimumSpendPerOrder                      Float?
  bookingInAdvanceMinSeconds                Int?
  bookingInAdvanceMaxSeconds                Int?
  hasSpecificBooking                        Boolean?
  shippingFees                              Float?
  timeRequiredBetweenEachBookingSeconds     Int?
  allowMultipleBookings                     Boolean?
  squareLogoId                              String?
  bannerLogoId                              String?
  stripeAccountId                           String?
  stripeAccountAccessToken                  String?
  isApproved                                Boolean? @default(true)
  businessBio                               String?
  businessDescription                       String?
  businessBioFr                             String?
  businessDescriptionFr                     String?
  deliveryFees                              Float?
  timeRequiredBetweenEachBookingMS          Int?
  comingSoon                                Boolean? @default(false)
  appPosition                               Int?
  hasPickup                                 Boolean? @default(false)
  bookingInAdvanceMinSecondsForPickup       Int?
  bookingInAdvanceMaxSecondsForPickup       Int?
  allowMultipleBookingsForPickup            Boolean?
  hasSpecificBookingForPickup               Boolean?
  timeRequiredBetweenEachBookingMSForPickup Int?
  hasDelivery                               Boolean? @default(true)
  chargeTaxes                               Boolean? @default(true)
  address                                   Address?         @relation(fields: [addressId], references: [id])
  bannerLogo                                Picture?         @relation("PictureToService_bannerLogo", fields: [bannerLogoId], references: [id])
  phone                                     Phone?           @relation(fields: [phoneId], references: [id])
  squareLogo                                Picture?         @relation("PictureToService_squareLogo", fields: [squareLogoId], references: [id])
  invoices                                  Invoice[]
  options                                   Option[]
  categories                                OptionCategory[]
  picturesHeroImageOfServiceToService       Picture[]        @relation("Picture_HeroImageOfServiceToService")
  picturesIconOfServiceToService            Picture[]        @relation("Picture_iconOfServiceToService")
  serviceProjects                           ServiceProject[]
  users                                     User[]
  businessHours                             BusinessHour[]  @relation("BusinessHoursOfService")
  contactPersons                            ContactPerson[]
  owner                                     User[]           @relation("OwnerOfService")
  pickupHours                               BusinessHour[]  @relation("PickupHoursOfService")
  frequentlyAskedQuestions                  FaqItem[]
  shippingLines                             ShippingLine[]
  taxLines                                  Tax[]
  specialDates                              BusinessHour[]  @relation("SpecialDatesOfService")
}

model ServiceProject {
  id                   String          @default(cuid()) @id
  createdAt            DateTime        @default(now())
  updatedAt            DateTime        @updatedAt
  minHoursBooking      Int?
  totalRating          Float? @default(5)
  numberOfRating       Int? @default(0)
  hasSpecificBooking   Boolean?
  receiveOrderBySMS    Boolean?
  receiveOrderByEmail  Boolean?
  projectId            String?
  serviceId            String?
  shippingFees         Float?
  minimumSpendPerOrder Float?
  project              Project?        @relation(fields: [projectId], references: [id])
  service              Service?        @relation(fields: [serviceId], references: [id])
  businessHours        BusinessHour[] @relation("BusinessHours_serviceProjectBusinessHoursToServiceProject")
  specialDates         BusinessHour[] @relation("BusinessHours_serviceProjectSpecialDateToServiceProject")
  notifications        Notification[]
  options              Option[]
  orders               Order[]
  reviews              Review[]
}

model ServiceRequest {
  id                     String                  @default(cuid()) @id
  status                 SERVICE_REQUEST_STATUS? @default(PENDING_APPROVAL)
  createdAt              DateTime                @default(now())
  updatedAt              DateTime                @updatedAt
  category               String?
  description            String?
  isCommonArea           Boolean?
  propertyId             String?
  projectId              String?
  createdById            String?
  residentWantsToBeThere Boolean?
  priorityId             String?
  associatedToId         String?
  assignedToId           String?
  isDraft                Boolean?
  identificationNumber   String?
  assignedTo             User?                   @relation("ServiceRequest_assignedToToUser", fields: [assignedToId], references: [id])
  associatedTo           User?                   @relation("ServiceRequest_associatedToToUser", fields: [associatedToId], references: [id])
  createdBy              User?                   @relation("ServiceRequest_createdByToUser", fields: [createdById], references: [id])
  priority               ServiceRequestPriority? @relation(fields: [priorityId], references: [id])
  project                Project?                @relation(fields: [projectId], references: [id])
  property               Property?               @relation(fields: [propertyId], references: [id])
  comments               Comment[]
  pictures               Picture[]
  seenBy                 User[]                  @relation("ServiceRequestsSeenByUser")
}

model ServiceRequestCategory {
  id           String   @default(cuid()) @id
  createdAt    DateTime @default(now())
  updatedAt    DateTime @updatedAt
  category     String?
  description  String?
  isFromWalter Boolean? @default(false)
}

model ServiceRequestPriority {
  id                String            @default(cuid()) @id
  createdAt         DateTime          @default(now())
  updatedAt         DateTime          @updatedAt
  title             String?
  description       String?
  color             String?
  isFromWalter      Boolean? @default(false)
  serviceRequests   ServiceRequest[]
  managingCompanies ManagingCompany[] @relation("ServiceRequestPrioritiesOfManagingCompany")
}

model ShippingLine {
  id        String    @default(cuid()) @id
  createdAt DateTime  @default(now())
  updatedAt DateTime  @updatedAt
  code      String?
  price     Float
  source    String?
  title     String?
  services  Service[]
  taxLines  Tax[]
}

model SyncStatus {
  id                                       String                  @default(cuid()) @id
  status                                   THIRD_PARTY_SYNC_STATUS
  overwriteWalterConfirmed                 Boolean
  overwriteThirdPartyServiceConfirmed      Boolean
  dataToConfirm                            String?
  lastSeenPrismaValue                      String?
  mappingId                                  String?
  projectId                                  String?
  mapping                                  Mapping?                @relation(fields: [mappingId], references: [id])
  project                                  Project?                @relation(fields: [projectId], references: [id])
  addressesSyncAddress1                    Address[]               @relation("AddressSyncAddress1")
  addressesSyncApartmentNumber             Address[]               @relation("AddressSyncApartmentNumber")
  addressesSyncCity                        Address[]               @relation("AddressSyncCity")
  addressesSyncCountry                     Address[]               @relation("AddressSyncCountry")
  addressesSyncCountryCode                 Address[]               @relation("AddressSyncCountryCode")
  addressesSyncProvinceCode                Address[]               @relation("AddressSyncProvinceCode")
  addressesSyncState                       Address[]               @relation("AddressSyncState")
  addressesSyncZip                         Address[]               @relation("AddressSyncZip")
  usersCondoManagerCompteUserNumbersSynced User[]                  @relation("CondoManagerCompteUserNumbersSynced")
  usersCondoManagerNoCompteReelsSynced     User[]                  @relation("CondoManagerNoCompteReelsSynced")
  phonesCountryCodesSynced                 Phone[]                 @relation("CountryCodesSynced")
  usersEmailsSynced                        User[]                  @relation("EmailsSynced")
  phonesExtensionsSynced                   Phone[]                 @relation("ExtensionsSynced")
  usersFirstNamesSynced                    User[]                  @relation("FirstNamesSynced")
  usersIsResidentSynced                    User[]                  @relation("IsResidentSynced")
  usersLastNamesSynced                     User[]                  @relation("LastNamesSynced")
  phonesNationalFormatsSynced              Phone[]                 @relation("NationalFormatsSynced")
  phonesNumbersSynced                      Phone[]                 @relation("NumbersSynced")
}

model Task {
  id                    String         @default(cuid()) @id
  createdAt             DateTime       @default(now())
  updatedAt             DateTime       @updatedAt
  identificationNumber  String?
  title                 String?
  description           String?
  categoryId            String?
  assignedToId          String?
  statusId              String?
  associatedPropertyId  String?
  associatedResidentId  String?
  associatedProjectId   String?
  createdById           String?
  isArchived            Boolean? @default(false)
  movedToCompleteListAt DateTime?
  assignedTo            User?          @relation("Task_assignedToToUser", fields: [assignedToId], references: [id])
  associatedProject     Project?       @relation(fields: [associatedProjectId], references: [id])
  associatedProperty    Property?      @relation(fields: [associatedPropertyId], references: [id])
  associatedResident    User?          @relation("Task_associatedResidentToUser", fields: [associatedResidentId], references: [id])
  category              TaskCategory?  @relation(fields: [categoryId], references: [id])
  createdBy             User?          @relation("Task_createdByToUser", fields: [createdById], references: [id])
  status                TaskStatus?    @relation(fields: [statusId], references: [id])
  comments              Comment[]
  activities            TaskActivity[]
  customFields          CustomField[]
  attachments           File[]
  pictures              Picture[]
  collaborators         User[]         @relation("TaskCollaborators")
}

model TaskActivity {
  id          String   @default(cuid()) @id
  createdAt   DateTime @default(now())
  updatedAt   DateTime @updatedAt
  text        String?
  createdById String?
  taskId      String?
  createdBy   User?    @relation(fields: [createdById], references: [id])
  task        Task?    @relation(fields: [taskId], references: [id])
}

model TaskCategory {
  id                String           @default(cuid()) @id
  createdAt         DateTime         @default(now())
  updatedAt         DateTime         @updatedAt
  title             String
  description       String?
  managingCompanyId String?
  managingCompany   ManagingCompany? @relation(fields: [managingCompanyId], references: [id])
  tasks             Task[]
}

model TaskStatus {
  id                String           @default(cuid()) @id
  createdAt         DateTime         @default(now())
  updatedAt         DateTime         @updatedAt
  title             String
  description       String?
  color             String?
  actAsComplete     Boolean? @default(false)
  managingCompanyId String?
  orderPosition     Int?
  managingCompany   ManagingCompany? @relation(fields: [managingCompanyId], references: [id])
  tasks             Task[]
}

model Tax {
  id            String         @default(cuid()) @id
  createdAt     DateTime       @default(now())
  updatedAt     DateTime       @updatedAt
  price         Float
  rate          Float
  title         String?
  services      Service[]
  shippingLines ShippingLine[]
}

model ThirdPartyVersion {
  id            String  @default(cuid()) @id
  friendlyName  String?
  versionNumber String?
}

model UnitRoom {
  id           String        @default(cuid()) @id
  createdAt    DateTime      @default(now())
  updatedAt    DateTime      @updatedAt
  title        String?
  description  String?
  projectId    String?
  project      Project?      @relation(fields: [projectId], references: [id])
  chosenModels ChosenModel[]
  roomModels   RoomModel[]
}

model User {
  id                                       String                           @default(cuid()) @id
  role                                     USER_ROLE                        @default(RESIDENT)
  cantDeliverEmailReason                   CANT_DELIVER_EMAIL_REASON?
  signedInPlatform                         PLATFORM?
  createdAt                                DateTime                         @default(now())
  updatedAt                                DateTime                         @updatedAt
  email                                    String?
  title                                    String?
  username                                 String?
  birthday                                 DateTime?
  secondaryEmail                           String? @default("")
  fullname                                 String? @default("")
  firstName                                String? @default("")
  lastName                                 String?
  cantDeliverSMS                           Boolean?
  cantDeliverEmail                         Boolean?
  hasAppNotificationEnable                 Boolean? @default(true)
  hasEmailNotificationEnable               Boolean? @default(true)
  hasSMSNotificationEnable                 Boolean? @default(false)
  currentAppVersion                        String?
  password                                 String?
  hasResetPassword                         Boolean?
  resetPasswordToken                       String?
  expoNotificationToken                    String?
  notificationToken                        String?
  signedInAt                               DateTime?
  condoManagerNoCompteReel                 String?
  condoManagerCompteUserNumber             Int?
  appNotificationsBadgesNumber             Int? @default(0)
  isSignedOut                              Boolean?
  appLoginCode                             String?
  hasReceivedOnboarding                    Boolean?
  hasReceivedInvitation                    Boolean?
  hasInstalledApp                          Boolean?
  hasInstalledDesktop                      Boolean?
  hasUninstalledApp                        Boolean?
  hasDog                                   Boolean?
  stripeCustomerId                         String?
  operatingSystem                          String?
  emergencyContact                         String?
  preferedLanguage                         String?
  active                                   Boolean? @default(true)
  isResident                               Boolean?
  homePhoneId                              String?
  officePhoneId                            String?
  phoneId                                  String?
  serviceProviderId                        String?
  avatarId                                 String?
  managingCompanyRoleId                    String?
  managingCompanyId                        String?
  addressId                                String?
  propertyId                               String?
  copropertyDueAmount                      Float?
  hasPaymentError                          Boolean?
  oneSignalUserId                          String?
  isTenant                                 Boolean?
  hasReceivedInvitationAt                  DateTime?
  hasReceivedInvitationByEmail             Boolean?
  hasReceivedInvitationByEmailAt           DateTime?
  hasOpenedEmailInvitation                 Boolean?
  hasOpenedEmailInvitationAt               DateTime?
  hasClickedOnCTAInEmailInvitation         Boolean?
  hasClickedOnCTAInEmailInvitationAt       DateTime?
  hasReceivedInvitationBySMS               Boolean?
  hasReceivedInvitationBySMSAt             DateTime?
  hasRegisterAt                            DateTime?
  waitingForApproval                       Boolean?
  createdById                              String?
  signedInPlatformId                       String?
  hasReceivedSecondInvitation              Boolean?
  hasReceivedSecondInvitationAt            DateTime?
  hasReceivedSecondInvitationByEmail       Boolean?
  hasReceivedSecondInvitationByEmailAt     DateTime?
  hasReceivedSecondInvitationBySMS         Boolean?
  hasReceivedSecondInvitationBySMSAt       DateTime?
  hasPrivateChat                           Boolean?
  condoManagerId                           String?
  hasAlarmSystem                           Boolean?
  managingCompanyName                      String?
  hasOpenedSecondEmailInvitation           Boolean?
  hasOpenedSecondEmailInvitationAt         DateTime?
  hasClickedOnCTAInSecondEmailInvitation   Boolean?
  hasClickedOnCTAInSecondEmailInvitationAt DateTime?
  hasConfirmedEmail                        Boolean?                     @default(false)
  hasConfirmedEmailAt                      DateTime?
  confirmEmailToken                        String?
  hasConfirmedPhone                        Boolean?                     @default(false)
  hasConfirmedPhoneAt                      DateTime?
  hasConfirmedBasicInformations            Boolean?                     @default(false)
  condoManagerNomCompte                    String?
  currentProjectId                         String?
  note                                     String?
  sendOnPressEnter                         Boolean?
  cantDeliverEmailFullReason               String?
  address                                  Address?                         @relation(fields: [addressId], references: [id])
  avatar                                   Picture?                         @relation(fields: [avatarId], references: [id])
  createdBy                                User?                            @relation("UserToUser_createdBy", fields: [createdById], references: [id])
  currentProject                           Project?                         @relation(fields: [currentProjectId], references: [id])
  homePhone                                Phone?                           @relation("PhoneToUser_homePhone", fields: [homePhoneId], references: [id])
  managingCompany                          ManagingCompany?                 @relation(fields: [managingCompanyId], references: [id])
  managingCompanyRole                      ManagingCompanyRole?             @relation(fields: [managingCompanyRoleId], references: [id])
  officePhone                              Phone?                           @relation("PhoneToUser_officePhone", fields: [officePhoneId], references: [id])
  phone                                    Phone?                           @relation("PhoneToUser_phone", fields: [phoneId], references: [id])
  property                                 Property?                        @relation(fields: [propertyId], references: [id])
  serviceProvider                          Service?                         @relation(fields: [serviceProviderId], references: [id])
  ads                                      Ad[]
  additionalServices                       AdditionalService[]
  cars                                     Car[]
  createdComments                          Comment[]
  issues                                   Issue[]
  managerStoreOrders                       ManagerStoreOrder[]
  meetingParticipantsIsRepresentedByToUser MeetingParticipant[]             @relation("MeetingParticipant_isRepresentedByToUser")
  meetingParticipantUserToUser             MeetingParticipant[]             @relation("MeetingParticipant_userToUser")
  noteComments                             NoteComment[]
  notifications                            Notification[]
  receivedOffenses                         Offense[]
  packages                                 Package[]
  paymentsCreatedByToUser                  Payment[]                        @relation("Payment_createdByToUser")
  paymentsCustomerToUser                   Payment[]                        @relation("Payment_customerToUser")
  paymentAccounts                          PaymentAccount[]
  paymentMethods                           PaymentMethod[] //unsure
  signedProxies                            Proxy[]
  reservations                             Reservation[]
  serviceRequestsAssignedToToUser          ServiceRequest[]                 @relation("ServiceRequest_assignedToToUser")
  serviceRequestsAssociatedToToUser        ServiceRequest[]                 @relation("ServiceRequest_associatedToToUser")
  serviceRequests                          ServiceRequest[]                 @relation("ServiceRequest_createdByToUser")
  assignedTasks                            Task[]                           @relation("Task_assignedToToUser")
  associatedTasks                          Task[]                           @relation("Task_associatedResidentToUser")
  createdTasks                             Task[]                           @relation("Task_createdByToUser")
  taskActivities                           TaskActivity[]
  others                                   User[]                           @relation("UserToUser_createdBy")
  chatNotificationTypes                    NOTIFICATION_DELIVERY_PLATFORM[]
  managerNotificationTypes                 NOTIFICATION_DELIVERY_PLATFORM[]
  orderNotificationTypes                   NOTIFICATION_DELIVERY_PLATFORM[]
  expoNotificationTokens                   String[]
  accessKeys                               AccessKey[]                      @relation("AccessKeysOfUser")
  projectsActive                           Project[]                        @relation("ActiveUsersForProject")
  amenities                                Amenity[]
  posts_AudienceOfPost                     Post[]                           @relation("AudienceOfPost")
  projectsBoardMember                      Project[]                        @relation("BoardMembersOfProject")
  car                                      Car[]                            @relation("CarOfUser") //unsure TO REVIEW
  condoManagerNomComptes                   CondoManagerCompte[]
  condoManagerCompteUserNumberSyncStatuses SyncStatus[]                     @relation("CondoManagerCompteUserNumbersSynced")
  condoManagerNoCompteReelSyncStatuses     SyncStatus[]                     @relation("CondoManagerNoCompteReelsSynced")
  contacts                                 Contact[]
  emailSyncStatuses                        SyncStatus[]                     @relation("EmailsSynced")
  eventsSeen                               Event[]                          @relation("EventsSeenByUser")
  filesSeen                                File[]                           @relation("FilesSeenByUser")
  firstNameSyncStatuses                    SyncStatus[]                     @relation("FirstNamesSynced")
  isResidentSyncStatuses                   SyncStatus[]                     @relation("IsResidentSynced")
  lastNameSyncStatuses                     SyncStatus[]                     @relation("LastNamesSynced")
  lockers                                  Locker[]                         @relation("LockersOfUser")
  meetingParticipantUsers                  MeetingParticipant[]             @relation("MeetingParticipantUsers")
  mentionedComments                        Comment[]                        @relation("MentionedUsersInComments")
  notes                                    Note[]                           @relation("NotesOfUser")
  notificationPreferences                  NotificationPreference[]
  orders                                   Order[]                          @relation("OrdersOfUser")
  service                                  Service[]                        @relation("OwnerOfService")
  properties                               Property[]                       @relation("OwnersOfProperty")
  parkings                                 Parking[]                        @relation("ParkingsOfUser")
  paysafeAccounts                          PaysafeAccount[]
  pollQuestionAnswers                      PollQuestionAnswer[]
  polls                                    Poll[]
  postsSeen                                Post[]                           @relation("PostsSeenByUser")
  propertiesPreviousOwnersOfProperty       Property[]                       @relation("PreviousOwnersOfProperty")
  previousProjects                         Project[]                        @relation("PreviousProjectsOfUser")
  propertiesPreviousUsersOfProperty        Property[]                       @relation("PreviousUsersOfProperty")
  projectsManaging                         Project[]                        @relation("ProjectsThatUserManage")
  remotes                                  Remote[]                         @relation("RemotesOfUser")
  rules                                    Rule[]
  segments                                 Segment[]
  serviceRequestsServiceRequestsSeenByUser ServiceRequest[]                 @relation("ServiceRequestsSeenByUser")
  tasksTaskCollaborators                   Task[]                           @relation("TaskCollaborators")
  propertiesTenantsOfProperty              Property[]                       @relation("TenantsOfProperty")
  projectsTenants                          Project[]                        @relation("TenantUsersForProject")
  offenses                                 Offense[]                        @relation("UserReceivedOffenses")
  cantGoEvents                             Event[]                          @relation("UsersCantGoToEvent")
  goingEvents                              Event[]                          @relation("UsersGoingToEvent")
  projects                                 Project[]                        @relation("UsersInProject")
  interestedEvents                         Event[]                          @relation("UsersInterestedToEvent")
  packagesSeen                             Package[]                        @relation("UsersThatSeenPackage")
} 