little bugfixes
if finanzer add credit or amount to somebody it will update ui
This commit is contained in:
parent
f6b28aa7ae
commit
3d6d3259a5
|
@ -161,7 +161,7 @@
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log(this.selectedYear.value, this.type.value, this.selectedMonth.value)
|
console.log(this.selectedYear.value, this.type.value, this.selectedMonth.value)
|
||||||
if (this.type.value === 'amount') {
|
if (this.type.value === 'amount') {
|
||||||
this.$emit("add:amount", {user: user, amount: this.amount, year: this.selectedYear, month: this.selectedMonth})
|
this.$emit("add:amount", {user: user, amount: this.amount, year: this.selectedYear.value, month: this.selectedMonth.value})
|
||||||
}
|
}
|
||||||
if (this.type.value === 'credit') {
|
if (this.type.value === 'credit') {
|
||||||
this.$emit("add:credit", {user: user, credit: this.amount, year: this.selectedYear.value, month: this.selectedMonth.value})
|
this.$emit("add:credit", {user: user, credit: this.amount, year: this.selectedYear.value, month: this.selectedMonth.value})
|
||||||
|
|
|
@ -81,7 +81,7 @@
|
||||||
return {
|
return {
|
||||||
headers: [
|
headers: [
|
||||||
{
|
{
|
||||||
text: 'Schulden / Guthpaben',
|
text: 'Schulden / Guthaben',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
sortable: false,
|
sortable: false,
|
||||||
value: 'type'
|
value: 'type'
|
||||||
|
|
|
@ -47,9 +47,11 @@
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
// eslint-disable-next-line no-console
|
if (error.response) {
|
||||||
console.log(error)
|
if (error.response.status == 401) {
|
||||||
this.$store.dispatch("logout")
|
this.$store.dispatch('logout')
|
||||||
|
}
|
||||||
|
}
|
||||||
this.users = []
|
this.users = []
|
||||||
})
|
})
|
||||||
this.users = this.users.sort((a,b) => {
|
this.users = this.users.sort((a,b) => {
|
||||||
|
@ -73,6 +75,14 @@
|
||||||
})
|
})
|
||||||
user.amount = response.data.amount
|
user.amount = response.data.amount
|
||||||
})
|
})
|
||||||
|
.catch(error => {
|
||||||
|
if (error.response) {
|
||||||
|
if (error.response.status == 401) {
|
||||||
|
this.$store.dispatch('logout')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.users = []
|
||||||
|
})
|
||||||
},
|
},
|
||||||
addCreditList(user) {
|
addCreditList(user) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
|
|
|
@ -59,56 +59,47 @@
|
||||||
this.activeUser = {...e}
|
this.activeUser = {...e}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getUser() {
|
createAmount(creditList) {
|
||||||
httpClient.getFinanzerMain(this.$store.getters.getToken)
|
|
||||||
.then(response => {
|
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.log("ich bin hier. response: ", response.data)
|
|
||||||
for (let user in response.data) {
|
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.log("user: ", user)
|
|
||||||
const lastId = this.users.length > 0 ? this.users[this.users.length - 1].id : 0
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
|
||||||
let list = {}
|
|
||||||
for (let creditList in response.data[user]['creditList']) {
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.log('creditList: ', creditList, response.data[user]['creditList'])
|
|
||||||
let amount = {
|
let amount = {
|
||||||
type:'Schulden',
|
type:'Schulden',
|
||||||
jan_amount: 0 - response.data[user]['creditList'][creditList].jan.depts,
|
jan_amount: 0 - creditList.jan.depts,
|
||||||
feb_amount: 0 - response.data[user]['creditList'][creditList].feb.depts,
|
feb_amount: 0 - creditList.feb.depts,
|
||||||
maer_amount: 0 - response.data[user]['creditList'][creditList].maer.depts,
|
maer_amount: 0 - creditList.maer.depts,
|
||||||
apr_amount:0 - response.data[user]['creditList'][creditList].apr.depts,
|
apr_amount:0 - creditList.apr.depts,
|
||||||
mai_amount: 0 - response.data[user]['creditList'][creditList].mai.depts,
|
mai_amount: 0 - creditList.mai.depts,
|
||||||
jun_amount: 0 - response.data[user]['creditList'][creditList].jun.depts,
|
jun_amount: 0 - creditList.jun.depts,
|
||||||
jul_amount: 0 - response.data[user]['creditList'][creditList].jul.depts,
|
jul_amount: 0 - creditList.jul.depts,
|
||||||
aug_amount: 0 - response.data[user]['creditList'][creditList].aug.depts,
|
aug_amount: 0 - creditList.aug.depts,
|
||||||
sep_amount: 0 - response.data[user]['creditList'][creditList].sep.depts,
|
sep_amount: 0 - creditList.sep.depts,
|
||||||
okt_amount: 0 - response.data[user]['creditList'][creditList].okt.depts,
|
okt_amount: 0 - creditList.okt.depts,
|
||||||
nov_amount: 0 - response.data[user]['creditList'][creditList].nov.depts,
|
nov_amount: 0 - creditList.nov.depts,
|
||||||
dez_amount: 0 - response.data[user]['creditList'][creditList].dez.depts,
|
dez_amount: 0 - creditList.dez.depts,
|
||||||
last: 0 - response.data[user]['creditList'][creditList]['last']
|
last: 0 - creditList['last']
|
||||||
}
|
}
|
||||||
|
|
||||||
amount.sum = amount.jan_amount + amount.feb_amount + amount.maer_amount + amount.apr_amount + amount.mai_amount + amount.jun_amount + amount.jul_amount + amount.aug_amount + amount.sep_amount + amount.okt_amount + amount.nov_amount + amount.dez_amount
|
amount.sum = amount.jan_amount + amount.feb_amount + amount.maer_amount + amount.apr_amount + amount.mai_amount + amount.jun_amount + amount.jul_amount + amount.aug_amount + amount.sep_amount + amount.okt_amount + amount.nov_amount + amount.dez_amount
|
||||||
|
return amount
|
||||||
|
},
|
||||||
|
createCredit(creditList) {
|
||||||
let credit = {
|
let credit = {
|
||||||
type:'Guthaben',
|
type:'Guthaben',
|
||||||
jan_amount: response.data[user]['creditList'][creditList].jan.credit,
|
jan_amount: creditList.jan.credit,
|
||||||
feb_amount: response.data[user]['creditList'][creditList].feb.credit,
|
feb_amount: creditList.feb.credit,
|
||||||
maer_amount: response.data[user]['creditList'][creditList].maer.credit,
|
maer_amount: creditList.maer.credit,
|
||||||
apr_amount:response.data[user]['creditList'][creditList].apr.credit,
|
apr_amount: creditList.apr.credit,
|
||||||
mai_amount:response.data[user]['creditList'][creditList].mai.credit,
|
mai_amount: creditList.mai.credit,
|
||||||
jun_amount:response.data[user]['creditList'][creditList].jun.credit,
|
jun_amount: creditList.jun.credit,
|
||||||
jul_amount:response.data[user]['creditList'][creditList].jul.credit,
|
jul_amount: creditList.jul.credit,
|
||||||
aug_amount:response.data[user]['creditList'][creditList].aug.credit,
|
aug_amount: creditList.aug.credit,
|
||||||
sep_amount:response.data[user]['creditList'][creditList].sep.credit,
|
sep_amount: creditList.sep.credit,
|
||||||
okt_amount:response.data[user]['creditList'][creditList].okt.credit,
|
okt_amount: creditList.okt.credit,
|
||||||
nov_amount:response.data[user]['creditList'][creditList].nov.credit,
|
nov_amount: creditList.nov.credit,
|
||||||
dez_amount:response.data[user]['creditList'][creditList].dez.credit
|
dez_amount: creditList.dez.credit
|
||||||
}
|
}
|
||||||
credit.sum = credit.jan_amount + credit.feb_amount + credit.maer_amount + credit.apr_amount + credit.mai_amount + credit.jun_amount + credit.jul_amount + credit.aug_amount + credit.sep_amount + credit.okt_amount + credit.nov_amount + credit.dez_amount
|
credit.sum = credit.jan_amount + credit.feb_amount + credit.maer_amount + credit.apr_amount + credit.mai_amount + credit.jun_amount + credit.jul_amount + credit.aug_amount + credit.sep_amount + credit.okt_amount + credit.nov_amount + credit.dez_amount
|
||||||
|
return credit
|
||||||
|
},
|
||||||
|
createSum(credit, amount) {
|
||||||
let sum = {
|
let sum = {
|
||||||
type:'Summe',
|
type:'Summe',
|
||||||
jan_amount: credit.jan_amount + amount.jan_amount,
|
jan_amount: credit.jan_amount + amount.jan_amount,
|
||||||
|
@ -125,7 +116,27 @@
|
||||||
dez_amount: credit.dez_amount + amount.dez_amount,
|
dez_amount: credit.dez_amount + amount.dez_amount,
|
||||||
}
|
}
|
||||||
sum.sum = sum.jan_amount + sum.feb_amount + sum.maer_amount + sum.apr_amount + sum.mai_amount + sum.jun_amount + sum.jul_amount + sum.aug_amount + sum.sep_amount + sum.okt_amount + sum.nov_amount + sum.dez_amount
|
sum.sum = sum.jan_amount + sum.feb_amount + sum.maer_amount + sum.apr_amount + sum.mai_amount + sum.jun_amount + sum.jul_amount + sum.aug_amount + sum.sep_amount + sum.okt_amount + sum.nov_amount + sum.dez_amount
|
||||||
|
return sum
|
||||||
|
},
|
||||||
|
getUser() {
|
||||||
|
httpClient.getFinanzerMain(this.$store.getters.getToken)
|
||||||
|
.then(response => {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log("ich bin hier. response: ", response.data)
|
||||||
|
for (let user in response.data) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log("user: ", user)
|
||||||
|
const lastId = this.users.length > 0 ? this.users[this.users.length - 1].id : 0
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
let list = {}
|
||||||
|
for (let creditList in response.data[user]['creditList']) {
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log('creditList: ', creditList, response.data[user]['creditList'])
|
||||||
|
|
||||||
|
let amount = this.createAmount(response.data[user]['creditList'][creditList])
|
||||||
|
let credit = this.createCredit(response.data[user]['creditList'][creditList])
|
||||||
|
let sum = this.createSum(credit, amount)
|
||||||
list[creditList] = [{...credit}, {...amount}, {...sum}]
|
list[creditList] = [{...credit}, {...amount}, {...sum}]
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log("creditList list:", creditList, list)
|
console.log("creditList list:", creditList, list)
|
||||||
|
@ -141,8 +152,12 @@
|
||||||
})
|
})
|
||||||
}})
|
}})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
// eslint-disable-next-line no-console
|
if (error.response) {
|
||||||
console.log("error: ", error.response.data.error)
|
if (error.response.status == 401) {
|
||||||
|
this.$store.dispatch('logout')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.users = []
|
||||||
})
|
})
|
||||||
|
|
||||||
this.users = this.users.sort((a, b) => {
|
this.users = this.users.sort((a, b) => {
|
||||||
|
@ -158,10 +173,68 @@
|
||||||
},
|
},
|
||||||
addAmount(data) {
|
addAmount(data) {
|
||||||
httpClient.addAmountFinanzer(this.$store.getters.getToken, {userId: data.user.username, amount: data.amount * 100, year: data.year, month: data.month})
|
httpClient.addAmountFinanzer(this.$store.getters.getToken, {userId: data.user.username, amount: data.amount * 100, year: data.year, month: data.month})
|
||||||
|
.then(response => {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(response.data)
|
||||||
|
|
||||||
|
let user = this.users.find(user => {return user.username === data.user.username})
|
||||||
|
let index = this.users.indexOf(user)
|
||||||
|
let list = {}
|
||||||
|
for (let creditList in response.data) {
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log('creditList: ', creditList, response.data[creditList])
|
||||||
|
|
||||||
|
let amount = this.createAmount(response.data[creditList])
|
||||||
|
let credit = this.createCredit(response.data[creditList])
|
||||||
|
let sum = this.createSum(credit, amount)
|
||||||
|
list[creditList] = [{...credit}, {...amount}, {...sum}]
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log("creditList list:", creditList, list)
|
||||||
|
}
|
||||||
|
this.users[index].creditList = list
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
if (error.response) {
|
||||||
|
if (error.response.status == 401) {
|
||||||
|
this.$store.dispatch('logout')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.users = []
|
||||||
|
})
|
||||||
},
|
},
|
||||||
addCredit(data) {
|
addCredit(data) {
|
||||||
|
|
||||||
httpClient.addCreditFinanzer(this.$store.getters.getToken, {userId: data.user.username, credit: data.credit * 100, year: data.year, month: data.month})
|
httpClient.addCreditFinanzer(this.$store.getters.getToken, {userId: data.user.username, credit: data.credit * 100, year: data.year, month: data.month})
|
||||||
|
.then(response => {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(response.data)
|
||||||
|
|
||||||
|
let user = this.users.find(user => {return user.username === data.user.username})
|
||||||
|
let index = this.users.indexOf(user)
|
||||||
|
let list = {}
|
||||||
|
for (let creditList in response.data) {
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log('creditList: ', creditList, response.data[creditList])
|
||||||
|
|
||||||
|
let amount = this.createAmount(response.data[creditList])
|
||||||
|
let credit = this.createCredit(response.data[creditList])
|
||||||
|
let sum = this.createSum(credit, amount)
|
||||||
|
list[creditList] = [{...credit}, {...amount}, {...sum}]
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log("creditList list:", creditList, list)
|
||||||
|
}
|
||||||
|
this.users[index].creditList = list
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
if (error.response) {
|
||||||
|
if (error.response.status == 401) {
|
||||||
|
this.$store.dispatch('logout')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.users = []
|
||||||
|
})
|
||||||
},
|
},
|
||||||
deactivateAllUser() {
|
deactivateAllUser() {
|
||||||
for (let user in this.users) {
|
for (let user in this.users) {
|
||||||
|
|
Loading…
Reference in New Issue