From 08469c556b76c925fc4a5748bd44dad210e0a0f3 Mon Sep 17 00:00:00 2001 From: Phillip Thelen Date: Fri, 28 Oct 2022 12:41:43 +0200 Subject: [PATCH] fix lint errors --- test/api/unit/libs/payments/payments.test.js | 2 +- website/server/libs/payments/subscriptions.js | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/test/api/unit/libs/payments/payments.test.js b/test/api/unit/libs/payments/payments.test.js index e9fdd3b90f..75500e28f5 100644 --- a/test/api/unit/libs/payments/payments.test.js +++ b/test/api/unit/libs/payments/payments.test.js @@ -12,7 +12,7 @@ import { } from '../../../../helpers/api-unit.helper'; import * as worldState from '../../../../../website/server/libs/worldState'; -describe.only('payments/index', () => { +describe('payments/index', () => { let user; let group; let data; let plan; diff --git a/website/server/libs/payments/subscriptions.js b/website/server/libs/payments/subscriptions.js index 11dd5768c1..f478317e12 100644 --- a/website/server/libs/payments/subscriptions.js +++ b/website/server/libs/payments/subscriptions.js @@ -70,8 +70,15 @@ async function createSubscription (data) { ? data.gift.subscription.key : data.sub.key]; const autoRenews = data.autoRenews !== undefined ? data.autoRenews : true; - const updatedFrom = data.updatedFrom ? shared.content.subscriptionBlocks[data.updatedFrom.key] : undefined; - const months = updatedFrom && Number(updatedFrom.months) !== 1 ? Math.max(0, Number(block.months) - Number(updatedFrom.months)) : Number(block.months); + const updatedFrom = data.updatedFrom + ? shared.content.subscriptionBlocks[data.updatedFrom.key] + : undefined; + let months; + if (updatedFrom && Number(updatedFrom.months) !== 1) { + months = Math.max(0, Number(block.months) - Number(updatedFrom.months)); + } else { + months = Number(block.months); + } const today = new Date(); let group; let groupId;