diff --git a/frontend/src/pages/Community.vue b/frontend/src/pages/Community.vue index 9a18db9c0..1332ca9d7 100644 --- a/frontend/src/pages/Community.vue +++ b/frontend/src/pages/Community.vue @@ -5,8 +5,8 @@
@@ -138,21 +138,20 @@ export default { formDate.getMonth() === this.maximalDate.getMonth() ) }, - maxGddLastMonth() { + amountToAdd() { // when existing contribution is edited, the amount is added back on top of the amount - if (this.openCreations && this.openCreations.length) - return this.form.id && !this.isThisMonth - ? parseInt(this.openCreations[1].amount) + parseInt(this.updateAmount) - : parseInt(this.openCreations[1].amount) + if (this.form.id) return parseInt(this.updateAmount) return 0 }, - maxGddThisMonth() { - // when existing contribution is edited, the amount is added back on top of the amount + maxForMonths() { + const formDate = new Date(this.form.date) if (this.openCreations && this.openCreations.length) - return this.form.id && this.isThisMonth - ? parseInt(this.openCreations[2].amount) + parseInt(this.updateAmount) - : parseInt(this.openCreations[2].amount) - return 0 + return this.openCreations.slice(1).map((creation) => { + if (creation.year === formDate.getFullYear() && creation.month === formDate.getMonth()) + return parseInt(creation.amount) + this.amountToAdd + return parseInt(creation.amount) + }) + return [0, 0] }, }, methods: {