diff --git a/packages/app/pages/subscriptions/[subscriptionId]/index.vue b/packages/app/pages/subscriptions/[subscriptionId]/index.vue
index e24b53a..59e49dd 100644
--- a/packages/app/pages/subscriptions/[subscriptionId]/index.vue
+++ b/packages/app/pages/subscriptions/[subscriptionId]/index.vue
@@ -26,10 +26,6 @@
-
-
-
-
diff --git a/packages/server/src/api/endpoints/customer.ts b/packages/server/src/api/endpoints/customer.ts
index 84dcaa4..9d7efe7 100644
--- a/packages/server/src/api/endpoints/customer.ts
+++ b/packages/server/src/api/endpoints/customer.ts
@@ -4,7 +4,6 @@ import { getProjectFromRequest } from '~/api/helpers';
import { database } from '~/database';
import { Customer, Project } from '~/entities';
import { getPaymentProvider } from '~/payment_providers';
-import { getActiveUntilDate } from '~/utils';
// eslint-disable-next-line @typescript-eslint/require-await
export async function customerEndpoints(server: FastifyInstance): Promise {
@@ -323,18 +322,7 @@ export async function customerEndpoints(server: FastifyInstance): Promise
const subscriptions = await database.subscriptions.find({ project, customer }, { populate: ['changes'] });
- const _subscriptions = subscriptions.map((subscription) => {
- const activeUntil = subscription.lastPayment
- ? getActiveUntilDate(subscription.lastPayment, subscription.anchorDate)
- : undefined;
-
- return {
- ...subscription.toJSON(),
- activeUntil,
- };
- });
-
- await reply.send(_subscriptions);
+ await reply.send(subscriptions.map((subscription) => subscription.toJSON()));
},
});
diff --git a/packages/server/src/api/endpoints/subscription.ts b/packages/server/src/api/endpoints/subscription.ts
index a56b243..cab96e9 100644
--- a/packages/server/src/api/endpoints/subscription.ts
+++ b/packages/server/src/api/endpoints/subscription.ts
@@ -3,7 +3,7 @@ import { FastifyInstance } from 'fastify';
import { getProjectFromRequest } from '~/api/helpers';
import { database } from '~/database';
import { Subscription } from '~/entities';
-import { getActiveUntilDate, getPeriodFromAnchorDate } from '~/utils';
+import { getPeriodFromAnchorDate } from '~/utils';
// eslint-disable-next-line @typescript-eslint/require-await
export async function subscriptionEndpoints(server: FastifyInstance): Promise {
@@ -117,18 +117,7 @@ export async function subscriptionEndpoints(server: FastifyInstance): Promise {
- const activeUntil = subscription.lastPayment
- ? getActiveUntilDate(subscription.lastPayment, subscription.anchorDate)
- : undefined;
-
- return {
- ...subscription.toJSON(),
- activeUntil,
- };
- });
-
- await reply.send(_subscriptions);
+ await reply.send(subscriptions.map((subscription) => subscription.toJSON()));
},
});
@@ -250,16 +239,7 @@ export async function subscriptionEndpoints(server: FastifyInstance): Promise {
- const getActiveUntilDateTests = [
- // oldActiveUntil, anchorDate, activeUntil
- ['2022-01-15', '2022-01-15', '2022-02-14'],
- ['2022-02-15', '2022-01-15', '2022-03-14'],
- ['2022-01-31', '2022-01-31', '2022-02-27'],
- ['2022-02-28', '2022-01-31', '2022-03-30'],
- ['2022-03-31', '2022-01-31', '2022-04-29'],
- ];
- it.each(getActiveUntilDateTests)(
- 'getActiveUntilDate oldActiveUntil: %s & anchorDate: %s => activeUntil: %s',
- (oldActiveUntil, anchorDate, expected) => {
- // when
- const activeUntil = getActiveUntilDate(dayjs(oldActiveUntil).toDate(), dayjs(anchorDate).toDate());
-
- // then
- expect(dayjs(activeUntil).format('DD.MM.YYYY')).toStrictEqual(dayjs(expected).endOf('day').format('DD.MM.YYYY'));
- },
- );
-
// For example, a customer with a monthly subscription set to cycle on the 2nd of the month will
// always be billed on the 2nd.
diff --git a/packages/server/src/utils.ts b/packages/server/src/utils.ts
index 8f11871..3ffb33a 100644
--- a/packages/server/src/utils.ts
+++ b/packages/server/src/utils.ts
@@ -27,8 +27,3 @@ export function getPreviousPeriod(nextPayment: Date, anchorDate: Date): { start:
const { start } = getPeriodFromAnchorDate(nextPayment, anchorDate);
return getPeriodFromAnchorDate(dayjs(start).subtract(1, 'day').toDate(), anchorDate);
}
-
-export function getActiveUntilDate(oldActiveUntil: Date, anchorDate: Date): Date {
- const { end } = getPeriodFromAnchorDate(oldActiveUntil, anchorDate);
- return end;
-}