STORNIERT!!!
@@ -76,6 +112,10 @@
{{ menuIcon }}
+
+ Nur noch {{ ((user.limit + getAllSum()) / 100).toFixed(2) }} €
+ übrig!!
+
@@ -166,14 +206,11 @@
{{
- (getAllSum() / 100).toFixed(2)
- }}
+ >{{ (getAllSum() / 100).toFixed(2) }}
€
-
+
- - {{(toSetAmount / 100).toFixed(2)}}
+ - {{ (toSetAmount / 100).toFixed(2) }}
@@ -188,7 +225,6 @@
-
{{createSum(message)}}
{{ createMessage(message) }}
+
{{ createSum(message) }}
+ {{ createMessage(message) }}
- {{now(message.date)}}
+ {{ now(message.date) }}
- {{close}}
+ {{ close }}
@@ -235,7 +272,9 @@ export default {
checkValidate: false,
stornoMessage: null,
timeout: null,
- toSetAmount: null
+ toSetAmount: null,
+ overLimitUser: null,
+ overOverLimit: null,
}
},
created() {
@@ -246,15 +285,63 @@ export default {
addAmount: 'user/addAmount',
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) {
clearTimeout(this.timeout)
this.toSetAmount = this.toSetAmount ? this.toSetAmount + amount : amount
- this.timeout = setTimeout(() => {
- this.addAmount(this.toSetAmount)
- setTimeout(() => {
- this.toSetAmount = null
- }, 300)
- }, 2000)
+ if (this.checkOverLimitIsValid(this.user)) {
+ if (this.checkOverLimit(this.user)) {
+ this.overLimitUser = this.user
+ } else {
+ this.timeout = setTimeout(() => {
+ this.addAmount(this.toSetAmount)
+ setTimeout(() => {
+ this.toSetAmount = null
+ }, 300)
+ }, 2000)
+ }
+ }
},
forceRender() {
this.componentRenderer += 1
@@ -279,29 +366,37 @@ export default {
}
}
},
- acceptStorno() {
- this.commitStorno({
- amount: this.stornoMessage.amount,
- date: this.stornoMessage.date
- })
- setTimeout(() => {
- this.cancelStorno()
- }, 300)
- },
- cancelStorno() {
- this.stornoMessage = null
- this.checkValidate = null
- },
- addAmountMore() {
- this.addAmount(Math.abs(this.value * 100))
+ acceptStorno() {
+ this.commitStorno({
+ amount: this.stornoMessage.amount,
+ date: this.stornoMessage.date
+ })
setTimeout(() => {
- this.value = null
+ this.cancelStorno()
}, 300)
},
+ cancelStorno() {
+ this.stornoMessage = null
+ this.checkValidate = null
+ },
+ 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))
+ setTimeout(() => {
+ this.value = null
+ }, 300)
+ }
+ }
+ },
createSum(message) {
- var text = '' +
- (message.amount / 100).toFixed(2) +
- '€'
+ var text = '' + (message.amount / 100).toFixed(2) + '€'
return text
},
createMessage(message) {
@@ -335,7 +430,7 @@ export default {
under5minutes() {
return now => {
var actual = new Date()
- return actual - now < 15000
+ return actual - now < 15000
}
},
now() {
diff --git a/src/store/modules/barUsers.js b/src/store/modules/barUsers.js
index 7130ca8..3a8a906 100644
--- a/src/store/modules/barUsers.js
+++ b/src/store/modules/barUsers.js
@@ -242,6 +242,7 @@ const actions = {
},
{ headers: { Token: rootState.login.user.accessToken } }
)
+ console.log(response.data)
commit('setUsers', { [response.data.username]: response.data })
commit('updateMessage', { date: data.date, storno: true })
dispatch('getLifeTime', null, { root: true })