add server to monorepo.

This commit is contained in:
a.bouhuolia
2023-02-03 11:57:50 +02:00
parent 28e309981b
commit 80b97b5fdc
1303 changed files with 137049 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
import { Transformer } from '@/lib/Transformer/Transformer';
import Time from 'models/Time';
import { formatMinutes } from 'utils/formatMinutes';
export class TimeTransformer extends Transformer {
/**
* Include these attributes to sale invoice object.
* @returns {Array}
*/
public includeAttributes = (): string[] => {
return ['projectName', 'taskName', 'customerName', 'durationFormatted'];
};
/**
* Exclude attributes.
* @returns {string[]}
*/
public excludeAttributes = (): string[] => {
return ['project', 'task'];
};
/**
* Retrieves the project name that associated to the time entry.
* @param {Time} time
* @returns {string}
*/
public projectName = (time: Time) => {
return time.project.name;
};
/**
* Retrieves the task name that associated to the time entry.
* @param {Time} time
* @returns {string}
*/
public taskName = (time: Time) => {
return time.task.name;
};
/**
* Retrieves the customer name that associated to the task of the time entry.
* @param {Time} time
* @returns {string}
*/
public customerName = (time: Time) => {
return time?.project?.contact?.displayName;
};
/**
* Retrieves the formatted duration.
* @param {Time} time
* @returns {string}
*/
public durationFormatted = (time: Time) => {
return formatMinutes(time.duration);
}
}