Compare commits
8 Commits
b266e9de9b
...
5020479b0a
Author | SHA1 | Date | |
---|---|---|---|
5020479b0a | |||
899fd95dbd | |||
1a2799e986 | |||
7ca7af24b9 | |||
6188337140 | |||
791aa12d2d | |||
4a9e49fc20 | |||
0bd48159a4 |
0
jsconfig.json
Normal file
0
jsconfig.json
Normal file
@ -15,6 +15,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"core-js": "^3.6.5",
|
"core-js": "^3.6.5",
|
||||||
"date-fns": "^2.23.0",
|
"date-fns": "^2.23.0",
|
||||||
|
"papaparse": "^5.3.1",
|
||||||
"vls": "^0.7.4",
|
"vls": "^0.7.4",
|
||||||
"vue": "^3.0.0",
|
"vue": "^3.0.0",
|
||||||
"vue-router": "^4.0.8",
|
"vue-router": "^4.0.8",
|
||||||
|
@ -74,10 +74,14 @@ export default {
|
|||||||
...mapActions('travail', {
|
...mapActions('travail', {
|
||||||
'createMonth': 'createMonth',
|
'createMonth': 'createMonth',
|
||||||
}),
|
}),
|
||||||
|
...mapActions('config', {
|
||||||
|
'writeData': 'writeData',
|
||||||
|
}),
|
||||||
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: this.monthDate, month: this.monthCopy})
|
||||||
|
this.writeData()
|
||||||
},
|
},
|
||||||
cancel: function () {
|
cancel: function () {
|
||||||
this.monthCopy = this.theEmptyMonth
|
this.monthCopy = this.theEmptyMonth
|
||||||
|
@ -69,12 +69,16 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
...mapActions('travail', {
|
...mapActions('travail', {
|
||||||
'updateMonth': 'updateMonth',
|
'updateMonth': 'updateMonth',
|
||||||
|
}),
|
||||||
|
...mapActions('config', {
|
||||||
|
'writeData': 'writeData',
|
||||||
}),
|
}),
|
||||||
toggleEdit: function () {
|
toggleEdit: function () {
|
||||||
this.editing = !this.editing
|
this.editing = !this.editing
|
||||||
},
|
},
|
||||||
save: function () {
|
save: function () {
|
||||||
this.updateMonth({date: this.TheDate, month: {...this.monthCopy}})
|
this.updateMonth({date: this.TheDate, month: {...this.monthCopy}})
|
||||||
|
this.writeData()
|
||||||
this.toggleEdit()
|
this.toggleEdit()
|
||||||
},
|
},
|
||||||
cancel: function () {
|
cancel: function () {
|
||||||
|
@ -71,6 +71,8 @@ export default {
|
|||||||
retrocessionMean: "retrocessionMean",
|
retrocessionMean: "retrocessionMean",
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
mounted () {
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
range: function (newRange, oldRange) {
|
range: function () {
|
||||||
this.start = this.range.start
|
this.start = this.range.start
|
||||||
this.end = this.range.end
|
this.end = this.range.end
|
||||||
},
|
},
|
||||||
|
42
src/store/config/index.js
Normal file
42
src/store/config/index.js
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
import path from 'path'
|
||||||
|
import Papa from 'papaparse'
|
||||||
|
import { writeFile } from 'fs'
|
||||||
|
|
||||||
|
const config = {
|
||||||
|
namespaced: true,
|
||||||
|
state() {
|
||||||
|
return {
|
||||||
|
//userDir: '~/.config/sousmargot/',
|
||||||
|
userDir: './userDir/',
|
||||||
|
dataFile: 'datas.csv'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
getters: {
|
||||||
|
userDir (state) { return state.userDir },
|
||||||
|
dataFilePath (state) { return path.join(state.userDir, state.dataFile) },
|
||||||
|
},
|
||||||
|
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
|
||||||
|
|
@ -1,10 +1,12 @@
|
|||||||
import { createStore } from 'vuex'
|
import { createStore } from 'vuex'
|
||||||
import travailStore from "./travail"
|
import travailStore from "./travail"
|
||||||
|
import configStore from "./config"
|
||||||
|
|
||||||
// Create a new store instance.
|
// Create a new store instance.
|
||||||
const store = createStore({
|
const store = createStore({
|
||||||
modules:{
|
modules:{
|
||||||
travail: travailStore,
|
travail: travailStore,
|
||||||
|
config: configStore,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
import { readFile } from 'fs'
|
||||||
|
import Papa from 'papaparse'
|
||||||
|
|
||||||
function monthCA(month) {
|
function monthCA(month) {
|
||||||
if (month.ca_react) {
|
if (month.ca_react) {
|
||||||
return month.ca_react
|
return month.ca_react
|
||||||
@ -19,54 +22,54 @@ const travail = {
|
|||||||
remuneration: 0, // rémunération décidée
|
remuneration: 0, // rémunération décidée
|
||||||
},
|
},
|
||||||
months: {
|
months: {
|
||||||
"2021-01": {
|
//"2021-01": {
|
||||||
ca_theo: null, // ca théorique basé sur les séances effectuées
|
// 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
|
// nbr_seances: null, // Nombre de séances effectuées sur le mois
|
||||||
ca_retro: 6747, // ca au moment de la rétrocession
|
// ca_retro: 6747, // ca au moment de la rétrocession
|
||||||
ca_react: null, // ca réactualisé
|
// ca_react: null, // ca réactualisé
|
||||||
retro: 893, // montant de la rétrocession
|
// retro: 893, // montant de la rétrocession
|
||||||
remuneration: 2000, // rémunération décidée
|
// remuneration: 2000, // rémunération décidée
|
||||||
},
|
//},
|
||||||
"2021-02": {
|
//"2021-02": {
|
||||||
ca_theo: null, // ca théorique basé sur les séances effectuées
|
// 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
|
// nbr_seances: null, // Nombre de séances effectuées sur le mois
|
||||||
ca_retro: 5183, // ca au moment de la rétrocession
|
// ca_retro: 5183, // ca au moment de la rétrocession
|
||||||
ca_react: null, // ca réactualisé
|
// ca_react: null, // ca réactualisé
|
||||||
retro: 665, // montant de la rétrocession
|
// retro: 665, // montant de la rétrocession
|
||||||
remuneration: 1500, // rémunération décidée
|
// remuneration: 1500, // rémunération décidée
|
||||||
},
|
//},
|
||||||
"2021-03": {
|
//"2021-03": {
|
||||||
ca_theo: null, // ca théorique basé sur les séances effectuées
|
// 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
|
// nbr_seances: null, // Nombre de séances effectuées sur le mois
|
||||||
ca_retro: 7088, // ca au moment de la rétrocession
|
// ca_retro: 7088, // ca au moment de la rétrocession
|
||||||
ca_react: null, // ca réactualisé
|
// ca_react: null, // ca réactualisé
|
||||||
retro: 855, // montant de la rétrocession
|
// retro: 855, // montant de la rétrocession
|
||||||
remuneration: 2000, // rémunération décidée
|
// remuneration: 2000, // rémunération décidée
|
||||||
},
|
//},
|
||||||
"2021-04": {
|
//"2021-04": {
|
||||||
ca_theo: null, // ca théorique basé sur les séances effectuées
|
// 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
|
// nbr_seances: null, // Nombre de séances effectuées sur le mois
|
||||||
ca_retro: 4194, // ca au moment de la rétrocession
|
// ca_retro: 4194, // ca au moment de la rétrocession
|
||||||
ca_react: 5630, // ca réactualisé
|
// ca_react: 5630, // ca réactualisé
|
||||||
retro: 627, // montant de la rétrocession
|
// retro: 627, // montant de la rétrocession
|
||||||
remuneration: 2000, // rémunération décidée
|
// remuneration: 2000, // rémunération décidée
|
||||||
},
|
//},
|
||||||
"2021-05": {
|
//"2021-05": {
|
||||||
ca_theo: null, // ca théorique basé sur les séances effectuées
|
// 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
|
// nbr_seances: null, // Nombre de séances effectuées sur le mois
|
||||||
ca_retro: 5564, // ca au moment de la rétrocession
|
// ca_retro: 5564, // ca au moment de la rétrocession
|
||||||
ca_react: 6335, // ca réactualisé
|
// ca_react: 6335, // ca réactualisé
|
||||||
retro: 699, // montant de la rétrocession
|
// retro: 699, // montant de la rétrocession
|
||||||
remuneration: 2800, // rémunération décidée
|
// remuneration: 2800, // rémunération décidée
|
||||||
},
|
//},
|
||||||
"2021-06": {
|
//"2021-06": {
|
||||||
ca_theo: null, // ca théorique basé sur les séances effectuées
|
// 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
|
// nbr_seances: null, // Nombre de séances effectuées sur le mois
|
||||||
ca_retro: 5442, // ca au moment de la rétrocession
|
// ca_retro: 5442, // ca au moment de la rétrocession
|
||||||
ca_react: 6335, // ca réactualisé
|
// ca_react: 6335, // ca réactualisé
|
||||||
retro: 638, // montant de la rétrocession
|
// retro: 638, // montant de la rétrocession
|
||||||
remuneration: 2800, // rémunération décidée
|
// remuneration: 2800, // rémunération décidée
|
||||||
},
|
//},
|
||||||
},
|
},
|
||||||
range: {
|
range: {
|
||||||
start: "2021-01",
|
start: "2021-01",
|
||||||
@ -87,12 +90,17 @@ const travail = {
|
|||||||
},
|
},
|
||||||
months: (state, getters) => {
|
months: (state, getters) => {
|
||||||
// Get in range months
|
// Get in range months
|
||||||
return Object.keys(state.months)
|
const a = Object.keys(state.months)
|
||||||
.filter(a => getters.MonthsDate.includes(a))
|
.filter(a => getters.MonthsDate.includes(a))
|
||||||
.reduce((acc, v) => {
|
.reduce((acc, v) => {
|
||||||
acc[v] = state.months[v];
|
acc[v] = state.months[v];
|
||||||
return acc;
|
return acc;
|
||||||
}, {})
|
}, {})
|
||||||
|
return a
|
||||||
|
},
|
||||||
|
monthsAll: (state) => {
|
||||||
|
// Get in range months
|
||||||
|
return state.months
|
||||||
},
|
},
|
||||||
getMonth: (state) => (date) => {
|
getMonth: (state) => (date) => {
|
||||||
return state.months[date]
|
return state.months[date]
|
||||||
@ -103,17 +111,19 @@ const travail = {
|
|||||||
},
|
},
|
||||||
ca: (state, getters) => {
|
ca: (state, getters) => {
|
||||||
// Total CA (ca_react if sets, ca_retro otherwise)
|
// Total CA (ca_react if sets, ca_retro otherwise)
|
||||||
return Object.values(getters.months).map(a => monthCA(a)).reduce(
|
const a = Object.values(getters.months).map(a => monthCA(a)).reduce(
|
||||||
(acc, v) => acc + v,
|
(acc, v) => acc + v
|
||||||
0
|
,0
|
||||||
)
|
)
|
||||||
|
return a
|
||||||
},
|
},
|
||||||
caMean: (state, getters) => {
|
caMean: (state, getters) => {
|
||||||
// Mean of CA
|
// Mean of CA
|
||||||
return Math.floor(Object.values(state.months).map(a => monthCA(a)).reduce(
|
if (getters.count > 0) {
|
||||||
(acc, v) => acc + v,
|
return Math.floor(getters.ca / getters.count)
|
||||||
0
|
} else {
|
||||||
) / getters.count)
|
return "..."
|
||||||
|
}
|
||||||
},
|
},
|
||||||
caTheo: (state, getters) => {
|
caTheo: (state, getters) => {
|
||||||
// Total theorical CA
|
// Total theorical CA
|
||||||
@ -131,10 +141,7 @@ const travail = {
|
|||||||
},
|
},
|
||||||
remunerationMean: (state, getters) => {
|
remunerationMean: (state, getters) => {
|
||||||
// Mean of remuneration
|
// Mean of remuneration
|
||||||
return Math.floor(Object.values(getters.months).map(a => a.remuneration).reduce(
|
return Math.floor(getters.remuneration / getters.count)
|
||||||
(acc, v) => acc + v,
|
|
||||||
0
|
|
||||||
) / getters.count)
|
|
||||||
},
|
},
|
||||||
retrocession: (state, getters) => {
|
retrocession: (state, getters) => {
|
||||||
// Total retrocession
|
// Total retrocession
|
||||||
@ -147,17 +154,19 @@ const travail = {
|
|||||||
},
|
},
|
||||||
retrocessionMean: (state, getters) => {
|
retrocessionMean: (state, getters) => {
|
||||||
// Mean of retrocession
|
// Mean of retrocession
|
||||||
return Math.floor(
|
return Math.floor(getters.retrocession / getters.count
|
||||||
Object.values(getters.months)
|
|
||||||
.map(a => a.retro)
|
|
||||||
.reduce(
|
|
||||||
(acc, v) => acc + v,
|
|
||||||
0
|
|
||||||
) / getters.count
|
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
|
cleanMonths (state) {
|
||||||
|
// erase months
|
||||||
|
state.months = []
|
||||||
|
},
|
||||||
|
importMonths(state, months) {
|
||||||
|
// overwrite months
|
||||||
|
state.months = months
|
||||||
|
},
|
||||||
updateMonth(state, { date, month }) {
|
updateMonth(state, { date, month }) {
|
||||||
state.months[date] = month
|
state.months[date] = month
|
||||||
},
|
},
|
||||||
@ -169,6 +178,23 @@ const travail = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
|
cleanMonths (context) {
|
||||||
|
context.commit("cleanMonths")
|
||||||
|
},
|
||||||
|
loadMonths (context) {
|
||||||
|
// import all months from storage
|
||||||
|
readFile(context.rootGetters["config/dataFilePath"], (err, data) => {
|
||||||
|
if (err) throw err;
|
||||||
|
const months = Papa.parse(data.toString(), {header: true, dynamicTyping:true, skipEmptyLines:true})
|
||||||
|
.data
|
||||||
|
.reduce(
|
||||||
|
(acc, el) => {
|
||||||
|
acc[el.date] = el;
|
||||||
|
return acc
|
||||||
|
}, {})
|
||||||
|
context.commit("importMonths", months)
|
||||||
|
})
|
||||||
|
},
|
||||||
updateMonth(context, { date, month }) {
|
updateMonth(context, { date, month }) {
|
||||||
// update month's datas
|
// update month's datas
|
||||||
if (date in context.state.months) {
|
if (date in context.state.months) {
|
||||||
@ -180,9 +206,7 @@ const travail = {
|
|||||||
createMonth(context, { date, month }) {
|
createMonth(context, { date, month }) {
|
||||||
// Create a new month
|
// Create a new month
|
||||||
if (!(date in context.state.months)) {
|
if (!(date in context.state.months)) {
|
||||||
console.log(date)
|
|
||||||
context.commit('createMonth', { date, month })
|
context.commit('createMonth', { date, month })
|
||||||
console.log(context.state.months)
|
|
||||||
} else {
|
} else {
|
||||||
console.log("This month already exists")
|
console.log("This month already exists")
|
||||||
}
|
}
|
||||||
@ -190,7 +214,6 @@ const travail = {
|
|||||||
setRange(context, range) {
|
setRange(context, range) {
|
||||||
context.commit("setRange", range)
|
context.commit("setRange", range)
|
||||||
},
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<h1>Home</h1>
|
<h1>Home</h1>
|
||||||
|
<button @click="writeData" ></button>
|
||||||
<section id="selector">
|
<section id="selector">
|
||||||
<month-selector>
|
<month-selector>
|
||||||
</month-selector>
|
</month-selector>
|
||||||
@ -18,7 +19,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapGetters, mapActions } from 'vuex'
|
import { mapActions } from 'vuex'
|
||||||
import MonthsList from '../components/MonthsUl.vue'
|
import MonthsList from '../components/MonthsUl.vue'
|
||||||
import CreateMonth from '../components/CreateMonth.vue'
|
import CreateMonth from '../components/CreateMonth.vue'
|
||||||
import MonthSelector from '../components/monthSelector.vue'
|
import MonthSelector from '../components/monthSelector.vue'
|
||||||
@ -30,19 +31,23 @@ export default {
|
|||||||
CreateMonth: CreateMonth,
|
CreateMonth: CreateMonth,
|
||||||
MonthSelector: MonthSelector,
|
MonthSelector: MonthSelector,
|
||||||
highlights: Highlights,
|
highlights: Highlights,
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {}
|
return {}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters({
|
},
|
||||||
count: "datas/count",
|
methods: {
|
||||||
})
|
...mapActions('config', {
|
||||||
},
|
'writeData': 'writeData',
|
||||||
methods: {
|
}),
|
||||||
...mapActions({
|
...mapActions('travail', {
|
||||||
})
|
'loadMonths': 'loadMonths',
|
||||||
},
|
}),
|
||||||
|
},
|
||||||
|
mounted () {
|
||||||
|
this.loadMonths()
|
||||||
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
1
userDir/datas.csv
Normal file
1
userDir/datas.csv
Normal file
@ -0,0 +1 @@
|
|||||||
|
ca_theo, nbr_seances, ca_retro, ca_react, retro, remuneration,
|
|
7
vue.config.js
Normal file
7
vue.config.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
module.exports = {
|
||||||
|
pluginOptions: {
|
||||||
|
electronBuilder: {
|
||||||
|
nodeIntegration: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user