karbe/prisma/migrations
Ubuntu 5be62f012f
All checks were successful
CI / test (pull_request) Successful in 2m40s
feat(rental): Sprint O — reversements prestataires (payouts)
Marketplace encaisse centralisé sur System D → besoin de tracer les
virements mensuels aux prestataires tiers. Migration appliquée prod.

Schema :
- Modèle RentalPayoutMark { id, providerId, periodMonth, amount,
  reference, paidAt, paidByEmail }. Unique (providerId, periodMonth)
  → 1 mark = 1 mois = 1 virement par provider.

Lib src/lib/payouts.ts :
- monthKey(d) → 1er du mois minuit UTC (clé de période).
- listProviderPayouts({monthsBack=6}) → grid provider × mois avec
  bookingsCount + grossAmount (itemsTotal) + commission + netAmount
  (gross-commission) + statut paid via RentalPayoutMark. Exclut
  System D (commission 0%, géré par l'asso). Statut « payé » lu
  depuis les marks. Tri : mois desc puis providerName.
- createPayoutMark (idempotent via findUnique avant insert) +
  deletePayoutMark.

Politique : net dû = itemsTotal - commissionAmount (depositTotal
hors flux, collecté par le provider auprès du client). Politique
documentée dans le commentaire en tête de payouts.ts.

/admin/payouts/page.tsx :
- 3 KPIs (À payer / Déjà payé / Mois affichés).
- Une section par mois (6 derniers), tableau provider × CA brut +
  commission + net dû + statut.
- MarkPaidForm : bouton « Marquer payé » → form inline (amount
  pré-rempli avec net dû, reference optionnelle) → action
  markPayoutPaidAction. Statut payé montre amount + ref + bouton
  « Annuler marquage ».

Server actions :
- markPayoutPaidAction (admin only, idempotent, audit
  admin.payouts/payout.mark + payout.already_marked) → envoie
  sendPayoutSent au contactEmail du provider (best-effort).
- unmarkPayoutPaidAction → delete + audit payout.unmark.

Email sendPayoutSent : notification au provider quand un virement est
marqué payé. Inclut amount + reference + lien dashboard.

Sidebar admin gagne entrée « Reversements » sous Activité.

Tests vitest tests/lib/payouts.test.ts (4 cas) : monthKey
normalisation UTC + idempotence + janvier sans bug, formatMonth fr-FR.
Total : 74/74 ✓.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-03 02:59:16 +00:00
..
20260529000000_init_karbe_schema feat(prisma): add full Karbé schema and initial migration 2026-05-29 16:59:35 +00:00
20260530173000_add_last_booked_at feat(carbet): add lastBookedAt and endpoint 2026-05-30 17:52:41 +00:00
20260530200000_add_plugin_system feat(plugins): foundation système Plugin Karbé 2026-05-30 22:17:10 +00:00
20260531000000_add_access_type feat(plugins): access-type + demo-carbets-seed (Phase 3.1 + 2.5) 2026-05-31 02:56:25 +00:00
20260531120000_add_seasonality_and_min_stay feat(plugins): seasonality + min-stay (Phase 3.2 + 3.4) 2026-05-31 08:50:26 +00:00
20260531180000_add_content_pages feat(plugins): content-pages + legal-pages (Phase 4.1 + 4.3) 2026-05-31 10:12:13 +00:00
20260531200000_add_pirogue_providers feat(plugin): pirogue-providers (Phase 3.3) 2026-05-31 11:29:29 +00:00
20260531220000_content_page_composite_key feat: ContentPage bilingue (PK composite slug+lang) + seed pages EN 2026-05-31 11:45:47 +00:00
20260601000000_audit_and_settings feat(admin): Sprint 5 — Audit log + Settings (gouvernance) 2026-06-01 00:13:49 +00:00
20260601060000_password_reset_token feat: reset password + page mon-compte (RGPD) + facettes recherche (prix max, équipements) 2026-06-01 10:16:37 +00:00
20260601120000_translation_overrides feat(admin): /admin/home — éditeur des textes de la page d'accueil (FR+EN, override DB) 2026-06-01 01:10:49 +00:00
20260601150000_carbet_nightly_price feat(p0): prix/nuit + booking form public + /inscription + /reservations/[id] 2026-06-01 01:34:00 +00:00
20260602030000_operational_criteria feat: 4 critères opérationnels (route/capacité/électricité/GSM) + presets profils + badges 2026-06-02 02:26:02 +00:00
20260602100000_favorite feat: « Au fil de l'eau » — Reels mobile + uploader pro + favoris 2026-06-02 00:27:16 +00:00
20260603000000_rental_marketplace feat(rental): Sprint A — modèle Prisma + admin CRUD + seed 13 items 2026-06-02 03:26:04 +00:00
20260603100000_rental_item_media feat(rental): Sprint F — photos & vidéos items rental 2026-06-02 09:34:09 +00:00
20260603200000_ce_management feat(ce): Sprint G — data model + admin validation 2026-06-02 22:55:54 +00:00
20260603300000_org_invite_token feat(ce): Sprint K — public badge + invites CE_MEMBER + tests 2026-06-03 00:03:03 +00:00
20260603400000_rental_payout_mark feat(rental): Sprint O — reversements prestataires (payouts) 2026-06-03 02:59:16 +00:00
migration_lock.toml feat(prisma): add full Karbé schema and initial migration 2026-05-29 16:59:35 +00:00