fixed bug ##292

hier wurde beim baruser und normalen user folgendes hinzugefügt:
es wird kontrolliert ob der anzuschreibene betrag das limit überschreitet. falls ja wird ein dialog gezeigt, welcher eine bestätigung zum anschreiben verlangt oder zurücksetzt.
sollte der betrag 5 € über den limit betragen, wird das anzuschreibende zurückgesetzt und es kommt eine warnung, dass das nicht geht.
This commit is contained in:
Tim Gröger 2020-06-19 22:51:01 +02:00
parent c86f1afd4c
commit c78ef99a0d
3 changed files with 278 additions and 81 deletions

View File

@ -35,6 +35,40 @@
</v-card-actions> </v-card-actions>
</v-card> </v-card>
</v-dialog> </v-dialog>
<v-dialog
v-if="overLimitUser"
v-model="overLimitUser"
max-width="290"
persistent
>
<v-card>
<v-card-title>Warnung</v-card-title>
<v-card-text>
{{ overLimitUser.firstname }} {{ overLimitUser.lastname }} übersteigt
das Anschreibelimit von
{{ (overLimitUser.limit / 100).toFixed(2) }} . Danach kann dieses
Mitglied nichts mehr anschreiben. Will er das wirklich?
</v-card-text>
<v-card-actions>
<v-spacer />
<v-btn text @click="cancel()">Abbrechen</v-btn>
<v-btn text @click="continueAdd(overLimitUser)">Anschreiben</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<v-dialog v-if="overOverLimit" v-model="overOverLimit" max-width="290" persistent>
<v-card>
<v-card-title>Anschreiben nicht möglich</v-card-title>
<v-card-text>
{{ overOverLimit.firstname }}
{{ overOverLimit.lastname }} überschreitet das Anschreibelimit zuviel.
Das Anschreiben wurde daher gestoppt und zurückgesetzt.
</v-card-text>
<v-card-actions>
<v-btn text @click="overOverLimit = null">Verstanden</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<v-progress-linear v-if="loading && users.length !== 0" indeterminate /> <v-progress-linear v-if="loading && users.length !== 0" indeterminate />
<v-container> <v-container>
<AddAmountSkeleton v-if="loading && users.length === 0" /> <AddAmountSkeleton v-if="loading && users.length === 0" />
@ -173,9 +207,7 @@
<v-list-item> <v-list-item>
<v-list-item-content class="text-center"> <v-list-item-content class="text-center">
<v-list-item-action-text :class="getColor(user.type)" <v-list-item-action-text :class="getColor(user.type)"
>{{ >{{ (user.amount / 100).toFixed(2) }}
(user.amount / 100).toFixed(2)
}}
</v-list-item-action-text> </v-list-item-action-text>
<v-list-item-action-text v-if="user.toSetAmount"> <v-list-item-action-text v-if="user.toSetAmount">
@ -192,20 +224,16 @@
>{{ user.firstname }} darf nicht mehr anschreiben. >{{ user.firstname }} darf nicht mehr anschreiben.
{{ user.firstname }} sollte sich lieber mal beim Finanzer {{ user.firstname }} sollte sich lieber mal beim Finanzer
melden. melden.
</v-alert </v-alert>
>
</v-col> </v-col>
<v-col align-self="center" v-if="user.locked"> <v-col align-self="center" v-if="user.locked">
<v-row> <v-row>
<v-list-item> <v-list-item>
<v-list-item-content class="text-center"> <v-list-item-content class="text-center">
<v-list-item-action-text :class="getColor(user.type)" <v-list-item-action-text :class="getColor(user.type)"
>{{ >{{ (user.amount / 100).toFixed(2) }}
(user.amount / 100).toFixed(2)
}}
</v-list-item-action-text </v-list-item-action-text>
>
</v-list-item-content> </v-list-item-content>
</v-list-item> </v-list-item>
</v-row> </v-row>
@ -221,10 +249,12 @@
:value="messages.length > 0 ? messages[0].visible : test" :value="messages.length > 0 ? messages[0].visible : test"
vertical vertical
> >
<v-list-item v-for="message in messages" <v-list-item
v-for="message in messages"
:key="messages.indexOf(message)" :key="messages.indexOf(message)"
style="background-color: #4CAF50;" style="background-color: #4CAF50;"
v-show="message.visible"> v-show="message.visible"
>
<v-list-item-content> <v-list-item-content>
<v-list-item-title style="color: white"> <v-list-item-title style="color: white">
{{ createMessage(message) }} {{ createMessage(message) }}
@ -258,7 +288,9 @@ export default {
timer: '', timer: '',
stornoMessage: null, stornoMessage: null,
checkValidate: false, checkValidate: false,
test: null test: null,
overLimitUser: null,
overOverLimit: null
} }
}, },
created() { created() {
@ -273,17 +305,75 @@ export default {
deactivate: 'barUsers/deactivateMenu', deactivate: 'barUsers/deactivateMenu',
commitStorno: 'barUsers/storno' commitStorno: 'barUsers/storno'
}), }),
addingAmount(user, amount) { continueAdd(user) {
clearTimeout(user.timeout) this.overLimitUser = null
user.toSetAmount = user.toSetAmount ? user.toSetAmount + amount : amount user.checkedOverLimit = true
if (user.value) {
this.addAmount({
username: user.username,
amount: Math.round(Math.abs(user.value * 100)),
user: user
})
setTimeout(() => {
user.value = null
user.toSetAmount = null
}, 300)
} else {
user.timeout = setTimeout(() => { user.timeout = setTimeout(() => {
this.addAmount({username: user.username, this.addAmount({
username: user.username,
amount: user.toSetAmount, amount: user.toSetAmount,
user: user}) user: user
})
setTimeout(() => { setTimeout(() => {
user.toSetAmount = null user.toSetAmount = null
}, 300) }, 300)
}, 2000) }, 2000)
}
},
cancel() {
this.overLimitUser.toSetAmount = null
this.overLimitUser.value = null
this.overLimitUser = null
},
checkOverLimitIsValid(user) {
if (user.toSetAmount) {
if (Math.abs(user.amount - Number.parseInt(user.toSetAmount)) > user.limit + 500) {
this.overOverLimit = user
user.toSetAmount = null
user.value = null
return false
}
}
return true
},
checkOverLimit(user) {
if (user.toSetAmount) {
if (Math.abs( user.amount - user.toSetAmount) > user.limit) {
return user.checkedOverLimit ? false : true
}
}
return false
},
addingAmount(user, amount) {
clearTimeout(user.timeout)
user.toSetAmount = user.toSetAmount ? user.toSetAmount + amount : amount
if (this.checkOverLimitIsValid(user)) {
if (this.checkOverLimit(user)) {
this.overLimitUser = user
} else {
user.timeout = setTimeout(() => {
this.addAmount({
username: user.username,
amount: user.toSetAmount,
user: user
})
setTimeout(() => {
user.toSetAmount = null
}, 300)
}, 2000)
}
}
}, },
forceRender() { forceRender() {
this.componentRenderer += 1 this.componentRenderer += 1
@ -315,6 +405,14 @@ export default {
} }
}, },
addAmountMore(user) { addAmountMore(user) {
user.toSetAmount = user.toSetAmount
? user.toSetAmount + Math.round(Math.abs(user.value * 100))
: Math.round(Math.abs(user.value * 100))
if (this.checkOverLimitIsValid(user)) {
if (this.checkOverLimit(user)) {
this.overLimitUser = user
}
else {
this.addAmount({ this.addAmount({
username: user.username, username: user.username,
amount: Math.round(Math.abs(user.value * 100)), amount: Math.round(Math.abs(user.value * 100)),
@ -322,7 +420,10 @@ export default {
}) })
setTimeout(() => { setTimeout(() => {
user.value = null user.value = null
user.toSetAmount = null
}, 300) }, 300)
}
}
}, },
storno(message) { storno(message) {
if (!message.error) { if (!message.error) {
@ -373,7 +474,7 @@ export default {
calcLastSeen(user) { calcLastSeen(user) {
if (user.last_seen) { if (user.last_seen) {
let date = new Date() let date = new Date()
if (((date - user.last_seen)/1000/60/60) < 72) { if ((date - user.last_seen) / 1000 / 60 / 60 < 72) {
return true return true
} }
} }

View File

@ -6,7 +6,9 @@
Willst du wirklich?? Willst du wirklich??
</v-card-title> </v-card-title>
<v-card-text v-if="stornoMessage"> <v-card-text v-if="stornoMessage">
Willst du wirklich den Betrag {{(stornoMessage.amount/100).toFixed(2)}} von {{stornoMessage.user.firstname}} Willst du wirklich den Betrag
{{ (stornoMessage.amount / 100).toFixed(2) }} von
{{ stornoMessage.user.firstname }}
{{ stornoMessage.user.lastname }} stornieren? {{ stornoMessage.user.lastname }} stornieren?
</v-card-text> </v-card-text>
<v-card-actions> <v-card-actions>
@ -34,6 +36,40 @@
</v-card-actions> </v-card-actions>
</v-card> </v-card>
</v-dialog> </v-dialog>
<v-dialog
v-if="overLimitUser"
v-model="overLimitUser"
max-width="290"
persistent
>
<v-card>
<v-card-title>Warnung</v-card-title>
<v-card-text>
{{ overLimitUser.firstname }} {{ overLimitUser.lastname }} übersteigt
das Anschreibelimit von
{{ (overLimitUser.limit / 100).toFixed(2) }} . Danach kann dieses
Mitglied nichts mehr anschreiben. Will er das wirklich?
</v-card-text>
<v-card-actions>
<v-spacer />
<v-btn text @click="cancel()">Abbrechen</v-btn>
<v-btn text @click="continueAdd(overLimitUser)">Anschreiben</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<v-dialog v-if="overOverLimit" v-model="overOverLimit" max-width="290" persistent>
<v-card>
<v-card-title>Anschreiben nicht möglich</v-card-title>
<v-card-text>
{{ overOverLimit.firstname }}
{{ overOverLimit.lastname }} überschreitet das Anschreibelimit zuviel.
Das Anschreiben wurde daher gestoppt und zurückgesetzt.
</v-card-text>
<v-card-actions>
<v-btn text @click="overOverLimit = null">Verstanden</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<AddAmountSkeleton v-if="loading" /> <AddAmountSkeleton v-if="loading" />
<v-navigation-drawer v-model="menu" right app clipped> <v-navigation-drawer v-model="menu" right app clipped>
<v-list-item-group :key="componentRenderer"> <v-list-item-group :key="componentRenderer">
@ -76,6 +112,10 @@
<v-icon>{{ menuIcon }}</v-icon> <v-icon>{{ menuIcon }}</v-icon>
</v-btn> </v-btn>
</v-card-title> </v-card-title>
<v-card-subtitle v-if="user.limit + getAllSum() > 0">
Nur noch {{ ((user.limit + getAllSum()) / 100).toFixed(2) }}
übrig!!
</v-card-subtitle>
<v-card-text> <v-card-text>
<v-row> <v-row>
<v-col cols="10"> <v-col cols="10">
@ -166,12 +206,9 @@
<v-list-item> <v-list-item>
<v-list-item-content class="text-center"> <v-list-item-content class="text-center">
<v-list-item-action-text :class="getColor(getAllSum())" <v-list-item-action-text :class="getColor(getAllSum())"
>{{ >{{ (getAllSum() / 100).toFixed(2) }}
(getAllSum() / 100).toFixed(2)
}}
</v-list-item-action-text </v-list-item-action-text>
>
<v-list-item-action-text v-if="toSetAmount"> <v-list-item-action-text v-if="toSetAmount">
- {{ (toSetAmount / 100).toFixed(2) }} - {{ (toSetAmount / 100).toFixed(2) }}
</v-list-item-action-text> </v-list-item-action-text>
@ -188,7 +225,6 @@
</v-card-text> </v-card-text>
</v-card> </v-card>
<v-snackbar <v-snackbar
v-for="message in messages" v-for="message in messages"
:key="messages.indexOf(message)" :key="messages.indexOf(message)"
:color="message.error ? 'error' : 'success'" :color="message.error ? 'error' : 'success'"
@ -199,7 +235,8 @@
vertical vertical
> >
<div class="title"> <div class="title">
<p style="font-size: 5em; margin: 20px">{{createSum(message)}}</p>{{ createMessage(message) }} <p style="font-size: 5em; margin: 20px">{{ createSum(message) }}</p>
{{ createMessage(message) }}
</div> </div>
<div> <div>
{{ now(message.date) }} {{ now(message.date) }}
@ -235,7 +272,9 @@ export default {
checkValidate: false, checkValidate: false,
stornoMessage: null, stornoMessage: null,
timeout: null, timeout: null,
toSetAmount: null toSetAmount: null,
overLimitUser: null,
overOverLimit: null,
} }
}, },
created() { created() {
@ -246,15 +285,63 @@ export default {
addAmount: 'user/addAmount', addAmount: 'user/addAmount',
commitStorno: 'user/storno' commitStorno: 'user/storno'
}), }),
continueAdd(user) {
this.overLimitUser = null
user.checkedOverLimit = true
if (this.value) {
this.addAmount(Math.round(Math.abs(this.value * 100)))
setTimeout(() => {
this.value = null
this.toSetAmount = null
}, 300)
} else {
user.timeout = setTimeout(() => {
this.addAmount(this.toSetAmount)
setTimeout(() => {
this.toSetAmount = null
}, 300)
}, 2000)
}
},
cancel() {
this.toSetAmount = null
this.value = null
this.overLimitUser = null
},
checkOverLimitIsValid(user) {
if (this.toSetAmount) {
if (Math.abs(this.getAllSum() - Number.parseInt(this.toSetAmount)) > user.limit + 500) {
this.overOverLimit = user
this.toSetAmount = null
this.value = null
return false
}
}
return true
},
checkOverLimit(user) {
if (this.toSetAmount) {
if (Math.abs( this.getAllSum() - this.toSetAmount) > user.limit) {
return user.checkedOverLimit ? false : true
}
}
return false
},
addingAmount(amount) { addingAmount(amount) {
clearTimeout(this.timeout) clearTimeout(this.timeout)
this.toSetAmount = this.toSetAmount ? this.toSetAmount + amount : amount this.toSetAmount = this.toSetAmount ? this.toSetAmount + amount : amount
if (this.checkOverLimitIsValid(this.user)) {
if (this.checkOverLimit(this.user)) {
this.overLimitUser = this.user
} else {
this.timeout = setTimeout(() => { this.timeout = setTimeout(() => {
this.addAmount(this.toSetAmount) this.addAmount(this.toSetAmount)
setTimeout(() => { setTimeout(() => {
this.toSetAmount = null this.toSetAmount = null
}, 300) }, 300)
}, 2000) }, 2000)
}
}
}, },
forceRender() { forceRender() {
this.componentRenderer += 1 this.componentRenderer += 1
@ -293,15 +380,23 @@ export default {
this.checkValidate = null this.checkValidate = null
}, },
addAmountMore() { addAmountMore() {
this.toSetAmount = this.toSetAmount
? this.toSetAmount + Math.round(Math.abs(this.value * 100))
: Math.round(Math.abs(this.value * 100))
if (this.checkOverLimitIsValid(this.user)) {
if (this.checkOverLimit(this.user)) {
this.overLimitUser = this.user
}
else {
this.addAmount(Math.abs(this.value * 100)) this.addAmount(Math.abs(this.value * 100))
setTimeout(() => { setTimeout(() => {
this.value = null this.value = null
}, 300) }, 300)
}
}
}, },
createSum(message) { createSum(message) {
var text = '' + var text = '' + (message.amount / 100).toFixed(2) + '€'
(message.amount / 100).toFixed(2) +
'€'
return text return text
}, },
createMessage(message) { createMessage(message) {

View File

@ -242,6 +242,7 @@ const actions = {
}, },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken } }
) )
console.log(response.data)
commit('setUsers', { [response.data.username]: response.data }) commit('setUsers', { [response.data.username]: response.data })
commit('updateMessage', { date: data.date, storno: true }) commit('updateMessage', { date: data.date, storno: true })
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })