const { PrismaClient } = require('@prisma/client') const prisma = new PrismaClient() async function checkAllSupplies() { console.log('🔍 Проверяем ВСЕ Supply записи в базе...') try { // Найдем организацию фулфилмента const fulfillmentOrg = await prisma.organization.findFirst({ where: { type: 'FULFILLMENT' }, select: { id: true, name: true } }) if (!fulfillmentOrg) { console.log('❌ Организация фулфилмента не найдена') return } console.log(`🏢 Организация фулфилмента: ${fulfillmentOrg.name} (${fulfillmentOrg.id})`) // Проверяем ВСЕ Supply записи в базе const allSupplies = await prisma.supply.findMany({ select: { id: true, name: true, type: true, currentStock: true, quantity: true, status: true, organizationId: true, sellerOwnerId: true, createdAt: true, updatedAt: true }, orderBy: { createdAt: 'desc' } }) console.log(`\n📦 ВСЕ Supply записи в базе (${allSupplies.length}):`) allSupplies.forEach((supply, index) => { const isFulfillmentSupply = supply.organizationId === fulfillmentOrg.id || supply.type === 'FULFILLMENT_CONSUMABLES' console.log(` ${index + 1}. ${supply.name} ${isFulfillmentSupply ? '🔥 ФУЛФИЛМЕНТ' : ''}`) console.log(` ID: ${supply.id}`) console.log(` Тип: ${supply.type}`) console.log(` Текущий остаток: ${supply.currentStock}`) console.log(` Общее количество: ${supply.quantity}`) console.log(` Статус: ${supply.status}`) console.log(` Организация: ${supply.organizationId}`) console.log(` Владелец селлер: ${supply.sellerOwnerId}`) console.log(` Создан: ${supply.createdAt}`) console.log(` Обновлен: ${supply.updatedAt}`) console.log(` ---`) }) // Специально проверим что точно вернет myFulfillmentSupplies resolver const fulfillmentSupplies = await prisma.supply.findMany({ where: { organizationId: fulfillmentOrg.id, type: 'FULFILLMENT_CONSUMABLES', }, include: { organization: true, }, orderBy: { createdAt: 'desc' }, }) console.log(`\n🎯 Что вернет myFulfillmentSupplies resolver (${fulfillmentSupplies.length}):`) fulfillmentSupplies.forEach((supply, index) => { console.log(` ${index + 1}. ${supply.name}`) console.log(` ID: ${supply.id}`) console.log(` Остаток: ${supply.currentStock}`) console.log(` Количество: ${supply.quantity}`) console.log(` Статус: ${supply.status}`) console.log(` Создан: ${supply.createdAt}`) console.log(` ---`) }) } catch (error) { console.error('❌ Ошибка:', error) } finally { await prisma.$disconnect() } } checkAllSupplies()