Compare commits

...

7 Commits

11 changed files with 206 additions and 235 deletions

View File

@ -1,53 +1,36 @@
<template> <template>
<div class="boxed-green month-presentation" id="new-month"> <div class="toolbar">
<button v-show='!addingMonth' @click='toggleAdding'>
Ajouter {{ formatedDate }}
</button>
</div>
<div class="boxed-green month-presentation" id="new-month" v-show='addingMonth'>
<div class="date"> <div class="date">
<input type="month" v-model="monthDate"> <div class="month">
{{ theMonth }}
</div>
<div class="year">
{{ theYear }}
</div>
<div class="actions"> <div class="actions">
<button class="validate" @click="save"> Valider </button> <button class="validate" @click="save"> Valider </button>
<button class="cancel" @click="cancel"> Annuler </button> <button class="cancel" @click="cancel"> Annuler </button>
</div> </div>
</div> </div>
<div class="datas"> <div class="datas">
<ul> <li v-for="cara in monthDesc" :key='cara.name'>
<li> <label :for='cara.name'>{{ cara.desc }}</label>
<label for="ca-theo">CA théorique</label> <input type="number" v-model.number="monthCopy[cara.name]" id="cara.name" class="value">
<input type="number" v-model.number="monthCopy.ca_theo" id="ca-theo" class="value" > </li>
</li>
<li>
<label for="ca-retro">CA rétrocession</label>
<input type="number" v-model.number="monthCopy.ca_retro" id="ca-retro" class="value" >
</li>
<li>
<label for="ca-react">CA réactualisé</label>
<input type="number" v-model.number="monthCopy.ca_react" id="ca-react" class="value" >
</li>
<li>
<label for="nbr-seances">Nombre de séances effectuées</label>
<input type="number" v-model.number="monthCopy.nbr_seances" id="nbr-seances" class="value" >
</li>
<li>
<label for="retro">Montant de la rétrocession</label>
<input type="number" v-model.number="monthCopy.retro" id="retro" class="value" >
</li>
<li>
<label for="remuneration">Rémunération effectuée</label>
<input type="number" v-model.number="monthCopy.remuneration" id="remuneration" class="value">
</li>
</ul>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import { mapGetters, mapActions } from 'vuex' import { mapGetters, mapActions } from 'vuex'
const today = new Date(); import { parseISO, addMonths, format } from 'date-fns'
function formatDate(date) { import frLocal from 'date-fns/locale/fr'
var y = ''+date.getFullYear()
var m = ''+(date.getMonth()+1)
if (m.length < 2) { m = '0'+m}
return [y, m].join('-')
}
export default { export default {
name: 'NewMonth', name: 'NewMonth',
@ -57,17 +40,41 @@ export default {
}, },
data () { data () {
return { return {
monthDate: formatDate(today), monthDate: new Date(),
monthCopy: Object, monthCopy: Object,
addingMonth: false,
} }
}, },
mounted () { mounted () {
this.monthCopy = this.theEmptyMonth this.monthCopy = this.theEmptyMonth
}, },
watch: {
lastMonthDate: function () {
if (this.lastMonthDate) {
this.monthDate = addMonths(parseISO(this.lastMonthDate, "yyyy-MM", new Date()), 1)
} else {
this.monthDate = new Date()
}
},
},
computed: { computed: {
...mapGetters('travail', { ...mapGetters('travail', {
'theEmptyMonth': 'TheEmptyMonth', 'theEmptyMonth': 'TheEmptyMonth',
'lastMonthDate': 'lastMonthDate',
}), }),
...mapGetters('config', {
'monthDesc': 'monthDesc',
}),
formatedDate: function () {
return format(this.monthDate, "MMMM YYY", {locale: frLocal} )
},
theMonth: function () {
return format(this.monthDate, "MMM", {locale: frLocal})
},
theYear: function () {
return format(this.monthDate, "YYY", {locale: frLocal})
},
}, },
methods: { methods: {
...mapActions('travail', { ...mapActions('travail', {
@ -76,14 +83,19 @@ export default {
...mapActions('config', { ...mapActions('config', {
'writeData': 'writeData', 'writeData': 'writeData',
}), }),
toggleAdding: function () {
this.addingMonth = !this.addingMonth
},
save: function () { save: function () {
console.log("save") console.log("save")
console.log(this.monthCopy) console.log(this.monthCopy)
this.createMonth({date: this.monthDate, month: this.monthCopy}) this.createMonth({date: format(this.monthDate, "yyyy-MM"), month: this.monthCopy})
this.toggleAdding()
this.writeData() this.writeData()
}, },
cancel: function () { cancel: function () {
this.monthCopy = this.theEmptyMonth this.toggleAdding()
this.monthCopy = this.theEmptyMonth
}, },
}, },
} }
@ -117,12 +129,13 @@ export default {
} }
li { li {
margin: 3px; margin: 3px;
width: 30%;
display: flex; display: flex;
flex-direction: column-reverse; flex-direction: column-reverse;
} }
.value { .value {
font-size: 1.5em;
font-weight: bold; font-weight: bold;
} }
.toolbar {
text-align: center;
}
</style> </style>

View File

@ -14,45 +14,27 @@
</div> </div>
</div> </div>
<div id="display"> <div id="display">
<ul> <ul v-show="!editing">
<li> <li v-for="cara in monthDesc" :key='cara.name'>
<label for="ca-theo">CA "Séances effectuées"</label> <label :for='cara.name'>{{ cara.desc }}</label>
<span class="value" v-show="!editing">{{ TheMonth.ca_theo ?? ""}}</span> <span class="value" >{{ TheMonth.[cara.name] ?? "∅"}} {{cara.unit}}</span>
<input type="number" v-model.number="monthCopy.ca_theo" id="ca-theo" class="value" v-show="editing">
</li>
<li>
<label for="ca-retro">CA "Séances facturées"</label>
<span class="value" v-show="!editing">{{ TheMonth.ca_retro ?? ""}}</span>
<input type="number" v-model.number="monthCopy.ca_retro" id="ca-retro" class="value" v-show="editing">
</li>
<li>
<label for="ca-react">CA "Séances facturées" réactualisé</label>
<span class="value" v-show="!editing">{{ TheMonth.ca_react ?? ""}}</span>
<input type="number" v-model.number="monthCopy.ca_react" id="ca-react" class="value" v-show="editing">
</li>
<li>
<label for="nbr-seances">Nombre de séances effectuées</label>
<span class="value" v-show="!editing">{{ TheMonth.nbr_seances ?? ""}}</span>
<input type="number" v-model.number="monthCopy.nbr_seances" id="nbr-seances" class="value" v-show="editing">
</li>
<li>
<label for="retro">Montant de la rétrocession</label>
<span class="value" v-show="!editing">{{ TheMonth.retro ?? ""}}</span>
<input type="number" v-model.number="monthCopy.retro" id="retro" class="value" v-show="editing">
</li>
<li>
<label for="remuneration">Rémunération </label>
<span class="value" v-show="!editing">{{ TheMonth.remuneration ?? ""}}</span>
<input type="number" v-model.number="monthCopy.remuneration" id="remuneration" class="value" v-show="editing">
</li> </li>
</ul> </ul>
<ul v-show="editing">
<li v-for="cara in monthDesc" :key='cara.name'>
<label :for='cara.name'>{{ cara.desc }}</label>
<input type="number" v-model.number="monthCopy[cara.name]" id="cara.name" class="value">
</li>
</ul>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import { mapActions } from 'vuex' import { mapActions, mapGetters } from 'vuex'
import { parseISO, format } from 'date-fns' import { parseISO, format } from 'date-fns'
import frLocal from 'date-fns/locale/fr'
export default { export default {
name: 'MonthPresentation', name: 'MonthPresentation',
props: { props: {
@ -71,11 +53,14 @@ export default {
this.monthCopy = {...this.TheMonth} this.monthCopy = {...this.TheMonth}
}, },
computed: { computed: {
...mapGetters('config', {
'monthDesc': 'monthHightlightDesc',
}),
rawDate: function () { rawDate: function () {
return parseISO(this.TheDate, "yyyy-MM", new Date()) return parseISO(this.TheDate, "yyyy-MM", new Date())
}, },
theMonth: function () { theMonth: function () {
return format(this.rawDate, "MMM", ) return format(this.rawDate, "MMM", {locale: frLocal})
}, },
theYear: function () { theYear: function () {
return format(this.rawDate, "YYY", ) return format(this.rawDate, "YYY", )
@ -148,6 +133,5 @@ export default {
padding: 4px; padding: 4px;
font-size: 0.8em; font-size: 0.8em;
width: auto; width: auto;
} }
</style> </style>

View File

@ -24,10 +24,11 @@
<script> <script>
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import { caTotal, import {
caMean, ca,
remuneration, caPersoUntouch,
caPersoUntouch sum,
mean,
} from '../lib/months' } from '../lib/months'
import RevenusChart from '../components/graphs/RevenusChart.vue' import RevenusChart from '../components/graphs/RevenusChart.vue'
@ -40,16 +41,13 @@ export default {
return {} return {}
}, },
computed: { computed: {
...mapGetters('config', {
caProPercentage: 'caProPercentage',
}),
...mapGetters('travail', { ...mapGetters('travail', {
months: "months", months: "months",
}), }),
ca: function () {return caTotal(this.months).toLocaleString()}, ca: function () {return sum(Object.values(this.months).map(a => ca(a))).toLocaleString()},
caMean: function () {return caMean(this.months).toLocaleString()}, caMean: function () {return mean(Object.values(this.months).map(a => ca(a))).toLocaleString()},
remuneration: function () {return remuneration(this.months).toLocaleString()}, remuneration: function () {return sum(Object.values(this.months).map(a => a.remuneration)).toLocaleString()},
caPersoUntouch: function () {return caPersoUntouch(this.months, this.caProPercentage).toLocaleString()}, caPersoUntouch: function () {return sum(Object.values(this.months).map(a => caPersoUntouch(a))).toLocaleString()},
}, },
mounted () { mounted () {

View File

@ -25,9 +25,8 @@
<script> <script>
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import { import {
caTheo, sum,
notInvoiced, notInvoiced,
retrocession,
} from '../lib/months' } from '../lib/months'
import RepartitionChart from './graphs/RepartitionChart.vue' import RepartitionChart from './graphs/RepartitionChart.vue'
@ -40,16 +39,12 @@ export default {
return {} return {}
}, },
computed: { computed: {
...mapGetters('config', {
caProPercentage: 'caProPercentage',
}),
...mapGetters('travail', { ...mapGetters('travail', {
months: "months", months: "months",
}), }),
caTheo: function () {return caTheo(this.months).toLocaleString()}, caTheo: function () {return sum(Object.values(this.months).map(a => a.caTheo)).toLocaleString()},
notInvoiced: function () {return notInvoiced(this.months).toLocaleString()}, retrocession: function () {return sum(Object.values(this.months).map(a => a.retro)).toLocaleString()},
retrocession: function () {return retrocession(this.months).toLocaleString()}, notInvoiced: function () {return sum(Object.values(this.months).map(a => notInvoiced(a))).toLocaleString()},
}, },
mounted () { mounted () {
}, },

View File

@ -10,9 +10,8 @@ import { mapGetters } from 'vuex'
import { import {
notInvoiced, notInvoiced,
caPro, caPro,
remuneration,
retrocession,
caPersoUntouch, caPersoUntouch,
sum,
} from '../../lib/months' } from '../../lib/months'
export default { export default {
@ -43,11 +42,11 @@ export default {
{ {
label: "Difference CA perso et remuneration", label: "Difference CA perso et remuneration",
data: [ data: [
caPro(this.months, this.caProPercentage), sum(Object.values(this.months).map(a => caPro(a))),
notInvoiced(this.months), sum(Object.values(this.months).map(a => notInvoiced(a))),
retrocession(this.months), sum(Object.values(this.months).map(a => a.retro)),
remuneration(this.months), sum(Object.values(this.months).map(a => a.remuneration)),
caPersoUntouch(this.months, this.caProPercentage), sum(Object.values(this.months).map(a => caPersoUntouch(a))),
], ],
}, },
], ],

View File

@ -7,7 +7,7 @@
<script> <script>
import Chart from 'chart.js' import Chart from 'chart.js'
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import { monthCA, caPersoUntouch, caPerso, remuneration } from '../../lib/months' import { ca, caPersoUntouch, sum } from '../../lib/months'
export default { export default {
name: 'RevenusChart', name: 'RevenusChart',
@ -37,7 +37,7 @@ export default {
{ {
type: "bar", type: "bar",
label: "Difference CA perso et remuneration", label: "Difference CA perso et remuneration",
data: Object.values(this.months).map(a => caPerso({bar: a}, this.caProPercentage) - remuneration({bar:a})), data: Object.values(this.months).map(a => caPersoUntouch(a)),
backgroundColor: "red", backgroundColor: "red",
borderColor: "light-red", borderColor: "light-red",
borderWidth: 3 borderWidth: 3
@ -45,7 +45,7 @@ export default {
{ {
type: "bar", type: "bar",
label: "CA", label: "CA",
data: Object.values(this.months).map(a => monthCA(a)), data: Object.values(this.months).map(a => ca(a)),
backgroundColor: "rgba(54,73,93,.5)", backgroundColor: "rgba(54,73,93,.5)",
borderColor: "#36495d", borderColor: "#36495d",
borderWidth: 3 borderWidth: 3
@ -79,7 +79,9 @@ export default {
}, },
untouchEvo: function () { untouchEvo: function () {
const cumulativeArray = (arr => value => {arr.push(value); return [...arr];})([]); const cumulativeArray = (arr => value => {arr.push(value); return [...arr];})([]);
return Object.values(this.months).map(cumulativeArray).map(a => caPersoUntouch(a, this.caProPercentage)) return Object.values(this.months)
.map(cumulativeArray)
.map(a => sum(a.map(m => caPersoUntouch(m))))
}, },
}, },
methods: { methods: {

View File

@ -1,83 +1,44 @@
// Function on a month
export function monthCA(month) { export function ca(month) {
// Extract the CA of the month // Extract the CA of the month
if (month.ca_react) { if (month.caReact) {
return month.ca_react return month.caReact
} else { } else {
return month.ca_retro return month.caRetro
} }
} }
export function count (months) { export function notInvoiced (month) {
// Count how many months there are // Compute how much has not been invoiced
return Object.keys(months).length return month.caTheo - ca(month)
} }
export function caTotal (months) { export function caPro (month) {
// Total CA (ca_react if sets, ca_retro otherwise) // Compute the part of the CA to go pro usage
return Object.values(months).map(a => monthCA(a)).reduce( return ca(month) * month.proPercentage / 100
(acc, v) => acc + v
,0
)
} }
export function caMean (months) { export function caPerso (month) {
// Mean of CA // Compute the part of the CA to go personnal usage
return Math.floor(caTotal(months) / count(months)) return ca(month) * (1 - month.proPercentage / 100)
} }
export function caTheo (months) { export function caPersoUntouch (month) {
// Total theorical CA // Compute the part of the CA to go personnal usage
return Object.values(months).map(a => a.ca_theo).reduce( return caPerso(month) - month.remuneration
(acc, v) => acc + v,
0
)
} }
export function notInvoiced (months) {
// Total of not invoiced sessions // Function on an array of month
return caTheo(months) - caTotal(months)
export function sum (array) {
// sum the array
return array.reduce((acc, v)=> acc + v, 0)
} }
export function remuneration (months) { export function mean(array) {
// Total remuneration console.log(array)
return Object.values(months).map(a => a.remuneration).reduce( return Math.floor(array.reduce((acc, v)=> acc + v, 0) / array.length)
(acc, v) => acc + v,
0
)
} }
export function remunerationMean (months) {
// Mean of remuneration
return Math.floor(remuneration(months) / count(months))
}
export function retrocession (months) {
// Total retrocession
return Object.values(months)
.map(a => a.retro)
.reduce(
(acc, v) => acc + v,
0
)
}
export function retrocessionMean (months) {
// Mean of retrocession
return Math.floor(retrocession(months) / count(months))
}
export function caPro (months, keepPercent) {
// Part of the CA to keep for professional use
return caTotal(months) * keepPercent
}
export function caPerso (months, keepPercent) {
// Part of the CA to keep for personal use
return caTotal(months) - caPro(months, keepPercent)
}
export function caPersoUntouch (months, keepPercent) {
// Part of the personnal use CA that haven't been use
return caPerso(months, keepPercent) - remuneration(months)
}

View File

@ -10,11 +10,71 @@ const config = {
userDir: './userDir/', userDir: './userDir/',
dataFile: 'datas.csv', dataFile: 'datas.csv',
caProPercentage: 0.5, caProPercentage: 0.5,
monthDesc : [
{
color: '',
desc: 'CA "scéances effectuées"',
type: 'base',
name: 'caTheo',
unit: '€',
hightlight: true,
},
{
color: '',
desc: 'CA "Séances facturées"',
type: 'base',
name: 'caRetro',
unit: '€',
hightlight: false,
},
{
color: '',
desc: 'CA "Séances facturées" réactualisé',
type: 'base',
name: 'caReact',
unit: '€',
hightlight: true,
},
{
color: '',
desc: 'Nombre de séances effectuées',
type: 'base',
name: 'sessionQty',
unit: '',
hightlight: false,
},
{
color: '',
desc: 'Montant de la rétrocession',
type: 'base',
name: 'retro',
unit: '€',
hightlight: false,
},
{
color: '',
desc: 'Rémuneration',
type: 'base',
name: 'remuneration',
unit: '€',
hightlight: true,
},
{
color: '',
desc: 'Pourcentage du CA pour la partie pro',
type: 'base',
name: 'proPercentage',
unit: '%',
hightlight: false,
},
],
} }
}, },
getters: { getters: {
userDir (state) { return state.userDir }, userDir (state) { return state.userDir },
dataFilePath (state) { return path.join(state.userDir, state.dataFile) }, dataFilePath (state) { return path.join(state.userDir, state.dataFile) },
monthDesc (state) { return state.monthDesc },
monthHightlightDesc (state) { return state.monthDesc.filter(a => a.hightlight) },
caProPercentage (state) { return state.caProPercentage }, caProPercentage (state) { return state.caProPercentage },
}, },
mutations: { mutations: {

View File

@ -7,62 +7,15 @@ const travail = {
state() { state() {
return { return {
empty: { empty: {
ca_theo: null, // ca théorique basé sur les séances effectuées caTheo: null, // ca théorique basé sur les séances effectuées
nbr_seances: null, // Nombre de séances effectuées sur le mois sessionQty: null, // Nombre de séances effectuées sur le mois
ca_retro: null, // ca au moment de la rétrocession caRetro: null, // ca au moment de la rétrocession
ca_react: null, // ca réactualisé caReact: null, // ca réactualisé
retro: 0, // montant de la rétrocession retro: 0, // montant de la rétrocession
remuneration: 0, // rémunération décidée remuneration: 0, // rémunération décidée
proPercentage: 50, // Pourcentage du CA pour la partie pro
}, },
months: { months: {
// "2021-01": {
// ca_theo: null, // ca théorique basé sur les séances effectuées
// nbr_seances: null, // Nombre de séances effectuées sur le mois
// ca_retro: 6747, // ca au moment de la rétrocession
// ca_react: null, // ca réactualisé
// retro: 893, // montant de la rétrocession
// remuneration: 2000, // rémunération décidée
// },
// "2021-02": {
// ca_theo: null, // ca théorique basé sur les séances effectuées
// nbr_seances: null, // Nombre de séances effectuées sur le mois
// ca_retro: 5183, // ca au moment de la rétrocession
// ca_react: null, // ca réactualisé
// retro: 665, // montant de la rétrocession
// remuneration: 1500, // rémunération décidée
// },
// "2021-03": {
// ca_theo: null, // ca théorique basé sur les séances effectuées
// nbr_seances: null, // Nombre de séances effectuées sur le mois
// ca_retro: 7088, // ca au moment de la rétrocession
// ca_react: null, // ca réactualisé
// retro: 855, // montant de la rétrocession
// remuneration: 2000, // rémunération décidée
// },
// "2021-04": {
// ca_theo: null, // ca théorique basé sur les séances effectuées
// nbr_seances: null, // Nombre de séances effectuées sur le mois
// ca_retro: 4194, // ca au moment de la rétrocession
// ca_react: 5630, // ca réactualisé
// retro: 627, // montant de la rétrocession
// remuneration: 2000, // rémunération décidée
// },
// "2021-05": {
// ca_theo: null, // ca théorique basé sur les séances effectuées
// nbr_seances: null, // Nombre de séances effectuées sur le mois
// ca_retro: 5564, // ca au moment de la rétrocession
// ca_react: 6335, // ca réactualisé
// retro: 699, // montant de la rétrocession
// remuneration: 2800, // rémunération décidée
// },
// "2021-06": {
// ca_theo: null, // ca théorique basé sur les séances effectuées
// nbr_seances: null, // Nombre de séances effectuées sur le mois
// ca_retro: 5442, // ca au moment de la rétrocession
// ca_react: 6335, // ca réactualisé
// retro: 638, // montant de la rétrocession
// remuneration: 2800, // rémunération décidée
// },
}, },
range: { range: {
start: "2021-01", start: "2021-01",
@ -81,6 +34,10 @@ const travail = {
// Get all the months // Get all the months
return Object.keys(state.months).sort().reverse() return Object.keys(state.months).sort().reverse()
}, },
lastMonthDate(state) {
// Return the date of the last registered month
return Object.keys(state.months).sort().reverse()[0]
},
months: (state, getters) => { months: (state, getters) => {
// Get in range months // Get in range months
const a = Object.keys(state.months) const a = Object.keys(state.months)

View File

@ -3,7 +3,7 @@ body {
} }
button { button {
color: white; color: black;
padding: 4px; padding: 4px;
box-shadow: 1px 1px 2px gray; box-shadow: 1px 1px 2px gray;
text-align: center; text-align: center;
@ -17,6 +17,8 @@ button {
} }
button:hover { button:hover {
background-color: black;
color: white;
transition: all 0.2s ease-out; transition: all 0.2s ease-out;
} }

View File

@ -1,8 +1,8 @@
ca_theo,nbr_seances,ca_retro,ca_react,retro,remuneration,date caTheo,sessionQty,caRetro,caReact,retro,remuneration,date,proPercentage
7000,,6747,,893,2000,2021-01 7000,,6747,,893,2000,2021-01,50
5200,,5183,,665,1500,2021-02 5200,,5183,,665,1500,2021-02,50
7100,,7088,,855,2000,2021-03 7100,,7088,,855,2000,2021-03,50
5700,,4194,5630,627,2000,2021-04 5700,,4194,5630,627,2000,2021-04,50
6500,,5564,6335,699,2800,2021-05 6500,,5564,6335,699,2800,2021-05,50
6725,235,5442,6376,638,2800,2021-06 6725,235,5442,6376,638,2800,2021-06,50
2176,81,1274,,172,2000,2021-07 2176,81,1274,,172,2000,2021-07,50

1 ca_theo caTheo nbr_seances sessionQty ca_retro caRetro ca_react caReact retro remuneration date proPercentage
2 7000 7000 6747 6747 893 2000 2021-01 50
3 5200 5200 5183 5183 665 1500 2021-02 50
4 7100 7100 7088 7088 855 2000 2021-03 50
5 5700 5700 4194 4194 5630 5630 627 2000 2021-04 50
6 6500 6500 5564 5564 6335 6335 699 2800 2021-05 50
7 6725 6725 235 235 5442 5442 6376 6376 638 2800 2021-06 50
8 2176 2176 81 81 1274 1274 172 2000 2021-07 50