feat(payments): automatic monthly charges with combined links per payer
- Teacher picks a day of the month in Settings; an hourly job creates the fees of all monthly groups on that day in the teacher's time zone (one run per teacher and month, partial unique index per attendee/period). - One Mercado Pago link per payer (PaymentCheckout): the adult in charge bundles their kids and their own fees; external_reference chk_<id>, dedicated webhook and reconciliation mark every fee PAID at once. - Person.payWithMercadoPago toggle (default on): off creates the fee without a link so the student pays by transfer. - A fee paid some other way supersedes its combined link and expires the preference; renewing rebuilds the combined link or a single one. - Optional WhatsApp delivery (PAYMENT_LINK kind, new Kapso template); weekly reminders now go once per combined link. - Web: auto charge settings card, per-student toggle, combined link label in Cobros and "Pay all" in the student app, in the four locales. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -40,6 +40,21 @@ export class GetStudentFees {
|
||||
dueDate: true,
|
||||
status: true,
|
||||
checkoutUrl: true,
|
||||
periodKey: true,
|
||||
checkout: {
|
||||
select: {
|
||||
status: true,
|
||||
amount: true,
|
||||
payments: {
|
||||
where: { status: { in: ['PENDING', 'OVERDUE'] } },
|
||||
orderBy: { createdAt: 'asc' },
|
||||
select: {
|
||||
group: { select: { name: true } },
|
||||
attendee: { select: { person: { select: { fullName: true } } } },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
reportedItems: { where: { reportedPayment: { status: 'REPORTED' } }, select: { paymentId: true } },
|
||||
},
|
||||
}),
|
||||
@@ -76,6 +91,17 @@ export class GetStudentFees {
|
||||
dueDate: payment.dueDate.toISOString(),
|
||||
status,
|
||||
checkoutUrl: payment.checkoutUrl,
|
||||
periodKey: payment.periodKey,
|
||||
checkout:
|
||||
payment.checkout?.status === 'OPEN' && payment.checkout.payments.length > 1
|
||||
? {
|
||||
total: payment.checkout.amount.toNumber(),
|
||||
items: payment.checkout.payments.map((line) => ({
|
||||
groupName: line.group.name,
|
||||
studentName: line.attendee.person.fullName,
|
||||
})),
|
||||
}
|
||||
: null,
|
||||
};
|
||||
}),
|
||||
transfer: transferAlias ? { alias: transferAlias, holder: transferHolder } : null,
|
||||
|
||||
Reference in New Issue
Block a user