feat: add country selection during onboarding and implement payment management features
- Introduced CountryStep component for selecting the country during onboarding, affecting payment currency. - Updated FirstGroupStep to include country information. - Enhanced PaymentsProvider to manage payment states and renewals. - Created PaymentRow component for displaying individual payment details. - Implemented PaymentsView for listing and filtering payments by group and status. - Added API endpoints for fetching and creating payments, including batch processing. - Defined payment schemas for validation and data handling. - Updated GroupHeader and GroupDetailView to include charging functionality for group members.
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import type { PrismaClient } from '@generated/prisma/client';
|
||||
import prisma from '@/lib/prisma';
|
||||
|
||||
/**
|
||||
* Marks overdue rows. A payment whose due date (plus a day of grace) passed and
|
||||
* is still PENDING becomes OVERDUE; it stays billable, so the professor can
|
||||
* renew its link from Cobros.
|
||||
*/
|
||||
const GRACE_MS = 24 * 60 * 60 * 1000;
|
||||
|
||||
export type MarkOverduePaymentsResult = {
|
||||
marked: number;
|
||||
};
|
||||
|
||||
type MarkOverduePaymentsDeps = {
|
||||
db?: PrismaClient;
|
||||
now?: Date;
|
||||
};
|
||||
|
||||
export class MarkOverduePayments {
|
||||
constructor(private readonly deps: MarkOverduePaymentsDeps = {}) {}
|
||||
|
||||
async execute(): Promise<MarkOverduePaymentsResult> {
|
||||
const db = this.deps.db ?? prisma;
|
||||
const now = this.deps.now ?? new Date();
|
||||
const horizon = new Date(now.getTime() - GRACE_MS);
|
||||
|
||||
const updated = await db.payment.updateMany({
|
||||
where: { status: 'PENDING', dueDate: { lt: horizon } },
|
||||
data: { status: 'OVERDUE' },
|
||||
});
|
||||
|
||||
return { marked: updated.count };
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user