Skip to content

Commit

Permalink
fix: Don't include paused payments for upcoming subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
tklein1801 committed Jun 22, 2024
1 parent 791beac commit 55ca3cd
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/components/Subscription/Subscription.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,13 @@ export class SubscriptionService {
*/
static getUpcomingX(data: 'INCOME' | 'EXPENSES', subscriptions: TSubscription[]) {
const today = new Date().getDate();
return subscriptions.reduce((acc, {transfer_amount, execute_at}) => {
if ((data === 'INCOME' && transfer_amount > 0) || (data === 'EXPENSES' && transfer_amount < 0)) {
return execute_at > today ? acc + transfer_amount : acc;
}
return acc;
}, 0);
return subscriptions
.filter(({paused}) => !paused)
.reduce((acc, {transfer_amount, execute_at}) => {
if ((data === 'INCOME' && transfer_amount > 0) || (data === 'EXPENSES' && transfer_amount < 0)) {
return execute_at > today ? acc + transfer_amount : acc;
}
return acc;
}, 0);
}
}

0 comments on commit 55ca3cd

Please sign in to comment.