math addition if edit contribution

This commit is contained in:
ogerly 2022-07-21 15:50:37 +02:00
parent 4abac7a3c1
commit cd5f90205b

View File

@ -135,18 +135,14 @@ export default {
// new Date().getMonth === 1 If the current month is January, then one year must be gone back in the previous month // new Date().getMonth === 1 If the current month is January, then one year must be gone back in the previous month
const obj = { const obj = {
monthAndYear: this.$d(new Date(this.minimalDate), 'monthAndYear'), monthAndYear: this.$d(new Date(this.minimalDate), 'monthAndYear'),
creation: this.id creation: this.maxGddLastMonth,
? this.$store.state.creation[1] + this.form.amount
: this.$store.state.creation[1],
} }
return this.$t('contribution.formText.openAmountForMonth', obj) return this.$t('contribution.formText.openAmountForMonth', obj)
}, },
thisMonthObject() { thisMonthObject() {
const obj = { const obj = {
monthAndYear: this.$d(new Date(), 'monthAndYear'), monthAndYear: this.$d(new Date(), 'monthAndYear'),
creation: this.id creation: this.maxGddThisMonth,
? parseInt(this.$store.state.creation[2]) + parseInt(this.form.amount)
: this.$store.state.creation[2],
} }
return this.$t('contribution.formText.openAmountForMonth', obj) return this.$t('contribution.formText.openAmountForMonth', obj)
}, },
@ -155,14 +151,14 @@ export default {
}, },
maxGddLastMonth() { maxGddLastMonth() {
// When edited, the amount is added back on top of the amount // When edited, the amount is added back on top of the amount
return this.id return this.value.id
? parseInt(this.$store.state.creation[1]) + parseInt(this.form.amount) ? parseInt(this.$store.state.creation[1]) + parseInt(this.value.amount)
: this.$store.state.creation[1] : this.$store.state.creation[1]
}, },
maxGddThisMonth() { maxGddThisMonth() {
// When edited, the amount is added back on top of the amount // When edited, the amount is added back on top of the amount
return this.id return this.value.id
? parseInt(this.$store.state.creation[2]) + parseInt(this.form.amount) ? parseInt(this.$store.state.creation[2]) + parseInt(this.value.amount)
: this.$store.state.creation[2] : this.$store.state.creation[2]
}, },
}, },