import { TaskCategory, CategoryID } from "./task"; import { Project } from "./project"; export interface TaskCategoriesIndex { [id: string]: TaskCategory } export interface TimeUnit { label: string acronym: string } export interface Params { taskCategories: TaskCategoriesIndex timeUnit: TimeUnit currency: string roundUpEstimations: boolean } export const defaults = { taskCategories: { "7e92266f-0a7b-4728-8322-5fe05ff3b929": { id: "7e92266f-0a7b-4728-8322-5fe05ff3b929", label: "Développement", costPerTimeUnit: 500, }, "508a0925-a664-4426-8d40-6974156f0f00": { id: "508a0925-a664-4426-8d40-6974156f0f00", label: "Conduite de projet", costPerTimeUnit: 500, }, "7aab4d66-072e-4cc8-aae8-b62edd3237a8": { id: "7aab4d66-072e-4cc8-aae8-b62edd3237a8", label: "Recette", costPerTimeUnit: 500, }, }, timeUnit: { label: "jour/homme", acronym: "j/h", }, roundUpEstimations: true, currency: "€ H.T.", } export function getTimeUnit(project: Project): TimeUnit { return project.params.timeUnit ? project.params.timeUnit : defaults.timeUnit; } export function getRoundUpEstimations(project: Project): boolean { return project.params.hasOwnProperty("roundUpEstimations") ? project.params.roundUpEstimations : defaults.roundUpEstimations; } export function getCurrency(project: Project): string { return project.params.currency ? project.params.currency : defaults.currency; } export function getTaskCategories(project: Project): TaskCategoriesIndex { return project.params.taskCategories ? project.params.taskCategories : defaults.taskCategories; }