mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
refactor month logic
This commit is contained in:
parent
3a63e2721d
commit
148b1cb41d
@ -5,8 +5,8 @@
|
|||||||
<b-tab no-body>
|
<b-tab no-body>
|
||||||
<open-creations-amount
|
<open-creations-amount
|
||||||
:minimalDate="minimalDate"
|
:minimalDate="minimalDate"
|
||||||
:maxGddThisMonth="maxGddThisMonth"
|
:maxGddLastMonth="maxForMonths[0]"
|
||||||
:maxGddLastMonth="maxGddLastMonth"
|
:maxGddThisMonth="maxForMonths[1]"
|
||||||
/>
|
/>
|
||||||
<div class="mb-3"></div>
|
<div class="mb-3"></div>
|
||||||
<contribution-form
|
<contribution-form
|
||||||
@ -15,8 +15,8 @@
|
|||||||
v-model="form"
|
v-model="form"
|
||||||
:isThisMonth="isThisMonth"
|
:isThisMonth="isThisMonth"
|
||||||
:minimalDate="minimalDate"
|
:minimalDate="minimalDate"
|
||||||
:maxGddLastMonth="maxGddLastMonth"
|
:maxGddLastMonth="maxForMonths[0]"
|
||||||
:maxGddThisMonth="maxGddThisMonth"
|
:maxGddThisMonth="maxForMonths[1]"
|
||||||
/>
|
/>
|
||||||
</b-tab>
|
</b-tab>
|
||||||
<b-tab no-body>
|
<b-tab no-body>
|
||||||
@ -138,21 +138,20 @@ export default {
|
|||||||
formDate.getMonth() === this.maximalDate.getMonth()
|
formDate.getMonth() === this.maximalDate.getMonth()
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
maxGddLastMonth() {
|
amountToAdd() {
|
||||||
// when existing contribution is edited, the amount is added back on top of the amount
|
// when existing contribution is edited, the amount is added back on top of the amount
|
||||||
if (this.openCreations && this.openCreations.length)
|
if (this.form.id) return parseInt(this.updateAmount)
|
||||||
return this.form.id && !this.isThisMonth
|
|
||||||
? parseInt(this.openCreations[1].amount) + parseInt(this.updateAmount)
|
|
||||||
: parseInt(this.openCreations[1].amount)
|
|
||||||
return 0
|
return 0
|
||||||
},
|
},
|
||||||
maxGddThisMonth() {
|
maxForMonths() {
|
||||||
// when existing contribution is edited, the amount is added back on top of the amount
|
const formDate = new Date(this.form.date)
|
||||||
if (this.openCreations && this.openCreations.length)
|
if (this.openCreations && this.openCreations.length)
|
||||||
return this.form.id && this.isThisMonth
|
return this.openCreations.slice(1).map((creation) => {
|
||||||
? parseInt(this.openCreations[2].amount) + parseInt(this.updateAmount)
|
if (creation.year === formDate.getFullYear() && creation.month === formDate.getMonth())
|
||||||
: parseInt(this.openCreations[2].amount)
|
return parseInt(creation.amount) + this.amountToAdd
|
||||||
return 0
|
return parseInt(creation.amount)
|
||||||
|
})
|
||||||
|
return [0, 0]
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user