fix logic

This commit is contained in:
Phillip Thelen 2023-03-14 15:55:41 +01:00
parent f6f1202baf
commit 93e922e774

View file

@ -57,11 +57,14 @@ schema.methods.incrementPerkCounterAndReward = async function incrementPerkCount
addingNumber = parseInt(adding, 10); addingNumber = parseInt(adding, 10);
} }
// if perkMonthCount wasn't used before, initialize it. // if perkMonthCount wasn't used before, initialize it.
if ((this.perkMonthCount === undefined || this.perkMonthCount === -1) && addingNumber === 1) { if (this.perkMonthCount === undefined || this.perkMonthCount === -1) {
this.perkMonthCount = (this.consecutive.count - 1) % SUBSCRIPTION_BASIC_BLOCK_LENGTH; if (this.planId == 'basic_earned') {
} else { this.perkMonthCount = (this.consecutive.count - 1) % SUBSCRIPTION_BASIC_BLOCK_LENGTH;
this.perkMonthCount += addingNumber; } else {
this.perkMonthCount = 0;
}
} }
this.perkMonthCount += addingNumber;
const perks = Math.floor(this.perkMonthCount / 3); const perks = Math.floor(this.perkMonthCount / 3);
if (perks > 0) { if (perks > 0) {