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:
@@ -19,6 +19,8 @@ enum WhatsappAccountStatus {
|
||||
enum WhatsappMessageKind {
|
||||
PAYMENT_REMINDER
|
||||
REENGAGEMENT
|
||||
// The monthly combined payment link, sent when it is generated.
|
||||
PAYMENT_LINK
|
||||
}
|
||||
|
||||
enum OutboundMessageStatus {
|
||||
@@ -92,9 +94,10 @@ model OutboundMessage {
|
||||
groupId String @map("group_id")
|
||||
attendeeId String @map("attendee_id")
|
||||
paymentId String? @map("payment_id")
|
||||
checkoutId String? @map("checkout_id")
|
||||
kind WhatsappMessageKind
|
||||
provider MessagingProviderId
|
||||
// ISO week the job ran for, e.g. "2026-W43".
|
||||
// ISO week the job ran for, e.g. "2026-W43"; the month ("2026-12") for PAYMENT_LINK.
|
||||
periodKey String @map("period_key")
|
||||
toPhone String @map("to_phone")
|
||||
providerMessageId String? @map("provider_message_id")
|
||||
@@ -105,9 +108,10 @@ model OutboundMessage {
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
group Group @relation(fields: [groupId], references: [id], onDelete: Cascade, map: "outbound_messages_groupId_fkey")
|
||||
attendee Attendee @relation(fields: [attendeeId], references: [id], onDelete: Cascade, map: "outbound_messages_attendeeId_fkey")
|
||||
payment Payment? @relation(fields: [paymentId], references: [id], onDelete: SetNull, map: "outbound_messages_paymentId_fkey")
|
||||
group Group @relation(fields: [groupId], references: [id], onDelete: Cascade, map: "outbound_messages_groupId_fkey")
|
||||
attendee Attendee @relation(fields: [attendeeId], references: [id], onDelete: Cascade, map: "outbound_messages_attendeeId_fkey")
|
||||
payment Payment? @relation(fields: [paymentId], references: [id], onDelete: SetNull, map: "outbound_messages_paymentId_fkey")
|
||||
checkout PaymentCheckout? @relation(fields: [checkoutId], references: [id], onDelete: SetNull)
|
||||
|
||||
@@unique([kind, attendeeId, periodKey], map: "outbound_messages_kind_attendeeId_periodKey_key")
|
||||
@@unique([provider, providerMessageId], map: "outbound_messages_provider_providerMessageId_key")
|
||||
|
||||
Reference in New Issue
Block a user