feat(vendors): auto-verify vendor on first successful payment
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 <noreply@anthropic.com>
This commit is contained in:
parent
a5fb7d088c
commit
891e854c7c
1 changed files with 8 additions and 0 deletions
|
|
@ -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] });
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue