Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 280 lines (253 sloc) 8.01 KB
users
dynamic : .'Users'
password : +'Personalia'.'Password'
interfaces
root {
can-read: user
can-update: user +'Roles'?'Manager'|'Yes'
'Users': collection {
'Personalia': group {
can-update: user +'Roles'?'Manager'|'Yes' || equal ( user , $ ^ )
'Name': text @identifying
'Password': text @validate: ".{8}" @description: "At least 8 characters"
}
'Roles': group {
'Manager': stategroup @default: 'No' (
'Yes' -> { }
'No' -> { }
)
'Project Manager': stategroup @default: 'No' (
'Yes' -> { }
'No' -> { }
)
'Employee': stategroup @default: 'Yes' (
'Yes' -> { }
'No' -> { }
)
}
'Contracts': collection @small @dormant ?'Active'|'No' {
can-read: user +'Roles'?'Manager'|'Yes' || equal ( user , $ ^ )
'Time Per Week': natural 'Minutes'
'Active': stategroup @default: 'Yes' (
'Yes' -> { }
'No' -> { }
)
}
}
'Years': collection @dormant ?'Closed'|'Yes' {
'Closed': stategroup @default: 'No' (
'Yes' -> { }
'No' -> { }
)
'Weeks': collection {
'Days': collection {
'Date': integer 'Date' @identifying
'Is a Holiday': stategroup (
'No' -> { }
'Yes' -> {
'Holiday': text @identifying
}
)
'Week Day': stategroup (
'Monday' -> { }
'Tuesday' -> { }
'Wednesday' -> { }
'Thursday' -> { }
'Friday' -> { }
'Saturday' -> { }
'Sunday' -> { }
)
}
}
'Project Groups': collection
can-create: user +'Roles'?'Manager'|'Yes'
|| user +'Roles'?'Project Manager'|'Yes'
{
can-update: user +'Roles'?'Manager'|'Yes'
|| user +'Roles'?'Project Manager'|'Yes'
|| equal ( user , $ >'Owner'>key )
'Owner': text -> forward .^ %'Users'
'Comments': text @multi-line
'Sections': collection {
'Projects': reference-set
-> .'Years'.'Projects'?'Billable'|'Yes'
=> inverse >'Section'
'Rate': integer '€/hour'
'Declaration Method': stategroup @default: 'Declaration' (
'Fixed Price' -> {
'Final Amount': integer '€'
}
'Declaration' -> {
'Budget': integer 'Hours'
'Budget Amount':= integer '€' = product (
#'Budget' as 'Hours',
?^ #'Rate'
)
}
)
'Declaration Budget':= integer '€' = switch ( ? 'Declaration Method' ) (
|'Fixed Price' = $ #'Final Amount'
|'Declaration' = $ #'Budget Amount'
)
'Expenses Budget': integer '€'
'Total Budget':= integer '€' = sumlist (
#'Declaration Budget',
#'Expenses Budget'
)
}
'Total Budget':= integer '€' = sum .'Sections'#'Total Budget'
}
'Projects': collection
can-create: user +'Roles'?'Manager'|'Yes'
|| user +'Roles'?'Project Manager'|'Yes'
@dormant ?'Active'|'No'
{
can-update: user +'Roles'?'Manager'|'Yes'
|| user +'Roles'?'Project Manager'|'Yes'
|| equal ( user , $ >'Project Group'>'Owner'>key )
'Project Group': text -> .^ .'Project Groups'
'Active': stategroup @default: 'Yes' (
'Yes' -> { }
'No' -> { }
)
'Subsidized': stategroup (
'Yes' -> { }
'No' -> { }
)
'Registrations On Project': reference-set
-> .'Years'%'Users'%'Weeks'%'Days'.'Registrations'?'Activity'|'Worked On Project'
=> inverse > 'Project'
'Registered Time':= integer 'Minutes' = sum < 'Registrations On Project' ?^ #'Duration'
'Billable': stategroup (
'No' -> { }
'Yes' -> {
'Section': text -> ?^ >'Project Group'.'Sections' -< 'Projects' @identifying
'Budget': natural 'Minutes'
'Declarations': collection {
'Minutes': natural 'Minutes'
}
'Declared':= integer 'Minutes' = sum .'Declarations' #'Minutes'
'Remaining Budget':= integer 'Minutes' = sumlist (
#'Budget',
- #'Declared'
)
}
)
}
'Users': collection -> .^ .'Users' {
'Subsidized': stategroup @description: "WBSO" (
'Yes' -> { }
'No' -> { }
)
'Weeks': collection -> %^ .'Weeks'
can-create: user +'Roles'?'Manager'|'Yes'
can-delete: user +'Roles'?'Manager'|'Yes'
@dormant ?'Status'|'Approved'
{
can-update: equal ( user , $ ?'Status'|'Open'>'Owner' )
|| equal ( user , $ ?'Status'|'Submitted'>'Owner' )
|| equal ( user , $ ?'Status'|'Approved'>'Approver' )
|| user +'Roles'?'Manager'|'Yes'
'Days': collection -> >key .'Days'
can-create: user +'Roles'?'Manager'|'Yes'
can-delete: user +'Roles'?'Manager'|'Yes'
@ascending: ( >key ) #'Date'
@small
{
'Registrations': collection
can-create: equal ( user , $ ^ ?'Status'|'Open'>'Owner' )
|| equal ( user , $ ^ ?'Status'|'Submitted'>'Owner' )
|| equal ( user , $ ^ ?'Status'|'Approved'>'Approver' )
@guid @small
{
can-update: equal ( user , $ ^ ^ ?'Status'|'Open'>'Owner' )
|| equal ( user , $ ^ ^ ?'Status'|'Submitted'>'Owner' )
|| equal ( user , $ ^ ^ ?'Status'|'Approved'>'Approver' )
'Duration': natural 'Minutes' @min: 15 @max: 1440 @description: "At least 15min"
'Activity': stategroup @default: 'Worked On Project' (
'Worked On Project' -> {
'Project': text -> ?^ .^ %^ %^ %^ .'Projects' -< 'Registrations On Project'
}
'Holiday' -> { }
'Sick Leave' -> { }
'Furlough' -> {
'Furlough Taken':= natural 'Minutes' = ?^ #'Duration'
}
'TBD' -> {
has-todo: equal ( user , $ ^ ^ ^ ^ >key )
}
)
'Description': text @multi-line
}
'Total Duration' := integer 'Minutes' = sum .'Registrations'#'Duration'
'Furlough Taken':= integer 'Minutes' = sum .'Registrations'?'Activity'|'Furlough'#'Furlough Taken'
}
'Fixed Contract': stategroup @default: 'No' (
'No' -> { }
'Yes' -> {
'Contract': text -> ?^ %^ >key .'Contracts'
'Contractual Time Per Week':= natural 'Minutes' = >'Contract'#'Time Per Week'
}
)
'Status': stategroup @default: 'Open' (
'Open' -> {
has-todo: equal ( user , $ ^ ^ >key )
'Owner':= text => ( ?^ %^ %^ .^ .'Users' ) ?^ %^ >key
}
'Submitted' -> {
has-todo: user +'Roles'?'Project Manager'|'Yes'
'Owner':= text => ( ?^ %^ %^ .^ .'Users' ) ?^ %^ >key
}
'Approved' -> can-create: user +'Roles'?'Project Manager'|'Yes' {
can-update: equal ( user , $ > 'Approver' )
'Timestamp': integer 'Time' = creation-time
'Approver': text -> ?^ %^ %^ .^ .'Users' @metadata
}
)
'Total Duration':= integer 'Minutes' = sum % 'Days' #'Total Duration'
'Furlough Taken':= integer 'Minutes' = sum % 'Days' #'Furlough Taken'
'Overtime Known':= stategroup = switch ( ?'Status' ) (
|'Open' = 'No'
|'Submitted' = switch ( $^ ?'Fixed Contract' ) (
|'No' = 'No'
|'Yes' = 'Yes' ( 'Contract Known' => $ )
)
|'Approved' = switch ( $^ ?'Fixed Contract' ) (
|'No' = 'No'
|'Yes' = 'Yes' ( 'Contract Known' => $ )
)
) (
'No' -> { }
'Yes' ( 'Contract Known': .'Years'%'Users'%'Weeks'?'Fixed Contract'|'Yes' ) -> {
'Deviation':= integer 'Minutes' = sumlist (
?^ #'Total Duration',
- & 'Contract Known' #'Contractual Time Per Week'
)
}
)
}
'Furlough Budget': integer 'Minutes'
@description: "Available time off according to your contract."
'Furlough Taken' := integer 'Minutes' = sum %'Weeks'#'Furlough Taken'
@description: "Time off already used."
'Furlough Remaining':= integer 'Minutes' = sumlist (
#'Furlough Budget',
- #'Furlough Taken'
) @description: "Difference between available and used time off."
'Overtime':= integer 'Minutes' = sum %'Weeks'?'Overtime Known'|'Yes'#'Deviation'
@description: "Total of all deviations from your contractual time."
'Furlough Budget Remaining':= integer 'Minutes' = sumlist (
#'Furlough Budget',
#'Overtime',
- #'Furlough Taken'
) @description: "Time off remaining for this year."
}
}
}
numerical-types
'Date' @date
'Time' @date-time
'Hours' @duration: hours
'Minutes' @duration: minutes
'€' = 'Hours' * '€/hour' @label: "€"
'€/hour' @label: "€/h"