
## Структурные изменения: ### 📁 Организация архивных файлов: - Перенос всех устаревших правил в legacy-rules/ - Создание структуры docs-and-reports/ для отчетов - Архивация backup файлов в legacy-rules/backups/ ### 🔧 Критические компоненты: - src/components/supplies/multilevel-supplies-table.tsx - многоуровневая таблица поставок - src/components/supplies/components/recipe-display.tsx - отображение рецептур - src/components/fulfillment-supplies/fulfillment-goods-orders-tab.tsx - вкладка товарных заказов ### 🎯 GraphQL обновления: - Обновление mutations.ts, queries.ts, resolvers.ts, typedefs.ts - Синхронизация с Prisma schema.prisma - Backup файлы для истории изменений ### 🛠️ Утилитарные скрипты: - 12 новых скриптов в scripts/ для анализа данных - Скрипты проверки фулфилмент-пользователей - Утилиты очистки и фиксации данных поставок ### 📊 Тестирование: - test-fulfillment-filtering.js - тестирование фильтрации фулфилмента - test-full-workflow.js - полный workflow тестирование ### 📝 Документация: - logistics-statistics-warehouse-rules.md - объединенные правила модулей - Обновление журналов модуляризации и разработки ### ✅ Исправления ESLint: - Исправлены критические ошибки в sidebar.tsx - Исправлены ошибки типизации в multilevel-supplies-table.tsx - Исправлены неиспользуемые переменные в goods-supplies-table.tsx - Заменены типы any на строгую типизацию - Исправлены console.log на console.warn ## Результат: - Завершена полная модуляризация системы - Организована архитектура legacy файлов - Добавлены критически важные компоненты таблиц - Создана полная инфраструктура тестирования - Исправлены все критические ESLint ошибки - Сохранены 103 незакоммиченных изменения 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
136 lines
5.7 KiB
JavaScript
136 lines
5.7 KiB
JavaScript
const { PrismaClient } = require('@prisma/client')
|
||
|
||
const prisma = new PrismaClient()
|
||
|
||
async function checkUIFulfillmentStats() {
|
||
try {
|
||
console.log('📊 ПРОВЕРКА ДАННЫХ ДЛЯ UI "РАСХОДНИКИ ФУЛФИЛМЕНТ"')
|
||
console.log('=' .repeat(60))
|
||
|
||
// Находим фулфилмент организацию
|
||
const fulfillmentUser = await prisma.user.findFirst({
|
||
where: { phone: '79999999999' },
|
||
include: { organization: true }
|
||
})
|
||
|
||
if (!fulfillmentUser?.organization) {
|
||
console.log('❌ Фулфилмент организация не найдена')
|
||
return
|
||
}
|
||
|
||
const orgId = fulfillmentUser.organization.id
|
||
console.log(`🏢 Организация: ${fulfillmentUser.organization.name} (${orgId})`)
|
||
console.log('')
|
||
|
||
// === ДАННЫЕ КАК В UI КОМПОНЕНТЕ ===
|
||
|
||
// 1. ЗАКАЗАНО - из SupplyOrder (все заказы фулфилмента на расходники)
|
||
const supplyOrders = await prisma.supplyOrder.findMany({
|
||
where: {
|
||
organizationId: orgId, // Заказчик = фулфилмент
|
||
consumableType: 'FULFILLMENT_CONSUMABLES'
|
||
},
|
||
include: {
|
||
items: {
|
||
include: { product: true }
|
||
}
|
||
}
|
||
})
|
||
|
||
const totalOrdered = supplyOrders.reduce((sum, order) => {
|
||
return sum + order.items.reduce((itemSum, item) => itemSum + item.quantity, 0)
|
||
}, 0)
|
||
|
||
console.log('📋 1. ЗАКАЗАНО (всего в SupplyOrder):')
|
||
console.log(` Всего заказов: ${supplyOrders.length}`)
|
||
console.log(` Общее количество: ${totalOrdered} шт`)
|
||
|
||
// Разбивка по статусам
|
||
const ordersByStatus = {}
|
||
supplyOrders.forEach(order => {
|
||
if (!ordersByStatus[order.status]) {
|
||
ordersByStatus[order.status] = { count: 0, quantity: 0 }
|
||
}
|
||
ordersByStatus[order.status].count++
|
||
ordersByStatus[order.status].quantity += order.items.reduce((sum, item) => sum + item.quantity, 0)
|
||
})
|
||
|
||
Object.entries(ordersByStatus).forEach(([status, data]) => {
|
||
console.log(` ${status}: ${data.count} заказов, ${data.quantity} шт`)
|
||
})
|
||
console.log('')
|
||
|
||
// 2. ПОСТАВЛЕНО - из SupplyOrder со статусом DELIVERED
|
||
const deliveredOrders = supplyOrders.filter(order => order.status === 'DELIVERED')
|
||
const totalDelivered = deliveredOrders.reduce((sum, order) => {
|
||
return sum + order.items.reduce((itemSum, item) => itemSum + item.quantity, 0)
|
||
}, 0)
|
||
|
||
console.log('🚚 2. ПОСТАВЛЕНО (DELIVERED заказы):')
|
||
console.log(` Доставленных заказов: ${deliveredOrders.length}`)
|
||
console.log(` Общее количество: ${totalDelivered} шт`)
|
||
|
||
if (deliveredOrders.length > 0) {
|
||
console.log(' Детали доставленных заказов:')
|
||
deliveredOrders.forEach((order, index) => {
|
||
const orderQuantity = order.items.reduce((sum, item) => sum + item.quantity, 0)
|
||
console.log(` ${index + 1}. Заказ ${order.id}: ${orderQuantity} шт`)
|
||
order.items.forEach(item => {
|
||
console.log(` - ${item.product.name} (${item.product.article}): ${item.quantity} шт`)
|
||
})
|
||
})
|
||
}
|
||
console.log('')
|
||
|
||
// 3. ОСТАТОК - из Supply записей типа FULFILLMENT_CONSUMABLES
|
||
const fulfillmentSupplies = await prisma.supply.findMany({
|
||
where: {
|
||
organizationId: orgId,
|
||
type: 'FULFILLMENT_CONSUMABLES'
|
||
}
|
||
})
|
||
|
||
const totalInStock = fulfillmentSupplies.reduce((sum, supply) => sum + supply.currentStock, 0)
|
||
|
||
console.log('📦 3. ОСТАТОК (Supply записи):')
|
||
console.log(` Записей на складе: ${fulfillmentSupplies.length}`)
|
||
console.log(` Общий остаток: ${totalInStock} шт`)
|
||
|
||
if (fulfillmentSupplies.length > 0) {
|
||
console.log(' Детали по складу:')
|
||
fulfillmentSupplies.forEach((supply, index) => {
|
||
console.log(` ${index + 1}. "${supply.name}" (${supply.article}):`)
|
||
console.log(` Количество: ${supply.quantity} шт`)
|
||
console.log(` Текущий остаток: ${supply.currentStock} шт`)
|
||
console.log(` Использовано: ${supply.usedStock} шт`)
|
||
console.log(` Статус: ${supply.status}`)
|
||
})
|
||
}
|
||
console.log('')
|
||
|
||
// === СВОДКА ДЛЯ UI ===
|
||
console.log('📊 ИТОГОВЫЕ ЦИФРЫ ДЛЯ UI:')
|
||
console.log(` 📋 ЗАКАЗАНО: ${totalOrdered} шт`)
|
||
console.log(` 🚚 ПОСТАВЛЕНО: ${totalDelivered} шт`)
|
||
console.log(` 📦 ОСТАТОК: ${totalInStock} шт`)
|
||
console.log('')
|
||
|
||
// === ПРОВЕРКА ЛОГИКИ ===
|
||
console.log('🔍 ПРОВЕРКА ЛОГИКИ:')
|
||
const expectedRemaining = totalDelivered - (fulfillmentSupplies.reduce((sum, s) => sum + s.usedStock, 0))
|
||
console.log(` Ожидаемый остаток: ${totalDelivered} поставлено - ${fulfillmentSupplies.reduce((sum, s) => sum + s.usedStock, 0)} использовано = ${expectedRemaining} шт`)
|
||
console.log(` Фактический остаток: ${totalInStock} шт`)
|
||
console.log(` ${expectedRemaining === totalInStock ? '✅' : '❌'} Соответствие: ${expectedRemaining === totalInStock ? 'КОРРЕКТНО' : 'ОШИБКА'}`)
|
||
|
||
console.log('')
|
||
console.log('=' .repeat(60))
|
||
console.log('✅ ПРОВЕРКА ЗАВЕРШЕНА')
|
||
|
||
} catch (error) {
|
||
console.error('❌ ОШИБКА при проверке:', error)
|
||
} finally {
|
||
await prisma.$disconnect()
|
||
}
|
||
}
|
||
|
||
checkUIFulfillmentStats() |