---
# System prepended metadata

title: Core
tags: [nextup]

---

# Core
###### tags: `nextup`

## Domain model
```plantuml

package common {
    class Address {
        googlePlacesId: String
        latitude: BigDecimal
        longitude: BigDecimal
        streetName: String
        streetNumber: Sting
        zipCode: String
        city: String
        coutry: String
    }
}
package User {
    class User {
        email: String
        password: String
        roles: List<UserRole>
        status: UserStatus
        rolesString: String
    }

    enum UserRole {
        ADMIN,
        OWNER,
        TENANT,
        SYSTEM
    }

    enum UserStatus {
        ACTIVE,
        INACTIVE
    } 
}

package Link {
    
    Link "1" --> "1" User
    RefreshToken "1" --> "1" User
    
    class Link {
        token: String
        type: LinkType
        expiresAt: Instant
    }
    
    class RefreshToken {
        token: String    
    }
    
    enum LinkType {
        RESET_PASSWORD,
        ACTIVATION,
    }
}

package person {
    Person "1" --> "1" Address
    Person "1" --> "1" User
    IndividualPerson -up-|> Person
    LegalPerson -up-|> Person
    
    class Person {
        email: String
        firstName: String
        lastName: String
        phone: String
        note: String
        deleted: boolean
    }
    
    class IndividualPerson {
        title: Title
        gender: Gender
    }
    
    class LegalPerson {
        companyName: String
        companyId: String
        vatId: String
    }
    
    enum Gender {
        M,
        F,
        OTHER
    }
    
    enum Title {
        MR,
        MRS,
        OTHER
    }
}

package payment {
    class Payment {
        personPaid: String
        paymentDate: LocalDate
        booked: boolean
        type: PaymentType
        paymentPurpose: String
        amount: MonteryAmount
        coldRent: BigDecimal
        runningCost: BigDecimal
        heatingCost: BigDecimal
        tax: BigDecimal
        amountAdded: BigDecimal
    }
    
    enum PaymentType {
        CASH,
        BANK_TRANSFER
    }
}

package Rent {
    
    Debit "*" --> "0..1" Person: tenant
    Debit "0..1" <--> "*" Payment: payments
    
    class Debit {
        date: LocalDate
        paymentDueDate: String
        month: Month
        year: Year
        booked: boolean
        amount: MonteryAmount
        coldRentAmount: MonteryAmount
        heatingCost: MonteryAmount
        runningCost: MonteryAmount
        BigDecimal: taxAmount
        status: DebitStatus
        
    }
    
    enum RentType {
        RENT
        DEPOSIT
    }
    
    enum DebitStatus {
        OPEN,
        EXPECTED,
        OVERDUE,
        PAID,
        PARTIALLY_PAID,
        OVERPAID
    }
}

package account {
    Account "1" <--> "*" AccountTransaction
    
    class Account {
        name: String
        remainingAmount: BigDecimal
    }
    
    class AccountTransaction {
        type: TransactionType
        date: LocalDate
        amount: BigDecimal
    }
    
    enum TransactionType {
        CREDIT, DEBIT
    }
}
package rental {
    RentalObject "1" --> "1" Address
    RentalObject "*" --> "0..1" Person: owner
    RentalObject "0..1" <--> "*" RentalUnit
    
    RentalUnit "*" --> "1" Person: owner
    
    RentalUnitContract "*" --> "0..1" RentalUnit: rentalUnit
    RentalUnitContract "*" --> "0..1" RentalUnitContract: replacedContract
    RentalUnitContract "*" --> "*" Person: tenants
    RentalUnitContract "1" --> "0..1" RentalUnitContractDetails: moveInDetails
    RentalUnitContract "1" --> "0..1" RentalUnitContractDetails: moveOutDetails
    RentalUnitContract "0..1" <--> "*" Debit: debits
    RentalUnitContract "0..1" <--> "*" Account: account
    
    class RentalObject {
        name: String
        category: RentalObjectCategory
        totalArea: Quantity
        note: String
        iban: String
        bankAccountUuid: String
        accountId: Long
        internalCode: String
        folderUuid: String
        deleted: boolean
    }
    
    class RentalUnit {
        type: RentalUnitType
        floor: String
        livingArea: Quantity
        name: String
        description: String
        note: String
        withTax: boolean
        status: RentalUnitStatus
        folderUuid: String
        deleted: boolean
    }
    
    class RentalUnitContract {
        startDate: LocalDate
        endDate: LocalDate
        note: String
        rentDueDay: Integer
        coldRentAmount: MonetaryAmount
        heatingCost: MonetaryAmount
        runningCost: MonetaryAmount
        depositAmount: MonetaryAmount
        taxAmount: BigDecimal
        attachments: Set<String>
        withTax: boolean
        annexed: boolean
        deleted: boolean
    }
    
    class RentalUnitContractDetails {
        meterReadingGas: BigDecimal
        meterReadingWater: BigDecimal
        meterReadingElectricity: BigDecimal
        note: String
        attachments: Set<String>
        
    }
    
    enum RentalObjectCategory {
        ENTIRE_BUILDING,
        HOUSING_UNITS,
        FAMILY_HOUSE
    }
    
    enum RentalUnitType {
        APARTMENT,
        GARAGE,
        PARKING_LOT,
        COMMERCIAL
    }
    
    enum RentalUnitStatus {
        ACTIVE,
        INACTIVE
    }

}

package email {
    class EmailTemplate {
        subject: String
        body: String
        type: EmailTemplateType
    }
    
    enum EmailTemplateType {
        RESET_PASSWORD,
        RESET_PASSWORD_SUCCESS,
        ACTIVATION,
        RENTAL_UNIT_OWNER,
        RENTAL_OBJECT_OWNER
    }
}

package content {
    enum ContentResourceType {
        RENTAL_OBJECT,
        RENTAL_UNIT,
        COST
    }
}

```