feat(inventory): implement numeric stock inventory across fullstack and improve prescription UX handoff
Deploy Canina / deploy (push) Failing after 2m31s
E2E Playwright Tests / Run Full E2E & Security Suites (push) Failing after 7s

This commit is contained in:
devops committed 2026-10-12 19:29:48 +00:00
1 parent e9582430e6
commit 741365f04c
13 files changed
+177 -47

No files matched your search

+25 -1
View File
@@ -433,12 +433,36 @@ export class PaymentService {
},
});
// Mark inventory reservations as CONSUMED
// Mark inventory reservations as CONSUMED and decrement product stock
await tx.inventoryReservation.updateMany({
where: { orderId: transaction.orderId, status: 'ACTIVE' },
data: { status: 'CONSUMED' },
});
const orderWithItems = await tx.order.findUnique({
where: { id: transaction.orderId },
include: { orderItems: true },
});
if (orderWithItems?.orderItems) {
for (const item of orderWithItems.orderItems) {
if (item.productId) {
const updated = await tx.product.update({
where: { id: item.productId },
data: {
stock: { decrement: item.quantity },
},
});
if (updated.stock <= 0) {
await tx.product.update({
where: { id: item.productId },
data: { stockStatus: 'OUT_OF_STOCK' },
});
}
}
}
}
// If charity donation was made, update user's total charity
if (
transaction.order &&