45 lines
1010 B
JavaScript
45 lines
1010 B
JavaScript
// Function on a month
|
|
export function ca(month) {
|
|
// Extract the CA of the month
|
|
if (month.caReact) {
|
|
return month.caReact
|
|
} else {
|
|
return month.caRetro
|
|
}
|
|
}
|
|
|
|
export function notInvoiced (month) {
|
|
// Compute how much has not been invoiced
|
|
return month.caTheo - ca(month)
|
|
}
|
|
|
|
export function caPro (month) {
|
|
// Compute the part of the CA to go pro usage
|
|
return ca(month) * month.proPercentage / 100
|
|
}
|
|
|
|
export function caPerso (month) {
|
|
// Compute the part of the CA to go personnal usage
|
|
return ca(month) * (1 - month.proPercentage / 100)
|
|
}
|
|
|
|
export function caPersoUntouch (month) {
|
|
// Compute the part of the CA to go personnal usage
|
|
return caPerso(month) - month.remuneration
|
|
}
|
|
|
|
|
|
// Function on an array of month
|
|
|
|
|
|
export function sum (array) {
|
|
// sum the array
|
|
return array.reduce((acc, v)=> acc + v, 0)
|
|
}
|
|
|
|
export function mean(array) {
|
|
console.log(array)
|
|
return Math.floor(array.reduce((acc, v)=> acc + v, 0) / array.length)
|
|
}
|
|
|