From 891e854c7cca8ed3cbe7c5b367d341e8640e8efd Mon Sep 17 00:00:00 2001 From: Hardik Date: Sat, 16 May 2026 21:11:25 +0530 Subject: [PATCH] feat(vendors): auto-verify vendor on first successful payment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When accounts confirms a payment (SENT_FOR_PAYMENT → PAID_DELIVERED), set Vendor.isVerified = true for the PO's vendor. The field already exists in the schema (default false); this closes the loop so vendors who have transacted at least once are marked verified automatically without manual admin intervention. Co-Authored-By: Claude Sonnet 4.6 --- App/pelagia-portal/app/(portal)/payments/actions.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/App/pelagia-portal/app/(portal)/payments/actions.ts b/App/pelagia-portal/app/(portal)/payments/actions.ts index 2e59400..d047338 100644 --- a/App/pelagia-portal/app/(portal)/payments/actions.ts +++ b/App/pelagia-portal/app/(portal)/payments/actions.ts @@ -169,6 +169,14 @@ export async function markPaid({ // Sync product catalog: auto-create new items, upsert per-vendor prices await syncProductCatalog(poId, po.lineItems, po.vendorId, session.user.id); + // Auto-verify the vendor on first successful payment + if (po.vendorId) { + await db.vendor.update({ + where: { id: po.vendorId }, + data: { isVerified: true }, + }); + } + const managers = await db.user.findMany({ where: { role: "MANAGER", isActive: true } }); await notify({ event: "PAYMENT_SENT", po, recipients: [po.submitter, ...managers] });