module BankingSystem/core/humanResources

------------------------------------------------------------------------------------------------------------------

-- This Alloy file is generated using Umple from BankingSystem.ump

------------------------------------------------------------------------------------------------------------------


-- Defines a signature for class PersonRole
sig PersonRole {
  person : one Person
}

-- Defines a signature for class Person
sig Person {
  personRoles : set PersonRole,
  name : String,
  address : String,
  phoneNumber : String
}

-- Defines a signature for class Employee
sig Employee extends PersonRole {
  manager : lone Manager,
  division : one Division
}

-- Defines a signature for class Client
sig Client extends PersonRole {
  accounts : some Account,
  name : String,
  address : String,
  phoneNumber : String
}

-- Defines a signature for class Manager
sig Manager extends Employee {
  employees : set Employee
}

-- Defines a signature for class Account
sig Account {
  accountType : one AccountType,
  clients : some Client,
  branch : one Branch,
  accountNumber : Int,
  balance : Int,
  creditLimit : Int
}

-- Defines a signature for class AccountType
sig AccountType {
  privileges : set Privilege,
  monthlyFee : Int,
  interestRate : Int
}

-- Defines a signature for class Privilege
sig Privilege {
  accountTypes : set AccountType,
  description : String
}

-- Defines a signature for class CreditCardAccount
sig CreditCardAccount extends Account {
  cards : some Card,
  expiryDate : String
}

-- Defines a signature for class MortgageAccount
sig MortgageAccount extends Account {
  collateral : String
}

-- Defines a signature for class Card
sig Card {
  creditCardAccount : one CreditCardAccount,
  holderName : String
}

-- Defines a signature for class Branch
sig Branch extends Division {
  accounts : set Account,
  address : String,
  branchNumber : String
}

-- Defines a signature for class Division
sig Division {
  employees : set Employee,
  subDivision : set Division,
  name : String
}


-- Defines constraints on association between PersonRole and Person
fact AssociationFact {
  PersonRole <: person in (PersonRole) set -> set (Person)
}

-- Defines constraints on association between Account and Client
fact AssociationFact {
  Account <: clients in (Account) some -> some (Client)
}

-- Defines constraints on association between Employee and Manager
fact AssociationFact {
  Employee <: manager in (Employee) set -> set (Manager)
}

-- Defines constraints on association between Account and AccountType
fact AssociationFact {
  Account <: accountType in (Account) set -> one (AccountType)
}

-- Defines constraints on association between Privilege and AccountType
fact AssociationFact {
  Privilege <: accountTypes in (Privilege) set -> set (AccountType)
}

-- Defines constraints on association between Card and CreditCardAccount
fact AssociationFact {
  Card <: creditCardAccount in (Card) some -> some (CreditCardAccount)
}

-- Defines constraints on association between Account and Branch
fact AssociationFact {
  Account <: branch in (Account) set -> set (Branch)
}

-- Defines constraints on association between Employee and Division
fact AssociationFact {
  Employee <: division in (Employee) set -> set (Division)
}

-- Defines non-reflexive rule for class Division
fact NonReflexiveRule {
  no division_1 : Division |
    division_1 in subDivision[division_1]
}

-- Defines symmetric rule for class Division
fact SymmetricRelation {
  all division_1, division_2 : Division |
    division_1 in subDivision[division_2] <=> division_2 in subDivision[division_1]
}

-- Defines non-reflexive rule for class Division
fact NonReflexiveRule {
  no division_1 : Division |
    division_1 in subDivision[division_1]
}

-- Defines symmetric rule for class Division
fact SymmetricRelation {
  all division_1, division_2 : Division |
    division_1 in subDivision[division_2] <=> division_2 in subDivision[division_1]
}

-- Defines bidirectionality rule between class Person and class PersonRole
fact BidirectionalityRule {
  all person_1 : Person, personrole_1 : PersonRole |
    person_1 in person[personrole_1] <=> personrole_1 in personRoles[person_1]
}

-- Defines bidirectionality rule between class Client and class Account
fact BidirectionalityRule {
  all client_1 : Client, account_1 : Account |
    client_1 in clients[account_1] <=> account_1 in accounts[client_1]
}

-- Defines numeric bound rule for class Account
fact NumericBoundFact {
  no account_1 : Account |
    #account_1.clients < 1 || #account_1.clients > 2
}

-- Defines bidirectionality rule between class Manager and class Employee
fact BidirectionalityRule {
  all manager_1 : Manager, employee_1 : Employee |
    manager_1 in manager[employee_1] <=> employee_1 in employees[manager_1]
}

-- Defines bidirectionality rule between class AccountType and class Privilege
fact BidirectionalityRule {
  all accounttype_1 : AccountType, privilege_1 : Privilege |
    accounttype_1 in accountTypes[privilege_1] <=> privilege_1 in privileges[accounttype_1]
}

-- Defines bidirectionality rule between class CreditCardAccount and class Card
fact BidirectionalityRule {
  all creditcardaccount_1 : CreditCardAccount, card_1 : Card |
    creditcardaccount_1 in creditCardAccount[card_1] <=> card_1 in cards[creditcardaccount_1]
}

-- Defines bidirectionality rule between class Branch and class Account
fact BidirectionalityRule {
  all branch_1 : Branch, account_1 : Account |
    branch_1 in branch[account_1] <=> account_1 in accounts[branch_1]
}

-- Defines bidirectionality rule between class Division and class Employee
fact BidirectionalityRule {
  all division_1 : Division, employee_1 : Employee |
    division_1 in division[employee_1] <=> employee_1 in employees[division_1]
}

-- Defines generalization hierarchy rule between class Employee and Manager
fact GenHierarchyFact {
  no manager_1 : Manager |
    manager_1.employees = manager_1
}
