fix(inventory): enforce out-of-stock validation in cartStore, ordersService, and JSON-LD availability
Deploy Canina / deploy (push) Failing after 59s
E2E Playwright Tests / Run Full E2E & Security Suites (push) Failing after 6s

This commit is contained in:
devops committed 2026-10-12 18:42:47 +00:00
1 parent 11dd549c7c
commit cae22ff7c9
3 files changed
+27 -5

No files matched your search

+11 -1
View File
@@ -142,9 +142,19 @@ export class OrdersService {
const productMap = new Map(products.map((p) => [p.id, p]));
for (const productId of productIds) {
if (!productMap.has(productId)) {
const product = productMap.get(productId);
if (!product) {
throw new NotFoundException(`محصول یافت نشد`);
}
const isOutOfStock =
product.stockStatus === 'OUT_OF_STOCK' ||
product.stockStatus === 'DISCONTINUED' ||
(product.packageSize !== null && Number(product.packageSize) <= 0);
if (isOutOfStock) {
throw new BadRequestException(
`محصول «${product.nameFa || product.name}» در حال حاضر ناموجود است و امکان ثبت سفارش آن وجود ندارد`,
);
}
}
let cartTotal = new Prisma.Decimal(0);