162 lines
5.3 KiB
JavaScript
162 lines
5.3 KiB
JavaScript
import path from 'path'
|
|
import Papa from 'papaparse'
|
|
import { writeFile } from 'fs'
|
|
import {
|
|
ca,
|
|
notInvoiced,
|
|
caPro,
|
|
caPerso,
|
|
caPersoUntouch,
|
|
} from '../../lib/months.js'
|
|
|
|
const config = {
|
|
namespaced: true,
|
|
state() {
|
|
return {
|
|
//userDir: '~/.config/sousmargot/',
|
|
userDir: './userDir/',
|
|
dataFile: 'datas.csv',
|
|
caProPercentage: 0.5,
|
|
monthDesc : [
|
|
{
|
|
name: 'caTheo',
|
|
color: '',
|
|
desc: 'CA "scéances effectuées"',
|
|
type: 'base',
|
|
unit: '€',
|
|
hightlight: false,
|
|
output: month => month.caTheo,
|
|
},
|
|
{
|
|
name: 'caRetro',
|
|
color: '',
|
|
desc: 'CA "Séances facturées"',
|
|
type: 'base',
|
|
unit: '€',
|
|
hightlight: false,
|
|
output: month => month.caRetro,
|
|
},
|
|
{
|
|
name: 'caReact',
|
|
color: '',
|
|
desc: 'CA "Séances facturées" réactualisé',
|
|
type: 'base',
|
|
unit: '€',
|
|
hightlight: false,
|
|
output: month => month.caReact,
|
|
},
|
|
{
|
|
name: 'sessionQty',
|
|
color: '',
|
|
desc: 'Nombre de séances effectuées',
|
|
unit: '',
|
|
hightlight: false,
|
|
output: month => month.sessionQty,
|
|
},
|
|
{
|
|
name: 'retro',
|
|
color: '',
|
|
desc: 'Montant de la rétrocession',
|
|
type: 'base',
|
|
unit: '€',
|
|
hightlight: false,
|
|
output: month => month.retro,
|
|
},
|
|
{
|
|
name: 'remuneration',
|
|
color: '',
|
|
desc: 'Rémuneration',
|
|
type: 'base',
|
|
unit: '€',
|
|
hightlight: true,
|
|
output: month => month.remuneration,
|
|
},
|
|
{
|
|
name: 'proPercentage',
|
|
color: '',
|
|
desc: 'Pourcentage du CA pour la partie pro',
|
|
type: 'base',
|
|
unit: '%',
|
|
hightlight: false,
|
|
output: month => month.proPercentage,
|
|
},
|
|
{
|
|
name: 'ca',
|
|
color: '',
|
|
desc: 'ca',
|
|
type: 'compute',
|
|
unit: '€',
|
|
hightlight: true,
|
|
output: month => ca(month),
|
|
},
|
|
{
|
|
name: 'notInvoiced',
|
|
color: '',
|
|
desc: 'Non facturé',
|
|
type: 'compute',
|
|
unit: '€',
|
|
hightlight: true,
|
|
output: month => notInvoiced(month),
|
|
},
|
|
{
|
|
name: 'caPro',
|
|
color: '',
|
|
desc: 'CA pour le partie pro',
|
|
type: 'compute',
|
|
unit: '€',
|
|
hightlight: false,
|
|
output: month => caPro(month),
|
|
},
|
|
{
|
|
name: 'caPerso',
|
|
color: '',
|
|
desc: 'CA destiné à la rémuneration',
|
|
type: 'compute',
|
|
unit: '€',
|
|
hightlight: false,
|
|
output: month => caPerso(month),
|
|
},
|
|
{
|
|
name: 'caPersoUntouch',
|
|
color: '',
|
|
desc: 'CA destiné à la rémuneration non reversé',
|
|
type: 'compute',
|
|
unit: '€',
|
|
hightlight: false,
|
|
output: month => caPersoUntouch(month),
|
|
},
|
|
],
|
|
}
|
|
},
|
|
getters: {
|
|
userDir (state) { return state.userDir },
|
|
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 },
|
|
},
|
|
mutations: {
|
|
},
|
|
actions: {
|
|
loadConfig (context) {
|
|
// load config file at ~/.config/sousmargot/config.json
|
|
return context.state.userDir
|
|
},
|
|
writeData (context) {
|
|
// overwrite the dataFile with months datas
|
|
const months = context.rootGetters['travail/monthsAll']
|
|
const unpackMonths = Object.keys(months).map(k => {return { ...months[k], date: k}})
|
|
const csv = Papa.unparse(unpackMonths)
|
|
writeFile(context.getters.dataFilePath, csv, (err) => {
|
|
if (err) {
|
|
console.log(err)
|
|
} else {
|
|
console.log("Datas sauvegardées")
|
|
}
|
|
})
|
|
},
|
|
},
|
|
}
|
|
|
|
export default config
|